@mindline/sync 1.0.96 → 1.0.98

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/dist/sync.umd.js CHANGED
@@ -1,4 +1,4 @@
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,M,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 q=Xe(T),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"}function U(){return"1.0.95"}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=U(),this.array=null}}class z{}l(z,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),l(z,"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 L{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",U());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=U(),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(L,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.version=U(),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 L;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 x{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,M);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,M,ue).call(this,e);return}}}W(this,M,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 x(n+1);this.milestones.unshift(s),this.milestones=this.milestones.map(e=>{let r=new x(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 x(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 x(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)}}M=new WeakSet,ue=function(t){t==null?this.milestones=new Array:this.milestones=t.map(n=>{let s=new x(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"),j=y[m].endsWith("DeferredCount"),oe=y[m].endsWith("RescheduledCount");if(y[m].startsWith("Reader")){let _=/Reader\/TID:(.+)\/TotalCount/;if(X&&(_=/Reader\/TID:(.+)\/CurrentCount/),j&&(_=/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/),j&&(_=/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(j||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 j=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=j,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 q.HubConnectionBuilder().withUrl(v.href).withAutomaticReconnect().configureLogging(q.LogLevel.Information).build();g.on("newMessage",D),g.onreconnecting(R=>{console.assert(g.state===q.HubConnectionState.Reconnecting),console.log(`Connection lost due to error "${R}". Reconnecting.`)}),g.onreconnected(R=>{console.assert(g.state===q.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 L;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 L;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: "+U()),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 L,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.workspaceOwnerUserId;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=z.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=z.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=z.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=`
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,M,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 q=Xe(T),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:[]}],U="workspaceIDs";function ot(a,t){return a+t}function it(){return"hello NPM"}function F(){return"1.0.97"}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=F(),this.array=null}}class z{}l(z,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),l(z,"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 L{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 B(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",F());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=F(),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(L,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[U]+=t.id,s[U]+=" ";else debugger}for(let n of t.associatedTenants){let s=this.ts.find(e=>e.tid===n);if(s!==void 0)s[U]+=t.id,s[U]+=" ";else debugger}for(let n of t.associatedConfigs){let s=this.cs.find(e=>e.id===n);if(s!==void 0)s[U]+=t.id,s[U]+=" ";else debugger}}return!0}}Q=new WeakSet,Qe=function(t){this.tab=t.tab,this.version=F(),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 L;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 x{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,M);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,M,ue).call(this,e);return}}}W(this,M,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 x(n+1);this.milestones.unshift(s),this.milestones=this.milestones.map(e=>{let r=new x(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 x(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 x(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)}}M=new WeakSet,ue=function(t){t==null?this.milestones=new Array:this.milestones=t.map(n=>{let s=new x(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"),j=y[m].endsWith("DeferredCount"),oe=y[m].endsWith("RescheduledCount");if(y[m].startsWith("Reader")){let _=/Reader\/TID:(.+)\/TotalCount/;if(X&&(_=/Reader\/TID:(.+)\/CurrentCount/),j&&(_=/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/),j&&(_=/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(j||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 j=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=j,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 q.HubConnectionBuilder().withUrl(v.href).withAutomaticReconnect().configureLogging(q.LogLevel.Information).build();g.on("newMessage",D),g.onreconnecting(R=>{console.assert(g.state===q.HubConnectionState.Reconnecting),console.log(`Connection lost due to error "${R}". Reconnecting.`)}),g.onreconnected(R=>{console.assert(g.state===q.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=B(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=B(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=B(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=B(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 L;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=B(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=B(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=B(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 L;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: "+F()),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 L,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.workspaceOwnerUserId;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="",s=F();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]);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:o})).accessToken,console.log("PowerBI token acquired silently: "+n.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return console.log(s),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=z.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=z.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=z.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
2
  {"email": "${n.mail}",
3
3
  "tenantId": "${n.tid}",
4
4
  "workspaceId": "${s}"
@@ -50,5 +50,5 @@
50
50
  "domain": "${n.domain}",
51
51
  "type": 1,
52
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=x,f.MilestoneArray=me,f.ResourceArray=te,f.ResourceNode=ye,f.Task=V,f.TaskArray=ht,f.Tenant=L,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=z,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.getSyncVersion=U,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"})});
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=x,f.MilestoneArray=me,f.ResourceArray=te,f.ResourceNode=ye,f.Task=V,f.TaskArray=ht,f.Tenant=L,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=z,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.getSyncVersion=F,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