@mindline/sync 1.0.91 → 1.0.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vs/VSWorkspaceState.json +1 -2
- package/.vs/slnx.sqlite +0 -0
- package/.vs/sync/CopilotIndices/17.14.260.54502/CodeChunks.db +0 -0
- package/.vs/sync/CopilotIndices/17.14.260.54502/SemanticSymbols.db +0 -0
- package/.vs/sync/FileContentIndex/37cf3ba8-be62-4549-89ef-f092c9f43d47.vsidx +0 -0
- package/.vs/sync/FileContentIndex/b22d6a63-ec64-479e-b70a-dd1a66299e4c.vsidx +0 -0
- package/.vs/sync/FileContentIndex/d5a4b6e4-5645-45e1-8135-648e002a306d.vsidx +0 -0
- package/.vs/sync/FileContentIndex/f1c0dd18-8f11-493d-b452-9a59ff91ffb8.vsidx +0 -0
- package/.vs/sync/FileContentIndex/fee90bf7-9f86-4fc9-a06e-ccbbe7777bfe.vsidx +0 -0
- package/.vs/sync/v17/.wsuo +0 -0
- package/.vs/sync/v17/DocumentLayout.backup.json +19 -34
- package/.vs/sync/v17/DocumentLayout.json +17 -68
- package/dist/sync.es.js +1331 -3449
- package/dist/sync.es.js.map +1 -1
- package/dist/sync.umd.js +39 -39
- package/dist/sync.umd.js.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +2 -2
- package/vite.config.ts +9 -9
- package/.vs/sync/FileContentIndex/0f447c8e-f707-40c3-aa4c-30bfeab10f57.vsidx +0 -0
- package/.vs/sync/FileContentIndex/b3821e23-fbe8-43ca-9167-2deeb211602b.vsidx +0 -0
package/dist/sync.umd.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
(function(f,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(f=typeof globalThis<"u"?globalThis:f||self,I(f.sync={}))})(this,function(f){"use strict";var ps=Object.defineProperty;var Pt=f=>{throw TypeError(f)};var gs=(f,I,j)=>I in f?ps(f,I,{enumerable:!0,configurable:!0,writable:!0,value:j}):f[I]=j;var d=(f,I,j)=>gs(f,typeof I!="symbol"?I+"":I,j),ms=(f,I,j)=>I.has(f)||Pt("Cannot "+j);var De=(f,I,j)=>I.has(f)?Pt("Cannot add the same private member more than once"):I instanceof WeakSet?I.add(f):I.set(f,j);var ee=(f,I,j)=>(ms(f,I,"access private method"),j);var Pe,$t,Q,Ue,He,je,me,ze;class I extends Error{constructor(e,t){const n=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=n}}class j extends Error{constructor(e="A timeout occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Z extends Error{constructor(e="An abort occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Dt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=n}}class Rt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=n}}class xt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=n}}class qe extends Error{constructor(e){const t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class Nt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=n}}class Je{constructor(e,t,n){this.statusCode=e,this.statusText=t,this.content=n}}class Se{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}var h;(function(r){r[r.Trace=0]="Trace",r[r.Debug=1]="Debug",r[r.Information=2]="Information",r[r.Warning=3]="Warning",r[r.Error=4]="Error",r[r.Critical=5]="Critical",r[r.None=6]="None"})(h||(h={}));class pe{constructor(){}log(e,t){}}pe.instance=new pe;const Ot="8.0.7";class O{static isRequired(e,t){if(e==null)throw new Error(`The '${t}' argument is required.`)}static isNotEmpty(e,t){if(!e||e.match(/^\s*$/))throw new Error(`The '${t}' argument should not be empty.`)}static isIn(e,t,n){if(!(e in t))throw new Error(`Unknown ${n} value: ${e}.`)}}class P{static get isBrowser(){return!P.isNode&&typeof window=="object"&&typeof window.document=="object"}static get isWebWorker(){return!P.isNode&&typeof self=="object"&&"importScripts"in self}static get isReactNative(){return!P.isNode&&typeof window=="object"&&typeof window.document>"u"}static get isNode(){return typeof process<"u"&&process.release&&process.release.name==="node"}}function ge(r,e){let t="";return ne(r)?(t=`Binary data of length ${r.byteLength}`,e&&(t+=`. Content: '${Mt(r)}'`)):typeof r=="string"&&(t=`String data of length ${r.length}`,e&&(t+=`. Content: '${r}'`)),t}function Mt(r){const e=new Uint8Array(r);let t="";return e.forEach(n=>{const s=n<16?"0":"";t+=`0x${s}${n.toString(16)} `}),t.substr(0,t.length-1)}function ne(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}async function Ke(r,e,t,n,s,o){const i={},[c,a]=re();i[c]=a,r.log(h.Trace,`(${e} transport) sending data. ${ge(s,o.logMessageContent)}.`);const l=ne(s)?"arraybuffer":"text",u=await t.post(n,{content:s,headers:{...i,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});r.log(h.Trace,`(${e} transport) request complete. Response status: ${u.statusCode}.`)}function Lt(r){return r===void 0?new be(h.Information):r===null?pe.instance:r.log!==void 0?r:new be(r)}class Gt{constructor(e,t){this._subject=e,this._observer=t}dispose(){const e=this._subject.observers.indexOf(this._observer);e>-1&&this._subject.observers.splice(e,1),this._subject.observers.length===0&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(t=>{})}}class be{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){const n=`[${new Date().toISOString()}] ${h[e]}: ${t}`;switch(e){case h.Critical:case h.Error:this.out.error(n);break;case h.Warning:this.out.warn(n);break;case h.Information:this.out.info(n);break;default:this.out.log(n);break}}}}function re(){let r="X-SignalR-User-Agent";return P.isNode&&(r="User-Agent"),[r,Wt(Ot,Bt(),Ut(),Ft())]}function Wt(r,e,t,n){let s="Microsoft SignalR/";const o=r.split(".");return s+=`${o[0]}.${o[1]}`,s+=` (${r}; `,e&&e!==""?s+=`${e}; `:s+="Unknown OS; ",s+=`${t}`,n?s+=`; ${n}`:s+="; Unknown Runtime Version",s+=")",s}function Bt(){if(P.isNode)switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}else return""}function Ft(){if(P.isNode)return process.versions.node}function Ut(){return P.isNode?"NodeJS":"Browser"}function Re(r){return r.stack?r.stack:r.message?r.message:`${r}`}function Ht(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("could not find global")}class jt extends Se{constructor(e){if(super(),this._logger=e,typeof fetch>"u"||P.isNode){const t=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._jar=new(t("tough-cookie")).CookieJar,typeof fetch>"u"?this._fetchType=t("node-fetch"):this._fetchType=fetch,this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(Ht());if(typeof AbortController>"u"){const t=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._abortControllerType=t("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new Z;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let n;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),n=new Z});let s=null;if(e.timeout){const a=e.timeout;s=setTimeout(()=>{t.abort(),this._logger.log(h.Warning,"Timeout from HTTP request."),n=new j},a)}e.content===""&&(e.content=void 0),e.content&&(e.headers=e.headers||{},ne(e.content)?e.headers["Content-Type"]="application/octet-stream":e.headers["Content-Type"]="text/plain;charset=UTF-8");let o;try{o=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:e.withCredentials===!0?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(a){throw n||(this._logger.log(h.Warning,`Error from HTTP request. ${a}.`),a)}finally{s&&clearTimeout(s),e.abortSignal&&(e.abortSignal.onabort=null)}if(!o.ok){const a=await Xe(o,"text");throw new I(a||o.statusText,o.status)}const c=await Xe(o,e.responseType);return new Je(o.status,o.statusText,c)}getCookieString(e){let t="";return P.isNode&&this._jar&&this._jar.getCookies(e,(n,s)=>t=s.join("; ")),t}}function Xe(r,e){let t;switch(e){case"arraybuffer":t=r.arrayBuffer();break;case"text":t=r.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:t=r.text();break}return t}class zt extends Se{constructor(e){super(),this._logger=e}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Z):e.method?e.url?new Promise((t,n)=>{const s=new XMLHttpRequest;s.open(e.method,e.url,!0),s.withCredentials=e.withCredentials===void 0?!0:e.withCredentials,s.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.content===""&&(e.content=void 0),e.content&&(ne(e.content)?s.setRequestHeader("Content-Type","application/octet-stream"):s.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const o=e.headers;o&&Object.keys(o).forEach(i=>{s.setRequestHeader(i,o[i])}),e.responseType&&(s.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=()=>{s.abort(),n(new Z)}),e.timeout&&(s.timeout=e.timeout),s.onload=()=>{e.abortSignal&&(e.abortSignal.onabort=null),s.status>=200&&s.status<300?t(new Je(s.status,s.statusText,s.response||s.responseText)):n(new I(s.response||s.responseText||s.statusText,s.status))},s.onerror=()=>{this._logger.log(h.Warning,`Error from HTTP request. ${s.status}: ${s.statusText}.`),n(new I(s.statusText,s.status))},s.ontimeout=()=>{this._logger.log(h.Warning,"Timeout from HTTP request."),n(new j)},s.send(e.content)}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class qt extends Se{constructor(e){if(super(),typeof fetch<"u"||P.isNode)this._httpClient=new jt(e);else if(typeof XMLHttpRequest<"u")this._httpClient=new zt(e);else throw new Error("No usable HttpClient found.")}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Z):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}class K{static write(e){return`${e}${K.RecordSeparator}`}static parse(e){if(e[e.length-1]!==K.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(K.RecordSeparator);return t.pop(),t}}K.RecordSeparatorCode=30,K.RecordSeparator=String.fromCharCode(K.RecordSeparatorCode);class Jt{writeHandshakeRequest(e){return K.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,n;if(ne(e)){const c=new Uint8Array(e),a=c.indexOf(K.RecordSeparatorCode);if(a===-1)throw new Error("Message is incomplete.");const l=a+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(c.slice(0,l))),n=c.byteLength>l?c.slice(l).buffer:null}else{const c=e,a=c.indexOf(K.RecordSeparator);if(a===-1)throw new Error("Message is incomplete.");const l=a+1;t=c.substring(0,l),n=c.length>l?c.substring(l):null}const s=K.parse(t),o=JSON.parse(s[0]);if(o.type)throw new Error("Expected a handshake response from the server.");return[n,o]}}var y;(function(r){r[r.Invocation=1]="Invocation",r[r.StreamItem=2]="StreamItem",r[r.Completion=3]="Completion",r[r.StreamInvocation=4]="StreamInvocation",r[r.CancelInvocation=5]="CancelInvocation",r[r.Ping=6]="Ping",r[r.Close=7]="Close",r[r.Ack=8]="Ack",r[r.Sequence=9]="Sequence"})(y||(y={}));class Kt{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new Gt(this,e)}}class Xt{constructor(e,t,n){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=e,this._connection=t,this._bufferSize=n}async _send(e){const t=this._protocol.writeMessage(e);let n=Promise.resolve();if(this._isInvocationMessage(e)){this._totalMessageCount++;let s=()=>{},o=()=>{};ne(t)?this._bufferedByteCount+=t.byteLength:this._bufferedByteCount+=t.length,this._bufferedByteCount>=this._bufferSize&&(n=new Promise((i,c)=>{s=i,o=c})),this._messages.push(new Zt(t,this._totalMessageCount,s,o))}try{this._reconnectInProgress||await this._connection.send(t)}catch{this._disconnected()}await n}_ack(e){let t=-1;for(let n=0;n<this._messages.length;n++){const s=this._messages[n];if(s._id<=e.sequenceId)t=n,ne(s._message)?this._bufferedByteCount-=s._message.byteLength:this._bufferedByteCount-=s._message.length,s._resolver();else if(this._bufferedByteCount<this._bufferSize)s._resolver();else break}t!==-1&&(this._messages=this._messages.slice(t+1))}_shouldProcessMessage(e){if(this._waitForSequenceMessage)return e.type!==y.Sequence?!1:(this._waitForSequenceMessage=!1,!0);if(!this._isInvocationMessage(e))return!0;const t=this._nextReceivingSequenceId;return this._nextReceivingSequenceId++,t<=this._latestReceivedSequenceId?(t===this._latestReceivedSequenceId&&this._ackTimer(),!1):(this._latestReceivedSequenceId=t,this._ackTimer(),!0)}_resetSequence(e){if(e.sequenceId>this._nextReceivingSequenceId){this._connection.stop(new Error("Sequence ID greater than amount of messages we've received."));return}this._nextReceivingSequenceId=e.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){const e=this._messages.length!==0?this._messages[0]._id:this._totalMessageCount+1;await this._connection.send(this._protocol.writeMessage({type:y.Sequence,sequenceId:e}));const t=this._messages;for(const n of t)await this._connection.send(n._message);this._reconnectInProgress=!1}_dispose(e){e??(e=new Error("Unable to reconnect to server."));for(const t of this._messages)t._rejector(e)}_isInvocationMessage(e){switch(e.type){case y.Invocation:case y.StreamItem:case y.Completion:case y.StreamInvocation:case y.CancelInvocation:return!0;case y.Close:case y.Sequence:case y.Ping:case y.Ack:return!1}}_ackTimer(){this._ackTimerHandle===void 0&&(this._ackTimerHandle=setTimeout(async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:y.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0},1e3))}}class Zt{constructor(e,t,n,s){this._message=e,this._id=t,this._resolver=n,this._rejector=s}}const Qt=30*1e3,Yt=15*1e3,Vt=1e5;var k;(function(r){r.Disconnected="Disconnected",r.Connecting="Connecting",r.Connected="Connected",r.Disconnecting="Disconnecting",r.Reconnecting="Reconnecting"})(k||(k={}));class xe{static create(e,t,n,s,o,i,c){return new xe(e,t,n,s,o,i,c)}constructor(e,t,n,s,o,i,c){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(h.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},O.isRequired(e,"connection"),O.isRequired(t,"logger"),O.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=o??Qt,this.keepAliveIntervalInMilliseconds=i??Yt,this._statefulReconnectBufferSize=c??Vt,this._logger=t,this._protocol=n,this.connection=e,this._reconnectPolicy=s,this._handshakeProtocol=new Jt,this.connection.onreceive=a=>this._processIncomingData(a),this.connection.onclose=a=>this._connectionClosed(a),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=k.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:y.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==k.Disconnected&&this._connectionState!==k.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==k.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=k.Connecting,this._logger.log(h.Debug,"Starting HubConnection.");try{await this._startInternal(),P.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=k.Connected,this._connectionStarted=!0,this._logger.log(h.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=k.Disconnected,this._logger.log(h.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const e=new Promise((t,n)=>{this._handshakeResolver=t,this._handshakeRejecter=n});await this.connection.start(this._protocol.transferFormat);try{let t=this._protocol.version;this.connection.features.reconnect||(t=1);const n={protocol:this._protocol.name,version:t};if(this._logger.log(h.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(n)),this._logger.log(h.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError;(this.connection.features.reconnect||!1)&&(this._messageBuffer=new Xt(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(t){throw this._logger.log(h.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(t),t}}async stop(){const e=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch{}}_stopInternal(e){if(this._connectionState===k.Disconnected)return this._logger.log(h.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===k.Disconnecting)return this._logger.log(h.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;const t=this._connectionState;return this._connectionState=k.Disconnecting,this._logger.log(h.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(h.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(t===k.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Z("The connection was stopped before the hub handshake could complete."),this.connection.stop(e))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(e,...t){const[n,s]=this._replaceStreamingParams(t),o=this._createStreamInvocation(e,t,s);let i;const c=new Kt;return c.cancelCallback=()=>{const a=this._createCancelInvocation(o.invocationId);return delete this._callbacks[o.invocationId],i.then(()=>this._sendWithProtocol(a))},this._callbacks[o.invocationId]=(a,l)=>{if(l){c.error(l);return}else a&&(a.type===y.Completion?a.error?c.error(new Error(a.error)):c.complete():c.next(a.item))},i=this._sendWithProtocol(o).catch(a=>{c.error(a),delete this._callbacks[o.invocationId]}),this._launchStreams(n,i),c}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._messageBuffer?this._messageBuffer._send(e):this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){const[n,s]=this._replaceStreamingParams(t),o=this._sendWithProtocol(this._createInvocation(e,t,!0,s));return this._launchStreams(n,o),o}invoke(e,...t){const[n,s]=this._replaceStreamingParams(t),o=this._createInvocation(e,t,!1,s);return new Promise((c,a)=>{this._callbacks[o.invocationId]=(u,g)=>{if(g){a(g);return}else u&&(u.type===y.Completion?u.error?a(new Error(u.error)):c(u.result):a(new Error(`Unexpected message type: ${u.type}`)))};const l=this._sendWithProtocol(o).catch(u=>{a(u),delete this._callbacks[o.invocationId]});this._launchStreams(n,l)})}on(e,t){!e||!t||(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),this._methods[e].indexOf(t)===-1&&this._methods[e].push(t))}off(e,t){if(!e)return;e=e.toLowerCase();const n=this._methods[e];if(n)if(t){const s=n.indexOf(t);s!==-1&&(n.splice(s,1),n.length===0&&delete this._methods[e])}else delete this._methods[e]}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e){const t=this._protocol.parseMessages(e,this._logger);for(const n of t)if(!(this._messageBuffer&&!this._messageBuffer._shouldProcessMessage(n)))switch(n.type){case y.Invocation:this._invokeClientMethod(n).catch(s=>{this._logger.log(h.Error,`Invoke client method threw error: ${Re(s)}`)});break;case y.StreamItem:case y.Completion:{const s=this._callbacks[n.invocationId];if(s){n.type===y.Completion&&delete this._callbacks[n.invocationId];try{s(n)}catch(o){this._logger.log(h.Error,`Stream callback threw error: ${Re(o)}`)}}break}case y.Ping:break;case y.Close:{this._logger.log(h.Information,"Close message received from server.");const s=n.error?new Error("Server returned an error on close: "+n.error):void 0;n.allowReconnect===!0?this.connection.stop(s):this._stopPromise=this._stopInternal(s);break}case y.Ack:this._messageBuffer&&this._messageBuffer._ack(n);break;case y.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(n);break;default:this._logger.log(h.Warning,`Invalid message type: ${n.type}.`);break}}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,n;try{[n,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(s){const o="Error parsing handshake response: "+s;this._logger.log(h.Error,o);const i=new Error(o);throw this._handshakeRejecter(i),i}if(t.error){const s="Server returned handshake error: "+t.error;this._logger.log(h.Error,s);const o=new Error(s);throw this._handshakeRejecter(o),o}else this._logger.log(h.Debug,"Server handshake complete.");return this._handshakeResolver(),n}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=new Date().getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if((!this.connection.features||!this.connection.features.inherentKeepAlive)&&(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),this._pingServerHandle===void 0)){let e=this._nextKeepAlive-new Date().getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===k.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(e){const t=e.target.toLowerCase(),n=this._methods[t];if(!n){this._logger.log(h.Warning,`No client method with the name '${t}' found.`),e.invocationId&&(this._logger.log(h.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null)));return}const s=n.slice(),o=!!e.invocationId;let i,c,a;for(const l of s)try{const u=i;i=await l.apply(this,e.arguments),o&&i&&u&&(this._logger.log(h.Error,`Multiple results provided for '${t}'. Sending error to server.`),a=this._createCompletionMessage(e.invocationId,"Client provided multiple results.",null)),c=void 0}catch(u){c=u,this._logger.log(h.Error,`A callback for the method '${t}' threw error '${u}'.`)}a?await this._sendWithProtocol(a):o?(c?a=this._createCompletionMessage(e.invocationId,`${c}`,null):i!==void 0?a=this._createCompletionMessage(e.invocationId,null,i):(this._logger.log(h.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),a=this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(a)):i&&this._logger.log(h.Error,`Result given for '${t}' method but server is not expecting a result.`)}_connectionClosed(e){this._logger.log(h.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Z("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===k.Disconnecting?this._completeClose(e):this._connectionState===k.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===k.Connected&&this._completeClose(e)}_completeClose(e){if(this._connectionStarted){this._connectionState=k.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(e??new Error("Connection closed.")),this._messageBuffer=void 0),P.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(t=>t.apply(this,[e]))}catch(t){this._logger.log(h.Error,`An onclose callback called with error '${e}' threw error '${t}'.`)}}}async _reconnect(e){const t=Date.now();let n=0,s=e!==void 0?e:new Error("Attempting to reconnect due to a unknown error."),o=this._getNextRetryDelay(n++,0,s);if(o===null){this._logger.log(h.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this._completeClose(e);return}if(this._connectionState=k.Reconnecting,e?this._logger.log(h.Information,`Connection reconnecting because of error '${e}'.`):this._logger.log(h.Information,"Connection reconnecting."),this._reconnectingCallbacks.length!==0){try{this._reconnectingCallbacks.forEach(i=>i.apply(this,[e]))}catch(i){this._logger.log(h.Error,`An onreconnecting callback called with error '${e}' threw error '${i}'.`)}if(this._connectionState!==k.Reconnecting){this._logger.log(h.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");return}}for(;o!==null;){if(this._logger.log(h.Information,`Reconnect attempt number ${n} will start in ${o} ms.`),await new Promise(i=>{this._reconnectDelayHandle=setTimeout(i,o)}),this._reconnectDelayHandle=void 0,this._connectionState!==k.Reconnecting){this._logger.log(h.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");return}try{if(await this._startInternal(),this._connectionState=k.Connected,this._logger.log(h.Information,"HubConnection reconnected successfully."),this._reconnectedCallbacks.length!==0)try{this._reconnectedCallbacks.forEach(i=>i.apply(this,[this.connection.connectionId]))}catch(i){this._logger.log(h.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${i}'.`)}return}catch(i){if(this._logger.log(h.Information,`Reconnect attempt failed because of error '${i}'.`),this._connectionState!==k.Reconnecting){this._logger.log(h.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),this._connectionState===k.Disconnecting&&this._completeClose();return}s=i instanceof Error?i:new Error(i.toString()),o=this._getNextRetryDelay(n++,Date.now()-t,s)}}this._logger.log(h.Information,`Reconnect retries have been exhausted after ${Date.now()-t} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(e,t,n){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:n})}catch(s){return this._logger.log(h.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${s}'.`),null}}_cancelCallbacksWithError(e){const t=this._callbacks;this._callbacks={},Object.keys(t).forEach(n=>{const s=t[n];try{s(null,e)}catch(o){this._logger.log(h.Error,`Stream 'error' callback called with '${e}' threw error: ${Re(o)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,n,s){if(n)return s.length!==0?{arguments:t,streamIds:s,target:e,type:y.Invocation}:{arguments:t,target:e,type:y.Invocation};{const o=this._invocationId;return this._invocationId++,s.length!==0?{arguments:t,invocationId:o.toString(),streamIds:s,target:e,type:y.Invocation}:{arguments:t,invocationId:o.toString(),target:e,type:y.Invocation}}}_launchStreams(e,t){if(e.length!==0){t||(t=Promise.resolve());for(const n in e)e[n].subscribe({complete:()=>{t=t.then(()=>this._sendWithProtocol(this._createCompletionMessage(n)))},error:s=>{let o;s instanceof Error?o=s.message:s&&s.toString?o=s.toString():o="Unknown error",t=t.then(()=>this._sendWithProtocol(this._createCompletionMessage(n,o)))},next:s=>{t=t.then(()=>this._sendWithProtocol(this._createStreamItemMessage(n,s)))}})}}_replaceStreamingParams(e){const t=[],n=[];for(let s=0;s<e.length;s++){const o=e[s];if(this._isObservable(o)){const i=this._invocationId;this._invocationId++,t[i]=o,n.push(i.toString()),e.splice(s,1)}}return[t,n]}_isObservable(e){return e&&e.subscribe&&typeof e.subscribe=="function"}_createStreamInvocation(e,t,n){const s=this._invocationId;return this._invocationId++,n.length!==0?{arguments:t,invocationId:s.toString(),streamIds:n,target:e,type:y.StreamInvocation}:{arguments:t,invocationId:s.toString(),target:e,type:y.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:y.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:y.StreamItem}}_createCompletionMessage(e,t,n){return t?{error:t,invocationId:e,type:y.Completion}:{invocationId:e,result:n,type:y.Completion}}_createCloseMessage(){return{type:y.Close}}}const en=[0,2e3,1e4,3e4,null];class Ze{constructor(e){this._retryDelays=e!==void 0?[...e,null]:en}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class se{}se.Authorization="Authorization",se.Cookie="Cookie";class tn extends Se{constructor(e,t){super(),this._innerClient=e,this._accessTokenFactory=t}async send(e){let t=!0;this._accessTokenFactory&&(!this._accessToken||e.url&&e.url.indexOf("/negotiate?")>0)&&(t=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(e);const n=await this._innerClient.send(e);return t&&n.statusCode===401&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(e),await this._innerClient.send(e)):n}_setAuthorizationHeader(e){e.headers||(e.headers={}),this._accessToken?e.headers[se.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&e.headers[se.Authorization]&&delete e.headers[se.Authorization]}getCookieString(e){return this._innerClient.getCookieString(e)}}var M;(function(r){r[r.None=0]="None",r[r.WebSockets=1]="WebSockets",r[r.ServerSentEvents=2]="ServerSentEvents",r[r.LongPolling=4]="LongPolling"})(M||(M={}));var F;(function(r){r[r.Text=1]="Text",r[r.Binary=2]="Binary"})(F||(F={}));let nn=class{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}};class Qe{get pollAborted(){return this._pollAbort.aborted}constructor(e,t,n){this._httpClient=e,this._logger=t,this._pollAbort=new nn,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}async connect(e,t){if(O.isRequired(e,"url"),O.isRequired(t,"transferFormat"),O.isIn(t,F,"transferFormat"),this._url=e,this._logger.log(h.Trace,"(LongPolling transport) Connecting."),t===F.Binary&&typeof XMLHttpRequest<"u"&&typeof new XMLHttpRequest().responseType!="string")throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,s]=re(),o={[n]:s,...this._options.headers},i={abortSignal:this._pollAbort.signal,headers:o,timeout:1e5,withCredentials:this._options.withCredentials};t===F.Binary&&(i.responseType="arraybuffer");const c=`${e}&_=${Date.now()}`;this._logger.log(h.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this._httpClient.get(c,i);a.statusCode!==200?(this._logger.log(h.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this._closeError=new I(a.statusText||"",a.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,i)}async _poll(e,t){try{for(;this._running;)try{const n=`${e}&_=${Date.now()}`;this._logger.log(h.Trace,`(LongPolling transport) polling: ${n}.`);const s=await this._httpClient.get(n,t);s.statusCode===204?(this._logger.log(h.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):s.statusCode!==200?(this._logger.log(h.Error,`(LongPolling transport) Unexpected response code: ${s.statusCode}.`),this._closeError=new I(s.statusText||"",s.statusCode),this._running=!1):s.content?(this._logger.log(h.Trace,`(LongPolling transport) data received. ${ge(s.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(s.content)):this._logger.log(h.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(n){this._running?n instanceof j?this._logger.log(h.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=n,this._running=!1):this._logger.log(h.Trace,`(LongPolling transport) Poll errored after shutdown: ${n.message}`)}}finally{this._logger.log(h.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Ke(this._logger,"LongPolling",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(h.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(h.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const e={},[t,n]=re();e[t]=n;const s={headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};let o;try{await this._httpClient.delete(this._url,s)}catch(i){o=i}o?o instanceof I&&(o.statusCode===404?this._logger.log(h.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this._logger.log(h.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this._logger.log(h.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this._logger.log(h.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(h.Trace,e),this.onclose(this._closeError)}}}class sn{constructor(e,t,n,s){this._httpClient=e,this._accessToken=t,this._logger=n,this._options=s,this.onreceive=null,this.onclose=null}async connect(e,t){return O.isRequired(e,"url"),O.isRequired(t,"transferFormat"),O.isIn(t,F,"transferFormat"),this._logger.log(h.Trace,"(SSE transport) Connecting."),this._url=e,this._accessToken&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise((n,s)=>{let o=!1;if(t!==F.Text){s(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));return}let i;if(P.isBrowser||P.isWebWorker)i=new this._options.EventSource(e,{withCredentials:this._options.withCredentials});else{const c=this._httpClient.getCookieString(e),a={};a.Cookie=c;const[l,u]=re();a[l]=u,i=new this._options.EventSource(e,{withCredentials:this._options.withCredentials,headers:{...a,...this._options.headers}})}try{i.onmessage=c=>{if(this.onreceive)try{this._logger.log(h.Trace,`(SSE transport) data received. ${ge(c.data,this._options.logMessageContent)}.`),this.onreceive(c.data)}catch(a){this._close(a);return}},i.onerror=c=>{o?this._close():s(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},i.onopen=()=>{this._logger.log(h.Information,`SSE connected to ${this._url}`),this._eventSource=i,o=!0,n()}}catch(c){s(c);return}})}async send(e){return this._eventSource?Ke(this._logger,"SSE",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class on{constructor(e,t,n,s,o,i){this._logger=n,this._accessTokenFactory=t,this._logMessageContent=s,this._webSocketConstructor=o,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=i}async connect(e,t){O.isRequired(e,"url"),O.isRequired(t,"transferFormat"),O.isIn(t,F,"transferFormat"),this._logger.log(h.Trace,"(WebSockets transport) Connecting.");let n;return this._accessTokenFactory&&(n=await this._accessTokenFactory()),new Promise((s,o)=>{e=e.replace(/^http/,"ws");let i;const c=this._httpClient.getCookieString(e);let a=!1;if(P.isNode||P.isReactNative){const l={},[u,g]=re();l[u]=g,n&&(l[se.Authorization]=`Bearer ${n}`),c&&(l[se.Cookie]=c),i=new this._webSocketConstructor(e,void 0,{headers:{...l,...this._headers}})}else n&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);i||(i=new this._webSocketConstructor(e)),t===F.Binary&&(i.binaryType="arraybuffer"),i.onopen=l=>{this._logger.log(h.Information,`WebSocket connected to ${e}.`),this._webSocket=i,a=!0,s()},i.onerror=l=>{let u=null;typeof ErrorEvent<"u"&&l instanceof ErrorEvent?u=l.error:u="There was an error with the transport",this._logger.log(h.Information,`(WebSockets transport) ${u}.`)},i.onmessage=l=>{if(this._logger.log(h.Trace,`(WebSockets transport) data received. ${ge(l.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(l.data)}catch(u){this._close(u);return}},i.onclose=l=>{if(a)this._close(l);else{let u=null;typeof ErrorEvent<"u"&&l instanceof ErrorEvent?u=l.error:u="WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",o(new Error(u))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(h.Trace,`(WebSockets transport) sending data. ${ge(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(h.Trace,"(WebSockets transport) socket closed."),this.onclose&&(this._isCloseEvent(e)&&(e.wasClean===!1||e.code!==1e3)?this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)):e instanceof Error?this.onclose(e):this.onclose())}_isCloseEvent(e){return e&&typeof e.wasClean=="boolean"&&typeof e.code=="number"}}const Ye=100;class rn{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,O.isRequired(e,"url"),this._logger=Lt(t.logger),this.baseUrl=this._resolveUrl(e),t=t||{},t.logMessageContent=t.logMessageContent===void 0?!1:t.logMessageContent,typeof t.withCredentials=="boolean"||t.withCredentials===void 0)t.withCredentials=t.withCredentials===void 0?!0:t.withCredentials;else throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.timeout=t.timeout===void 0?100*1e3:t.timeout;let n=null,s=null;if(P.isNode&&typeof require<"u"){const o=typeof __webpack_require__=="function"?__non_webpack_require__:require;n=o("ws"),s=o("eventsource")}!P.isNode&&typeof WebSocket<"u"&&!t.WebSocket?t.WebSocket=WebSocket:P.isNode&&!t.WebSocket&&n&&(t.WebSocket=n),!P.isNode&&typeof EventSource<"u"&&!t.EventSource?t.EventSource=EventSource:P.isNode&&!t.EventSource&&typeof s<"u"&&(t.EventSource=s),this._httpClient=new tn(t.httpClient||new qt(this._logger),t.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||F.Binary,O.isIn(e,F,"transferFormat"),this._logger.log(h.Debug,`Starting connection with transfer format '${F[e]}'.`),this._connectionState!=="Disconnected")return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,this._connectionState==="Disconnecting"){const t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(h.Error,t),await this._stopPromise,Promise.reject(new Z(t))}else if(this._connectionState!=="Connected"){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(h.Error,t),Promise.reject(new Z(t))}this._connectionStarted=!0}send(e){return this._connectionState!=="Connected"?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new Ne(this.transport)),this._sendQueue.send(e))}async stop(e){if(this._connectionState==="Disconnected")return this._logger.log(h.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve();if(this._connectionState==="Disconnecting")return this._logger.log(h.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;this._connectionState="Disconnecting",this._stopPromise=new Promise(t=>{this._stopPromiseResolver=t}),await this._stopInternal(e),await this._stopPromise}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch{}if(this.transport){try{await this.transport.stop()}catch(t){this._logger.log(h.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(h.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(e){let t=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation)if(this._options.transport===M.WebSockets)this.transport=this._constructTransport(M.WebSockets),await this._startTransport(t,e);else throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");else{let n=null,s=0;do{if(n=await this._getNegotiationResponse(t),this._connectionState==="Disconnecting"||this._connectionState==="Disconnected")throw new Z("The connection was stopped during negotiation.");if(n.error)throw new Error(n.error);if(n.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(n.url&&(t=n.url),n.accessToken){const o=n.accessToken;this._accessTokenFactory=()=>o,this._httpClient._accessToken=o,this._httpClient._accessTokenFactory=void 0}s++}while(n.url&&s<Ye);if(s===Ye&&n.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(t,this._options.transport,n,e)}this.transport instanceof Qe&&(this.features.inherentKeepAlive=!0),this._connectionState==="Connecting"&&(this._logger.log(h.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(n){return this._logger.log(h.Error,"Failed to start the connection: "+n),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(n)}}async _getNegotiationResponse(e){const t={},[n,s]=re();t[n]=s;const o=this._resolveNegotiateUrl(e);this._logger.log(h.Debug,`Sending negotiation request: ${o}.`);try{const i=await this._httpClient.post(o,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(i.statusCode!==200)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${i.statusCode}'`));const c=JSON.parse(i.content);return(!c.negotiateVersion||c.negotiateVersion<1)&&(c.connectionToken=c.connectionId),c.useStatefulReconnect&&this._options._useStatefulReconnect!==!0?Promise.reject(new qe("Client didn't negotiate Stateful Reconnect but the server did.")):c}catch(i){let c="Failed to complete negotiation with the server: "+i;return i instanceof I&&i.statusCode===404&&(c=c+" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(h.Error,c),Promise.reject(new qe(c))}}_createConnectUrl(e,t){return t?e+(e.indexOf("?")===-1?"?":"&")+`id=${t}`:e}async _createTransport(e,t,n,s){let o=this._createConnectUrl(e,n.connectionToken);if(this._isITransport(t)){this._logger.log(h.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(o,s),this.connectionId=n.connectionId;return}const i=[],c=n.availableTransports||[];let a=n;for(const l of c){const u=this._resolveTransportOrError(l,t,s,(a==null?void 0:a.useStatefulReconnect)===!0);if(u instanceof Error)i.push(`${l.transport} failed:`),i.push(u);else if(this._isITransport(u)){if(this.transport=u,!a){try{a=await this._getNegotiationResponse(e)}catch(g){return Promise.reject(g)}o=this._createConnectUrl(e,a.connectionToken)}try{await this._startTransport(o,s),this.connectionId=a.connectionId;return}catch(g){if(this._logger.log(h.Error,`Failed to start the transport '${l.transport}': ${g}`),a=void 0,i.push(new xt(`${l.transport} failed: ${g}`,M[l.transport])),this._connectionState!=="Connecting"){const p="Failed to select transport before stop() was called.";return this._logger.log(h.Debug,p),Promise.reject(new Z(p))}}}}return i.length>0?Promise.reject(new Nt(`Unable to connect to the server with any of the available transports. ${i.join(" ")}`,i)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case M.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new on(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case M.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new sn(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case M.LongPolling:return new Qe(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async n=>{let s=!1;if(this.features.reconnect)try{this.features.disconnected(),await this.transport.connect(e,t),await this.features.resend()}catch{s=!0}else{this._stopConnection(n);return}s&&this._stopConnection(n)}:this.transport.onclose=n=>this._stopConnection(n),this.transport.connect(e,t)}_resolveTransportOrError(e,t,n,s){const o=M[e.transport];if(o==null)return this._logger.log(h.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(an(t,o))if(e.transferFormats.map(c=>F[c]).indexOf(n)>=0){if(o===M.WebSockets&&!this._options.WebSocket||o===M.ServerSentEvents&&!this._options.EventSource)return this._logger.log(h.Debug,`Skipping transport '${M[o]}' because it is not supported in your environment.'`),new Dt(`'${M[o]}' is not supported in your environment.`,o);this._logger.log(h.Debug,`Selecting transport '${M[o]}'.`);try{return this.features.reconnect=o===M.WebSockets?s:void 0,this._constructTransport(o)}catch(c){return c}}else return this._logger.log(h.Debug,`Skipping transport '${M[o]}' because it does not support the requested transfer format '${F[n]}'.`),new Error(`'${M[o]}' does not support ${F[n]}.`);else return this._logger.log(h.Debug,`Skipping transport '${M[o]}' because it was disabled by the client.`),new Rt(`'${M[o]}' is disabled by the client.`,o)}_isITransport(e){return e&&typeof e=="object"&&"connect"in e}_stopConnection(e){if(this._logger.log(h.Debug,`HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`),this.transport=void 0,e=this._stopError||e,this._stopError=void 0,this._connectionState==="Disconnected"){this._logger.log(h.Debug,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`);return}if(this._connectionState==="Connecting")throw this._logger.log(h.Warning,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);if(this._connectionState==="Disconnecting"&&this._stopPromiseResolver(),e?this._logger.log(h.Error,`Connection disconnected with error '${e}'.`):this._logger.log(h.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(t=>{this._logger.log(h.Error,`TransportSendQueue.stop() threw error '${t}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this._logger.log(h.Error,`HttpConnection.onclose(${e}) threw error '${t}'.`)}}}_resolveUrl(e){if(e.lastIndexOf("https://",0)===0||e.lastIndexOf("http://",0)===0)return e;if(!P.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(h.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){const t=new URL(e);t.pathname.endsWith("/")?t.pathname+="negotiate":t.pathname+="/negotiate";const n=new URLSearchParams(t.searchParams);return n.has("negotiateVersion")||n.append("negotiateVersion",this._negotiateVersion.toString()),n.has("useStatefulReconnect")?n.get("useStatefulReconnect")==="true"&&(this._options._useStatefulReconnect=!0):this._options._useStatefulReconnect===!0&&n.append("useStatefulReconnect","true"),t.search=n.toString(),t.toString()}}function an(r,e){return!r||(e&r)!==0}class Ne{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new Te,this._transportResult=new Te,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new Te),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new Te;const e=this._transportResult;this._transportResult=void 0;const t=typeof this._buffer[0]=="string"?this._buffer.join(""):Ne._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(t),e.resolve()}catch(n){e.reject(n)}}}static _concatBuffers(e){const t=e.map(o=>o.byteLength).reduce((o,i)=>o+i),n=new Uint8Array(t);let s=0;for(const o of e)n.set(new Uint8Array(o),s),s+=o.byteLength;return n.buffer}}class Te{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}}const cn="json";class ln{constructor(){this.name=cn,this.version=2,this.transferFormat=F.Text}parseMessages(e,t){if(typeof e!="string")throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];t===null&&(t=pe.instance);const n=K.parse(e),s=[];for(const o of n){const i=JSON.parse(o);if(typeof i.type!="number")throw new Error("Invalid payload.");switch(i.type){case y.Invocation:this._isInvocationMessage(i);break;case y.StreamItem:this._isStreamItemMessage(i);break;case y.Completion:this._isCompletionMessage(i);break;case y.Ping:break;case y.Close:break;case y.Ack:this._isAckMessage(i);break;case y.Sequence:this._isSequenceMessage(i);break;default:t.log(h.Information,"Unknown message type '"+i.type+"' ignored.");continue}s.push(i)}return s}writeMessage(e){return K.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),e.invocationId!==void 0&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),e.item===void 0)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_isAckMessage(e){if(typeof e.sequenceId!="number")throw new Error("Invalid SequenceId for Ack message.")}_isSequenceMessage(e){if(typeof e.sequenceId!="number")throw new Error("Invalid SequenceId for Sequence message.")}_assertNotEmptyString(e,t){if(typeof e!="string"||e==="")throw new Error(t)}}const un={trace:h.Trace,debug:h.Debug,info:h.Information,information:h.Information,warn:h.Warning,warning:h.Warning,error:h.Error,critical:h.Critical,none:h.None};function dn(r){const e=un[r.toLowerCase()];if(typeof e<"u")return e;throw new Error(`Unknown log level: ${r}`)}class hn{configureLogging(e){if(O.isRequired(e,"logging"),fn(e))this.logger=e;else if(typeof e=="string"){const t=dn(e);this.logger=new be(t)}else this.logger=new be(e);return this}withUrl(e,t){return O.isRequired(e,"url"),O.isNotEmpty(e,"url"),this.url=e,typeof t=="object"?this.httpConnectionOptions={...this.httpConnectionOptions,...t}:this.httpConnectionOptions={...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return O.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new Ze(e):this.reconnectPolicy=e:this.reconnectPolicy=new Ze,this}withServerTimeout(e){return O.isRequired(e,"milliseconds"),this._serverTimeoutInMilliseconds=e,this}withKeepAliveInterval(e){return O.isRequired(e,"milliseconds"),this._keepAliveIntervalInMilliseconds=e,this}withStatefulReconnect(e){return this.httpConnectionOptions===void 0&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=e==null?void 0:e.bufferSize,this}build(){const e=this.httpConnectionOptions||{};if(e.logger===void 0&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const t=new rn(this.url,e);return xe.create(t,this.logger||pe.instance,this.protocol||new ln,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}}function fn(r){return r.log!==void 0}var S;(function(r){r[r.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",r[r.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",r[r.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(S||(S={}));var pn=function(){function r(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return r.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},r.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.findTransformMetadatas=function(e,t,n){return this.findMetadatas(this._transformMetadatas,e,t).filter(function(s){return!s.options||s.options.toClassOnly===!0&&s.options.toPlainOnly===!0?!0:s.options.toClassOnly===!0?n===S.CLASS_TO_CLASS||n===S.PLAIN_TO_CLASS:s.options.toPlainOnly===!0?n===S.CLASS_TO_PLAIN:!0})},r.prototype.findExcludeMetadata=function(e,t){return this.findMetadata(this._excludeMetadatas,e,t)},r.prototype.findExposeMetadata=function(e,t){return this.findMetadata(this._exposeMetadatas,e,t)},r.prototype.findExposeMetadataByCustomName=function(e,t){return this.getExposedMetadatas(e).find(function(n){return n.options&&n.options.name===t})},r.prototype.findTypeMetadata=function(e,t){return this.findMetadata(this._typeMetadatas,e,t)},r.prototype.getStrategy=function(e){var t=this._excludeMetadatas.get(e),n=t&&t.get(void 0),s=this._exposeMetadatas.get(e),o=s&&s.get(void 0);return n&&o||!n&&!o?"none":n?"excludeAll":"exposeAll"},r.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},r.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},r.prototype.getExposedProperties=function(e,t){return this.getExposedMetadatas(e).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?t===S.CLASS_TO_CLASS||t===S.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?t===S.CLASS_TO_PLAIN:!0}).map(function(n){return n.propertyName})},r.prototype.getExcludedProperties=function(e,t){return this.getExcludedMetadatas(e).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?t===S.CLASS_TO_CLASS||t===S.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?t===S.CLASS_TO_PLAIN:!0}).map(function(n){return n.propertyName})},r.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},r.prototype.getMetadata=function(e,t){var n=e.get(t),s;n&&(s=Array.from(n.values()).filter(function(g){return g.propertyName!==void 0}));for(var o=[],i=0,c=this.getAncestors(t);i<c.length;i++){var a=c[i],l=e.get(a);if(l){var u=Array.from(l.values()).filter(function(g){return g.propertyName!==void 0});o.push.apply(o,u)}}return o.concat(s||[])},r.prototype.findMetadata=function(e,t,n){var s=e.get(t);if(s){var o=s.get(n);if(o)return o}for(var i=0,c=this.getAncestors(t);i<c.length;i++){var a=c[i],l=e.get(a);if(l){var u=l.get(n);if(u)return u}}},r.prototype.findMetadatas=function(e,t,n){var s=e.get(t),o;s&&(o=s.get(n));for(var i=[],c=0,a=this.getAncestors(t);c<a.length;c++){var l=a[c],u=e.get(l);u&&u.has(n)&&i.push.apply(i,u.get(n))}return i.slice().reverse().concat((o||[]).slice().reverse())},r.prototype.getAncestors=function(e){if(!e)return[];if(!this._ancestorsMap.has(e)){for(var t=[],n=Object.getPrototypeOf(e.prototype.constructor);typeof n.prototype<"u";n=Object.getPrototypeOf(n.prototype.constructor))t.push(n);this._ancestorsMap.set(e,t)}return this._ancestorsMap.get(e)},r}(),z=new pn;function gn(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self}function mn(r){return r!==null&&typeof r=="object"&&typeof r.then=="function"}var Ve=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function _n(r){var e=new r;return!(e instanceof Set)&&!("push"in e)?[]:e}var ie=function(){function r(e,t){this.transformationType=e,this.options=t,this.recursionStack=new Set}return r.prototype.transform=function(e,t,n,s,o,i){var c=this;if(i===void 0&&(i=0),Array.isArray(t)||t instanceof Set){var a=s&&this.transformationType===S.PLAIN_TO_CLASS?_n(s):[];return t.forEach(function(m,T){var w=e?e[T]:void 0;if(!c.options.enableCircularCheck||!c.isCircular(m)){var C=void 0;if(typeof n!="function"&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(c.transformationType===S.PLAIN_TO_CLASS){C=n.options.discriminator.subTypes.find(function(Y){return Y.name===m[n.options.discriminator.property]});var X={newObject:a,object:m,property:void 0},v=n.typeFunction(X);C===void 0?C=v:C=C.value,n.options.keepDiscriminatorProperty||delete m[n.options.discriminator.property]}c.transformationType===S.CLASS_TO_CLASS&&(C=m.constructor),c.transformationType===S.CLASS_TO_PLAIN&&(m[n.options.discriminator.property]=n.options.discriminator.subTypes.find(function(Y){return Y.value===m.constructor}).name)}else C=n;var L=c.transform(w,m,C,void 0,m instanceof Map,i+1);a instanceof Set?a.add(L):a.push(L)}else c.transformationType===S.CLASS_TO_CLASS&&(a instanceof Set?a.add(m):a.push(m))}),a}else{if(n===String&&!o)return t==null?t:String(t);if(n===Number&&!o)return t==null?t:Number(t);if(n===Boolean&&!o)return t==null?t:!!t;if((n===Date||t instanceof Date)&&!o)return t instanceof Date?new Date(t.valueOf()):t==null?t:new Date(t);if(gn().Buffer&&(n===Buffer||t instanceof Buffer)&&!o)return t==null?t:Buffer.from(t);if(mn(t)&&!o)return new Promise(function(m,T){t.then(function(w){return m(c.transform(void 0,w,n,void 0,void 0,i+1))},T)});if(!o&&t!==null&&typeof t=="object"&&typeof t.then=="function")return t;if(typeof t=="object"&&t!==null){!n&&t.constructor!==Object&&(!Array.isArray(t)&&t.constructor===Array||(n=t.constructor)),!n&&e&&(n=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(t);var l=this.getKeys(n,t,o),u=e||{};!e&&(this.transformationType===S.PLAIN_TO_CLASS||this.transformationType===S.CLASS_TO_CLASS)&&(o?u=new Map:n?u=new n:u={});for(var g=function(m){if(m==="__proto__"||m==="constructor")return"continue";var T=m,w=m,C=m;if(!p.options.ignoreDecorators&&n){if(p.transformationType===S.PLAIN_TO_CLASS){var X=z.findExposeMetadataByCustomName(n,m);X&&(C=X.propertyName,w=X.propertyName)}else if(p.transformationType===S.CLASS_TO_PLAIN||p.transformationType===S.CLASS_TO_CLASS){var X=z.findExposeMetadata(n,m);X&&X.options&&X.options.name&&(w=X.options.name)}}var v=void 0;p.transformationType===S.PLAIN_TO_CLASS?v=t[T]:t instanceof Map?v=t.get(T):t[T]instanceof Function?v=t[T]():v=t[T];var L=void 0,Y=v instanceof Map;if(n&&o)L=n;else if(n){var N=z.findTypeMetadata(n,C);if(N){var $e={newObject:u,object:t,property:C},fe=N.typeFunction?N.typeFunction($e):N.reflectedType;N.options&&N.options.discriminator&&N.options.discriminator.property&&N.options.discriminator.subTypes?t[T]instanceof Array?L=N:(p.transformationType===S.PLAIN_TO_CLASS&&(L=N.options.discriminator.subTypes.find(function(J){if(v&&v instanceof Object&&N.options.discriminator.property in v)return J.name===v[N.options.discriminator.property]}),L===void 0?L=fe:L=L.value,N.options.keepDiscriminatorProperty||v&&v instanceof Object&&N.options.discriminator.property in v&&delete v[N.options.discriminator.property]),p.transformationType===S.CLASS_TO_CLASS&&(L=v.constructor),p.transformationType===S.CLASS_TO_PLAIN&&v&&(v[N.options.discriminator.property]=N.options.discriminator.subTypes.find(function(J){return J.value===v.constructor}).name)):L=fe,Y=Y||N.reflectedType===Map}else if(p.options.targetMaps)p.options.targetMaps.filter(function(J){return J.target===n&&!!J.properties[C]}).forEach(function(J){return L=J.properties[C]});else if(p.options.enableImplicitConversion&&p.transformationType===S.PLAIN_TO_CLASS){var _e=Reflect.getMetadata("design:type",n.prototype,C);_e&&(L=_e)}}var ye=Array.isArray(t[T])?p.getReflectedType(n,C):void 0,we=e?e[T]:void 0;if(u.constructor.prototype){var b=Object.getOwnPropertyDescriptor(u.constructor.prototype,w);if((p.transformationType===S.PLAIN_TO_CLASS||p.transformationType===S.CLASS_TO_CLASS)&&(b&&!b.set||u[w]instanceof Function))return"continue"}if(!p.options.enableCircularCheck||!p.isCircular(v)){var H=p.transformationType===S.PLAIN_TO_CLASS?w:m,A=void 0;p.transformationType===S.CLASS_TO_PLAIN?(A=t[H],A=p.applyCustomTransformations(A,n,H,t,p.transformationType),A=t[H]===A?v:A,A=p.transform(we,A,L,ye,Y,i+1)):v===void 0&&p.options.exposeDefaultValues?A=u[w]:(A=p.transform(we,v,L,ye,Y,i+1),A=p.applyCustomTransformations(A,n,H,t,p.transformationType)),(A!==void 0||p.options.exposeUnsetFields)&&(u instanceof Map?u.set(w,A):u[w]=A)}else if(p.transformationType===S.CLASS_TO_CLASS){var A=v;A=p.applyCustomTransformations(A,n,m,t,p.transformationType),(A!==void 0||p.options.exposeUnsetFields)&&(u instanceof Map?u.set(w,A):u[w]=A)}},p=this,x=0,U=l;x<U.length;x++){var G=U[x];g(G)}return this.options.enableCircularCheck&&this.recursionStack.delete(t),u}else return t}},r.prototype.applyCustomTransformations=function(e,t,n,s,o){var i=this,c=z.findTransformMetadatas(t,n,this.transformationType);return this.options.version!==void 0&&(c=c.filter(function(a){return a.options?i.checkVersion(a.options.since,a.options.until):!0})),this.options.groups&&this.options.groups.length?c=c.filter(function(a){return a.options?i.checkGroups(a.options.groups):!0}):c=c.filter(function(a){return!a.options||!a.options.groups||!a.options.groups.length}),c.forEach(function(a){e=a.transformFn({value:e,key:n,obj:s,type:o,options:i.options})}),e},r.prototype.isCircular=function(e){return this.recursionStack.has(e)},r.prototype.getReflectedType=function(e,t){if(e){var n=z.findTypeMetadata(e,t);return n?n.reflectedType:void 0}},r.prototype.getKeys=function(e,t,n){var s=this,o=z.getStrategy(e);o==="none"&&(o=this.options.strategy||"exposeAll");var i=[];if((o==="exposeAll"||n)&&(t instanceof Map?i=Array.from(t.keys()):i=Object.keys(t)),n)return i;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&e){var c=z.getExposedProperties(e,this.transformationType),a=z.getExcludedProperties(e,this.transformationType);i=Ve(Ve([],c,!0),a,!0)}if(!this.options.ignoreDecorators&&e){var c=z.getExposedProperties(e,this.transformationType);this.transformationType===S.PLAIN_TO_CLASS&&(c=c.map(function(g){var p=z.findExposeMetadata(e,g);return p&&p.options&&p.options.name?p.options.name:g})),this.options.excludeExtraneousValues?i=c:i=i.concat(c);var l=z.getExcludedProperties(e,this.transformationType);l.length>0&&(i=i.filter(function(g){return!l.includes(g)})),this.options.version!==void 0&&(i=i.filter(function(g){var p=z.findExposeMetadata(e,g);return!p||!p.options?!0:s.checkVersion(p.options.since,p.options.until)})),this.options.groups&&this.options.groups.length?i=i.filter(function(g){var p=z.findExposeMetadata(e,g);return!p||!p.options?!0:s.checkGroups(p.options.groups)}):i=i.filter(function(g){var p=z.findExposeMetadata(e,g);return!p||!p.options||!p.options.groups||!p.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(i=i.filter(function(u){return s.options.excludePrefixes.every(function(g){return u.substr(0,g.length)!==g})})),i=i.filter(function(u,g,p){return p.indexOf(u)===g}),i},r.prototype.checkVersion=function(e,t){var n=!0;return n&&e&&(n=this.options.version>=e),n&&t&&(n=this.options.version<t),n},r.prototype.checkGroups=function(e){return e?this.options.groups.some(function(t){return e.includes(t)}):!0},r}(),ae={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},q=function(){return q=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=e[s])}return r},q.apply(this,arguments)},yn=function(){function r(){}return r.prototype.instanceToPlain=function(e,t){var n=new ie(S.CLASS_TO_PLAIN,q(q({},ae),t));return n.transform(void 0,e,void 0,void 0,void 0,void 0)},r.prototype.classToPlainFromExist=function(e,t,n){var s=new ie(S.CLASS_TO_PLAIN,q(q({},ae),n));return s.transform(t,e,void 0,void 0,void 0,void 0)},r.prototype.plainToInstance=function(e,t,n){var s=new ie(S.PLAIN_TO_CLASS,q(q({},ae),n));return s.transform(void 0,t,e,void 0,void 0,void 0)},r.prototype.plainToClassFromExist=function(e,t,n){var s=new ie(S.PLAIN_TO_CLASS,q(q({},ae),n));return s.transform(e,t,void 0,void 0,void 0,void 0)},r.prototype.instanceToInstance=function(e,t){var n=new ie(S.CLASS_TO_CLASS,q(q({},ae),t));return n.transform(void 0,e,void 0,void 0,void 0,void 0)},r.prototype.classToClassFromExist=function(e,t,n){var s=new ie(S.CLASS_TO_CLASS,q(q({},ae),n));return s.transform(t,e,void 0,void 0,void 0,void 0)},r.prototype.serialize=function(e,t){return JSON.stringify(this.instanceToPlain(e,t))},r.prototype.deserialize=function(e,t,n){var s=JSON.parse(t);return this.plainToInstance(e,s,n)},r.prototype.deserializeArray=function(e,t,n){var s=JSON.parse(t);return this.plainToInstance(e,s,n)},r}(),wn=new yn;function ce(r,e,t){return wn.deserializeArray(r,e,t)}const Ce="1.0.90",Sn=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],bn=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],Tn=[],Cn=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],In=[{Run:"3",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"2",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"1",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"}],vn=[{type:"mg",resource:"Tenant Root Group",cost:0,expanded:!0,resources:[{type:"sub",resource:"Applications",cost:16677.52,expanded:!0,resources:[{type:"rg",resource:"ssfdev",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFServices",cost:0,expanded:!1,resources:[]}]}]},{type:"sub",resource:"Infrastructure",cost:8737.58,expanded:!0,resources:[{type:"rg",resource:"SFFA_Prod_Mgmt_Shared_Resources_RG",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFA-Prod-UTIL-01",cost:0,expanded:!1,resources:[]}]}]}]}],kn=[{type:"user",actor:"arvind@mindline.site",resource:"kv-syncproject",role:"Key Vault Certificate Officer",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]},{type:"app",actor:"mindline1-sync-512169f5-38d1-4b57-be8b-967f2d0ae4c6",resource:"dev-subscription",role:"Contributor",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]}],le="workspaceIDs";function An(r,e){return r+e}function En(){return"hello NPM"}class E{constructor(){d(this,"result");d(this,"status");d(this,"error");d(this,"version");d(this,"array");this.result=!0,this.status=200,this.error="",this.version=Ce,this.array=null}}class ue{}d(ue,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),d(ue,"azureListRootAssignments","https://management.azure.com/providers/Microsoft.Authorization/roleAssignments?api-version=2022-04-01&$filter=principalId+eq+");const B=class B{static adminEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static configConsentEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${B.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static signalREndpoint(){return`https://${B.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}};d(B,"environmentTag","dev");let D=B;class _{}d(_,"graphGroupsPredicate","v1.0/groups"),d(_,"graphMailPredicate","v1.0/me/messages"),d(_,"graphMePredicate","v1.0/me"),d(_,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),d(_,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),d(_,"graphUsersPredicate","v1.0/users"),d(_,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),d(_,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),d(_,"authorityWW","https://login.microsoftonline.com/"),d(_,"authorityWWRegex",/^(https:\/\/login\.microsoftonline\.com\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),d(_,"authorityUS","https://login.microsoftonline.us/"),d(_,"authorityUSRegex",/^(https:\/\/login\.microsoftonline\.us\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),d(_,"authorityCN","https://login.partner.microsoftonline.cn/"),d(_,"authorityCNRegex",/^(https:\/\/login\.partner\.microsoftonline\.cn\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/);class Pn{constructor(){d(this,"id","");d(this,"displayName","");d(this,"description","")}}class $n{constructor(){d(this,"group","");d(this,"value","");d(this,"consented",!1);d(this,"removable",!1);d(this,"expanded","")}static compareByValue(e,t){return e.value.localeCompare(t.value)}static compareByGroup(e,t){return e.group.localeCompare(t.group)}}class Ie{constructor(){d(this,"oid");d(this,"name");d(this,"mail");d(this,"authority");d(this,"tid");d(this,"companyName");d(this,"companyDomain");d(this,"workspaceIDs");d(this,"session");d(this,"spacode");d(this,"graphAccessToken");d(this,"mindlineAccessToken");d(this,"azureAccessToken");d(this,"loginHint");d(this,"scopes");d(this,"authTS");d(this,"sel");d(this,"loggingIn");this.oid="",this.name="",this.mail="",this.authority="",this.tid="",this.companyName="",this.companyDomain="",this.workspaceIDs="",this.session="Sign In",this.spacode="",this.graphAccessToken="",this.mindlineAccessToken="",this.azureAccessToken="",this.loginHint="",this.scopes=new Array,this.authTS=new Date(0),this.sel=!1,this.loggingIn=!1}}var et=(r=>(r[r.invalid=0]="invalid",r[r.aad=1]="aad",r[r.ad=2]="ad",r[r.googleworkspace=3]="googleworkspace",r))(et||{}),tt=(r=>(r[r.read=1]="read",r[r.write=2]="write",r[r.notassigned=3]="notassigned",r))(tt||{});class de{constructor(){d(this,"tid");d(this,"name");d(this,"domain");d(this,"tenantType");d(this,"authority");d(this,"workspaceIDs");d(this,"sel");d(this,"graphSP");d(this,"lookupfield");this.tid="",this.name="",this.domain="",this.tenantType="aad",this.authority="",this.workspaceIDs="",this.sel=!1,this.graphSP="",this.lookupfield="Domain"}}function Dn(r,e){switch(r){case _.authorityWW:return e===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case _.authorityUS:return e===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case _.authorityCN:return e===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function oe(r){switch(r){case _.authorityWW:return"https://graph.microsoft.com/";case _.authorityUS:return"https://graph.microsoft.us/";case _.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function Rn(r){switch(r){case _.authorityWW:return"https://login.microsoftonline.com/";case _.authorityUS:return"https://login.microsoftonline.us/";case _.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var nt=(r=>(r[r.source=1]="source",r[r.target=2]="target",r[r.sourcetarget=3]="sourcetarget",r))(nt||{});class st{constructor(){d(this,"tid");d(this,"sourceGroupId");d(this,"sourceGroupName");d(this,"targetGroupId");d(this,"targetGroupName");d(this,"configurationTenantType");d(this,"deltaToken");d(this,"usersWritten");d(this,"configId");d(this,"batchId");d(this,"isReadPermissionConsented");d(this,"isWritePermissionConsented");this.tid="",this.sourceGroupId="",this.sourceGroupName="",this.targetGroupId="",this.targetGroupName="",this.configurationTenantType="source",this.deltaToken="",this.usersWritten=0,this.configId="",this.batchId="",this.isReadPermissionConsented=!1,this.isWritePermissionConsented=!1}}class ve{constructor(){d(this,"id");d(this,"workspaceId");d(this,"name");d(this,"description");d(this,"tenants");d(this,"isEnabled");d(this,"workspaceIDs");d(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.tenants=new Array,this.isEnabled=!1,this.workspaceIDs="",this.sel=!1}}class ke{constructor(){d(this,"id");d(this,"name");d(this,"ownerid");d(this,"associatedUsers");d(this,"associatedTenants");d(this,"associatedConfigs");d(this,"sel");this.id="",this.name="",this.ownerid="",this.associatedUsers=new Array,this.associatedTenants=new Array,this.associatedConfigs=new Array,this.sel=!1}}function V(){let r;try{r=window.localStorage;const e="__storage_test__";return r.setItem(e,e),r.removeItem(e),!0}catch(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")&&r&&r.length!==0}}class xn{constructor(e=!1){De(this,Pe);d(this,"version","");d(this,"tab",0);d(this,"us",[]);d(this,"ts",[]);d(this,"cs",[]);d(this,"ws",[]);d(this,"configlevelconsent_configid","");d(this,"configlevelconsent_access",3);this.init(e)}init(e){if(console.log(`Calling InitInfo::init(bClearLocalStorage: ${e?"true":"false"})`),V()){let i=localStorage.getItem("InitInfo");if(i!=null&&typeof i=="string"&&i!==""){let a=JSON.parse(i);if(a.us.length!==0)if(e)localStorage.removeItem("InitInfo");else{ee(this,Pe,$t).call(this,a);return}}}this.tab=0,this.version=Ce,this.configlevelconsent_configid="",this.configlevelconsent_access=3;var t=JSON.stringify(Sn),n=JSON.stringify(bn),s=JSON.stringify(Tn),o=JSON.stringify(Cn);try{this.us=ce(Ie,t),this.ts=ce(de,n),this.cs=ce(ve,s),this.ws=ce(ke,o),this.tagWithWorkspaces()}catch{debugger}}save(){let e=JSON.stringify(this);localStorage.setItem("InitInfo",e)}tagWithWorkspaces(){this.us.map(e=>e.workspaceIDs=""),this.ts.map(e=>e.workspaceIDs=""),this.cs.map(e=>e.workspaceIDs="");for(let e of this.ws){for(let t of e.associatedUsers){let n=this.us.find(s=>s.oid===t);if(n!==void 0)n[le]+=e.id,n[le]+=" ";else debugger}for(let t of e.associatedTenants){let n=this.ts.find(s=>s.tid===t);if(n!==void 0)n[le]+=e.id,n[le]+=" ";else debugger}for(let t of e.associatedConfigs){let n=this.cs.find(s=>s.id===t);if(n!==void 0)n[le]+=e.id,n[le]+=" ";else debugger}}return!0}}Pe=new WeakSet,$t=function(e){this.tab=e.tab,this.version=Ce,this.configlevelconsent_configid=e.configlevelconsent_configid,this.configlevelconsent_access=e.configlevelconsent_access,typeof e.us>"u"?this.us=new Array:this.us=e.us.map(t=>{let n=new Ie;return n.oid=t.oid,n.name=t.name,n.mail=t.mail,n.authority=t.authority,n.tid=t.tid,n.companyName=t.companyName,n.companyDomain=t.companyDomain,n.workspaceIDs=t.workspaceIDs,n.session=t.session,n.spacode=t.spacode,n.graphAccessToken=t.graphAccessToken,n.mindlineAccessToken=t.mindlineAccessToken,n.azureAccessToken=t.azureAccessToken,n.loginHint=t.loginHint,n.scopes=t.scopes,n.authTS=new Date(t.authTS),n.sel=t.sel,n.loggingIn=t.loggingIn,n}),typeof e.ts>"u"?this.ts=new Array:this.ts=e.ts.map(t=>{let n=new de;return n.tid=t.tid,n.name=t.name,n.domain=t.domain,n.tenantType=t.tenantType,n.authority=t.authority,n.workspaceIDs=t.workspaceIDs,n.sel=t.sel,n.lookupfield=t.lookupfield,n}),typeof e.cs>"u"?this.cs=new Array:this.cs=e.cs.map(t=>{let n=new ve;return n.id=t.id,n.workspaceId=t.workspaceId,n.name=t.name,n.description=t.description,n.tenants=t.tenants,n.isEnabled=t.isEnabled,n.workspaceIDs=t.workspaceIDs,n.sel=t.sel,n}),typeof e.ws>"u"?this.ws=new Array:this.ws=e.ws.map(t=>{let n=new ke;return n.id=t.id,n.name=t.name,n.ownerid=t.ownerid,n.associatedUsers=t.associatedUsers,n.associatedTenants=t.associatedTenants,n.associatedConfigs=t.associatedConfigs,n.sel=t.sel,n})};const Nn=[{id:1,task:"initialization",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:22",status:"not started",expanded:!0,subtasks:[{id:2,task:"authenticate user",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:3,task:"reload React",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:07",status:"not started"},{id:4,task:"GET tenant details",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:5,task:"POST config init",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:10",status:"not started"},{id:6,task:"GET workspaces",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:04",status:"not started"}]}];class On{constructor(e){De(this,Q);d(this,"tasks");this.tasks=[new Ae],this.init(e)}init(e){if(console.log(`Calling TaskArray::init(bClearLocalStorage: ${e?"true":"false"})`),this.tasks.length=0,e&&V()&&localStorage.removeItem("Tasks"),V()){let t=localStorage.getItem("Tasks");if(t!=null&&typeof t=="string"&&t!==""){let s=JSON.parse(t);if(this.tasks=ee(this,Q,He).call(this,s.tasks),this.tasks.length!==0)return}}this.tasks=ee(this,Q,He).call(this,Nn)}setTaskStart(e,t){let n=ee(this,Q,Ue).call(this,e);if(n!=null&&n!=null)n.setStart(t),n.status="in progress",ee(this,Q,je).call(this);else debugger}setTaskEnd(e,t,n){let s=ee(this,Q,Ue).call(this,e);if(s!=null&&s!=null)s.setEnd(t),s.status=n,ee(this,Q,je).call(this);else debugger}}Q=new WeakSet,Ue=function(e){let t=this.tasks.find(n=>n.task==e);if(t==null||t==null){for(t of this.tasks)if(t.subtasks!=null&&t.subtasks!=null&&(t=t.subtasks.find(n=>n.task==e),t!=null&&t!=null))break}return t},He=function(e){return e.map(t=>{let n=new Ae;return n.id=t.id,n.task=t.task,n.setStart(new Date(t.start)),n.setEnd(new Date(t.end)),n.expected=t.expected,n.status=t.status,n.expanded=t.expanded,typeof t.subtasks<"u"&&t.subtasks!=null&&(n.subtasks=t.subtasks.map(s=>{let o=new Ae;return o.id=s.id,o.task=s.task,o.setStart(new Date(s.start)),o.setEnd(new Date(s.end)),o.expected=s.expected,o.status=s.status,o.expanded=s.expanded,o})),n})},je=function(){let e=JSON.stringify(this);V()&&localStorage.setItem("Tasks",e)};class Ae{constructor(){d(this,"id",0);d(this,"task","");d(this,"start",new Date);d(this,"startDisplay","");d(this,"end",new Date);d(this,"endDisplay","");d(this,"elapsedDisplay","");d(this,"expected",0);d(this,"status","");d(this,"expanded",!1);d(this,"subtasks",[])}setEnd(e){this.end=e,this.endDisplay=`${this.end.getMinutes().toString().padStart(2,"0")}:${this.end.getSeconds().toString().padStart(2,"0")}`;let t=0,n=this.end.getSeconds()-this.start.getSeconds();n<0&&(n+=60,t=-1);let s=this.end.getMinutes()-this.start.getMinutes()+t;s<0&&(s+=60),this.elapsedDisplay=`${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}setStart(e){this.start=e,this.startDisplay=`${this.start.getMinutes().toString().padStart(2,"0")}:${this.start.getSeconds().toString().padStart(2,"0")}`}}class he{constructor(e){d(this,"Run",0);d(this,"Start",new Date);d(this,"startDisplay","");d(this,"POST");d(this,"postDisplay");d(this,"Read");d(this,"readDisplay");d(this,"Write");d(this,"writeDisplay");d(this,"Duration");d(this,"durationDisplay");this.Run=e,this.start(""),this.POST=new Date,this.postDisplay="",this.Read=new Date,this.readDisplay="",this.Write=new Date,this.writeDisplay="",this.Duration=new Date,this.durationDisplay=""}start(e){e==""?this.Start=new Date:this.Start=new Date(e),this.startDisplay=`${this.Start.getMinutes().toString().padStart(2,"0")}:${this.Start.getSeconds().toString().padStart(2,"0")}`}post(e){e==""?this.POST=new Date:this.POST=new Date(e),this.postDisplay=`${this.POST.getMinutes().toString().padStart(2,"0")}:${this.POST.getSeconds().toString().padStart(2,"0")}`}read(e){e==""?this.Read=new Date:this.Read=new Date(e),this.readDisplay=`${this.Read.getMinutes().toString().padStart(2,"0")}:${this.Read.getSeconds().toString().padStart(2,"0")}`}write(e){e==""?this.Write=new Date:this.Write=new Date(e),this.writeDisplay=`${this.Write.getMinutes().toString().padStart(2,"0")}:${this.Write.getSeconds().toString().padStart(2,"0")}`,this.Duration=new Date(this.Write.getTime()-this.Start.getTime()),this.durationDisplay=`${this.Duration.getMinutes().toString().padStart(2,"0")}:${this.Duration.getSeconds().toString().padStart(2,"0")}`}}class ot{constructor(e){De(this,me);d(this,"milestones",[]);this.init(e)}init(e){if(V()){let t=localStorage.getItem("syncmilestones");if(t!=null&&typeof t=="string"&&t!==""){let s=JSON.parse(t);if(s.length!==0)if(e)localStorage.removeItem("syncmilestones");else{ee(this,me,ze).call(this,s);return}}}ee(this,me,ze).call(this,In)}save(){let e=JSON.stringify(this.milestones);V()&&localStorage.setItem("syncmilestones",e)}start(e){if(this.milestones==null||this.milestones.length<1){debugger;return}let t=Number(this.milestones[0].Run),n=new he(t+1);this.milestones.unshift(n),this.milestones=this.milestones.map(s=>{let o=new he(s.Run);return o.Start=s.Start,o.startDisplay=s.startDisplay,o.POST=s.POST,o.postDisplay=s.postDisplay,o.Read=s.Read,o.readDisplay=s.readDisplay,o.Write=s.Write,o.writeDisplay=s.writeDisplay,o.Duration=s.Duration,o.durationDisplay=s.durationDisplay,o}),e(this.milestones),console.log(`Start milestone: ${this.milestones[0].Run}:${this.milestones[0].Start}`)}unstart(e){if(this.milestones==null||this.milestones.length<1){debugger;return}let t=this.milestones.shift();this.milestones=this.milestones.map(n=>{let s=new he(n.Run);return s.Start=n.Start,s.startDisplay=n.startDisplay,s.POST=n.POST,s.postDisplay=n.postDisplay,s.Read=n.Read,s.readDisplay=n.readDisplay,s.Write=n.Write,s.writeDisplay=n.writeDisplay,s.Duration=n.Duration,s.durationDisplay=n.durationDisplay,s}),e(this.milestones),console.log(`Unstart removed first milestone: ${t.Run}:${t.Start}`)}post(e){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].post(""),e(this.milestones),console.log(`POST milestone: ${this.milestones[0].Run}:${this.milestones[0].POST}`)}read(e){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].read(""),e(this.milestones),console.log(`Read milestone: ${this.milestones[0].Run}:${this.milestones[0].Read}`)}write(e){if(this.milestones==null||this.milestones.length<1){debugger;return}for(this.milestones[0].write("");this.milestones.length>10;){let t=this.milestones.pop();console.log(`Removed milestone #${t.Run}: ${t.Start}`)}this.save(),this.milestones=this.milestones.map(t=>{let n=new he(t.Run);return n.Start=t.Start,n.startDisplay=t.startDisplay,n.POST=t.POST,n.postDisplay=t.postDisplay,n.Read=t.Read,n.readDisplay=t.readDisplay,n.Write=t.Write,n.writeDisplay=t.writeDisplay,n.Duration=t.Duration,n.durationDisplay=t.durationDisplay,n}),e(this.milestones)}}me=new WeakSet,ze=function(e){e==null?this.milestones=new Array:this.milestones=e.map(t=>{let n=new he(Number(t.Run));return n.start(t.Start),n.post(t.POST),n.read(t.Read),n.write(t.Write),n})};class Mn{constructor(e,t,n){d(this,"tenantNodes");d(this,"pb_startTS");d(this,"pb_progress");d(this,"pb_increment");d(this,"pb_idle");d(this,"pb_idleMax");d(this,"pb_total");d(this,"pb_timer");d(this,"milestoneArray");this.tenantNodes=new Array,this.init(e,t,n),this.pb_startTS=0,this.pb_progress=0,this.pb_increment=0,this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.milestoneArray=new ot(!1)}init(e,t,n){console.log(`Calling BatchArray::init(config: "${e?e.name:"null"}", bClearLocalStorage: ${n?"true":"false"})`),n&&V()&&(localStorage.removeItem(e.name),this.milestoneArray.init(n)),e!=null&&e.tenants!=null&&t!=null&&(this.tenantNodes.length=0,e.tenants.map(s=>{if(s.configurationTenantType==="source"||s.configurationTenantType==="sourcetarget"){let o=t.ts.find(i=>i.tid===s.tid);if(o!=null){let i=new Oe(s.tid,o.name,s.batchId);this.tenantNodes.push(i)}else{console.log(`Error: no tenant found for config source tenant ${e.name}`);debugger;return}}}),this.tenantNodes.map(s=>{e.tenants.map(o=>{if((o.configurationTenantType==="target"||o.configurationTenantType==="sourcetarget")&&o.tid!==s.tid){let i=t.ts.find(c=>c.tid===o.tid);if(i!=null){let c=new Oe(o.tid,i.name,o.batchId);s.targets.push(c),s.expanded=!0}else{console.log(`Error: no tenant found for config target tenant ${e.name}`);debugger;return}}})}))}initializeProgressBar(e,t,n,s){this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_increment=.25,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.pb_timer=setInterval(()=>{this.milestoneArray.milestones[0].Write!=null?(clearInterval(this.pb_timer),this.pb_timer=null,this.pb_progress=100,e(this.pb_progress),n(`Complete. [max idle: ${this.pb_idleMax}]`)):(this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,this.pb_idleMax=Math.max(this.pb_idle,this.pb_idleMax),n(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`),this.pb_idle>=60&&this.milestoneArray.milestones[0].Write==null&&t(`sync continuing, but no update for ${this.pb_idle} seconds`),this.pb_progress<100&&(this.pb_progress=Math.min(100,this.pb_progress+this.pb_increment),e(this.pb_progress)))},1e3),this.milestoneArray.start(s)}uninitializeProgressBar(e,t,n,s){this.pb_startTS=0,this.pb_progress=0,e(this.pb_progress),t("sync failed to execute"),this.pb_increment=0,clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,n(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`),this.milestoneArray.unstart(s)}initializeSignalR(e,t,n,s,o,i,c,a,l,u,g){this.milestoneArray.post(l),u("started sync, waiting for updates..."),this.init(e,t,!1);let p=x=>{console.log(x);let U=JSON.parse(x);this.pb_idle=0;let G=n.find(b=>b.BatchId==U.TargetID);if(G==null){console.log(`Batch ${U.TargetID} not found in batchIdArray.`);debugger;return}let m=this.tenantNodes.find(b=>b.tid===G.SourceId);if(m==null){console.log(`Tenant ${G.SourceId} not found in BatchArray.`);debugger;return}m.batchId=G.BatchId;let T=U.Stats,w=Object.keys(T),C=Object.values(T),X=!1,v=!1;for(let b=0;b<w.length;b++){let H=w[b].endsWith("TotalCount"),A=w[b].endsWith("CurrentCount"),J=w[b].endsWith("DeferredCount"),Be=w[b].endsWith("RescheduledCount");if(w[b].startsWith("Reader")){let te=/Reader\/TID:(.+)\/TotalCount/;if(A&&(te=/Reader\/TID:(.+)\/CurrentCount/),J&&(te=/Reader\/TID:(.+)\/DeferredCount/),Be&&(te=/Reader\/TID:(.+)\/RescheduledCount/),w[b].match(te)==null){console.log(`tid not found in ${w[b]}.`);debugger;return}H?(X=Number(C[b])==0,m.total=Math.max(Number(C[b]),m.total),console.log(`----- ${m.name} TID: ${m.tid} batchId: ${m.batchId}`),console.log(`----- ${m.name} Total To Read: ${m.total}`)):(v=Number(C[b])==0,m.read=Math.max(Number(C[b]),m.read),console.log(`----- ${m.name} Currently Read: ${m.read}`))}if(m.nothingtosync=X&&v,w[b].startsWith("Writer")){let te=/Writer\/TID:(.+)\/TotalCount/;A&&(te=/Writer\/TID:(.+)\/CurrentCount/),J&&(te=/Writer\/TID:(.+)\/DeferredCount/),Be&&(te=/Writer\/TID:(.+)\/RescheduledCount/);let Fe=w[b].match(te);if(Fe==null){console.log(`tid not found in ${w[b]}.`);debugger;return}let $=m.targets.find(fs=>fs.tid===Fe[1]);if($==null){console.log(`Writer ${m.name} not found under Reader ${m.name}.`);debugger;return}if($.batchId=G.BatchId,H)$.total=Math.max(Number(C[b]),$.total),console.log(`----- ${$.name} TID: ${$.tid} batchId: ${$.batchId}`),console.log(`----- ${$.name} Total To Write: ${$.total}`);else if(A)$.written=Math.max(Number(C[b]),$.written),console.log(`----- ${$.name} Total Written: ${$.written}`);else if(J||Be)$.deferred=Math.max(Number(C[b]),$.deferred),console.log(`----- ${$.name} Total Deferred: ${$.deferred}`);else{console.log("unknown writer type");debugger;return}$.update($.total,$.read,$.written,$.deferred)}}m.update(m.total,m.read,m.written,m.deferred);let L=!0,Y=!0,N=!1,$e=!0,fe=0,_e=0,ye=0,we=0;if(this.tenantNodes.map(b=>{b.targets.map(H=>{Y&&(Y=H.status=="complete"||H.status=="failed"),N||(N=H.total>0||H.status!="not started"),ye+=Math.max(H.total,b.total),we+=H.written}),$e&&($e=b.nothingtosync),L&&(L=b.status=="complete"||b.status=="failed"),fe+=b.total,_e+=b.read}),o(fe),i(_e),c(Math.max(ye,fe)),a(we),$e)this.milestoneArray.write(l),u("nothing to sync"),console.log('Setting config sync result: "nothing to sync"');else{if(L&&this.milestoneArray.milestones[0].Read==null){this.milestoneArray.read(l),u("reading complete"),console.log('Setting config sync result: "reading complete"'),s(e.workspaceId);let J=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=J,console.log(`Setting increment: ${this.pb_increment}% per second`)}Y?(this.milestoneArray.write(l),u("sync complete"),console.log('Setting config sync result: "complete"')):N?(u("writing in progress"),console.log('Setting config sync result: "writing in progress"')):this.milestoneArray.milestones[0].Read==null&&(u("reading in progress"),console.log('Setting config sync result: "reading in progress"'))}};n.map(x=>{const U=D.signalREndpoint();let G=new URL(U);G.searchParams.append("statsId",x.BatchId),console.log(`Creating SignalR Hub for TID: ${x.SourceId} ${G.href}`);const m=new hn().withUrl(G.href).withAutomaticReconnect().configureLogging(h.Information).build();m.on("newMessage",p),m.onreconnecting(T=>{console.assert(m.state===k.Reconnecting),console.log(`Connection lost due to error "${T}". Reconnecting.`)}),m.onreconnected(T=>{console.assert(m.state===k.Connected),console.log(`Connection reestablished. Connected with connectionId "${T}".`)}),m.onclose(async()=>{console.log("Connection closing. Attempting restart."),await m.start()}),m.start().catch(console.error)})}async startSync(e,t,n){let s=new E;if(this.tenantNodes==null||this.tenantNodes.length==0){debugger;return s.result=!1,s.error="startSync: invalid parameters",s.status=500,s}return s=await Et(e,t,n),s}}class Oe{constructor(e,t,n){d(this,"expanded");d(this,"status","");d(this,"name");d(this,"tid");d(this,"batchId");d(this,"total",0);d(this,"read",0);d(this,"written",0);d(this,"deferred",0);d(this,"nothingtosync");d(this,"targets");this.expanded=!1,this.name=t,this.tid=e,this.batchId=n,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0)}update(e,t,n,s){this.total=e,this.read=t,this.written=n,this.deferred=s,this.read===0&&this.written===0&&(this.status="not started"),this.read>0?this.read<this.total?this.status="in progress":this.read===this.total&&(this.status="complete"):this.written>0&&(this.written+this.deferred<this.total?this.status="in progress":this.written===this.total?this.status="complete":this.written+this.deferred>=this.total&&(this.status="failed"))}}class Me{constructor(e,t){d(this,"resourceNodes");this.resourceNodes=new Array,e&&this.init(t)}init(e){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${e?"true":"false"})`),V()){let n=localStorage.getItem("ResourceArray");if(n!=null&&typeof n=="string"&&n!=="")if(e)localStorage.removeItem("ResourceArray");else{let o=JSON.parse(n);this.resourceNodes=o.resourceNodes;return}}var t=JSON.stringify(vn);try{this.resourceNodes=ce(rt,t)}catch{debugger}}async read(e,t){let n=new Me(!1,!1);return n.resourceNodes=await ds(e,t),n}save(){if(V()){let e=JSON.stringify(this);localStorage.setItem("ResourceArray",e)}}}class rt{constructor(e,t,n){d(this,"type");d(this,"resource");d(this,"cost");d(this,"expanded");d(this,"resources");this.type=e,this.resource=t,this.cost=n,this.expanded=!1,this.resources=new Array}}class Ln{constructor(e){d(this,"actorNodes");this.actorNodes=new Array,this.init(e)}init(e){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${e?"true":"false"})`),V()){let n=localStorage.getItem("RBACActors");if(n!=null&&typeof n=="string"&&n!=="")if(e)localStorage.removeItem("RBACActors");else{let o=JSON.parse(n);this.actorNodes=o.actorNodes;return}}var t=JSON.stringify(kn);try{this.actorNodes=ce(it,t)}catch{debugger}}}class it{constructor(e,t,n,s,o,i){d(this,"type");d(this,"actor");d(this,"resource");d(this,"role");d(this,"updatedby");d(this,"updatedon");d(this,"actors");this.type=e,this.actor=t,this.resource=n,this.role=s,this.updatedby=o,this.updatedon=i,this.actors=new Array}}function Gn(r){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function Ee(r,e){const t=new Headers;t.append("Content-Type","application/json"),t.append("accept","*/*");const n=Gn();if(e.graphAccessToken==null||e.graphAccessToken==="")try{let s=await r.acquireTokenByCode({code:e.spacode});e.graphAccessToken=s.accessToken,console.log("Front end token acquired by code: "+e.graphAccessToken.slice(0,20))}catch(s){console.log("Front end token failure: "+s)}else try{let s=r.getAllAccounts(),o=e.oid+"."+e.tid,i=null;for(let a=0;a<s.length;a++)s[a].homeAccountId==o&&(i=s[a]);let c=await r.acquireTokenSilent({scopes:[n],account:i});e.graphAccessToken=c.accessToken,console.log("Front end token graph acquired silently: "+e.graphAccessToken.slice(0,20))}catch(s){try{console.log("Front end graph token silent acquisition failure: "+s);let o=r.getAllAccounts(),i=e.oid+"."+e.tid,c=null;for(let a=0;a<o.length;a++)o[a].homeAccountId==i&&(c=o[a]);r.acquireTokenRedirect({scopes:[n],account:c})}catch(o){console.log("Front end graph token redirect acquisition failure: "+o)}}return t.append("Authorization",`Bearer ${e.graphAccessToken}`),t}async function Wn(r,e,t){if(e==null||e.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let s={method:"GET",headers:await Ee(r,e)};try{let o=oe(e.authority)+_.graphGroupsPredicate;o+=`/?$filter=startsWith(displayName, '${t}')`;let c=await(await fetch(o,s)).json();return typeof c.error<"u"?{groups:[],error:`${c.error.code}: ${c.error.message}`}:{groups:c.value,error:""}}catch(o){return console.log(o),{groups:[],error:`Exception: ${o}`}}}async function at(r,e,t,n){try{let s=oe(e.authority)+_.graphOauth2PermissionGrantsPredicate,o=new URL(s);o.searchParams.append("$filter",`resourceId eq '${t}' and consentType eq 'Principal' and principalId eq '${n}'`);let c=await(await fetch(o.href,r)).json();if(typeof c.error<"u")return{grants:null,id:null,error:`${c.error.code}: ${c.error.message}`};if(c.value.length!=1){debugger;return{grants:null,id:null,error:"oauth2PermissionGrantsGet: more than one matching delegated consent grant."}}return{grants:c.value[0].scope,id:c.value[0].id,error:""}}catch(s){return console.log(s),{grants:null,id:null,error:`Exception: ${s}`}}}async function ct(r,e,t,n){if(e==null||e.spacode=="")return!1;try{let s=oe(e.authority);s+=_.graphOauth2PermissionGrantsPredicate+`/${t}`;let o=`{ "scope": "${n}" }`,c={method:"PATCH",headers:await Ee(r,e),body:o},a=await fetch(s,c),l=await a.json();if(a.status==204&&a.statusText=="No Content")return!0;debugger;return console.log(`oauth2PermissionGrantsSet: PATCH failed ${l.error.code}: ${l.error.message}`),!1}catch(s){debugger;return console.log(s),!1}}function Bn(r,e){let t=Rn(r.authority);t+=r.tid,t+="/adminconsent";let n=new URL(t),s=Dn(r.authority,e);n.searchParams.append("client_id",s),n.searchParams.append("redirect_uri",window.location.origin),n.searchParams.append("domain_hint",r.companyDomain),n.searchParams.append("login_hint",r.mail),window.location.assign(n.href)}async function lt(r,e,t){try{let n=oe(e.authority);n+=_.graphServicePrincipalsPredicate,n+=`(appId='${t}')`;let s=new URL(n);s.searchParams.append("$select","id,appId,displayName");let i=await(await fetch(s.href,r)).json();return typeof i.error<"u"?{spid:"",error:`${i.error.code}: ${i.error.message}`}:{spid:i.id,error:""}}catch(n){return console.log(n),{spid:"",error:`Exception: ${n}`}}}async function Fn(r,e){if(r.authority==""){let s=new de;if(s.domain=r.tid,await Le(s,!1))r.authority=s.authority;else{debugger;return!1}}let t=window.location.href;switch(r.authority){case _.authorityWW:t+="MicrosoftIdentity/Account/SignIn";break;case _.authorityUS:t+="USGov/SignIn";break;case _.authorityCN:t+="China/SignIn";break;default:return!1}let n=new URL(t);if(n.searchParams.append("redirectUri",window.location.origin),r.oid!=="1"){n.searchParams.append("loginHint",r.mail);const s=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,o=r.mail.match(s);let i=o?o[1]:"organizations";n.searchParams.append("domainHint",i)}else n.searchParams.append("domainHint","organizations");return e.setTaskStart("initialization",new Date),e.setTaskStart("authenticate user",new Date),window.location.assign(n.href),!0}function Un(r,e){debugger;if(r.oid=="1")return;let t=window.location.href;switch(r.authority){case _.authorityWW:t+="MicrosoftIdentity/Account/Challenge";break;case _.authorityUS:t+="USGov/Challenge";break;case _.authorityCN:t+="China/Challenge";break;default:return}let n=new URL(t);n.searchParams.append("redirectUri",window.location.origin),n.searchParams.append("scope",e),n.searchParams.append("domainHint","organizations"),n.searchParams.append("loginHint",r.mail),window.location.assign(n.href)}async function Hn(r){if(r.oid=="1")return!1;let e=window.location.href;e+="user";let t=new URL(e);t.searchParams.append("oid",r.oid),t.searchParams.append("tid",r.tid),t.searchParams.append("loginHint",r.loginHint),t.searchParams.append("verb","LOGOUT");let n={method:"PATCH"},s=await fetch(t.href,n);if(s.status==200&&s.statusText=="OK")console.log(`Successfully set admin ${r.mail} logout_hint`);else return console.log(`Failed to set admin ${r.mail} logout_hint`),!1;let o=window.location.href;switch(r.authority){case _.authorityWW:o+="MicrosoftIdentity/Account/SignOut";break;case _.authorityUS:o+="USGov/SignOut";break;case _.authorityCN:o+="China/SignOut";break;default:return!1}return t=new URL(o),t.searchParams.append("redirectUri",window.location.origin),window.location.assign(t.href),!0}async function jn(r,e,t,n){if(n)debugger;if(e.name!=null&&e.name!=="")return!1;if(r.graphAccessToken!=null&&r.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${r.name}`);try{let a=await t.acquireTokenByCode({code:r.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});r.graphAccessToken=a.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+r.graphAccessToken.slice(0,20))}catch(a){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+a),!1}}const s=new Headers,o=`Bearer ${r.graphAccessToken}`;s.append("Authorization",o);let i={method:"GET",headers:s};try{var c=oe(e.authority)+_.graphTenantByDomainPredicate;c+="(domainName='",c+=e.domain,c+="')",console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:",c);let a=await fetch(c,i);if(a.status==200){let l=await a.json();if(l){if(l.error!=null){debugger;return console.log("tenantRelationshipsGetByDomain: Failed GET from /findTenantInformationByDomainName: ",l.error.message),!1}else if(l.displayName!=null&&l.displayName!=="")return e.tid=l.tenantId,e.name=l.displayName,console.log("tenantRelationshipsGetByDomain: Successful GET from /findTenantInformationByDomainName: ",l.displayName),!0}else console.log("tenantRelationshipsGetByDomain: Failed to GET from /findTenantInformationByDomainName: ",c)}}catch(a){return console.log("Failed to GET from /findTenantInformationByDomainName: ",a),!1}return!1}async function ut(r,e,t,n,s){if(console.log("**** tenantRelationshipsGetById"),s)debugger;if(r.graphAccessToken==="")try{let l=await n.acquireTokenByCode({code:r.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});r.graphAccessToken=l.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+r.graphAccessToken.slice(0,20))}catch(l){return console.log("tenantRelationshipsGetById: Front end token failure: "+l),!1}const o=new Headers,i=`Bearer ${r.graphAccessToken}`;o.append("Authorization",i);let c={method:"GET",headers:o};try{var a=oe(r.authority)+_.graphTenantByIdPredicate;a+="(tenantId='",a+=e.tid,a+="')",console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:",a);let u=await(await fetch(a,c)).json();if(u&&typeof u.displayName!==void 0&&u.displayName!==""){if(e!==void 0)e.name=u.displayName,e.domain=u.defaultDomainName;else{console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");debugger}return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ",u.displayName),!0}else console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",a)}catch(l){return console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",l),!1}return!1}async function Le(r,e){if(e)debugger;let t=[_.authorityWW,_.authorityUS,_.authorityCN],n=[_.authorityWWRegex,_.authorityUSRegex,_.authorityCNRegex],s=null;try{for(let a=0;a<3;a++){var o=t[a];if(r.lookupfield=="Domain"?o+=r.domain:r.lookupfield=="Tenant ID"&&(o+=r.tid),o+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",o),s=await fetch(o),s.status==200){let l=await s.json();if(l){var i=l.authorization_endpoint;for(let u=0;u<3;u++){var c=i.match(n[u]);if(c!=null)return r.tid=c[2],r.authority=c[1],console.log(`Successful GET from openid well-known endpoint: tid: ${r.tid} authority: ${r.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${o}.`)}else console.log(`Failed GET from ${o}.`)}}catch(a){console.log("Failed to GET from openid well-known endpoint: ",a)}return(r.tid==""||r.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${s?s.statusText:"unknown"}`),!1}async function dt(r,e,t){if(e==null||e.spacode==""||t==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let s={method:"GET",headers:await Ee(r,e)};try{if(t.graphSP==""){let{spid:a,error:l}=await lt(s,e,"00000003-0000-0000-c000-000000000000");if(l!=""){debugger;return{scopes:null,id:null,error:`${l}`}}t.graphSP=a}let{grants:o,id:i,error:c}=await at(s,e,t.graphSP,e.oid);if(c!=""){debugger;return{scopes:null,id:null,error:`${c}`}}return{scopes:o,id:i,error:""}}catch(o){debugger;return console.log(o),{scopes:null,id:null,error:`Exception: ${o}`}}}async function zn(r,e,t,n){if(e==null||e.spacode==""||t==null){debugger;return!1}let{scopes:s,id:o,error:i}=await dt(r,e,t);if(i!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${e.mail}: ${i}`),!1}s=s.replace(n,"");let c=await ct(r,e,o,s);if(!c){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${e.mail}: ${i}`),!1}return e.scopes=s.split(" "),c}async function qn(r,e){if(e==null||e.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let n={method:"GET",headers:await Ee(r,e)},s=oe(e.authority);s+=_.graphUsersPredicate;let i=await(await fetch(s,n)).json();if(typeof i.error<"u")return{users:[],error:`${i.error.code}: ${i.error.message}`};let c=new Array;for(let a of i.value)c.push(a.mail);return{users:c,error:""}}catch(t){return console.log(t),{users:[],error:`Exception: ${t}`}}}async function Jn(r,e,t,n,s,o,i,c){let a=new E;if(t.id==="1"){if(a=await St(r,e,t,o.id,c),a.result){n&&n(t.id);const l={};Object.defineProperty(l,t.id,{value:!0,writable:!0,enumerable:!0}),s(l);let u=o.associatedConfigs.findIndex(g=>g=="1");u!==-1&&(o.associatedConfigs.splice(u,1),o.associatedConfigs.push(t.id))}}else a=await bt(r,e,t,c);return i.save(),a}async function Kn(r,e,t,n,s){let o=new E;return o=await wt(r,e,t,n,s),o}async function Xn(r,e,t,n,s){return yt(r,e,t,n)}async function Zn(r,e,t,n,s){return mt(r,e,t,n,s)}async function Qn(r,e,t,n,s){return _t(r,e,t,n,s)}async function Yn(r,e,t,n,s){let o=new E;if(s)debugger;try{let i=n.ws.find(c=>c.id===t);if(i!=null){i.associatedConfigs.length=0;let c=await We(r,e,i.id,s);if(!c.result)return c;let a="";for(let l of i.associatedConfigs){let u=n.cs.find(g=>g.id===l);u!=null&&u.sel&&(a=u.id)}ht(i,n,c.array,a),n.tagWithWorkspaces()}return o}catch(i){console.log(i.message),o.error=i.message}return o.result=!1,o.status=500,o}async function Vn(r,e,t,n,s){console.log(">>>>>> initGet");let o=new E;if(s)debugger;let i=new de;return i.tid=e.tid,i.domain=e.tid,await Le(i,s)?(e.authority=i.authority,n.setTaskStart("GET tenant details",new Date),o.result=await ut(e,i,t,r,s),n.setTaskEnd("GET tenant details",new Date,"complete"),o.result&&(e.companyName=i.name,e.companyDomain=i.domain,n.setTaskStart("POST config init",new Date),o=await Tt(r,e,s),n.setTaskEnd("POST config init",new Date,o.result?"complete":"failed")),o.result&&(n.setTaskStart("GET workspaces",new Date),o=await as(r,e,t,s),n.setTaskEnd("GET workspaces",new Date,o.result?"complete":"failed")),console.log("initGet complete. Version: "+Ce),o):(o.error=`Failed to retrieve authority for user "${e.mail}" TID ${e.tid}.`,o.result=!1,o)}async function es(r,e,t,n){return vt(r,e,t,n)}async function ts(r,e,t,n,s){return Ct(r,e,t,n)}async function ns(r,e,t,n){return gt(r,e,t,n)}async function ss(r,e,t,n){return ft(r,e,t,n)}async function os(r,e,t,n){return await kt(r,e,t,n)}function rs(r,e,t,n){t.map(s=>{let o=null,i=e.us.findIndex(l=>l.oid===s.userId||l.oid===s.email);if(i===-1){let l=e.us.findIndex(u=>u.oid==="1");if(l!==-1){o=e.us.at(l);let u=r.associatedUsers.findIndex(g=>g=="1");u!==-1&&(r.associatedUsers.splice(u,1),r.associatedUsers.push(s.userId))}else o=new Ie,e.us.push(o)}else o=e.us.at(i);o.sel=n===s.userId,o.oid=s.userId?s.userId:s.email,o.name=s.firstName??o.name,o.mail=s.email,o.tid=s.tenantId;let c=e.ts.find(l=>l.tid===o.tid);c!=null&&(o.authority=c.authority,o.companyName=c.name,o.companyDomain=c.domain),r.associatedUsers.findIndex(l=>l===o.oid)==-1&&r.associatedUsers.push(o.oid)}),e.save()}function is(r,e,t,n){t.map(s=>{let o=null,i=e.ts.findIndex(u=>u.tid===s.tenantId);if(i===-1){let u=e.ts.findIndex(g=>g.tid==="1");if(u!==-1){o=e.ts.at(u);let g=r.associatedTenants.findIndex(p=>p=="1");g!==-1&&(r.associatedTenants.splice(g,1),r.associatedTenants.push(s.tenantId))}else o=new de,e.ts.push(o)}else o=e.ts.at(i);o.sel=n===s.tenantId,o.tid=s.tenantId,o.name=s.name,o.domain=s.domain,o.tenantType=s.type.toLowerCase();const c=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,a=s.authority.match(c);o.authority=a?a[1]:s.authority,r.associatedTenants.findIndex(u=>u===s.tenantId)==-1&&r.associatedTenants.push(s.tenantId)}),e.save()}function ht(r,e,t,n){t.map(s=>{let o=null,i=e.cs.findIndex(a=>a.id===s.id);if(i===-1){let a=e.cs.findIndex(l=>l.id==="1");if(a!==-1){o=e.cs.at(a);let l=r.associatedConfigs.findIndex(u=>u=="1");l!==-1&&(r.associatedConfigs.splice(l,1),r.associatedConfigs.push(s.id))}else o=new ve,e.cs.push(o)}else o=e.cs.at(i);o.sel=n===s.id,o.id=s.id,o.workspaceId=s.workspaceId,o.name=s.name,o.description=s.description,o.isEnabled=s.isEnabled,o.tenants.length=0,s.tenants.map(a=>{let l=new st;l.tid=a.tenantId,l.sourceGroupId=a.sourceGroupId??"",l.sourceGroupName=a.sourceGroupName??"",l.targetGroupId=a.targetGroupId??"",l.targetGroupName=a.targetGroupName??"",l.configurationTenantType=a.configurationTenantType.toLowerCase(),l.deltaToken=a.deltaToken??"",l.configId=o.id,l.batchId=a.batchId??"",l.isReadPermissionConsented=a.isReadPermissionConsented,l.isWritePermissionConsented=a.isWritePermissionConsented,o.tenants.push(l)}),r.associatedConfigs.findIndex(a=>a===s.id)==-1&&r.associatedConfigs.push(s.id)}),e.save()}async function as(r,e,t,n){let s=new E;if(n)debugger;try{if(s=await At(r,e,n),s.result){for(let o of s.array){let i=null,c=t.ws.findIndex(T=>T.id===o.id);if(c===-1){let T=t.ws.findIndex(w=>w.id==="1");T!==-1?i=t.ws.at(T):(i=new ke,t.ws.push(i))}else i=t.ws.at(c);let a="";for(let T of i.associatedUsers){let w=t.us.find(C=>C.oid===T);w!=null&&w.sel&&(a=w.oid)}let l="";for(let T of i.associatedTenants){let w=t.ts.find(C=>C.tid===T);w!=null&&w.sel&&(l=w.tid)}let u="";for(let T of i.associatedConfigs){let w=t.cs.find(C=>C.id===T);w!=null&&w.sel&&(u=w.id)}i.associatedUsers.length=0,i.associatedTenants.length=0,i.associatedConfigs.length=0,i.id=o.id,i.name=o.name,i.ownerid=o.ownerid;let g=pt(r,e,i.id,n),p=It(r,e,i.id,n),x=We(r,e,i.id,n),[U,G,m]=await Promise.all([g,p,x]);if(!U.result)return U;if(!G.result)return G;if(!m.result)return m;is(i,t,G.array,l),rs(i,t,U.array,a),ht(i,t,m.array,u),t.tagWithWorkspaces()}return s}}catch(o){console.log(o.message),s.error=o.message}return s.result=!1,s.status=500,s}async function cs(r,e){let t="";try{let n=r.getAllAccounts(),s=e.oid+"."+e.tid,o=null;for(let c=0;c<n.length;c++)n[c].homeAccountId==s&&(o=n[c]);t=(await r.acquireTokenSilent({scopes:["https://analysis.windows.net/powerbi/api/App.Read.All","https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All","https://analysis.windows.net/powerbi/api/Report.ReadWrite.All","https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"],account:o})).accessToken,console.log("PowerBI token acquired silently: "+t.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return t}async function Ge(r,e){const t=new Headers;if(t.append("Content-Type","application/json"),t.append("accept","*/*"),e.azureAccessToken==null||e.azureAccessToken==="")try{let n=r.getAllAccounts(),s=e.oid+"."+e.tid,o=null;for(let c=0;c<n.length;c++)n[c].homeAccountId==s&&(o=n[c]);let i=await r.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:o});e.azureAccessToken=i.accessToken,console.log("Front end token acquired silently: "+e.azureAccessToken.slice(0,20))}catch(n){try{console.log("Front end token silent acquisition failure: "+n);let s=r.getAllAccounts(),o=e.oid+"."+e.tid,i=null;for(let c=0;c<s.length;c++)s[c].homeAccountId==o&&(i=s[c]);r.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:i})}catch(s){console.log("Front end token popup acquisition failure: "+s)}}return t.append("Authorization",`Bearer ${e.azureAccessToken}`),t}async function ls(r,e){if(e==null||e.spacode=="")return!1;try{let n={method:"GET",headers:await Ge(r,e)},s=ue.azureListRootAssignments;s+="'",s+=e.oid,s+="'";let o=await fetch(s,n);if(o.status==200){let i=await o.json();i=i;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await R(o)),!1}catch(t){return console.log(t),!1}return!0}async function us(r,e){if(e==null||e.spacode=="")return!1;try{let n={method:"POST",headers:await Ge(r,e)},s=ue.azureElevateAccess,o=await fetch(s,n);if(o.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await R(o)),!1}catch(t){return console.log(t),!1}return!0}async function ds(r,e){let t=new Array;if(e==null||e.spacode=="")return t;try{let s={method:"GET",headers:await Ge(r,e)},o=ue.azureListRootAssignments;o+="'",o+=e.oid,o+="'";let i=await fetch(o,s);if(i.status==200){let c=await i.json();c=c;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await R(i)),t}catch(n){return console.log(n),t}return t}function hs(r){let e="8d95d21c-c378-4bb0-9f52-88c30d271e7a",t=r.authority.toLowerCase();return t.startsWith("https://login.microsoftonline.com/")?e="8d95d21c-c378-4bb0-9f52-88c30d271e7a":t.startsWith("https://login.microsoftonline.us/")?e="48da942e-ea3d-49e4-a054-81649012f8f2":t.startsWith("https://login.partner.microsoftonline.cn/")&&(e="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${e}/Config.Write`}async function W(r,e){debugger;console.log("DEBUGGER: mindlineDefineHeaders");const t=new Headers;t.append("Content-Type","application/json"),t.append("accept","*/*");const n=hs(e);try{let s=r.getAllAccounts(),o=e.oid+"."+e.tid,i=null;for(let a=0;a<s.length;a++)s[a].homeAccountId==o&&(i=s[a]);let c=await r.acquireTokenSilent({scopes:[n],account:i});e.mindlineAccessToken=c.accessToken,console.log("Front end mindline token acquired silently: "+e.mindlineAccessToken.slice(0,20))}catch(s){try{console.log("Front end mindline token silent acquisition failure, triggering redirect: "+s);let o=r.getAllAccounts(),i=e.oid+"."+e.tid,c=null;for(let a=0;a<o.length;a++)o[a].homeAccountId==i&&(c=o[a]);r.acquireTokenRedirect({scopes:[n],account:c})}catch(o){console.log("Front end mindline token redirect acquisition failure: "+o)}}return t.append("Authorization",`Bearer ${e.mindlineAccessToken}`),t}async function R(r){let e="";if(r.status===401&&(e=r.statusText,e!=""))return e;let t=await r.json();if(t.error!==void 0)e=`Error: ${t.error} Message: ${t.message}`;else if(t.errors!==void 0)e=Object.keys(t.errors).reduce((o,i)=>o+i+": "+t.errors[i]+" ","");else if(t.title!==void 0)e=t.title;else debugger;return e}async function ft(r,e,t,n){let s=new E;if(t.oid==""&&t.mail==""||n=="")return s.result=!1,s.error="adminDelete: invalid parameters",s.status=500,s;let o=null;o=new URL(D.adminEndpoint()),o.searchParams.append("workspaceId",n),o.searchParams.append("email",t.mail);let c={method:"DELETE",headers:await W(r,e)};try{console.log("Attempting DELETE from /admin: "+o.href);let a=await fetch(o.href,c);return a.status===200&&a.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${o.href}`),s):(s.error=await R(a),console.log(`Failed DELETE from /admin: ${o.href}`),console.log(s.error),s.status=500,s.result=!1,s)}catch(a){s.error=a.message,s.status=500,s.result=!1,console.log(a.message)}return s}async function pt(r,e,t,n){let s=new E;if(t==="")return s.result=!1,s.status=500,s.error="adminsGet: no workspace provided",s;let o=D.adminsEndpoint(),i=new URL(o);i.searchParams.append("workspaceId",t);let a={method:"GET",headers:await W(r,e)};try{if(n)debugger;console.log("Attempting GET from /admins: "+i.href);let l=await fetch(i.href,a);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return u!=null?(s.array=u,console.log(`Successful GET from /admins: ${s.array.reduce((p,x)=>p+x.email+" ","")}`),s):(s.error="Failed GET from /admins: failed to JSON-parse response",console.log(s.error),s.status=500,s.result=!1,s)}else return console.log(`Failed GET from /admins: ${i.href}`),s.error=await R(l),s.status=500,s.result=!1,console.log(s.error),s}catch(l){s.error=l.message,s.status=500,s.result=!1,console.log(l.message)}return s}async function gt(r,e,t,n){let s=new E;if(t.mail==""||t.authority==""||t.tid==="")return s.result=!1,s.error="adminPost: invalid argument",s.status=500,s;let o=D.adminEndpoint();const i=await W(r,e);let c=`
|
|
2
|
-
{"email": "${
|
|
3
|
-
"tenantId": "${
|
|
4
|
-
"workspaceId": "${
|
|
5
|
-
}`,
|
|
1
|
+
(function(f,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@microsoft/signalr"),require("class-transformer")):typeof define=="function"&&define.amd?define(["exports","@microsoft/signalr","class-transformer"],T):(f=typeof globalThis<"u"?globalThis:f||self,T(f.sync={},f.signalR,f.classTransformer))})(this,function(f,T,A){"use strict";var Jt=Object.defineProperty;var Ze=f=>{throw TypeError(f)};var Kt=(f,T,A)=>T in f?Jt(f,T,{enumerable:!0,configurable:!0,writable:!0,value:A}):f[T]=A;var l=(f,T,A)=>Kt(f,typeof T!="symbol"?T+"":T,A),Vt=(f,T,A)=>T.has(f)||Ze("Cannot "+A);var Y=(f,T,A)=>T.has(f)?Ze("Cannot add the same private member more than once"):T instanceof WeakSet?T.add(f):T.set(f,A);var W=(f,T,A)=>(Vt(f,T,"access private method"),A);var Q,Qe,C,le,ce,de,x,ue;function Xe(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const j=Xe(T),q="1.0.92",Ye=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],et=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],tt=[],st=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],nt=[{Run:"3",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"2",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"1",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"}],rt=[{type:"mg",resource:"Tenant Root Group",cost:0,expanded:!0,resources:[{type:"sub",resource:"Applications",cost:16677.52,expanded:!0,resources:[{type:"rg",resource:"ssfdev",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFServices",cost:0,expanded:!1,resources:[]}]}]},{type:"sub",resource:"Infrastructure",cost:8737.58,expanded:!0,resources:[{type:"rg",resource:"SFFA_Prod_Mgmt_Shared_Resources_RG",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFA-Prod-UTIL-01",cost:0,expanded:!1,resources:[]}]}]}]}],at=[{type:"user",actor:"arvind@mindline.site",resource:"kv-syncproject",role:"Key Vault Certificate Officer",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]},{type:"app",actor:"mindline1-sync-512169f5-38d1-4b57-be8b-967f2d0ae4c6",resource:"dev-subscription",role:"Contributor",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]}],B="workspaceIDs";function ot(a,t){return a+t}function it(){return"hello NPM"}class w{constructor(){l(this,"result");l(this,"status");l(this,"error");l(this,"version");l(this,"array");this.result=!0,this.status=200,this.error="",this.version=q,this.array=null}}class U{}l(U,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),l(U,"azureListRootAssignments","https://management.azure.com/providers/Microsoft.Authorization/roleAssignments?api-version=2022-04-01&$filter=principalId+eq+");const k=class k{static adminEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static configConsentEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static signalREndpoint(){return`https://${k.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}};l(k,"environmentTag","dev");let b=k;class p{}l(p,"graphGroupsPredicate","v1.0/groups"),l(p,"graphMailPredicate","v1.0/me/messages"),l(p,"graphMePredicate","v1.0/me"),l(p,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),l(p,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),l(p,"graphUsersPredicate","v1.0/users"),l(p,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),l(p,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),l(p,"authorityWW","https://login.microsoftonline.com/"),l(p,"authorityWWRegex",/^(https:\/\/login\.microsoftonline\.com\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),l(p,"authorityUS","https://login.microsoftonline.us/"),l(p,"authorityUSRegex",/^(https:\/\/login\.microsoftonline\.us\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),l(p,"authorityCN","https://login.partner.microsoftonline.cn/"),l(p,"authorityCNRegex",/^(https:\/\/login\.partner\.microsoftonline\.cn\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/);class lt{constructor(){l(this,"id","");l(this,"displayName","");l(this,"description","")}}class ct{constructor(){l(this,"group","");l(this,"value","");l(this,"consented",!1);l(this,"removable",!1);l(this,"expanded","")}static compareByValue(t,n){return t.value.localeCompare(n.value)}static compareByGroup(t,n){return t.group.localeCompare(n.group)}}class H{constructor(){l(this,"oid");l(this,"name");l(this,"mail");l(this,"authority");l(this,"tid");l(this,"companyName");l(this,"companyDomain");l(this,"workspaceIDs");l(this,"session");l(this,"spacode");l(this,"graphAccessToken");l(this,"mindlineAccessToken");l(this,"azureAccessToken");l(this,"loginHint");l(this,"scopes");l(this,"authTS");l(this,"sel");l(this,"loggingIn");this.oid="",this.name="",this.mail="",this.authority="",this.tid="",this.companyName="",this.companyDomain="",this.workspaceIDs="",this.session="Sign In",this.spacode="",this.graphAccessToken="",this.mindlineAccessToken="",this.azureAccessToken="",this.loginHint="",this.scopes=new Array,this.authTS=new Date(0),this.sel=!1,this.loggingIn=!1}}var fe=(a=>(a[a.invalid=0]="invalid",a[a.aad=1]="aad",a[a.ad=2]="ad",a[a.googleworkspace=3]="googleworkspace",a))(fe||{}),pe=(a=>(a[a.read=1]="read",a[a.write=2]="write",a[a.notassigned=3]="notassigned",a))(pe||{});class z{constructor(){l(this,"tid");l(this,"name");l(this,"domain");l(this,"tenantType");l(this,"authority");l(this,"workspaceIDs");l(this,"sel");l(this,"graphSP");l(this,"lookupfield");this.tid="",this.name="",this.domain="",this.tenantType="aad",this.authority="",this.workspaceIDs="",this.sel=!1,this.graphSP="",this.lookupfield="Domain"}}function dt(a,t){switch(a){case p.authorityWW:return t===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case p.authorityUS:return t===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case p.authorityCN:return t===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function F(a){switch(a){case p.authorityWW:return"https://graph.microsoft.com/";case p.authorityUS:return"https://graph.microsoft.us/";case p.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function ut(a){switch(a){case p.authorityWW:return"https://login.microsoftonline.com/";case p.authorityUS:return"https://login.microsoftonline.us/";case p.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var he=(a=>(a[a.source=1]="source",a[a.target=2]="target",a[a.sourcetarget=3]="sourcetarget",a))(he||{});class ge{constructor(){l(this,"tid");l(this,"sourceGroupId");l(this,"sourceGroupName");l(this,"targetGroupId");l(this,"targetGroupName");l(this,"configurationTenantType");l(this,"deltaToken");l(this,"usersWritten");l(this,"configId");l(this,"batchId");l(this,"isReadPermissionConsented");l(this,"isWritePermissionConsented");this.tid="",this.sourceGroupId="",this.sourceGroupName="",this.targetGroupId="",this.targetGroupName="",this.configurationTenantType="source",this.deltaToken="",this.usersWritten=0,this.configId="",this.batchId="",this.isReadPermissionConsented=!1,this.isWritePermissionConsented=!1}}class J{constructor(){l(this,"id");l(this,"workspaceId");l(this,"name");l(this,"description");l(this,"tenants");l(this,"isEnabled");l(this,"workspaceIDs");l(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.tenants=new Array,this.isEnabled=!1,this.workspaceIDs="",this.sel=!1}}class K{constructor(){l(this,"id");l(this,"name");l(this,"ownerid");l(this,"associatedUsers");l(this,"associatedTenants");l(this,"associatedConfigs");l(this,"sel");this.id="",this.name="",this.ownerid="",this.associatedUsers=new Array,this.associatedTenants=new Array,this.associatedConfigs=new Array,this.sel=!1}}function N(){let a;try{a=window.localStorage;const t="__storage_test__";return a.setItem(t,t),a.removeItem(t),!0}catch(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")&&a&&a.length!==0}}class ft{constructor(t=!1){Y(this,Q);l(this,"version",q);l(this,"tab",0);l(this,"us",[]);l(this,"ts",[]);l(this,"cs",[]);l(this,"ws",[]);l(this,"configlevelconsent_configid","");l(this,"configlevelconsent_access",3);this.init(t)}init(t){if(console.log(`Calling InitInfo::init(bClearLocalStorage: ${t?"true":"false"})`),N()){let o=localStorage.getItem("InitInfo");if(o!=null&&typeof o=="string"&&o!==""){let i=JSON.parse(o);if(i.us.length!==0)if(t)localStorage.removeItem("InitInfo");else{W(this,Q,Qe).call(this,i);return}}}this.tab=0,this.version=q,this.configlevelconsent_configid="",this.configlevelconsent_access=3;var n=JSON.stringify(Ye),s=JSON.stringify(et),e=JSON.stringify(tt),r=JSON.stringify(st);try{this.us=A.deserializeArray(H,n),this.ts=A.deserializeArray(z,s),this.cs=A.deserializeArray(J,e),this.ws=A.deserializeArray(K,r),this.tagWithWorkspaces()}catch{debugger}}save(){let t=JSON.stringify(this);localStorage.setItem("InitInfo",t)}tagWithWorkspaces(){this.us.map(t=>t.workspaceIDs=""),this.ts.map(t=>t.workspaceIDs=""),this.cs.map(t=>t.workspaceIDs="");for(let t of this.ws){for(let n of t.associatedUsers){let s=this.us.find(e=>e.oid===n);if(s!==void 0)s[B]+=t.id,s[B]+=" ";else debugger}for(let n of t.associatedTenants){let s=this.ts.find(e=>e.tid===n);if(s!==void 0)s[B]+=t.id,s[B]+=" ";else debugger}for(let n of t.associatedConfigs){let s=this.cs.find(e=>e.id===n);if(s!==void 0)s[B]+=t.id,s[B]+=" ";else debugger}}return!0}}Q=new WeakSet,Qe=function(t){this.tab=t.tab,this.configlevelconsent_configid=t.configlevelconsent_configid,this.configlevelconsent_access=t.configlevelconsent_access,typeof t.us>"u"?this.us=new Array:this.us=t.us.map(n=>{let s=new H;return s.oid=n.oid,s.name=n.name,s.mail=n.mail,s.authority=n.authority,s.tid=n.tid,s.companyName=n.companyName,s.companyDomain=n.companyDomain,s.workspaceIDs=n.workspaceIDs,s.session=n.session,s.spacode=n.spacode,s.graphAccessToken=n.graphAccessToken,s.mindlineAccessToken=n.mindlineAccessToken,s.azureAccessToken=n.azureAccessToken,s.loginHint=n.loginHint,s.scopes=n.scopes,s.authTS=new Date(n.authTS),s.sel=n.sel,s.loggingIn=n.loggingIn,s}),typeof t.ts>"u"?this.ts=new Array:this.ts=t.ts.map(n=>{let s=new z;return s.tid=n.tid,s.name=n.name,s.domain=n.domain,s.tenantType=n.tenantType,s.authority=n.authority,s.workspaceIDs=n.workspaceIDs,s.sel=n.sel,s.lookupfield=n.lookupfield,s}),typeof t.cs>"u"?this.cs=new Array:this.cs=t.cs.map(n=>{let s=new J;return s.id=n.id,s.workspaceId=n.workspaceId,s.name=n.name,s.description=n.description,s.tenants=n.tenants,s.isEnabled=n.isEnabled,s.workspaceIDs=n.workspaceIDs,s.sel=n.sel,s}),typeof t.ws>"u"?this.ws=new Array:this.ws=t.ws.map(n=>{let s=new K;return s.id=n.id,s.name=n.name,s.ownerid=n.ownerid,s.associatedUsers=n.associatedUsers,s.associatedTenants=n.associatedTenants,s.associatedConfigs=n.associatedConfigs,s.sel=n.sel,s})};const pt=[{id:1,task:"initialization",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:22",status:"not started",expanded:!0,subtasks:[{id:2,task:"authenticate user",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:3,task:"reload React",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:07",status:"not started"},{id:4,task:"GET tenant details",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:5,task:"POST config init",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:10",status:"not started"},{id:6,task:"GET workspaces",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:04",status:"not started"}]}];class ht{constructor(t){Y(this,C);l(this,"tasks");this.tasks=[new V],this.init(t)}init(t){if(console.log(`Calling TaskArray::init(bClearLocalStorage: ${t?"true":"false"})`),this.tasks.length=0,t&&N()&&localStorage.removeItem("Tasks"),N()){let n=localStorage.getItem("Tasks");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(this.tasks=W(this,C,ce).call(this,e.tasks),this.tasks.length!==0)return}}this.tasks=W(this,C,ce).call(this,pt)}setTaskStart(t,n){let s=W(this,C,le).call(this,t);if(s!=null&&s!=null)s.setStart(n),s.status="in progress",W(this,C,de).call(this);else debugger}setTaskEnd(t,n,s){let e=W(this,C,le).call(this,t);if(e!=null&&e!=null)e.setEnd(n),e.status=s,W(this,C,de).call(this);else debugger}}C=new WeakSet,le=function(t){let n=this.tasks.find(s=>s.task==t);if(n==null||n==null){for(n of this.tasks)if(n.subtasks!=null&&n.subtasks!=null&&(n=n.subtasks.find(s=>s.task==t),n!=null&&n!=null))break}return n},ce=function(t){return t.map(n=>{let s=new V;return s.id=n.id,s.task=n.task,s.setStart(new Date(n.start)),s.setEnd(new Date(n.end)),s.expected=n.expected,s.status=n.status,s.expanded=n.expanded,typeof n.subtasks<"u"&&n.subtasks!=null&&(s.subtasks=n.subtasks.map(e=>{let r=new V;return r.id=e.id,r.task=e.task,r.setStart(new Date(e.start)),r.setEnd(new Date(e.end)),r.expected=e.expected,r.status=e.status,r.expanded=e.expanded,r})),s})},de=function(){let t=JSON.stringify(this);N()&&localStorage.setItem("Tasks",t)};class V{constructor(){l(this,"id",0);l(this,"task","");l(this,"start",new Date);l(this,"startDisplay","");l(this,"end",new Date);l(this,"endDisplay","");l(this,"elapsedDisplay","");l(this,"expected",0);l(this,"status","");l(this,"expanded",!1);l(this,"subtasks",[])}setEnd(t){this.end=t,this.endDisplay=`${this.end.getMinutes().toString().padStart(2,"0")}:${this.end.getSeconds().toString().padStart(2,"0")}`;let n=0,s=this.end.getSeconds()-this.start.getSeconds();s<0&&(s+=60,n=-1);let e=this.end.getMinutes()-this.start.getMinutes()+n;e<0&&(e+=60),this.elapsedDisplay=`${e.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}setStart(t){this.start=t,this.startDisplay=`${this.start.getMinutes().toString().padStart(2,"0")}:${this.start.getSeconds().toString().padStart(2,"0")}`}}class L{constructor(t){l(this,"Run",0);l(this,"Start",new Date);l(this,"startDisplay","");l(this,"POST");l(this,"postDisplay");l(this,"Read");l(this,"readDisplay");l(this,"Write");l(this,"writeDisplay");l(this,"Duration");l(this,"durationDisplay");this.Run=t,this.start(""),this.POST=new Date,this.postDisplay="",this.Read=new Date,this.readDisplay="",this.Write=new Date,this.writeDisplay="",this.Duration=new Date,this.durationDisplay=""}start(t){t==""?this.Start=new Date:this.Start=new Date(t),this.startDisplay=`${this.Start.getMinutes().toString().padStart(2,"0")}:${this.Start.getSeconds().toString().padStart(2,"0")}`}post(t){t==""?this.POST=new Date:this.POST=new Date(t),this.postDisplay=`${this.POST.getMinutes().toString().padStart(2,"0")}:${this.POST.getSeconds().toString().padStart(2,"0")}`}read(t){t==""?this.Read=new Date:this.Read=new Date(t),this.readDisplay=`${this.Read.getMinutes().toString().padStart(2,"0")}:${this.Read.getSeconds().toString().padStart(2,"0")}`}write(t){t==""?this.Write=new Date:this.Write=new Date(t),this.writeDisplay=`${this.Write.getMinutes().toString().padStart(2,"0")}:${this.Write.getSeconds().toString().padStart(2,"0")}`,this.Duration=new Date(this.Write.getTime()-this.Start.getTime()),this.durationDisplay=`${this.Duration.getMinutes().toString().padStart(2,"0")}:${this.Duration.getSeconds().toString().padStart(2,"0")}`}}class me{constructor(t){Y(this,x);l(this,"milestones",[]);this.init(t)}init(t){if(N()){let n=localStorage.getItem("syncmilestones");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(e.length!==0)if(t)localStorage.removeItem("syncmilestones");else{W(this,x,ue).call(this,e);return}}}W(this,x,ue).call(this,nt)}save(){let t=JSON.stringify(this.milestones);N()&&localStorage.setItem("syncmilestones",t)}start(t){if(this.milestones==null||this.milestones.length<1){debugger;return}let n=Number(this.milestones[0].Run),s=new L(n+1);this.milestones.unshift(s),this.milestones=this.milestones.map(e=>{let r=new L(e.Run);return r.Start=e.Start,r.startDisplay=e.startDisplay,r.POST=e.POST,r.postDisplay=e.postDisplay,r.Read=e.Read,r.readDisplay=e.readDisplay,r.Write=e.Write,r.writeDisplay=e.writeDisplay,r.Duration=e.Duration,r.durationDisplay=e.durationDisplay,r}),t(this.milestones),console.log(`Start milestone: ${this.milestones[0].Run}:${this.milestones[0].Start}`)}unstart(t){if(this.milestones==null||this.milestones.length<1){debugger;return}let n=this.milestones.shift();this.milestones=this.milestones.map(s=>{let e=new L(s.Run);return e.Start=s.Start,e.startDisplay=s.startDisplay,e.POST=s.POST,e.postDisplay=s.postDisplay,e.Read=s.Read,e.readDisplay=s.readDisplay,e.Write=s.Write,e.writeDisplay=s.writeDisplay,e.Duration=s.Duration,e.durationDisplay=s.durationDisplay,e}),t(this.milestones),console.log(`Unstart removed first milestone: ${n.Run}:${n.Start}`)}post(t){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].post(""),t(this.milestones),console.log(`POST milestone: ${this.milestones[0].Run}:${this.milestones[0].POST}`)}read(t){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].read(""),t(this.milestones),console.log(`Read milestone: ${this.milestones[0].Run}:${this.milestones[0].Read}`)}write(t){if(this.milestones==null||this.milestones.length<1){debugger;return}for(this.milestones[0].write("");this.milestones.length>10;){let n=this.milestones.pop();console.log(`Removed milestone #${n.Run}: ${n.Start}`)}this.save(),this.milestones=this.milestones.map(n=>{let s=new L(n.Run);return s.Start=n.Start,s.startDisplay=n.startDisplay,s.POST=n.POST,s.postDisplay=n.postDisplay,s.Read=n.Read,s.readDisplay=n.readDisplay,s.Write=n.Write,s.writeDisplay=n.writeDisplay,s.Duration=n.Duration,s.durationDisplay=n.durationDisplay,s}),t(this.milestones)}}x=new WeakSet,ue=function(t){t==null?this.milestones=new Array:this.milestones=t.map(n=>{let s=new L(Number(n.Run));return s.start(n.Start),s.post(n.POST),s.read(n.Read),s.write(n.Write),s})};class gt{constructor(t,n,s){l(this,"tenantNodes");l(this,"pb_startTS");l(this,"pb_progress");l(this,"pb_increment");l(this,"pb_idle");l(this,"pb_idleMax");l(this,"pb_total");l(this,"pb_timer");l(this,"milestoneArray");this.tenantNodes=new Array,this.init(t,n,s),this.pb_startTS=0,this.pb_progress=0,this.pb_increment=0,this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.milestoneArray=new me(!1)}init(t,n,s){console.log(`Calling BatchArray::init(config: "${t?t.name:"null"}", bClearLocalStorage: ${s?"true":"false"})`),s&&N()&&(localStorage.removeItem(t.name),this.milestoneArray.init(s)),t!=null&&t.tenants!=null&&n!=null&&(this.tenantNodes.length=0,t.tenants.map(e=>{if(e.configurationTenantType==="source"||e.configurationTenantType==="sourcetarget"){let r=n.ts.find(o=>o.tid===e.tid);if(r!=null){let o=new ee(e.tid,r.name,e.batchId);this.tenantNodes.push(o)}else{console.log(`Error: no tenant found for config source tenant ${t.name}`);debugger;return}}}),this.tenantNodes.map(e=>{t.tenants.map(r=>{if((r.configurationTenantType==="target"||r.configurationTenantType==="sourcetarget")&&r.tid!==e.tid){let o=n.ts.find(d=>d.tid===r.tid);if(o!=null){let d=new ee(r.tid,o.name,r.batchId);e.targets.push(d),e.expanded=!0}else{console.log(`Error: no tenant found for config target tenant ${t.name}`);debugger;return}}})}))}initializeProgressBar(t,n,s,e){this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_increment=.25,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.pb_timer=setInterval(()=>{this.milestoneArray.milestones[0].Write!=null?(clearInterval(this.pb_timer),this.pb_timer=null,this.pb_progress=100,t(this.pb_progress),s(`Complete. [max idle: ${this.pb_idleMax}]`)):(this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,this.pb_idleMax=Math.max(this.pb_idle,this.pb_idleMax),s(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`),this.pb_idle>=60&&this.milestoneArray.milestones[0].Write==null&&n(`sync continuing, but no update for ${this.pb_idle} seconds`),this.pb_progress<100&&(this.pb_progress=Math.min(100,this.pb_progress+this.pb_increment),t(this.pb_progress)))},1e3),this.milestoneArray.start(e)}uninitializeProgressBar(t,n,s,e){this.pb_startTS=0,this.pb_progress=0,t(this.pb_progress),n("sync failed to execute"),this.pb_increment=0,clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,s(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`),this.milestoneArray.unstart(e)}initializeSignalR(t,n,s,e,r,o,d,i,c,u,h){this.milestoneArray.post(c),u("started sync, waiting for updates..."),this.init(t,n,!1);let D=P=>{console.log(P);let G=JSON.parse(P);this.pb_idle=0;let v=s.find(m=>m.BatchId==G.TargetID);if(v==null){console.log(`Batch ${G.TargetID} not found in batchIdArray.`);debugger;return}let g=this.tenantNodes.find(m=>m.tid===v.SourceId);if(g==null){console.log(`Tenant ${v.SourceId} not found in BatchArray.`);debugger;return}g.batchId=v.BatchId;let R=G.Stats,y=Object.keys(R),E=Object.values(R),Le=!1,xe=!1;for(let m=0;m<y.length;m++){let O=y[m].endsWith("TotalCount"),X=y[m].endsWith("CurrentCount"),M=y[m].endsWith("DeferredCount"),oe=y[m].endsWith("RescheduledCount");if(y[m].startsWith("Reader")){let _=/Reader\/TID:(.+)\/TotalCount/;if(X&&(_=/Reader\/TID:(.+)\/CurrentCount/),M&&(_=/Reader\/TID:(.+)\/DeferredCount/),oe&&(_=/Reader\/TID:(.+)\/RescheduledCount/),y[m].match(_)==null){console.log(`tid not found in ${y[m]}.`);debugger;return}O?(Le=Number(E[m])==0,g.total=Math.max(Number(E[m]),g.total),console.log(`----- ${g.name} TID: ${g.tid} batchId: ${g.batchId}`),console.log(`----- ${g.name} Total To Read: ${g.total}`)):(xe=Number(E[m])==0,g.read=Math.max(Number(E[m]),g.read),console.log(`----- ${g.name} Currently Read: ${g.read}`))}if(g.nothingtosync=Le&&xe,y[m].startsWith("Writer")){let _=/Writer\/TID:(.+)\/TotalCount/;X&&(_=/Writer\/TID:(.+)\/CurrentCount/),M&&(_=/Writer\/TID:(.+)\/DeferredCount/),oe&&(_=/Writer\/TID:(.+)\/RescheduledCount/);let ie=y[m].match(_);if(ie==null){console.log(`tid not found in ${y[m]}.`);debugger;return}let S=g.targets.find(Ht=>Ht.tid===ie[1]);if(S==null){console.log(`Writer ${g.name} not found under Reader ${g.name}.`);debugger;return}if(S.batchId=v.BatchId,O)S.total=Math.max(Number(E[m]),S.total),console.log(`----- ${S.name} TID: ${S.tid} batchId: ${S.batchId}`),console.log(`----- ${S.name} Total To Write: ${S.total}`);else if(X)S.written=Math.max(Number(E[m]),S.written),console.log(`----- ${S.name} Total Written: ${S.written}`);else if(M||oe)S.deferred=Math.max(Number(E[m]),S.deferred),console.log(`----- ${S.name} Total Deferred: ${S.deferred}`);else{console.log("unknown writer type");debugger;return}S.update(S.total,S.read,S.written,S.deferred)}}g.update(g.total,g.read,g.written,g.deferred);let Me=!0,je=!0,qe=!1,He=!0,ae=0,Je=0,Ke=0,Ve=0;if(this.tenantNodes.map(m=>{m.targets.map(O=>{je&&(je=O.status=="complete"||O.status=="failed"),qe||(qe=O.total>0||O.status!="not started"),Ke+=Math.max(O.total,m.total),Ve+=O.written}),He&&(He=m.nothingtosync),Me&&(Me=m.status=="complete"||m.status=="failed"),ae+=m.total,Je+=m.read}),r(ae),o(Je),d(Math.max(Ke,ae)),i(Ve),He)this.milestoneArray.write(c),u("nothing to sync"),console.log('Setting config sync result: "nothing to sync"');else{if(Me&&this.milestoneArray.milestones[0].Read==null){this.milestoneArray.read(c),u("reading complete"),console.log('Setting config sync result: "reading complete"'),e(t.workspaceId);let M=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=M,console.log(`Setting increment: ${this.pb_increment}% per second`)}je?(this.milestoneArray.write(c),u("sync complete"),console.log('Setting config sync result: "complete"')):qe?(u("writing in progress"),console.log('Setting config sync result: "writing in progress"')):this.milestoneArray.milestones[0].Read==null&&(u("reading in progress"),console.log('Setting config sync result: "reading in progress"'))}};s.map(P=>{const G=b.signalREndpoint();let v=new URL(G);v.searchParams.append("statsId",P.BatchId),console.log(`Creating SignalR Hub for TID: ${P.SourceId} ${v.href}`);const g=new j.HubConnectionBuilder().withUrl(v.href).withAutomaticReconnect().configureLogging(j.LogLevel.Information).build();g.on("newMessage",D),g.onreconnecting(R=>{console.assert(g.state===j.HubConnectionState.Reconnecting),console.log(`Connection lost due to error "${R}". Reconnecting.`)}),g.onreconnected(R=>{console.assert(g.state===j.HubConnectionState.Connected),console.log(`Connection reestablished. Connected with connectionId "${R}".`)}),g.onclose(async()=>{console.log("Connection closing. Attempting restart."),await g.start()}),g.start().catch(console.error)})}async startSync(t,n,s){let e=new w;if(this.tenantNodes==null||this.tenantNodes.length==0){debugger;return e.result=!1,e.error="startSync: invalid parameters",e.status=500,e}return e=await ze(t,n,s),e}}class ee{constructor(t,n,s){l(this,"expanded");l(this,"status","");l(this,"name");l(this,"tid");l(this,"batchId");l(this,"total",0);l(this,"read",0);l(this,"written",0);l(this,"deferred",0);l(this,"nothingtosync");l(this,"targets");this.expanded=!1,this.name=n,this.tid=t,this.batchId=s,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0)}update(t,n,s,e){this.total=t,this.read=n,this.written=s,this.deferred=e,this.read===0&&this.written===0&&(this.status="not started"),this.read>0?this.read<this.total?this.status="in progress":this.read===this.total&&(this.status="complete"):this.written>0&&(this.written+this.deferred<this.total?this.status="in progress":this.written===this.total?this.status="complete":this.written+this.deferred>=this.total&&(this.status="failed"))}}class te{constructor(t,n){l(this,"resourceNodes");this.resourceNodes=new Array,t&&this.init(n)}init(t){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${t?"true":"false"})`),N()){let s=localStorage.getItem("ResourceArray");if(s!=null&&typeof s=="string"&&s!=="")if(t)localStorage.removeItem("ResourceArray");else{let r=JSON.parse(s);this.resourceNodes=r.resourceNodes;return}}var n=JSON.stringify(rt);try{this.resourceNodes=A.deserializeArray(ye,n)}catch{debugger}}async read(t,n){let s=new te(!1,!1);return s.resourceNodes=await jt(t,n),s}save(){if(N()){let t=JSON.stringify(this);localStorage.setItem("ResourceArray",t)}}}class ye{constructor(t,n,s){l(this,"type");l(this,"resource");l(this,"cost");l(this,"expanded");l(this,"resources");this.type=t,this.resource=n,this.cost=s,this.expanded=!1,this.resources=new Array}}class mt{constructor(t){l(this,"actorNodes");this.actorNodes=new Array,this.init(t)}init(t){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${t?"true":"false"})`),N()){let s=localStorage.getItem("RBACActors");if(s!=null&&typeof s=="string"&&s!=="")if(t)localStorage.removeItem("RBACActors");else{let r=JSON.parse(s);this.actorNodes=r.actorNodes;return}}var n=JSON.stringify(at);try{this.actorNodes=A.deserializeArray(we,n)}catch{debugger}}}class we{constructor(t,n,s,e,r,o){l(this,"type");l(this,"actor");l(this,"resource");l(this,"role");l(this,"updatedby");l(this,"updatedon");l(this,"actors");this.type=t,this.actor=n,this.resource=s,this.role=e,this.updatedby=r,this.updatedon=o,this.actors=new Array}}function yt(a){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function Z(a,t){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const s=yt();if(t.graphAccessToken==null||t.graphAccessToken==="")try{let e=await a.acquireTokenByCode({code:t.spacode});t.graphAccessToken=e.accessToken,console.log("Front end token acquired by code: "+t.graphAccessToken.slice(0,20))}catch(e){console.log("Front end token failure: "+e)}else try{let e=a.getAllAccounts(),r=t.oid+"."+t.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.acquireTokenSilent({scopes:[s],account:o});t.graphAccessToken=d.accessToken,console.log("Front end token graph acquired silently: "+t.graphAccessToken.slice(0,20))}catch(e){try{console.log("Front end graph token silent acquisition failure: "+e);let r=a.getAllAccounts(),o=t.oid+"."+t.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[s],account:d})}catch(r){console.log("Front end graph token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${t.graphAccessToken}`),n}async function wt(a,t,n){if(t==null||t.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let e={method:"GET",headers:await Z(a,t)};try{let r=F(t.authority)+p.graphGroupsPredicate;r+=`/?$filter=startsWith(displayName, '${n}')`;let d=await(await fetch(r,e)).json();return typeof d.error<"u"?{groups:[],error:`${d.error.code}: ${d.error.message}`}:{groups:d.value,error:""}}catch(r){return console.log(r),{groups:[],error:`Exception: ${r}`}}}async function Te(a,t,n,s){try{let e=F(t.authority)+p.graphOauth2PermissionGrantsPredicate,r=new URL(e);r.searchParams.append("$filter",`resourceId eq '${n}' and consentType eq 'Principal' and principalId eq '${s}'`);let d=await(await fetch(r.href,a)).json();if(typeof d.error<"u")return{grants:null,id:null,error:`${d.error.code}: ${d.error.message}`};if(d.value.length!=1){debugger;return{grants:null,id:null,error:"oauth2PermissionGrantsGet: more than one matching delegated consent grant."}}return{grants:d.value[0].scope,id:d.value[0].id,error:""}}catch(e){return console.log(e),{grants:null,id:null,error:`Exception: ${e}`}}}async function Se(a,t,n,s){if(t==null||t.spacode=="")return!1;try{let e=F(t.authority);e+=p.graphOauth2PermissionGrantsPredicate+`/${n}`;let r=`{ "scope": "${s}" }`,d={method:"PATCH",headers:await Z(a,t),body:r},i=await fetch(e,d),c=await i.json();if(i.status==204&&i.statusText=="No Content")return!0;debugger;return console.log(`oauth2PermissionGrantsSet: PATCH failed ${c.error.code}: ${c.error.message}`),!1}catch(e){debugger;return console.log(e),!1}}function Tt(a,t){let n=ut(a.authority);n+=a.tid,n+="/adminconsent";let s=new URL(n),e=dt(a.authority,t);s.searchParams.append("client_id",e),s.searchParams.append("redirect_uri",window.location.origin),s.searchParams.append("domain_hint",a.companyDomain),s.searchParams.append("login_hint",a.mail),window.location.assign(s.href)}async function be(a,t,n){try{let s=F(t.authority);s+=p.graphServicePrincipalsPredicate,s+=`(appId='${n}')`;let e=new URL(s);e.searchParams.append("$select","id,appId,displayName");let o=await(await fetch(e.href,a)).json();return typeof o.error<"u"?{spid:"",error:`${o.error.code}: ${o.error.message}`}:{spid:o.id,error:""}}catch(s){return console.log(s),{spid:"",error:`Exception: ${s}`}}}async function St(a,t){if(a.authority==""){let e=new z;if(e.domain=a.tid,await se(e,!1))a.authority=e.authority;else{debugger;return!1}}let n=window.location.href;switch(a.authority){case p.authorityWW:n+="MicrosoftIdentity/Account/SignIn";break;case p.authorityUS:n+="USGov/SignIn";break;case p.authorityCN:n+="China/SignIn";break;default:return!1}let s=new URL(n);if(s.searchParams.append("redirectUri",window.location.origin),a.oid!=="1"){s.searchParams.append("loginHint",a.mail);const e=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,r=a.mail.match(e);let o=r?r[1]:"organizations";s.searchParams.append("domainHint",o)}else s.searchParams.append("domainHint","organizations");return t.setTaskStart("initialization",new Date),t.setTaskStart("authenticate user",new Date),window.location.assign(s.href),!0}function bt(a,t){debugger;if(a.oid=="1")return;let n=window.location.href;switch(a.authority){case p.authorityWW:n+="MicrosoftIdentity/Account/Challenge";break;case p.authorityUS:n+="USGov/Challenge";break;case p.authorityCN:n+="China/Challenge";break;default:return}let s=new URL(n);s.searchParams.append("redirectUri",window.location.origin),s.searchParams.append("scope",t),s.searchParams.append("domainHint","organizations"),s.searchParams.append("loginHint",a.mail),window.location.assign(s.href)}async function It(a){if(a.oid=="1")return!1;let t=window.location.href;t+="user";let n=new URL(t);n.searchParams.append("oid",a.oid),n.searchParams.append("tid",a.tid),n.searchParams.append("loginHint",a.loginHint),n.searchParams.append("verb","LOGOUT");let s={method:"PATCH"},e=await fetch(n.href,s);if(e.status==200&&e.statusText=="OK")console.log(`Successfully set admin ${a.mail} logout_hint`);else return console.log(`Failed to set admin ${a.mail} logout_hint`),!1;let r=window.location.href;switch(a.authority){case p.authorityWW:r+="MicrosoftIdentity/Account/SignOut";break;case p.authorityUS:r+="USGov/SignOut";break;case p.authorityCN:r+="China/SignOut";break;default:return!1}return n=new URL(r),n.searchParams.append("redirectUri",window.location.origin),window.location.assign(n.href),!0}async function At(a,t,n,s){if(s)debugger;if(t.name!=null&&t.name!=="")return!1;if(a.graphAccessToken!=null&&a.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${a.name}`);try{let i=await n.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=i.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(i){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+i),!1}}const e=new Headers,r=`Bearer ${a.graphAccessToken}`;e.append("Authorization",r);let o={method:"GET",headers:e};try{var d=F(t.authority)+p.graphTenantByDomainPredicate;d+="(domainName='",d+=t.domain,d+="')",console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:",d);let i=await fetch(d,o);if(i.status==200){let c=await i.json();if(c){if(c.error!=null){debugger;return console.log("tenantRelationshipsGetByDomain: Failed GET from /findTenantInformationByDomainName: ",c.error.message),!1}else if(c.displayName!=null&&c.displayName!=="")return t.tid=c.tenantId,t.name=c.displayName,console.log("tenantRelationshipsGetByDomain: Successful GET from /findTenantInformationByDomainName: ",c.displayName),!0}else console.log("tenantRelationshipsGetByDomain: Failed to GET from /findTenantInformationByDomainName: ",d)}}catch(i){return console.log("Failed to GET from /findTenantInformationByDomainName: ",i),!1}return!1}async function Ie(a,t,n,s,e){if(console.log("**** tenantRelationshipsGetById"),e)debugger;if(a.graphAccessToken==="")try{let c=await s.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=c.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(c){return console.log("tenantRelationshipsGetById: Front end token failure: "+c),!1}const r=new Headers,o=`Bearer ${a.graphAccessToken}`;r.append("Authorization",o);let d={method:"GET",headers:r};try{var i=F(a.authority)+p.graphTenantByIdPredicate;i+="(tenantId='",i+=t.tid,i+="')",console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:",i);let u=await(await fetch(i,d)).json();if(u&&typeof u.displayName!==void 0&&u.displayName!==""){if(t!==void 0)t.name=u.displayName,t.domain=u.defaultDomainName;else{console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");debugger}return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ",u.displayName),!0}else console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",i)}catch(c){return console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",c),!1}return!1}async function se(a,t){if(t)debugger;let n=[p.authorityWW,p.authorityUS,p.authorityCN],s=[p.authorityWWRegex,p.authorityUSRegex,p.authorityCNRegex],e=null;try{for(let i=0;i<3;i++){var r=n[i];if(a.lookupfield=="Domain"?r+=a.domain:a.lookupfield=="Tenant ID"&&(r+=a.tid),r+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",r),e=await fetch(r),e.status==200){let c=await e.json();if(c){var o=c.authorization_endpoint;for(let u=0;u<3;u++){var d=o.match(s[u]);if(d!=null)return a.tid=d[2],a.authority=d[1],console.log(`Successful GET from openid well-known endpoint: tid: ${a.tid} authority: ${a.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${r}.`)}else console.log(`Failed GET from ${r}.`)}}catch(i){console.log("Failed to GET from openid well-known endpoint: ",i)}return(a.tid==""||a.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${e?e.statusText:"unknown"}`),!1}async function Ae(a,t,n){if(t==null||t.spacode==""||n==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let e={method:"GET",headers:await Z(a,t)};try{if(n.graphSP==""){let{spid:i,error:c}=await be(e,t,"00000003-0000-0000-c000-000000000000");if(c!=""){debugger;return{scopes:null,id:null,error:`${c}`}}n.graphSP=i}let{grants:r,id:o,error:d}=await Te(e,t,n.graphSP,t.oid);if(d!=""){debugger;return{scopes:null,id:null,error:`${d}`}}return{scopes:r,id:o,error:""}}catch(r){debugger;return console.log(r),{scopes:null,id:null,error:`Exception: ${r}`}}}async function $t(a,t,n,s){if(t==null||t.spacode==""||n==null){debugger;return!1}let{scopes:e,id:r,error:o}=await Ae(a,t,n);if(o!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${t.mail}: ${o}`),!1}e=e.replace(s,"");let d=await Se(a,t,r,e);if(!d){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${t.mail}: ${o}`),!1}return t.scopes=e.split(" "),d}async function kt(a,t){if(t==null||t.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let s={method:"GET",headers:await Z(a,t)},e=F(t.authority);e+=p.graphUsersPredicate;let o=await(await fetch(e,s)).json();if(typeof o.error<"u")return{users:[],error:`${o.error.code}: ${o.error.message}`};let d=new Array;for(let i of o.value)d.push(i.mail);return{users:d,error:""}}catch(n){return console.log(n),{users:[],error:`Exception: ${n}`}}}async function Dt(a,t,n,s,e,r,o,d){let i=new w;if(n.id==="1"){if(i=await Ce(a,t,n,r.id,d),i.result){s&&s(n.id);const c={};Object.defineProperty(c,n.id,{value:!0,writable:!0,enumerable:!0}),e(c);let u=r.associatedConfigs.findIndex(h=>h=="1");u!==-1&&(r.associatedConfigs.splice(u,1),r.associatedConfigs.push(n.id))}}else i=await Ne(a,t,n,d);return o.save(),i}async function Pt(a,t,n,s,e){let r=new w;return r=await Ee(a,t,n,s,e),r}async function Rt(a,t,n,s,e){return Ge(a,t,n,s)}async function vt(a,t,n,s,e){return Re(a,t,n,s,e)}async function Gt(a,t,n,s,e){return ve(a,t,n,s,e)}async function Et(a,t,n,s,e){let r=new w;if(e)debugger;try{let o=s.ws.find(d=>d.id===n);if(o!=null){o.associatedConfigs.length=0;let d=await re(a,t,o.id,e);if(!d.result)return d;let i="";for(let c of o.associatedConfigs){let u=s.cs.find(h=>h.id===c);u!=null&&u.sel&&(i=u.id)}$e(o,s,d.array,i),s.tagWithWorkspaces()}return r}catch(o){console.log(o.message),r.error=o.message}return r.result=!1,r.status=500,r}async function Ct(a,t,n,s,e){console.log(">>>>>> initGet");let r=new w;if(e)debugger;let o=new z;return o.tid=t.tid,o.domain=t.tid,await se(o,e)?(t.authority=o.authority,s.setTaskStart("GET tenant details",new Date),r.result=await Ie(t,o,n,a,e),s.setTaskEnd("GET tenant details",new Date,"complete"),r.result&&(t.companyName=o.name,t.companyDomain=o.domain,s.setTaskStart("POST config init",new Date),r=await Oe(a,t,e),s.setTaskEnd("POST config init",new Date,r.result?"complete":"failed")),r.result&&(s.setTaskStart("GET workspaces",new Date),r=await zt(a,t,n,e),s.setTaskEnd("GET workspaces",new Date,r.result?"complete":"failed")),console.log("initGet complete. Version: "+q),r):(r.error=`Failed to retrieve authority for user "${t.mail}" TID ${t.tid}.`,r.result=!1,r)}async function Nt(a,t,n,s){return Fe(a,t,n,s)}async function Ot(a,t,n,s,e){return We(a,t,n,s)}async function Wt(a,t,n,s){return Pe(a,t,n,s)}async function _t(a,t,n,s){return ke(a,t,n,s)}async function Ft(a,t,n,s){return await Be(a,t,n,s)}function Bt(a,t,n,s){n.map(e=>{let r=null,o=t.us.findIndex(c=>c.oid===e.userId||c.oid===e.email);if(o===-1){let c=t.us.findIndex(u=>u.oid==="1");if(c!==-1){r=t.us.at(c);let u=a.associatedUsers.findIndex(h=>h=="1");u!==-1&&(a.associatedUsers.splice(u,1),a.associatedUsers.push(e.userId))}else r=new H,t.us.push(r)}else r=t.us.at(o);r.sel=s===e.userId,r.oid=e.userId?e.userId:e.email,r.name=e.firstName??r.name,r.mail=e.email,r.tid=e.tenantId;let d=t.ts.find(c=>c.tid===r.tid);d!=null&&(r.authority=d.authority,r.companyName=d.name,r.companyDomain=d.domain),a.associatedUsers.findIndex(c=>c===r.oid)==-1&&a.associatedUsers.push(r.oid)}),t.save()}function Ut(a,t,n,s){n.map(e=>{let r=null,o=t.ts.findIndex(u=>u.tid===e.tenantId);if(o===-1){let u=t.ts.findIndex(h=>h.tid==="1");if(u!==-1){r=t.ts.at(u);let h=a.associatedTenants.findIndex(D=>D=="1");h!==-1&&(a.associatedTenants.splice(h,1),a.associatedTenants.push(e.tenantId))}else r=new z,t.ts.push(r)}else r=t.ts.at(o);r.sel=s===e.tenantId,r.tid=e.tenantId,r.name=e.name,r.domain=e.domain,r.tenantType=e.type.toLowerCase();const d=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,i=e.authority.match(d);r.authority=i?i[1]:e.authority,a.associatedTenants.findIndex(u=>u===e.tenantId)==-1&&a.associatedTenants.push(e.tenantId)}),t.save()}function $e(a,t,n,s){n.map(e=>{let r=null,o=t.cs.findIndex(i=>i.id===e.id);if(o===-1){let i=t.cs.findIndex(c=>c.id==="1");if(i!==-1){r=t.cs.at(i);let c=a.associatedConfigs.findIndex(u=>u=="1");c!==-1&&(a.associatedConfigs.splice(c,1),a.associatedConfigs.push(e.id))}else r=new J,t.cs.push(r)}else r=t.cs.at(o);r.sel=s===e.id,r.id=e.id,r.workspaceId=e.workspaceId,r.name=e.name,r.description=e.description,r.isEnabled=e.isEnabled,r.tenants.length=0,e.tenants.map(i=>{let c=new ge;c.tid=i.tenantId,c.sourceGroupId=i.sourceGroupId??"",c.sourceGroupName=i.sourceGroupName??"",c.targetGroupId=i.targetGroupId??"",c.targetGroupName=i.targetGroupName??"",c.configurationTenantType=i.configurationTenantType.toLowerCase(),c.deltaToken=i.deltaToken??"",c.configId=r.id,c.batchId=i.batchId??"",c.isReadPermissionConsented=i.isReadPermissionConsented,c.isWritePermissionConsented=i.isWritePermissionConsented,r.tenants.push(c)}),a.associatedConfigs.findIndex(i=>i===e.id)==-1&&a.associatedConfigs.push(e.id)}),t.save()}async function zt(a,t,n,s){let e=new w;if(s)debugger;try{if(e=await Ue(a,t,s),e.result){for(let r of e.array){let o=null,d=n.ws.findIndex(R=>R.id===r.id);if(d===-1){let R=n.ws.findIndex(y=>y.id==="1");R!==-1?o=n.ws.at(R):(o=new K,n.ws.push(o))}else o=n.ws.at(d);let i="";for(let R of o.associatedUsers){let y=n.us.find(E=>E.oid===R);y!=null&&y.sel&&(i=y.oid)}let c="";for(let R of o.associatedTenants){let y=n.ts.find(E=>E.tid===R);y!=null&&y.sel&&(c=y.tid)}let u="";for(let R of o.associatedConfigs){let y=n.cs.find(E=>E.id===R);y!=null&&y.sel&&(u=y.id)}o.associatedUsers.length=0,o.associatedTenants.length=0,o.associatedConfigs.length=0,o.id=r.id,o.name=r.name,o.ownerid=r.ownerid;let h=De(a,t,o.id,s),D=_e(a,t,o.id,s),P=re(a,t,o.id,s),[G,v,g]=await Promise.all([h,D,P]);if(!G.result)return G;if(!v.result)return v;if(!g.result)return g;Ut(o,n,v.array,c),Bt(o,n,G.array,i),$e(o,n,g.array,u),n.tagWithWorkspaces()}return e}}catch(r){console.log(r.message),e.error=r.message}return e.result=!1,e.status=500,e}async function Lt(a,t){let n="";try{let s=a.getAllAccounts(),e=t.oid+"."+t.tid,r=null;for(let d=0;d<s.length;d++)s[d].homeAccountId==e&&(r=s[d]);n=(await a.acquireTokenSilent({scopes:["https://analysis.windows.net/powerbi/api/App.Read.All","https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All","https://analysis.windows.net/powerbi/api/Report.ReadWrite.All","https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"],account:r})).accessToken,console.log("PowerBI token acquired silently: "+n.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return n}async function ne(a,t){const n=new Headers;if(n.append("Content-Type","application/json"),n.append("accept","*/*"),t.azureAccessToken==null||t.azureAccessToken==="")try{let s=a.getAllAccounts(),e=t.oid+"."+t.tid,r=null;for(let d=0;d<s.length;d++)s[d].homeAccountId==e&&(r=s[d]);let o=await a.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:r});t.azureAccessToken=o.accessToken,console.log("Front end token acquired silently: "+t.azureAccessToken.slice(0,20))}catch(s){try{console.log("Front end token silent acquisition failure: "+s);let e=a.getAllAccounts(),r=t.oid+"."+t.tid,o=null;for(let d=0;d<e.length;d++)e[d].homeAccountId==r&&(o=e[d]);a.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:o})}catch(e){console.log("Front end token popup acquisition failure: "+e)}}return n.append("Authorization",`Bearer ${t.azureAccessToken}`),n}async function xt(a,t){if(t==null||t.spacode=="")return!1;try{let s={method:"GET",headers:await ne(a,t)},e=U.azureListRootAssignments;e+="'",e+=t.oid,e+="'";let r=await fetch(e,s);if(r.status==200){let o=await r.json();o=o;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await I(r)),!1}catch(n){return console.log(n),!1}return!0}async function Mt(a,t){if(t==null||t.spacode=="")return!1;try{let s={method:"POST",headers:await ne(a,t)},e=U.azureElevateAccess,r=await fetch(e,s);if(r.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await I(r)),!1}catch(n){return console.log(n),!1}return!0}async function jt(a,t){let n=new Array;if(t==null||t.spacode=="")return n;try{let e={method:"GET",headers:await ne(a,t)},r=U.azureListRootAssignments;r+="'",r+=t.oid,r+="'";let o=await fetch(r,e);if(o.status==200){let d=await o.json();d=d;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await I(o)),n}catch(s){return console.log(s),n}return n}function qt(a){let t="8d95d21c-c378-4bb0-9f52-88c30d271e7a",n=a.authority.toLowerCase();return n.startsWith("https://login.microsoftonline.com/")?t="8d95d21c-c378-4bb0-9f52-88c30d271e7a":n.startsWith("https://login.microsoftonline.us/")?t="48da942e-ea3d-49e4-a054-81649012f8f2":n.startsWith("https://login.partner.microsoftonline.cn/")&&(t="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${t}/Config.Write`}async function $(a,t){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const s=qt(t);try{let e=a.getAllAccounts(),r=t.oid+"."+t.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.acquireTokenSilent({scopes:[s],account:o});t.mindlineAccessToken=d.accessToken,console.log("Front end mindline token acquired silently: "+t.mindlineAccessToken.slice(0,20))}catch(e){try{console.log("Front end mindline token silent acquisition failure, triggering redirect: "+e);let r=a.getAllAccounts(),o=t.oid+"."+t.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[s],account:d})}catch(r){console.log("Front end mindline token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${t.mindlineAccessToken}`),n}async function I(a){let t="";if(a.status===401&&(t=a.statusText,t!=""))return t;let n=await a.json();if(n.error!==void 0)t=`Error: ${n.error} Message: ${n.message}`;else if(n.errors!==void 0)t=Object.keys(n.errors).reduce((r,o)=>r+o+": "+n.errors[o]+" ","");else if(n.title!==void 0)t=n.title;else debugger;return t}async function ke(a,t,n,s){let e=new w;if(n.oid==""&&n.mail==""||s=="")return e.result=!1,e.error="adminDelete: invalid parameters",e.status=500,e;let r=null;r=new URL(b.adminEndpoint()),r.searchParams.append("workspaceId",s),r.searchParams.append("email",n.mail);let d={method:"DELETE",headers:await $(a,t)};try{console.log("Attempting DELETE from /admin: "+r.href);let i=await fetch(r.href,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${r.href}`),e):(e.error=await I(i),console.log(`Failed DELETE from /admin: ${r.href}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(i){e.error=i.message,e.status=500,e.result=!1,console.log(i.message)}return e}async function De(a,t,n,s){let e=new w;if(n==="")return e.result=!1,e.status=500,e.error="adminsGet: no workspace provided",e;let r=b.adminsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await $(a,t)};try{if(s)debugger;console.log("Attempting GET from /admins: "+o.href);let c=await fetch(o.href,i);if(c.status===200&&c.statusText==="OK"){let u=await c.json();return u!=null?(e.array=u,console.log(`Successful GET from /admins: ${e.array.reduce((D,P)=>D+P.email+" ","")}`),e):(e.error="Failed GET from /admins: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /admins: ${o.href}`),e.error=await I(c),e.status=500,e.result=!1,console.log(e.error),e}catch(c){e.error=c.message,e.status=500,e.result=!1,console.log(c.message)}return e}async function Pe(a,t,n,s){let e=new w;if(n.mail==""||n.authority==""||n.tid==="")return e.result=!1,e.error="adminPost: invalid argument",e.status=500,e;let r=b.adminEndpoint();const o=await $(a,t);let d=`
|
|
2
|
+
{"email": "${n.mail}",
|
|
3
|
+
"tenantId": "${n.tid}",
|
|
4
|
+
"workspaceId": "${s}"
|
|
5
|
+
}`,i={method:"POST",headers:o,body:d};try{console.log("Attempting POST to /admin: "+r);let c=await fetch(r,i);return c.status===200&&c.statusText==="OK"?(console.log(`Successful POST to /admin: ${d}`),e):(e.error=await I(c),console.log(`Failed POST to /admin: ${d}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(c){e.error=c.message,e.status=500,e.result=!1,console.log(c.message)}return e}async function Re(a,t,n,s,e){let r=new w,o=b.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n);const i=await $(a,t);let c=`
|
|
6
6
|
{
|
|
7
|
-
"tenantId": "${
|
|
8
|
-
"isReadPermissionConsented": ${
|
|
9
|
-
}`,u={method:"PUT",headers:
|
|
7
|
+
"tenantId": "${s}",
|
|
8
|
+
"isReadPermissionConsented": ${e?"true":"false"}
|
|
9
|
+
}`,u={method:"PUT",headers:i,body:c};try{console.log("Attempting PUT read consent to /configuration/consent: "+d.href);let h=await fetch(d.href,u);return h.status===200&&h.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),r):(r.error=await I(h),console.log(`Failed PUT to ${d.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(h){r.error=h.message,r.status=500,r.result=!1,console.log(h.message)}return r}async function ve(a,t,n,s,e){let r=new w,o=b.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n);const i=await $(a,t);let c=`
|
|
10
10
|
{
|
|
11
|
-
"tenantId": "${
|
|
12
|
-
"isWritePermissionConsented": ${
|
|
13
|
-
}`,u={method:"PUT",headers:
|
|
11
|
+
"tenantId": "${s}",
|
|
12
|
+
"isWritePermissionConsented": ${e?"true":"false"}
|
|
13
|
+
}`,u={method:"PUT",headers:i,body:c};try{console.log("Attempting PUT read consent to /configuration/consent: "+d.href);let h=await fetch(d.href,u);return h.status===200&&h.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),r):(r.error=await I(h),console.log(`Failed PUT to ${d.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(h){r.error=h.message,r.status=500,r.result=!1,console.log(h.message)}return r}async function Ge(a,t,n,s,e){let r=new w;if(n.id===""||s=="")return r.result=!1,r.error="configPost: invalid config ID",r.status=500,r;let o=null;o=new URL(b.configEndpoint()),o.searchParams.append("configurationId",n.id);let i={method:"DELETE",headers:await $(a,t)};try{console.log("Attempting DELETE from /config: "+o.href);let c=await fetch(o.href,i);return c.status===200&&c.statusText==="OK"?(console.log("Successful DELETE from /config"),r):(r.error=await I(c),console.log(`Failed DELETE from ${o.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(c){r.error=c.message,r.status=500,r.result=!1,console.log(c.message)}return r}async function Ee(a,t,n,s,e){let r=new w;if(n==="")return r.result=!1,r.error="configPatch: invalid config ID",r.status=500,r;let o=b.configEnabledEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n),d.searchParams.append("isEnabled",s.toString());let c={method:"PATCH",headers:await $(a,t)};try{if(e)debugger;console.log("Attempting PATCH to /config: "+d.href);let u=await fetch(d.href,c);return u.status===200&&u.statusText==="OK"?(console.log(`Successful PATCH to ${d.href}: ${s.toString()}`),r):(r.error=await I(u),console.log(`Failed PATCH to ${d.href}: ${s.toString()}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(u){r.error=u.message,r.status=500,r.result=!1,console.log(u.message)}return r}async function Ce(a,t,n,s,e){let r=new w;if(n.id==="")return r.result=!1,r.error="configPost: invalid config ID",r.status=500,r;let o=b.configEndpoint();const d=await $(a,t);let i=`
|
|
14
14
|
{
|
|
15
|
-
"workspaceId": "${
|
|
16
|
-
"name": "${
|
|
17
|
-
"description": "${
|
|
18
|
-
"isEnabled": ${
|
|
19
|
-
"tenants": [`;
|
|
15
|
+
"workspaceId": "${s}",
|
|
16
|
+
"name": "${n.name}",
|
|
17
|
+
"description": "${n.description}",
|
|
18
|
+
"isEnabled": ${n.isEnabled},
|
|
19
|
+
"tenants": [`;n.tenants.map(u=>{let h=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",D=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",P=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",G=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i.slice(-1)==="}"&&(i+=","),i+=`{
|
|
20
20
|
"tenantId": "${u.tid}",
|
|
21
|
-
"sourceGroupId": ${
|
|
22
|
-
"sourceGroupName": ${
|
|
23
|
-
"targetGroupId": ${
|
|
24
|
-
"targetGroupName": ${
|
|
21
|
+
"sourceGroupId": ${h},
|
|
22
|
+
"sourceGroupName": ${D},
|
|
23
|
+
"targetGroupId": ${P},
|
|
24
|
+
"targetGroupName": ${G},
|
|
25
25
|
"configurationTenantType": "${u.configurationTenantType}"
|
|
26
|
-
}`}),
|
|
26
|
+
}`}),i+="]}";let c={method:"POST",headers:d,body:i};try{if(e)debugger;console.log("Attempting POST to /config: "+o);let u=await fetch(o,c);if(u.status===200&&u.statusText==="OK"){let h=await u.json();return n.id=h,console.log(`Successful ConfigID: ${h} from POST to /config: ${i}`),r}else return r.error=await I(u),console.log(`Failed PUT to /config: ${i}`),console.log(r.error),r.status=500,r.result=!1,r}catch(u){return r.status=500,r.result=!1,r.error=u.message,console.log(r.error),r}}async function Ne(a,t,n,s){let e=new w;if(n.id==="")return e.result=!1,e.error="configPost: invalid config ID",e.status=500,e;let r=b.configEndpoint(),o=new URL(r);o.searchParams.append("configurationId",n.id);const d=await $(a,t);let i=`
|
|
27
27
|
{
|
|
28
|
-
"name": "${
|
|
29
|
-
"description": "${
|
|
30
|
-
"tenants": [`;
|
|
28
|
+
"name": "${n.name}",
|
|
29
|
+
"description": "${n.description}",
|
|
30
|
+
"tenants": [`;n.tenants.map(u=>{i.slice(-1)==="}"&&(i+=",");let D=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",P=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",G=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",v=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i+=`{
|
|
31
31
|
"tenantId": "${u.tid}",
|
|
32
|
-
"sourceGroupId": ${
|
|
33
|
-
"sourceGroupName": ${
|
|
34
|
-
"targetGroupId": ${
|
|
35
|
-
"targetGroupName": ${
|
|
32
|
+
"sourceGroupId": ${D},
|
|
33
|
+
"sourceGroupName": ${P},
|
|
34
|
+
"targetGroupId": ${G},
|
|
35
|
+
"targetGroupName": ${v},
|
|
36
36
|
"configurationTenantType": "${u.configurationTenantType}",
|
|
37
37
|
"deltaToken": "${u.deltaToken}"
|
|
38
|
-
}`}),
|
|
38
|
+
}`}),i+="]}";let c={method:"PUT",headers:d,body:i};try{if(s)debugger;console.log("Attempting PUT to /config: "+o.href);let u=await fetch(o.href,c);return u.status===200&&u.statusText==="OK"?(console.log(`Successful PUT to ${o.href}: ${i}`),e):(e.error=await I(u),console.log(`Failed PUT to ${o.href}: ${i}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(u){e.error=u.message,e.status=500,e.result=!1,console.log(u.message)}return e}async function re(a,t,n,s){let e=new w;if(n==="")return e.result=!1,e.status=500,e.error="configsGet: no workspace provided",e;let r=b.configsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await $(a,t)};try{if(s)debugger;console.log("Attempting GET from /configurations: "+o.href);let c=await fetch(o.href,i);if(c.status===200&&c.statusText==="OK"){let u=await c.json();return u!=null?(e.array=u,console.log(`Successful GET from /configurations: ${e.array.reduce((D,P)=>D+P.name+" ","")}`),e):(e.error="Failed GET from /configurations: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /configurations: ${o.href}`),e.error=await I(c),e.status=500,e.result=!1,console.log(e.error),e}catch(c){e.error=c.message,e.status=500,e.result=!1,console.log(c.message)}return e}async function Oe(a,t,n){let s=new w;if(t.companyName===""||t.companyDomain==="")return s.result=!1,s.error="initPost: invalid company name or domain",s.status=500,s;let e=b.initEndpoint();const r=await $(a,t);let o=`
|
|
39
39
|
{
|
|
40
40
|
"tenantCreateModel": {
|
|
41
|
-
"tenantId": "${
|
|
42
|
-
"name": "${
|
|
43
|
-
"domain": "${
|
|
41
|
+
"tenantId": "${t.tid}",
|
|
42
|
+
"name": "${t.companyName}",
|
|
43
|
+
"domain": "${t.companyDomain}",
|
|
44
44
|
"type": "aad",
|
|
45
|
-
"authority": "${
|
|
45
|
+
"authority": "${t.authority}"
|
|
46
46
|
}
|
|
47
|
-
}`,
|
|
48
|
-
{"tenantId": "${
|
|
49
|
-
"name": "${
|
|
50
|
-
"domain": "${
|
|
47
|
+
}`,d={method:"POST",headers:r,body:o};try{if(n)debugger;console.log("Attempting POST to /configuration/init: "+e);let i=await fetch(e,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful POST to /configuration/init: ${o}`),s):(s.error=await I(i),s.status=500,s.result=!1,console.log(`Failed POST to /configuration/init: ${o}`),console.log(s.error),s)}catch(i){s.error=i.message,console.log(s.error)}return s.status=500,s.result=!1,s}async function We(a,t,n,s,e){let r=new w;if(n.tid===""||s==="")return r.result=!1,r.error="tenantDelete: invalid tid, workspaceId",r.status=500,r;let o=new URL(b.tenantEndpoint());o.searchParams.append("tenantId",n.tid),o.searchParams.append("workspaceId",s);let i={method:"DELETE",headers:await $(a,t)};try{console.log("Attempting DELETE from /tenant: "+o.href);let c=await fetch(o.href,i);return c.status===200&&c.statusText==="OK"?(console.log(`Successful DELETE from /tenant: ${o.href}`),r):(console.log(`Failed DELETE from /tenant: ${o.href}`),r.error=await I(c),console.log(r.error),r.status=500,r.result=!1,r)}catch(c){r.error=c.message,r.status=500,r.result=!1,console.log(r.error)}return r}async function _e(a,t,n,s){let e=new w;if(n==="")return e.result=!1,e.status=500,e.error="tenantsGet: no workspace provided",e;let r=b.tenantsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await $(a,t)};try{if(s)debugger;console.log(`Attempting GET from /tenants: ${o.href}`);let c=await fetch(o.href,i);if(c.status===200&&c.statusText==="OK"){let u=await c.json();return u!=null?(e.array=u,console.log(`Successful GET from /tenants: ${e.array.reduce((D,P)=>D+P.domain+" ","")}`),e):(e.error="Failed GET from /tenants: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /tenants: ${o.href}`),e.error=await I(c),e.status=500,e.result=!1,console.log(e.error),e}catch(c){e.error=c.message,e.status=500,e.result=!1,console.log(c.message)}return e}async function Fe(a,t,n,s){let e=new w;if(n.tid===""||n.name===""||n.domain==="")return e.result=!1,e.error="tenantPost: invalid tid, name, domain",e.status=500,e;let r=b.tenantEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",s);const d=await $(a,t);let i=`
|
|
48
|
+
{"tenantId": "${n.tid}",
|
|
49
|
+
"name": "${n.name}",
|
|
50
|
+
"domain": "${n.domain}",
|
|
51
51
|
"type": 1,
|
|
52
|
-
"authority": "${
|
|
53
|
-
}`,
|
|
52
|
+
"authority": "${n.authority}"
|
|
53
|
+
}`,c={method:"POST",headers:d,body:i};try{console.log(`Attempting POST to ${o.href}: ${i}`);let u=await fetch(o.href,c);return u.status===200&&u.statusText==="OK"?(console.log(`Successful POST to ${o.href}: ${i}`),e):(console.log(`Failed POST to ${o.href}: ${i}`),e.error=await I(u),console.log(e.error),e.status=500,e.result=!1,e)}catch(u){e.error=u.message,e.status=500,e.result=!1,console.log(e.error)}return e}async function Be(a,t,n,s){let e=new w;if(n==""||s=="")return e.result=!1,e.error="workspacePut: invalid workspace ID or name",e.status=500,e;let r=b.workspaceEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n),o.searchParams.append("workspaceName",s);let i={method:"PUT",headers:await $(a,t)};try{console.log("Attempting PUT to /workspace: "+o.href);let c=await fetch(o.href,i);return c.status===200&&c.statusText==="OK"?(console.log(`Successful PUT to ${o.href}`),e):(e.error=await I(c),console.log(`Failed PUT to ${o.href}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(c){e.error=c.message,e.status=500,e.result=!1,console.log(c.message)}return e}async function Ue(a,t,n){let s=new w;if(t.mail==null||t.mail=="")return s.result=!1,s.status=500,s.error="adminsGet: no workspace provided",s;let e=b.workspacesEndpoint(),r=new URL(e),d={method:"GET",headers:await $(a,t)};try{if(n)debugger;console.log("Attempting GET from /workspaces endpoint: "+r.href);let i=await fetch(r.href,d);if(i.status===200&&i.statusText==="OK"){let c=await i.json();return c!=null?(s.array=c,console.log(`Successful GET from /workspaces: ${s.array.reduce((h,D)=>h+D.name+" ","")}`),s):(s.error="Failed GET from /workspaces: failed to JSON-parse response",console.log(s.error),s.status=500,s.result=!1,s)}else return console.log(`Failed GET from /workspaces: ${r.href}`),s.error=await I(i),s.status=500,s.result=!1,console.log(s.error),s}catch(i){s.error=i.message,s.status=500,s.result=!1,console.log(i.message)}return s}async function ze(a,t,n){let s=new w;if(a==null||t==null)return s.result=!1,s.error="readerPost: invalid parameters",s.status=500,s;let e=b.readerStartSyncEndpoint(),r=new URL(e);r.searchParams.append("configurationId",n.id);let d={method:"POST",headers:await $(a,t)};try{console.log("Attempting POST to /startSync: "+r.href);let i=await fetch(r.href,d);if(i.status===200&&i.statusText==="OK"){console.log(`Successful POST to /startSync: ${e}`);let c=await i.json();return c.PayloadStr!=""?s.array=JSON.parse(c.PayloadStr):(s.result=!1,s.error="readerPost: blank payload returned, sync may be disabled on back end",s.status=500),s}else return s.error=await I(i),console.log(`Failed POST to /startSync: ${e}`),console.log(s.error),s.status=500,s.result=!1,s}catch(i){s.error=i.message,s.status=500,s.result=!1,console.log(i.message)}return s}f.APIResult=w,f.ActorArray=mt,f.ActorNode=we,f.BatchArray=gt,f.Config=J,f.Group=lt,f.InitInfo=ft,f.Milestone=L,f.MilestoneArray=me,f.ResourceArray=te,f.ResourceNode=ye,f.Task=V,f.TaskArray=ht,f.Tenant=z,f.TenantConfigInfo=ge,f.TenantConfigType=he,f.TenantNode=ee,f.TenantPermissionType=pe,f.TenantType=fe,f.User=H,f.UserScope=ct,f.Workspace=K,f.adminDelete=ke,f.adminPost=Pe,f.adminsGet=De,f.azureConfig=U,f.canListRootAssignments=xt,f.configConsentForRead=vt,f.configConsentForWrite=Gt,f.configConsentReadPut=Re,f.configConsentWritePut=ve,f.configDelete=Ge,f.configEdit=Dt,f.configEnable=Pt,f.configPatch=Ee,f.configPost=Ce,f.configPut=Ne,f.configRemove=Rt,f.configsGet=re,f.configsRefresh=Et,f.elevateGlobalAdminToUserAccessAdmin=Mt,f.getPowerBIAccessToken=Lt,f.graphConfig=p,f.groupsGet=wt,f.helloNpm=it,f.initGet=Ct,f.initPost=Oe,f.mindlineConfig=b,f.oauth2PermissionGrantsGet=Te,f.oauth2PermissionGrantsSet=Se,f.processErrors=I,f.readerPost=ze,f.requestAdminConsent=Tt,f.servicePrincipalGet=be,f.signIn=St,f.signInIncrementally=bt,f.signOut=It,f.sum=ot,f.tenantAdd=Nt,f.tenantDelete=We,f.tenantPost=Fe,f.tenantRelationshipsGetByDomain=At,f.tenantRelationshipsGetById=Ie,f.tenantRemove=Ot,f.tenantUnauthenticatedLookup=se,f.tenantsGet=_e,f.userAdd=Wt,f.userDelegatedScopesGet=Ae,f.userDelegatedScopesRemove=$t,f.userRemove=_t,f.usersGet=kt,f.workspaceEdit=Ft,f.workspacePut=Be,f.workspacesGet=Ue,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
54
54
|
//# sourceMappingURL=sync.umd.js.map
|