*/(function(i){"use strict";var a=i.setTimeout,s=i.clearTimeout,c=i.XMLHttpRequest,u=i.XDomainRequest,d=i.ActiveXObject,f=i.EventSource,l=i.document,h=i.Promise,p=i.fetch,v=i.Response,y=i.TextDecoder,g=i.TextEncoder,w=i.AbortController;if("undefined"===typeof window||"undefined"===typeof l||"readyState"in l||null!=l.body||(l.readyState="loading",window.addEventListener("load",(function(e){l.readyState="complete"}),!1)),null==c&&null!=d&&(c=function(){return new d("Microsoft.XMLHTTP")}),void 0==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),void 0==w){var m=p;p=function(e,t){var n=t.signal;return m(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},w=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function E(){this.bitsNeeded=0,this.codePoint=0}E.prototype.decode=function(e){function t(e,t,n){if(1===n)return e>=128>>t&&e<<t<=2047;if(2===n)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===n)return e>=65536>>t&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var r=65533,o="",i=this.bitsNeeded,a=this.codePoint,s=0;s<e.length;s+=1){var c=e[s];0!==i&&(c<128||c>191||!t(a<<6|63&c,i-6,n(i,a)))&&(i=0,a=r,o+=String.fromCharCode(a)),0===i?(c>=0&&c<=127?(i=0,a=c):c>=192&&c<=223?(i=6,a=31&c):c>=224&&c<=239?(i=12,a=15&c):c>=240&&c<=247?(i=18,a=7&c):(i=0,a=r),0===i||t(a,i,n(i,a))||(i=0,a=r)):(i-=6,a=a<<6|63&c),0===i&&(a<=65535?o+=String.fromCharCode(a):(o+=String.fromCharCode(55296+(a-65535-1>>10)),o+=String.fromCharCode(56320+(a-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=a,o};var C=function(){try{return"test"===(new y).decode((new g).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1};void 0!=y&&void 0!=g&&C()||(y=E);var b=function(){};function A(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function T(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function _(e){for(var t=Object.create(null),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r],i=o.split(": "),a=i.shift(),s=i.join(": ");t[T(a)]=s}this._map=t}function S(){}function x(e){this._headers=e}function k(){}function R(){this._listeners=Object.create(null)}function D(e){a((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function N(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function I(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function H(e,t){O.call(this,e),this.error=t.error}A.prototype.open=function(e,t){this._abort(!0);var n=this,r=this._xhr,o=1,i=0;this._abort=function(e){0!==n._sendTimeout&&(s(n._sendTimeout),n._sendTimeout=0),1!==o&&2!==o&&3!==o||(o=4,r.onload=b,r.onerror=b,r.onabort=b,r.onprogress=b,r.onreadystatechange=b,r.abort(),0!==i&&(s(i),i=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),o=0};var u=function(){if(1===o){var e=0,t="",i=void 0;if("contentType"in r)e=200,t="OK",i=r.contentType;else try{e=r.status,t=r.statusText,i=r.getResponseHeader("Content-Type")}catch(a){e=0,t="",i=void 0}0!==e&&(o=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=i,n.onreadystatechange())}},d=function(){if(u(),2===o||3===o){o=3;var e="";try{e=r.responseText}catch(t){}n.readyState=3,n.responseText=e,n.onprogress()}},f=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),d(),1===o||2===o||3===o){if(o=4,0!==i&&(s(i),i=0),n.readyState=4,"load"===e)n.onload(t);else if("error"===e)n.onerror(t);else{if("abort"!==e)throw new TypeError;n.onabort(t)}n.onreadystatechange()}},l=function(e){void 0!=r&&(4===r.readyState?"onload"in r&&"onerror"in r&&"onabort"in r||f(""===r.responseText?"error":"load",e):3===r.readyState?"onprogress"in r||d():2===r.readyState&&u())},h=function(){i=a((function(){h()}),500),3===r.readyState&&d()};"onload"in r&&(r.onload=function(e){f("load",e)}),"onerror"in r&&(r.onerror=function(e){f("error",e)}),"onabort"in r&&(r.onabort=function(e){f("abort",e)}),"onprogress"in r&&(r.onprogress=d),"onreadystatechange"in r&&(r.onreadystatechange=function(e){l(e)}),!("contentType"in r)&&"ontimeout"in c.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),r.open(e,t,!0),"readyState"in r&&(i=a((function(){h()}),0))},A.prototype.abort=function(){this._abort(!1)},A.prototype.getResponseHeader=function(e){return this._contentType},A.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},A.prototype.getAllResponseHeaders=function(){return void 0!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},A.prototype.send=function(){if("ontimeout"in c.prototype&&("sendAsBinary"in c.prototype||"mozAnon"in c.prototype)||void 0==l||void 0==l.readyState||"complete"===l.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(n){throw n}}else{var t=this;t._sendTimeout=a((function(){t._sendTimeout=0,t.send()}),4)}},_.prototype.get=function(e){return this._map[T(e)]},null!=c&&null==c.HEADERS_RECEIVED&&(c.HEADERS_RECEIVED=2),S.prototype.open=function(e,t,n,r,o,i,a){e.open("GET",o);var s=0;for(var u in e.onprogress=function(){var t=e.responseText,r=t.slice(s);s+=r.length,n(r)},e.onerror=function(e){e.preventDefault(),r(new Error("NetworkError"))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===c.HEADERS_RECEIVED){var n=e.status,r=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(n,r,o,new _(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},k.prototype.open=function(e,t,n,r,o,i,a){var s=null,c=new w,u=c.signal,d=new y;return p(o,{headers:a,credentials:i?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return s=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new h((function(e,t){var r=function(){s.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});n(o),r()}}))["catch"]((function(e){t(e)}))};r()}))}))["catch"]((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){r(e)})),{abort:function(){null!=s&&s.cancel(),c.abort()}}},R.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(void 0!=t)for(var n=t.length,r=0;r<n;r+=1){var o=t[r];try{"function"===typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(i){D(i)}}},R.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];void 0==r&&(r=[],n[e]=r);for(var o=!1,i=0;i<r.length;i+=1)r[i]===t&&(o=!0);o||r.push(t)},R.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(void 0!=r){for(var o=[],i=0;i<r.length;i+=1)r[i]!==t&&o.push(r[i]);0===o.length?delete n[e]:n[e]=o}},N.prototype=Object.create(O.prototype),I.prototype=Object.create(O.prototype),H.prototype=Object.create(O.prototype);var j=-1,P=0,L=1,U=2,B=-1,M=0,q=1,G=2,J=3,X=/^text\/event\-stream(;.*)?$/i,V=1e3,z=18e6,F=function(e,t){var n=null==e?t:parseInt(e,10);return n!==n&&(n=t),K(n)},K=function(e){return Math.min(Math.max(e,V),z)},Z=function(e,t,n){try{"function"===typeof t&&t.call(e,n)}catch(r){D(r)}};function Q(e,t){R.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,Y(this,e,t)}function $(){return void 0!=c&&"withCredentials"in c.prototype||void 0==u?new c:new u}var W=void 0!=p&&void 0!=v&&"body"in v.prototype;function Y(e,t,n){t=String(t);var r=Boolean(n.withCredentials),o=n.lastEventIdQueryParameterName||"lastEventId",i=K(1e3),c=F(n.heartbeatTimeout,45e3),u="",d=i,f=!1,l=0,h=n.headers||{},p=n.Transport,v=W&&void 0==p?void 0:new A(void 0!=p?new p:$()),y=null!=p&&"string"!==typeof p?new p:void 0==v?new k:new S,g=void 0,w=0,m=j,E="",C="",b="",T="",_=M,x=0,R=0,D=function(t,n,r,o){if(m===P)if(200===t&&void 0!=r&&X.test(r)){m=L,f=Date.now(),d=i,e.readyState=L;var a=new I("open",{status:t,statusText:n,headers:o});e.dispatchEvent(a),Z(e,e.onopen,a)}else{var s="";200!==t?(n&&(n=n.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+n+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(void 0==r?"-":r.replace(/\s+/g," "))+". Aborting the connection.",z();a=new I("error",{status:t,statusText:n,headers:o});e.dispatchEvent(a),Z(e,e.onerror,a),console.error(s)}},O=function(t){if(m===L){for(var n=-1,r=0;r<t.length;r+=1){var o=t.charCodeAt(r);o!=="\n".charCodeAt(0)&&o!=="\r".charCodeAt(0)||(n=r)}var h=(-1!==n?T:"")+t.slice(0,n+1);T=(-1===n?T:"")+t.slice(n+1),""!==t&&(f=Date.now(),l+=t.length);for(var p=0;p<h.length;p+=1){o=h.charCodeAt(p);if(_===B&&o==="\n".charCodeAt(0))_=M;else if(_===B&&(_=M),o==="\r".charCodeAt(0)||o==="\n".charCodeAt(0)){if(_!==M){_===q&&(R=p+1);var v=h.slice(x,R-1),y=h.slice(R+(R<p&&h.charCodeAt(R)===" ".charCodeAt(0)?1:0),p);"data"===v?(E+="\n",E+=y):"id"===v?C=y:"event"===v?b=y:"retry"===v?(i=F(y,i),d=i):"heartbeatTimeout"===v&&(c=F(y,c),0!==w&&(s(w),w=a((function(){Q()}),c)))}if(_===M){if(""!==E){u=C,""===b&&(b="message");var g=new N(b,{data:E.slice(1),lastEventId:C});if(e.dispatchEvent(g),"open"===b?Z(e,e.onopen,g):"message"===b?Z(e,e.onmessage,g):"error"===b&&Z(e,e.onerror,g),m===U)return}E="",b=""}_=o==="\r".charCodeAt(0)?B:M}else _===M&&(x=p,_=q),_===q?o===":".charCodeAt(0)&&(R=p+1,_=G):_===G&&(_=J)}}},V=function(t){if(m===L||m===P){m=j,0!==w&&(s(w),w=0),w=a((function(){Q()}),d),d=K(Math.min(16*i,2*d)),e.readyState=P;var n=new H("error",{error:t});e.dispatchEvent(n),Z(e,e.onerror,n),void 0!=t&&console.error(t)}},z=function(){m=U,void 0!=g&&(g.abort(),g=void 0),0!==w&&(s(w),w=0),e.readyState=U},Q=function(){if(w=0,m===j){f=!1,l=0,w=a((function(){Q()}),c),m=P,E="",b="",C=u,T="",x=0,R=0,_=M;var n=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==u){var r=t.indexOf("?");n=-1===r?t:t.slice(0,r+1)+t.slice(r+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===o?"":e})),n+=(-1===t.indexOf("?")?"?":"&")+o+"="+encodeURIComponent(u)}var i=e.withCredentials,s={Accept:"text/event-stream"},d=e.headers;if(void 0!=d)for(var h in d)Object.prototype.hasOwnProperty.call(d,h)&&(s[h]=d[h]);try{g=y.open(v,D,O,V,n,i,s)}catch(A){throw z(),A}}else if(f||void 0==g){var p=Math.max((f||Date.now())+c-Date.now(),1);f=!1,w=a((function(){Q()}),p)}else V(new Error("No activity within "+c+" milliseconds. "+(m===P?"No response received.":l+" chars received.")+" Reconnecting.")),void 0!=g&&(g.abort(),g=void 0)};e.url=t,e.readyState=P,e.withCredentials=r,e.headers=h,e._close=z,Q()}Q.prototype=Object.create(R.prototype),Q.prototype.CONNECTING=P,Q.prototype.OPEN=L,Q.prototype.CLOSED=U,Q.prototype.close=function(){this._close()},Q.CONNECTING=P,Q.OPEN=L,Q.CLOSED=U,Q.prototype.withCredentials=void 0;var ee=f;void 0==c||void 0!=f&&"withCredentials"in f.prototype||(ee=Q),function(i){if("object"===typeof e.exports){var a=i(t);void 0!==a&&(e.exports=a)}else r=[t],n=i,o="function"===typeof n?n.apply(t,r):n,void 0===o||(e.exports=o)}((function(e){e.EventSourcePolyfill=Q,e.NativeEventSource=f,e.EventSource=ee}))})("undefined"===typeof globalThis?"undefined"!==typeof window?window:"undefined"!==typeof self?self:this:globalThis)},12215:function(e,t,n){var r,o;
|
*/(function(i){var a;if(r=i,o="function"===typeof r?r.call(t,n,t,e):r,void 0===o||(e.exports=o),a=!0,e.exports=i(),a=!0,!a){var s=window.Cookies,c=window.Cookies=i();c.noConflict=function(){return window.Cookies=s,c}}})((function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}function n(r){function o(){}function i(t,n,i){if("undefined"!==typeof document){i=e({path:"/"},o.defaults,i),"number"===typeof i.expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var a=JSON.stringify(n);/^[\{\[]/.test(a)&&(n=a)}catch(u){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var c in i)i[c]&&(s+="; "+c,!0!==i[c]&&(s+="="+i[c].split(";")[0]));return document.cookie=t+"="+n+s}}function a(e,n){if("undefined"!==typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],a=0;a<i.length;a++){var s=i[a].split("="),c=s.slice(1).join("=");n||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(s[0]);if(c=(r.read||r)(c,u)||t(c),n)try{c=JSON.parse(c)}catch(d){}if(o[u]=c,e===u)break}catch(d){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return a(e,!1)},o.getJSON=function(e){return a(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}return n((function(){}))}))},92244:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var r=n(14048),o=n(30388),i=n(25026),a=n(69492),s=n(23772),c=n(96557),u=n(34642),d=n(61789),f=function(){function e(t){(0,i.A)(this,e),(0,s.A)(this,"url",null),(0,s.A)(this,"events",null),(0,s.A)(this,"sse",null),this.url=t}return(0,a.A)(e,[{key:"getEvents",value:function(){var e=(0,o.A)((0,r.A)().mark((function e(){var t;return(0,r.A)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,(0,c.get)("cms/notify/events");case 2:t=e.sent,this.events=t.events;case 4:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"initSse",value:function(){var e=(0,o.A)((0,r.A)().mark((function e(){return(0,r.A)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.getEvents();case 2:this.sse=new d["default"](u["default"].baseUrl+this.url,this.events);case 3:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"createEvents",value:function(){var e=(0,o.A)((0,r.A)().mark((function e(t,n){var o;return(0,r.A)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,(0,c.post)("cms/notify/events",{group_id:t,events:n});case 2:return o=e.sent,e.abrupt("return",o);case 4:case"end":return e.stop()}}),e)})));function t(t,n){return e.apply(this,arguments)}return t}()},{key:"updateEvents",value:function(){var e=(0,o.A)((0,r.A)().mark((function e(t,n){var o;return(0,r.A)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,(0,c.put)("cms/notify/events",{group_id:t,events:n});case 2:return o=e.sent,e.abrupt("return",o);case 4:case"end":return e.stop()}}),e)})));function t(t,n){return e.apply(this,arguments)}return t}()}])}()},54620:function(e,t,n){"use strict";n.r(t),n.d(t,{getToken:function(){return s},removeToken:function(){return c},saveAccessToken:function(){return a},saveTokens:function(){return i}});var r=n(12215),o=n.n(r);function i(e,t){o().set("access_token","Bearer ".concat(e)),o().set("refresh_token","Bearer ".concat(t))}function a(e){o().set("access_token","Bearer ".concat(e))}function s(e){return o().get(e)}function c(){o().remove("access_token"),o().remove("refresh_token"),sessionStorage.removeItem("flag"),sessionStorage.clear(),localStorage.clear()}},61789:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r=n(25026),o=n(69492),i=n(23772),a=(n(79432),n(26099),n(23500),n(20163)),s=(n(40377),n(54620)),c=n(55129),u=function(){function e(t,n){var o=this;(0,r.A)(this,e),(0,i.A)(this,"source",null),console.log(t,n),this.source=new EventSourcePolyfill(t,{headers:{Authorization:(0,s.getToken)("access_token")}}),this.open(),n.forEach((function(e){o.addEventListener(e)}))}return(0,o.A)(e,[{key:"open",value:function(){this.source.onopen=function(e){console.log("sse opened",e)}}},{key:"error",value:function(){this.source.onerror=function(e){console.log("error",e)}}},{key:"addEventListener",value:function(e){this.source.addEventListener(e,(function(e){c["default"].commit("MARK_UNREAD_MESSAGE",{data:e.data,id:e.lastEventId}),a.nk.warning(JSON.parse(e.data).message)}))}}])}()}}]);
|