matrix-api
Advanced tools
@@ -1,1 +0,1 @@ | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:v&&v.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var v=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=v&&v.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(o,e);var t,n,r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}(o);function o(e){var t;return function(e,t){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this),(t=r.call(this)).baseUrl=e||"https://matrix.org/_matrix",t.clientUrl="".concat(t.baseUrl,"/client/r0"),t.mediaUrl="".concat(t.baseUrl,"/media/r0"),t.profileCache=new Map,t.mediaCache=new Map,t}return t=o,(n=[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,r="login/sso/redirect?redirectUrl="+e,o=window.screenX+window.outerWidth/2+200,c=window.screenY+window.outerHeight/2-300,a="width=".concat(400,",height=").concat(600,",screenX=").concat(o,",screenY=").concat(c),s=(n.open("".concat(this.clientUrl,"/").concat(r),"matrix-login",a),function(e){if(e.origin===location.origin){var n=JSON.parse(e.data);"s.sso.complete"===n.type&&(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}});n.addEventListener("message",s)}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e))return this.profileCache.get(e);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.mediaUrl,"/upload?access_token=").concat(r.access_token),c=new Headers({"Content-Type":e.type});return fetch(o,{method:"POST",headers:c,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.syncRoom(e,t).then(function(t){return t.chunk&&r&&t.chunk.forEach(r),t.chunk.length&&n.syncRoomHistory(e,t.end,r)})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t={};e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),Object.assign(t,e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t)return t.user_id}},{key:"createRoom",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}])&&s(t.prototype,n),o}(o.Mixin.with(c.EventTargetMixin));e.Matrix=f}),require.register("___globals___",function(e,t,n){}),require("___globals___"); | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:m&&m.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var m=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=m&&m.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(o,e);var t,n,r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}(o);function o(e){var t;return function(e,t){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this),(t=r.call(this)).baseUrl=e||"https://matrix.org/_matrix",t.clientUrl="".concat(t.baseUrl,"/client/r0"),t.mediaUrl="".concat(t.baseUrl,"/media/r0"),t.profileCache=new Map,t.mediaCache=new Map,t}return t=o,(n=[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,r="login/sso/redirect?redirectUrl="+e,o=window.screenX+window.outerWidth/2+200,c=window.screenY+window.outerHeight/2-300,a="width=".concat(400,",height=").concat(600,",screenX=").concat(o,",screenY=").concat(c),s=(n.open("".concat(this.clientUrl,"/").concat(r),"matrix-login",a),function(e){if(e.origin===location.origin&&e.source!==window&&"string"==typeof e.data){var n=JSON.parse(e.data);"s.sso.complete"===n.type&&(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}});n.addEventListener("message",s)}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e))return this.profileCache.get(e);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.mediaUrl,"/upload?access_token=").concat(r.access_token),c=new Headers({"Content-Type":e.type});return fetch(o,{method:"POST",headers:c,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.syncRoom(e,t).then(function(t){var o=new CustomEvent("roomSyncFrame",{detail:{frame:t},cancelable:!0});if(n.dispatchEvent(o))return t.chunk&&r&&t.chunk.forEach(r),new Promise(function(o){setTimeout(function(){return o(t.chunk.length&&n.syncRoomHistory(e,t.end,r))},100)})})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t={};e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),Object.assign(t,e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t)return t.user_id}},{key:"createRoom",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}])&&s(t.prototype,n),o}(o.Mixin.with(c.EventTargetMixin));e.Matrix=f}),require.register("___globals___",function(e,t,n){}),require("___globals___"); |
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},r={},n={},o={}.hasOwnProperty,i=/^\.\.?(\/|$)/,a=function(e,t){for(var r,n=[],o=(i.test(t)?e+"/"+t:t).split("/"),a=0,u=o.length;a<u;a++)".."===(r=o[a])?n.pop():"."!==r&&""!==r&&n.push(r);return n.join("/")},u=function(e){return e.split("/").slice(0,-1).join("/")},f=function(t,n){var o,i={id:t,exports:{},hot:p&&p.createHot(t)};return r[t]=i,n(i.exports,(o=t,function(t){var r=a(u(o),t);return e.require(r,o)}),i),i.exports},c=function(e){var t=n[e];return t&&e!==t?c(t):e},l=function(e,n){null==n&&(n="/");var i=c(e);if(o.call(r,i))return r[i].exports;if(o.call(t,i))return f(i,t[i]);throw new Error("Cannot find module '"+e+"' from '"+n+"'")};l.alias=function(e,t){n[t]=e};var s=/\.[^.\/]+$/,y=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,i){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=i,delete r[e],function(e){if(s.test(e)){var t=e.replace(s,"");o.call(n,t)&&n[t].replace(s,"")!==t+"/index"||(n[t]=e)}if(y.test(e)){var r=e.replace(y,"");o.call(n,r)||(n[r]=e)}}(e)},l.list=function(){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e};var p=e._hmr&&new e._hmr(function(e,t){return c(a(u(e),t))},l,t,r);l._cache=r,l.hmr=p&&p.wrap,l.brunch=!0,e.require=l}}(),function(){"undefined"==typeof window||window;var e=function(e,t,r){var n={},o=function(t,r){try{return e(r+"/node_modules/"+t)}catch(e){if(-1===e.toString().indexOf("Cannot find module"))throw e;if(-1!==r.indexOf("node_modules")){var i=r.split("/"),a=i.lastIndexOf("node_modules"),u=i.slice(0,a).join("/");return o(t,u)}}return n};return function(i){if(i in t&&(i=t[i]),i){if("."!==i[0]&&r){var a=o(i,r);if(a!==n)return a}return e(i)}}};require.register("curvature/base/Bindable.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";function e(t,n,o){return(e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&r(i,n.prototype),i}).apply(null,arguments)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function n(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=i(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,f=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){f=!0,a=e},f:function(){try{u||null==r.return||r.return()}finally{if(f)throw a}}}}function i(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.Bindable=void 0;var l=Symbol("ref"),s=Symbol("original"),y=Symbol("deck"),p=Symbol("binding"),b=Symbol("subBinding"),v=Symbol("bindingAll"),d=Symbol("isBindable"),m=Symbol("wrapping"),h=Symbol("Names"),g=Symbol("executing"),w=Symbol("stack"),O=(Symbol("object"),Symbol("wrapped")),j=Symbol("unwrapped"),P=Symbol("getProto"),S=Symbol("onGet"),_=Symbol("onAllGet"),k=Symbol("bindChain"),A=Symbol("Descriptors"),x=Symbol("Before"),B=Symbol("After"),E=Symbol("NoGetters"),C=Object.getPrototypeOf(Int8Array),M=Set.prototype[Symbol.iterator],I=Map.prototype[Symbol.iterator],D=globalThis,T=[D.Node,D.File,D.Map,D.Set,D.WeakMap,D.WeakSet,D.ArrayBuffer,D.ResizeObserver,D.MutationObserver,D.PerformanceObserver,D.IntersectionObserver,D.IDBCursor,D.IDBCursorWithValue,D.IDBDatabase,D.IDBFactory,D.IDBIndex,D.IDBKeyRange,D.IDBObjectStore,D.IDBOpenDBRequest,D.IDBRequest,D.IDBTransaction,D.IDBVersionChangeEvent,D.Event,D.CustomEvent,D.FileSystemFileHandle].filter(function(e){return"function"==typeof e}),R=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var r,i;return r=t,i=[{key:"isBindable",value:function(e){return!(!e||!e[d])&&e[d]===t}},{key:"onDeck",value:function(e,t){return e[y][t]||!1}},{key:"ref",value:function(e){return e[l]||e||!1}},{key:"makeBindable",value:function(e){return this.make(e)}},{key:"shuck",value:function(e,r){r=r||new Map;var n={};if(e instanceof C||e instanceof ArrayBuffer){var o=e.slice(0);return r.set(e,o),o}var i=Object.keys(e);for(var a in i){var f=i[a];if("___"!==f.substring(0,3)){var c=r.get(e[f]);if(c)n[f]=c;else if(e[f]!==e){if(e[f]&&"object"===u(e[f])){var l=e[f];t.isBindable(e[f])&&(l=e[f][s]),n[f]=this.shuck(l,r)}else n[f]=e[f];r.set(e[f],n[f])}else r.set(e[f],n),n[f]=n}}return t.isBindable(e)&&(delete n.bindTo,delete n.isBound),n}},{key:"make",value:function(r){var i=this;if(!r||!["function","object"].includes(u(r)))return r;if(r[l])return r[l];if(r[d])return r;if(Object.isSealed(r)||Object.isFrozen(r)||!Object.isExtensible(r)||T.filter(function(e){return r instanceof e}).length)return r;Object.defineProperty(r,d,{configurable:!1,enumerable:!1,writable:!1,value:t}),Object.defineProperty(r,l,{configurable:!0,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(r,s,{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.defineProperty(r,y,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,p,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,b,{configurable:!1,enumerable:!1,writable:!1,value:new Map}),Object.defineProperty(r,v,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,g,{enumerable:!1,writable:!0}),Object.defineProperty(r,m,{enumerable:!1,writable:!0}),Object.defineProperty(r,w,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,x,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,B,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,O,{configurable:!1,enumerable:!1,writable:!1,value:Object.preventExtensions(new Map)}),Object.defineProperty(r,j,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,A,{configurable:!1,enumerable:!1,writable:!1,value:Object.preventExtensions(new Map)}),Object.defineProperty(r,"bindTo",{configurable:!1,enumerable:!1,writable:!1,value:function e(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=!1;if(Array.isArray(n)){var c=n.forEach(function(t){return e(t,o,a)});return function(){return c.forEach(function(e){return e()})}}if(n instanceof Function&&(a=o||{},o=n,f=!0),a.delay>=0&&(o=i.wrapDelayCallback(o,a.delay)),a.throttle>=0&&(o=i.wrapThrottleCallback(o,a.throttle)),a.wait>=0&&(o=i.wrapWaitCallback(o,a.wait)),a.frame&&(o=i.wrapFrameCallback(o,a.frame)),a.idle&&(o=i.wrapIdleCallback(o)),f){var l=r[v].length;if(r[v].push(o),!("now"in a)||a.now)for(var s in r)o(r[s],s,r,!1);return function(){delete r[v][l]}}if(r[p][n]||(r[p][n]=new Set),a.children){var y=o;o=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=n[0],f=r[b].get(y);if(f&&(r[b].delete(y),f()),"object"===u(i)){var c=t.make(i);t.isBindable(c)&&r[b].set(y,c.bindTo(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return y.apply(void 0,n.concat(t))},Object.assign({},a,{children:!1}))),y.apply(void 0,n)}else y.apply(void 0,n)}}r[p][n].add(o),"now"in a&&!a.now||o(r[n],n,r,!1);var d=function(){var e=r[b].get(o);e&&(r[b].delete(o),e()),r[p][n]&&r[p][n].has(o)&&r[p][n].delete(o)};return a.removeWith&&a.removeWith instanceof View&&a.removeWith.onRemove(function(){return d}),d}}),Object.defineProperty(r,k,{configurable:!1,enumerable:!1,writable:!1,value:function(e,t){var n=e.split("."),o=n.shift(),a=n.slice(0),u=[];return u.push(r.bindTo(o,function(e,r,n,o){var f=a.join(".");0!==a.length?(void 0===e&&(e=n[r]=i.make({})),u=u.concat(e[k](f,t))):t(e,r,n,o)})),function(){return u.forEach(function(e){return e()})}}}),Object.defineProperty(r,"___before",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=r[x].length;r[x].push(e);var n=!1;return function(){n||(n=!0,delete r[x][t])}}}),Object.defineProperty(r,"___after",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=r[B].length;r[B].push(e);var n=!1;return function(){n||(n=!0,delete r[B][t])}}}),Object.defineProperty(r,"isBound",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e in r[v])if(r[v][e])return!0;for(var t in r[p])for(var n in r[p][t])if(r[p][t][n])return!0;return!1}});var a=function(e){r[e]&&r[e]instanceof Object&&!r[e]instanceof Promise&&(T.filter(function(t){return r[e]instanceof t}).length||!Object.isExtensible(r[e])||Object.isSealed(r[e])||(r[e]=t.make(r[e])))};for(var f in r)a(f);var c=r[A],D=r[O],R=r[w],W={get:function(n,i){if(D.has(i))return D.get(i);if(i===l||i===s||"apply"===i||"isBound"===i||"bindTo"===i||"__proto__"===i||"constructor"===i)return r[i];var a;if(c.has(i)?a=c.get(i):(a=Object.getOwnPropertyDescriptor(r,i),c.set(i,a)),a&&!a.configurable&&!a.writable)return r[i];if(_ in r)return r[_](i);if(S in r&&!(i in r))return r[S](i);if(a&&!a.configurable&&!a.writable)return D.set(i,r[i]),r[i];if("function"==typeof r[i]){if(h in r[i])return r[i];Object.defineProperty(r[j],i,{configurable:!1,enumerable:!1,writable:!0,value:r[i]});var u=Object.getPrototypeOf(r)[i]===r[i],f="function"==typeof Promise&&r instanceof Promise||"function"==typeof Map&&r instanceof Map||"function"==typeof Set&&r instanceof Set||"function"==typeof I&&r.prototype===I||"function"==typeof M&&r.prototype===M||"function"==typeof M&&r.prototype===M||"function"==typeof WeakMap&&r instanceof WeakMap||"function"==typeof WeakSet&&r instanceof WeakSet||"function"==typeof Date&&r instanceof Date||"function"==typeof C&&r instanceof C||"function"==typeof ArrayBuffer&&r instanceof ArrayBuffer||"function"==typeof EventTarget&&r instanceof EventTarget||"function"==typeof ResizeObserver&&r instanceof ResizeObserver||"function"==typeof MutationObserver&&r instanceof MutationObserver||"function"==typeof PerformanceObserver&&r instanceof PerformanceObserver||"function"==typeof IntersectionObserver&&r instanceof IntersectionObserver||"function"==typeof r[Symbol.iterator]&&"next"===i?r:r[l],y=function(){r[g]=i,R.unshift(i);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];var c,l,s=o(r[x]);try{for(s.s();!(c=s.n()).done;){(0,c.value)(r,i,R,r,n)}}catch(e){s.e(e)}finally{s.f()}if(new.target)l=e(r[j][i],n);else{var y=r[j][i];l=u?y.apply(f||r,n):y.apply(void 0,n)}var p,b=o(r[B]);try{for(b.s();!(p=b.n()).done;){(0,p.value)(r,i,R,r,n)}}catch(e){b.e(e)}finally{b.f()}return r[g]=null,R.shift(),l};(y[h]=y[h]||new WeakMap).set(r,i),y[_]=function(e){var t=y[h].get(r);return r[t][e]};var p=t.make(y);return D.set(i,p),p}return r[i]},set:function(e,n,i){if(D.has(n)&&D.delete(n),n===s)return!0;var a=r[y];if(n in a&&a[n]===i)return!0;if(n.slice&&"___"===n.slice(-3))return!0;if(e[n]===i||"number"==typeof i&&isNaN(a[n])&&isNaN(i))return!0;for(var u in i&&i instanceof Object&&(T.filter(function(e){return r instanceof e}).length||!Object.isExtensible(r)||Object.isSealed(r)||(r[E],i=t.make(i))),a[n]=i,r[v])r[v][u]&&r[v][u](i,n,e,!1);var f=!1;if(n in r[p]){var c,l=o(r[p][n]);try{for(l.s();!(c=l.n()).done;)!1===(0,c.value)(i,n,e,!1,e[n])&&(f=!0)}catch(e){l.e(e)}finally{l.f()}}if(delete a[n],!f){var b=Object.getOwnPropertyDescriptor(e,n);e instanceof File&&"lastModifiedDate"==n||b&&!b.writable||e[n]!==i||(e[n]=i)}var d=Reflect.set(e,n,i);if(Array.isArray(e)&&r[p].length)for(var m in r[p].length)(0,r[p].length[m])(e.length,"length",e,!1,e.length);return d},construct:function(o,i){var a="constructor";for(var u in o[x])o[x][u](o,a,r[w],void 0,i);var f=t.make(e(o[s],n(i)));for(var c in o[B])o[B][c](o,a,r[w],f,i);return f},getPrototypeOf:function(e){return P in r?r[P]:Reflect.getPrototypeOf(e)},deleteProperty:function(e,t){var n=r[y];if(void 0!==n[t])return!0;if(!(t in e))return!0;if(c.has(t)){var i=c.get(t);if(i&&!i.configurable)return!1;c.delete(t)}for(var a in n[t]=null,D.has(t)&&D.delete(t),r[v])r[v][a](void 0,t,e,!0,e[t]);if(t in r[p]){var u,f=o(r[p][t]);try{for(f.s();!(u=f.n()).done;)(0,u.value)(void 0,t,e,!0,e[t])}catch(e){f.e(e)}finally{f.f()}}return delete n[t],delete e[t],!0}};return r[E]&&delete W.get,Object.defineProperty(r,l,{configurable:!1,enumerable:!1,writable:!1,value:new Proxy(r,W)}),r[l]}},{key:"clearBindings",value:function(e){var t;(t=function(e){return Object.keys(e).map(function(t){return delete e[t]})},function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.map(t)})(e[O],e[p],e[v],e[B],e[x])}},{key:"resolve",value:function(e,t){for(var r,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=t.split("."),i=o[0];o.length;){if(n&&1===o.length)return[this.make(e),o.shift(),i];!(!(r=o.shift())in e)&&e[r]&&e[r]instanceof Object||(e[r]={}),e=this.make(e[r])}return[this.make(e),r,i]}},{key:"wrapDelayCallback",value:function(e,t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return setTimeout(function(){return e.apply(void 0,n)},t)}}},{key:"wrapThrottleCallback",value:function(e,t){var r=this;return this.throttles.set(e,!1),function(){r.throttles.get(e,!0)||(e.apply(void 0,arguments),r.throttles.set(e,!0),setTimeout(function(){r.throttles.set(e,!1)},t))}}},{key:"wrapWaitCallback",value:function(e,t){var r=this;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a;(a=r.waiters.get(e))&&(r.waiters.delete(e),clearTimeout(a)),a=setTimeout(function(){return e.apply(void 0,o)},t),r.waiters.set(e,a)}}},{key:"wrapFrameCallback",value:function(e,t){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];requestAnimationFrame(function(){return e.apply(void 0,r)})}}},{key:"wrapIdleCallback",value:function(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(window.requestIdleCallback||requestAnimationFrame)(function(){return e.apply(void 0,r)})}}}],null&&f(r.prototype,null),i&&f(r,i),Object.defineProperty(r,"prototype",{writable:!1}),t}();t.Bindable=R,c(R,"waiters",new WeakMap),c(R,"throttles",new WeakMap),Object.defineProperty(R,"OnGet",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.defineProperty(R,"NoGetters",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(R,"GetProto",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.defineProperty(R,"OnAllGet",{configurable:!1,enumerable:!1,writable:!1,value:_})}()}),require.register("curvature/base/Mixin.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Mixin=void 0;var e=r("./Bindable");function n(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,f=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){f=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(f)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var v=Symbol("constructor"),d=(Symbol("mixinList"),function(){function t(){y(this,t)}return b(t,null,[{key:"from",value:function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}(u,e);var a=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=s(e);if(t){var o=s(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}(u);function u(){var r;y(this,u);for(var f=arguments.length,s=new Array(f),p=0;p<f;p++)s[p]=arguments[p];var b,v=e.constructor?r=a.call.apply(a,[this].concat(s)):null,d=i(n);try{for(d.s();!(b=d.n()).done;){var m=b.value;switch(m[t.Constructor]&&m[t.Constructor].apply(l(r)),o(m)){case"function":t.mixClass(m,u);break;case"object":t.mixObject(m,l(r))}}}catch(e){d.e(e)}finally{d.f()}return c(r,v)}return b(u)}()}},{key:"make",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r.pop();return t.to.apply(t,[o].concat(r))}},{key:"to",value:function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.map(function(r){switch(o(r)){case"object":Object.assign(t,Object.getOwnPropertyDescriptors(r));break;case"function":Object.assign(t,Object.getOwnPropertyDescriptors(r.prototype))}delete t.constructor,Object.defineProperties(e.prototype,t)})}},{key:"with",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.from.apply(this,[b(function e(){y(this,e)})].concat(t))}},{key:"mixObject",value:function(e,t){var r,n=i(Object.getOwnPropertyNames(e));try{for(n.s();!(r=n.n()).done;){var o=r.value;"function"!=typeof e[o]?t[o]=e[o]:t[o]=e[o].bind(t)}}catch(e){n.e(e)}finally{n.f()}var a,u=i(Object.getOwnPropertySymbols(e));try{for(u.s();!(a=u.n()).done;){var f=a.value;"function"!=typeof e[f]?t[f]=e[f]:t[f]=e[f].bind(t)}}catch(e){u.e(e)}finally{u.f()}}},{key:"mixClass",value:function(e,t){var r,n=i(Object.getOwnPropertyNames(e.prototype));try{for(n.s();!(r=n.n()).done;){var o=r.value;if(!["name","prototype","length"].includes(o)){var a=Object.getOwnPropertyDescriptor(t,o);a&&!a.writable||("function"==typeof e[o]?t.prototype[o]=e.prototype[o].bind(t.prototype):t.prototype[o]=e.prototype[o])}}}catch(e){n.e(e)}finally{n.f()}var u,f=i(Object.getOwnPropertySymbols(e.prototype));try{for(f.s();!(u=f.n()).done;){var c=u.value;"function"==typeof e[c]?t.prototype[c]=e.prototype[c].bind(t.prototype):t.prototype[c]=e.prototype[c]}}catch(e){f.e(e)}finally{f.f()}var l,s=i(Object.getOwnPropertyNames(e));try{var y=function(){var r=l.value;if(["name","prototype","length"].includes(r))return"continue";var n=Object.getOwnPropertyDescriptor(t,r);if(n&&!n.writable)return"continue";if("function"!=typeof e[r])return t[r]=e[r],"continue";var o=t[r]||!1,i=e[r].bind(t);t[r]=function(){return o&&o.apply(void 0,arguments),i.apply(void 0,arguments)}};for(s.s();!(l=s.n()).done;)y()}catch(e){s.e(e)}finally{s.f()}var p,b=i(Object.getOwnPropertySymbols(e));try{var v=function(){var r=p.value;if("function"!=typeof e[r])return t.prototype[r]=e[r],"continue";var n=t[r]||!1,o=e[r].bind(t);t[r]=function(){return n&&n.apply(void 0,arguments),o.apply(void 0,arguments)}};for(b.s();!(p=b.n()).done;)v()}catch(e){b.e(e)}finally{b.f()}}},{key:"mix",value:function(t){for(var r={},o={},a=e.Bindable.makeBindable(t),u=function(e){var t,u=Object.getOwnPropertyNames(e.prototype),f=/^(before|after)__(.+)/,c=i(Object.getOwnPropertyNames(e));try{var l=function(){var o=t.value,i=o.match(f);if(i){switch(i[1]){case"before":a.___before(function(t,r,a,u,f){if(r===i[2])return e[o].bind(u).apply(void 0,n(f))});break;case"after":a.___after(function(t,r,a,u,f){if(r===i[2])return e[o].bind(u).apply(void 0,n(f))})}return"continue"}return r[o]||"function"!=typeof e[o]?"continue":void(r[o]=e[o])};for(c.s();!(t=c.n()).done;)l()}catch(e){c.e(e)}finally{c.f()}var s,y=i(u);try{var p=function(){var t=s.value,r=t.match(f);if(r){switch(r[1]){case"before":a.___before(function(o,i,a,u,f){if(i===r[2])return e.prototype[t].bind(u).apply(void 0,n(f))});break;case"after":a.___after(function(o,i,a,u,f){if(i===r[2])return e.prototype[t].bind(u).apply(void 0,n(f))})}return"continue"}return o[t]||"function"!=typeof e.prototype[t]?"continue":void(o[t]=e.prototype[t])};for(y.s();!(s=y.n()).done;)p()}catch(e){y.e(e)}finally{y.f()}},f=this;f&&f.prototype;f=Object.getPrototypeOf(f))u(f);for(var c in r)t[c]=r[c].bind(t);var l=function(e){t.prototype[e]=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return o[e].apply(this,r)}};for(var s in o)l(s);return a}}]),t}());t.Mixin=d,d.Constructor=v}()}),require.register("curvature/mixin/EventTargetMixin.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetMixin=void 0;var e,n=r("../base/Mixin");function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=Symbol("Target"),a=(o(e={},n.Mixin.Constructor,function(){try{this[i]=new EventTarget}catch(e){this[i]=document.createDocumentFragment()}}),o(e,"dispatchEvent",function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var o=r[0];"string"==typeof o&&(o=new CustomEvent(o),r[0]=o),(e=this[i]).dispatchEvent.apply(e,r);var a="on".concat(o.type[0].toUpperCase()+o.type.slice(1));return"function"==typeof this[a]&&this[a](o),o.returnValue}),o(e,"addEventListener",function(){var e;(e=this[i]).addEventListener.apply(e,arguments)}),o(e,"removeEventListener",function(){var e;(e=this[i]).removeEventListener.apply(e,arguments)}),e);t.EventTargetMixin=a}()}),require.register("build/Config.js",function(e,t,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Config=void 0,e.Config={title:"matrix-api 0.0.0-f"}}),require.register("___globals___",function(e,t,r){})}(),require("___globals___"); | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:v&&v.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var v=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=v&&v.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(o,e);var t,n,r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}(o);function o(e){var t;return function(e,t){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this),(t=r.call(this)).baseUrl=e||"https://matrix.org/_matrix",t.clientUrl="".concat(t.baseUrl,"/client/r0"),t.mediaUrl="".concat(t.baseUrl,"/media/r0"),t.profileCache=new Map,t.mediaCache=new Map,t}return t=o,(n=[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,r="login/sso/redirect?redirectUrl="+e,o=window.screenX+window.outerWidth/2+200,c=window.screenY+window.outerHeight/2-300,a="width=".concat(400,",height=").concat(600,",screenX=").concat(o,",screenY=").concat(c),s=(n.open("".concat(this.clientUrl,"/").concat(r),"matrix-login",a),function(e){if(e.origin===location.origin){var n=JSON.parse(e.data);"s.sso.complete"===n.type&&(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}});n.addEventListener("message",s)}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e))return this.profileCache.get(e);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.mediaUrl,"/upload?access_token=").concat(r.access_token),c=new Headers({"Content-Type":e.type});return fetch(o,{method:"POST",headers:c,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.syncRoom(e,t).then(function(t){return t.chunk&&r&&t.chunk.forEach(r),t.chunk.length&&n.syncRoomHistory(e,t.end,r)})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t={};e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),Object.assign(t,e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t)return t.user_id}},{key:"createRoom",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}])&&s(t.prototype,n),o}(o.Mixin.with(c.EventTargetMixin));e.Matrix=f}),require.register("___globals___",function(e,t,n){}),require("___globals___"); | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:m&&m.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var m=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=m&&m.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(o,e);var t,n,r=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}(o);function o(e){var t;return function(e,t){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this),(t=r.call(this)).baseUrl=e||"https://matrix.org/_matrix",t.clientUrl="".concat(t.baseUrl,"/client/r0"),t.mediaUrl="".concat(t.baseUrl,"/media/r0"),t.profileCache=new Map,t.mediaCache=new Map,t}return t=o,(n=[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,r="login/sso/redirect?redirectUrl="+e,o=window.screenX+window.outerWidth/2+200,c=window.screenY+window.outerHeight/2-300,a="width=".concat(400,",height=").concat(600,",screenX=").concat(o,",screenY=").concat(c),s=(n.open("".concat(this.clientUrl,"/").concat(r),"matrix-login",a),function(e){if(e.origin===location.origin&&e.source!==window&&"string"==typeof e.data){var n=JSON.parse(e.data);"s.sso.complete"===n.type&&(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}});n.addEventListener("message",s)}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e))return this.profileCache.get(e);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.mediaUrl,"/upload?access_token=").concat(r.access_token),c=new Headers({"Content-Type":e.type});return fetch(o,{method:"POST",headers:c,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.syncRoom(e,t).then(function(t){var o=new CustomEvent("roomSyncFrame",{detail:{frame:t},cancelable:!0});if(n.dispatchEvent(o))return t.chunk&&r&&t.chunk.forEach(r),new Promise(function(o){setTimeout(function(){return o(t.chunk.length&&n.syncRoomHistory(e,t.end,r))},100)})})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t={};e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),Object.assign(t,e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t)return t.user_id}},{key:"createRoom",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()})}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}])&&s(t.prototype,n),o}(o.Mixin.with(c.EventTargetMixin));e.Matrix=f}),require.register("___globals___",function(e,t,n){}),require("___globals___"); |
+28
-3
@@ -95,2 +95,10 @@ "use strict"; | ||
| if (event.source === window) { | ||
| return; | ||
| } | ||
| if (typeof event.data !== 'string') { | ||
| return; | ||
| } | ||
| var request = JSON.parse(event.data); | ||
@@ -412,5 +420,22 @@ | ||
| var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
| this.syncRoom(room, from).then(function (chunk) { | ||
| chunk.chunk && callback && chunk.chunk.forEach(callback); | ||
| return chunk.chunk.length && _this5.syncRoomHistory(room, chunk.end, callback); | ||
| return this.syncRoom(room, from).then(function (frame) { | ||
| var cancelable = true; | ||
| var detail = { | ||
| frame: frame | ||
| }; | ||
| var event = new CustomEvent('roomSyncFrame', { | ||
| detail: detail, | ||
| cancelable: cancelable | ||
| }); | ||
| if (!_this5.dispatchEvent(event)) { | ||
| return; | ||
| } | ||
| frame.chunk && callback && frame.chunk.forEach(callback); | ||
| return new Promise(function (accept) { | ||
| setTimeout(function () { | ||
| return accept(frame.chunk.length && _this5.syncRoomHistory(room, frame.end, callback)); | ||
| }, 100); | ||
| }); | ||
| }); | ||
@@ -417,0 +442,0 @@ } |
+3
-4
@@ -6,3 +6,3 @@ { | ||
| "author": "Sean Morris", | ||
| "version": "0.0.0-g", | ||
| "version": "0.0.0-h", | ||
| "repository": "https://github.com/seanmorris/matrix-api", | ||
@@ -20,7 +20,6 @@ "devDependencies": { | ||
| "raw-brunch": "^1.0.2", | ||
| "terser-brunch": "^4", | ||
| "uglify-es-brunch": "^1" | ||
| "terser-brunch": "^4.1" | ||
| }, | ||
| "dependencies": { | ||
| "curvature": "^0.0.68-c" | ||
| "curvature": "^0.0.68-e" | ||
| }, | ||
@@ -27,0 +26,0 @@ "files": [ |
96730
1%11
-8.33%674
3.53%Updated