mftsccs-node 0.0.80-dev → 0.0.82-dev
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/bundle.js +2 -1
- package/dist/bundle.js.LICENSE.txt +1 -0
- package/dist/bundle.mjs +2 -1
- package/dist/bundle.mjs.LICENSE.txt +1 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +18 -0
- package/dist/types/Services/Http/HttpClient.service.d.ts +1 -45
- package/dist/types/Services/Security/ResolveUserId.d.ts +8 -0
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALLID:()=>Ki,AccessControlService:()=>Mi,AddGhostConcept:()=>Ko,AddGhostConnection:()=>Qo,BaseUrl:()=>n,BinaryTree:()=>G,CCSConfig:()=>gi,Composition:()=>yo,CompositionBinaryTree:()=>lo,CompositionNode:()=>so,Concept:()=>F,ConceptsData:()=>M,Connection:()=>ee,ConnectionData:()=>se,CreateComposition:()=>Bt,CreateConnection:()=>Tt,CreateConnectionBetweenTwoConcepts:()=>tn,CreateConnectionBetweenTwoConceptsGeneral:()=>on,CreateDefaultConcept:()=>b,CreateDefaultLConcept:()=>hn,CreateSession:()=>Po,CreateSessionVisit:()=>Fo,CreateTheCompositionWithCache:()=>vo,CreateTheConnectionGeneral:()=>mt,CreateTypeConcept:()=>sn,DATAID:()=>Wi,DATAIDDATE:()=>zi,DATAV2:()=>Yi,DeleteConceptById:()=>Pn,DeleteConnectionById:()=>Ot,DeleteConnectionByIdBulk:()=>Vt,DeleteConnectionByTypeBulk:()=>di,FilterSearch:()=>yi,FormatFromConnections:()=>ti,FreeSchemaResponse:()=>K,FreeschemaQuery:()=>fr,GetAllConnectionsOfComposition:()=>we,GetAllConnectionsOfCompositionBulk:()=>ve,GetAllTheConnectionsByTypeAndOfTheConcept:()=>pr,GetComposition:()=>Ae,GetCompositionBulk:()=>Hn,GetCompositionBulkWithDataId:()=>jn,GetCompositionFromConnectionsWithDataId:()=>Wn,GetCompositionFromConnectionsWithDataIdInObject:()=>zn,GetCompositionList:()=>$e,GetCompositionListWithId:()=>Oe,GetCompositionWithAllIds:()=>ke,GetCompositionWithCache:()=>Ro,GetCompositionWithDataIdBulk:()=>Uo,GetCompositionWithDataIdWithCache:()=>Bo,GetCompositionWithId:()=>Be,GetCompositionWithIdFromMemory:()=>xe,GetCompositionWithIdFromMemoryFromConnections:()=>Re,GetConceptBulk:()=>le,GetConceptByCharacter:()=>be,GetConceptByCharacterAndCategoryDirectApi:()=>He,GetConceptByCharacterAndType:()=>Nt,GetConceptByTypeBulk:()=>At,GetConnectionBulk:()=>Vn,GetConnectionById:()=>Dt,GetConnectionByTypeBulk:()=>ui,GetConnectionOfTheConcept:()=>Lt,GetConnectionsBetweenApi:()=>Co,GetLink:()=>ln,GetLinkRaw:()=>dn,GetLinkerConnectionFromConcepts:()=>Rn,GetLinkerConnectionToConcepts:()=>En,GetRelation:()=>Oo,GetRelationRaw:()=>Vo,GetRequestHeader:()=>z,GetRequestHeaderWithAuthorization:()=>q,GetTheConcept:()=>Ht,GetUserGhostConnectionId:()=>qo,GetUserGhostId:()=>zo,GiveConnection:()=>vr,HandleHttpError:()=>Q,HttpResponse:()=>l,JUSTDATA:()=>Ji,LConcept:()=>un,LConnection:()=>Ho,LISTNORMAL:()=>Qi,LoginToBackend:()=>Yn,MakeTheInstanceConcept:()=>Rt,MakeTheTimestamp:()=>Dn,MakeTheTypeConcept:()=>Nn,MakeTheTypeConceptApi:()=>Ke,NORMAL:()=>ji,PatcherStructure:()=>hi,PermissionSet:()=>Di,RAW:()=>qi,RecursiveSearchApi:()=>Kn,ReservedConnectionIds:()=>at,ReservedIds:()=>st,SchemaQueryListener:()=>hr,SearchAllConcepts:()=>ko,SearchLinkInternal:()=>ai,SearchLinkMultipleAll:()=>ei,SearchLinkMultipleApi:()=>Xo,SearchQuery:()=>$n,SearchStructure:()=>pi,SearchWithLinker:()=>xo,SessionData:()=>fi,Signin:()=>to,Signup:()=>Zn,SplitStrings:()=>W,SyncData:()=>vt,TokenRefreshError:()=>a,TokenStorage:()=>o,Transaction:()=>wo,TrashTheConcept:()=>Fn,UpdateComposition:()=>No,UserBinaryTree:()=>Wo,ViewInternalData:()=>ii,buildFetchConnection:()=>mo,convertFromLConceptToConcept:()=>ri,deleteWithRetry:()=>v,fetchWithCacheServerFallback:()=>T,fetchWithRetry:()=>h,getFromDatabaseWithType:()=>S,getFromDatabaseWithTypeOld:()=>x,getOAuthToken:()=>r,getWithRetry:()=>y,init:()=>mr,patchWithRetry:()=>g,postWithRetry:()=>f,putWithRetry:()=>p,recursiveFetch:()=>Ue,recursiveFetchNew:()=>ho,refreshOAuthToken:()=>c,requestWithRetry:()=>u,storeToDatabase:()=>k,updateAccessToken:()=>Cr});class n{static setNodeCacheUrl(e=""){this.NODE_CACHE_URL=e,this.isNearestCache=!0}static setCacheServers(e=[]){this.CACHE_SERVERS=e.filter((e=>"string"==typeof e&&""!==e.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetNodeBaseUrl(){return this.NODE_URL&&""!==this.NODE_URL.trim()?this.NODE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const e=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.GetNodeBaseUrl(),this.BASE_URL].filter((e=>"string"==typeof e&&""!==e.trim())).map((e=>e.trim()));return Array.from(new Set(e))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static CreateTypeConceptUrl(){return this.BASE_URL+"/api/create_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}n.BASE_URL="https://localhost:7053/",n.NODE_CACHE_URL="",n.CACHE_SERVERS=[],n.isNearestCache=!0,n.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(e,t){this.BearerAccessToken=e,this.TOKEN_EXPIRY=t&&t>0?Date.now()+1e3*t:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const e=Date.now(),t=this.TOKEN_EXPIRY-e;return t>0?Math.floor(t/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(e,t,n){this.CLIENT_ID=e,this.CLIENT_SECRET=t,this.APPLICATION_NAME=n}}o.BearerAccessToken="",o.CLIENT_ID="",o.CLIENT_SECRET="",o.APPLICATION_NAME="",o.TOKEN_EXPIRY=0,o.EXPIRY_BUFFER_MS=3e5;var i=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function r(e,t,r){return i(this,arguments,void 0,(function*(e,t,i,r=!0){try{const c=n.OAuthTokenUrl(),s=new URLSearchParams;s.append("client_id",e),s.append("client_secret",t),s.append("application_name",i);const a=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()});if(a.ok){let e="",t="Bearer",n=0;const i=a.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield a.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield a.text()}else e=yield a.text();return e?(r&&o.setToken(e,n),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield a.text();return{success:!1,error:`HTTP ${a.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}function c(e,t,r){return i(this,arguments,void 0,(function*(e,t,i,r=!0){try{const c=n.OAuthRefreshUrl(),s=new URLSearchParams;s.append("client_id",e),s.append("client_secret",t),s.append("refresh_token",i),s.append("grant_type","refresh_token");const a=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()});if(a.ok){let e="",t="Bearer",n=0;const i=a.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield a.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield a.text()}else e=yield a.text();return e?(r&&o.setToken(e,n),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield a.text();return{success:!1,error:`HTTP ${a.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}var s=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class a extends Error{constructor(e){super(e),this.name="TokenRefreshError"}}class l{constructor(e,t,n){this.status=e,this.body=t,this.headers=n}json(){return s(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return s(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return s(this,void 0,void 0,(function*(){if(!o.hasOAuthCredentials())return!1;try{return(yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0)).success}catch(e){return console.error("Token refresh failed:",e),!1}}))}function u(e,t,n,i){return s(this,arguments,void 0,(function*(e,t,n,i,r=1){var c,s;const u=Object.assign(Object.assign({},n),o.getAuthHeader()),h=["GET","HEAD","OPTIONS"].includes(e.toUpperCase());for(let n=0;n<=r;n++)try{const h={method:e,headers:u};void 0!==i&&("object"==typeof i?(u["Content-Type"]||u["content-type"]||(u["Content-Type"]="application/json"),(null===(c=u["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(s=u["content-type"])||void 0===s?void 0:s.includes("application/json"))?h.body=JSON.stringify(i):h.body=i):h.body=i),h.headers=u;const f=yield fetch(t,h),y=yield f.text(),p={};if(f.headers.forEach(((e,t)=>{p[t]=e})),401!==f.status)return new l(f.status,y,p);if(n<r){if(yield d()){Object.assign(u,o.getAuthHeader());continue}throw new a("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(e){if(e instanceof a)throw e;if(n>=r||!h)throw e;console.error(`Request failed (attempt ${n+1}/${r+1}):`,e)}throw new Error("Request failed after all retry attempts")}))}function h(e){return s(this,arguments,void 0,(function*(e,t={},n=1){return u(t.method||"GET",e,function(e){if(e){if(e instanceof Headers){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}return Array.isArray(e)?e.reduce(((e,[t,n])=>(e[t]=n,e)),{}):e}}(t.headers),t.body,n)}))}function f(e,t,n){return s(this,void 0,void 0,(function*(){return u("POST",e,t,n)}))}function y(e,t,n){return s(this,void 0,void 0,(function*(){let o=e;if(n){const t=[];for(const e in n)n.hasOwnProperty(e)&&t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n[e]))}`);t.length>0&&(o=`${e}?${t.join("&")}`)}return u("GET",o,t)}))}function p(e,t,n){return s(this,void 0,void 0,(function*(){return u("PUT",e,t,n)}))}function v(e,t){return s(this,void 0,void 0,(function*(){return u("DELETE",e,t)}))}function g(e,t,n){return s(this,void 0,void 0,(function*(){return u("PATCH",e,t,n)}))}var C=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function m(e,t){return`${e.replace(/\/+$/,"")}${t}`}function T(e){return C(this,arguments,void 0,(function*(e,t={},o=1){const i=n.GetReadBaseUrlCandidates();let r;for(const c of i){try{const i=yield h(m(c,e),t,o);if(c.replace(/\/+$/,"")===n.BASE_URL.replace(/\/+$/,""))return i;if(i.ok)return n.NODE_CACHE_URL=c,i;r=new Error(`Cache server ${c} returned status ${i.status}`)}catch(e){r=e}n.isNearestCache=!1}throw r instanceof Error?r:new Error("All cache servers failed")}))}class w{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var I=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const N={};function A(e){return N[e]||(N[e]=[]),N[e]}function k(e,t){const n=A(e);if(t&&"number"==typeof t.id){const e=n.findIndex((e=>e&&e.id===t.id));if(e>=0)return void(n[e]=t)}n.push(t)}function S(e,t,n){return I(this,void 0,void 0,(function*(){return A(e).filter((e=>e&&e[t]===n))}))}function x(e){return I(this,void 0,void 0,(function*(){return A(e).slice()}))}function _(e,t){const n=A(e),o=n.findIndex((e=>e&&e.id===t));o>=0&&n.splice(o,1)}function R(e){return I(this,void 0,void 0,(function*(){return A(e).slice()}))}class E{}E.isTypeLoaded=!1,E.isCharacterLoaded=!1,E.isDataLoaded=!1,E.isLocalDataLoaded=!1,E.isLocalCharacterLoaded=!1,E.isLocalTypeLoaded=!1,E.isConnectionLoaded=!1,E.isConnectionTypeLoaded=!1,E.isLocalConnectionLoaded=!1;class B{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var U=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class L{static waitForDataToLoad(){return U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isCharacterLoaded)return e("done");setTimeout(L.checkFlag,1e3,e)}static addNodeToTree(e){return U(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return U(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new B(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}L.characterRoot=null;var P=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class G{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return P(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isDataLoaded)return e("done");setTimeout(G.checkFlag,1e3,e)}static addConceptToTree(e){var t=new B(e.id,e,null,null),n=new B(e.characterValue,e,null,null);L.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return P(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return P(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}G.root=null;class F{constructor(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=o,this.ghostId=e,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,this.securityId=l,this.securityUserId=d,this.accessId=u,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=y,this.x=0,this.y=0,this.type=null,this.isNew=p,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function b(){let e=D(new Date),t=D(new Date);return new F(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function D(e){const t=e.getMonth()+1,n=e.getDate(),o=e.getFullYear();let i=e.getHours();const r=e.getMinutes(),c=e.getSeconds(),s=i>=12?"PM":"AM";i%=12,i=i||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${o} ${i}:${a(r)}:${a(c)} ${s}`}var $=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class O{static addNodeToTree(e){return $(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new B(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return $(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isTypeLoaded)return e("done");setTimeout(O.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return $(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)if(o.variants[e].value.userId==t){var i=!1;for(let t=0;t<n.length;t++)n[t].id==o.variants[e].value.id&&(i=!0);i||n.push(o.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return $(this,void 0,void 0,(function*(){let n=b();var o=this.getNodeFromTree(t);if(o){o.value.characterValue==e&&(n=o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.characterValue==e&&(n=o.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}O.typeRoot=null;var V=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class M{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(e=Date.now()){this.NPC=this.NPC.filter((t=>{const n=this.NPCMeta.get(t);return n&&n.expiresAt>e}))}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){var t;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(e)||this.NPC.push(e);const o=this.NPCMeta.get(e),i=(null!==(t=null==o?void 0:o.attempts)&&void 0!==t?t:0)+1;this.NPCMeta.set(e,{attempts:i,expiresAt:n+i*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(e){const t=Date.now();this.RemoveExpiredNpc(t);const n=this.NPCMeta.get(e);return!!(n&&n.expiresAt>t)}static AddConceptToStorage(e){e.id>0&&k("concept",e)}static AddConcept(e){e.id>0&&(k("concept",e),G.addConceptToTree(e),O.addConceptToTree(e),L.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(G.addConceptToTree(e),O.addConceptToTree(e),L.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);G.removeNodeFromTree(e.id),_("concept",e.id)}static GetConcept(e){return V(this,void 0,void 0,(function*(){var t=b(),n=yield G.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return V(this,void 0,void 0,(function*(){var t=b(),n=L.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return V(this,void 0,void 0,(function*(){var t=b(),n=L.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return V(this,void 0,void 0,(function*(){return b(),yield O.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return V(this,void 0,void 0,(function*(){var n=b(),o=yield L.getCharacterAndCategoryFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return V(this,void 0,void 0,(function*(){let n=[];return n=yield O.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return L.characterRoot}getName(){return this.name}}M.conceptsArray=[],M.NPC=[],M.NPCMeta=new Map,M.NPC_BACKOFF_SECONDS=30,M.conceptDictionary=[];var H=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function j(){return H(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield x("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];M.AddConceptToMemory(n)}(new Date).getTime()}))}function W(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var J=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function z(){return J(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:t}}))}function q(){return J(this,arguments,void 0,(function*(e="application/json",t="",n="application/json"){if(""!==t)return{"Content-Type":e,Authorization:"Bearer "+t,Accept:n};if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class K{constructor(e,t,o,i){this.url=n.BASE_URL,this.message=e,this.ok=t,this.status=o,this.data=i}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function Q(e){if(!e.ok){const t=e instanceof l,n=t?e.body||`HTTP error ${e.status}`:e.statusText||`HTTP error ${e.status}`;let o=new K(n,!1,e.status,"");throw o.setUrl(t?e.headers.url||"":e.url),o}}function Y(e){if(!e.ok){const t=e.body||`HTTP error ${e.status}`;let n=new K(t,!1,e.status,e.body);throw n.setUrl(e.headers.url||""),n}}var X=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Z(e,t){return X(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",e),o.append("user_id",t.toString());var i=yield z("application/x-www-form-urlencoded");const c=yield h(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++)M.AddConcept(e[r])}console.log("GetAllConceptsByType error",c.status),Q(c)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class ee{constructor(e=0,t,n,o,i,r,c,s,a,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=b(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=D(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class te{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class oe{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new te(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return ne(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isConnectionLoaded)return e("done");setTimeout(oe.checkFlag,1e3,e)}static removeNodeFromTree(e){return ne(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return ne(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}oe.connectionroot=null;var ie=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class re{static addNodeToTree(e){return ie(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return ie(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isConnectionTypeLoaded)return e("done");setTimeout(re.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new te(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return ie(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return ie(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}re.connectionTypeRoot=null;var ce=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class se{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){k("connection",e)}static AddConnection(e){e.isTemp||(k("connection",e),oe.addConnectionToTree(e),re.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(oe.addConnectionToTree(e),re.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(_("connection",e.id),oe.removeNodeFromTree(e.id),re.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return oe.connectionroot}static GetConnectionTypeTree(){return re.connectionTypeRoot}static GetConnection(e){return ce(this,void 0,void 0,(function*(){var t=new ee(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield oe.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return ce(this,void 0,void 0,(function*(){var t=[],n=yield re.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;if(o){let e=o;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}se.connectionArray=[],se.connectionDictionary=[];var ae=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function le(e){return ae(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield M.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{const e=JSON.stringify(n);var o=yield z();const i=yield T("/api/get_concept_bulk",{method:"POST",headers:o,body:e});if(console.log("[DEBUG] GetConceptBulk response:",{status:i.status,ok:i.ok}),i.ok){let e=yield i.json();if(e.length>0)for(let n=0;n<e.length;n++){let o=e[n];t.push(o),M.AddConcept(o)}}else console.log("Get Concept Bulk error",i.status),Q(i);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var de=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ue(){return de(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield le(t)}}))}var he=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function fe(){return he(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield se.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function ye(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||se.RemoveConnection(t[n]))}var pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ve(){return pe(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var o=yield fe(e),i=yield function(){return pe(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=yield z();const r=yield h(n.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});if(r.ok){const e=yield r.json();for(var i=0;i<e.length;i++)se.AddConnection(e[i]),t.push(e[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),Q(r);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return ye(t=i,o),yield ue(t),t}))}var ge=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Ce=new Map;function me(e){return ge(this,void 0,void 0,(function*(){let t=b();if(Ce.has(e))return Ce.get(e)||t;const o=(()=>ge(this,void 0,void 0,(function*(){try{var o=yield M.GetConcept(e);let r=M.GetNpc(e);if(0!=o.id||r)return o;{var i=yield z("application/x-www-form-urlencoded");const o=n.GetConceptUrl();console.log("[DEBUG] GetConcept request:",{url:o,method:"POST",headers:i,conceptId:e});const r=yield h(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${e}`});return console.log("[DEBUG] GetConcept response:",{status:r.status,ok:r.ok,conceptId:e}),r.ok?(t=yield r.json(),t.id>0?M.AddConcept(t):M.AddNpc(e)):(console.log("Get the concept error",r.status,e),Q(r)),t}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message,e):console.log("Get the concept unexpected error: ",t,e),t}finally{Ce.delete(e)}})))();return Ce.set(e,o),o}))}var Te=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function we(e){return Te(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield se.GetConnectionsOfCompositionLocal(e)).length)t=yield Ie(e);else{var n=yield Ie(e);ye(n,t),t=n}return t}))}function Ie(e){return Te(this,void 0,void 0,(function*(){var t=[];try{var o=yield z("application/x-www-form-urlencoded");const r=yield h(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${e}`});if(!r.ok)throw Q(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)se.AddConnection(c[i]),t.push(c[i]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var Ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ae(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function ke(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Le(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function Se(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function xe(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=i,l.id=e,l}))}function _e(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=i,l.id=e,l.created_at=s.entryTimeStamp,l}))}function Re(e,t){return Ne(this,void 0,void 0,(function*(){for(var n,o,i={},r=[],c=0;c<t.length;c++)r.includes(t[c].ofTheConceptId)||r.push(t[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,t,r);i[null!==(o=null===(n=null==s?void 0:s.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=i,l.id=e,l}))}function Ee(e,t){return Ne(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r={},c=yield M.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield me(e));var s=yield Ue(e,t,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=r,a.id=e,a}))}function Be(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=i,l.id=e,l}))}function Ue(e,t,n){return Ne(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield M.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield me(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield M.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield M.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield me(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield M.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ue(f,t,n,o);s[p]=e}}else{const e=yield Ue(f,t,n,o);a[p]=e,s=a}}return s}))}function Le(e,t,n){return Ne(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield M.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield me(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield M.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e),s.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield M.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield me(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield M.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Le(f,t,n);s[p]=e}}else{const e=yield Le(f,t,n);a[p]=e,s=a}}return s}))}var Pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ge(e){return Pe(this,void 0,void 0,(function*(){let t=b();try{var o=yield z("application/x-www-form-urlencoded");const i=yield h(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${e}`});return i.ok?(t=yield i.json(),t.id>0&&M.AddConcept(t)):(console.log("Error in Getting concept by character value Error",i.status),Q(i)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var Fe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function be(e){return Fe(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Ge(e),t=yield M.GetConceptByCharacter(e)),t}))}var De=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function $e(e,t){return De(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield be(e),r=[];if(i){yield Z(e,t);for(var c=yield M.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ve(a),l=s;l<s+n;l++)if(c[l]){var d=yield Se(c[l].id);r.push(d)}}return r}))}function Oe(e,t){return De(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield be(e),r=[];if(i){yield Z(e,t);for(var c=yield M.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ve(a),l=s;l<s+n;l++)if(c[l]){var d=yield xe(c[l].id);r.push(d)}}return r}))}var Ve=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Me=new Map;function He(e,t){return Ve(this,void 0,void 0,(function*(){let o=b();if(Me.has(e+t))return Me.get(e+t)||o;const i=(()=>Ve(this,void 0,void 0,(function*(){try{var i=yield z("application/x-www-form-urlencoded");const r=yield h(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${e}&category_id=${t}`});if(r.ok){let e=yield r.json();o=e,M.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),Q(r);return o}catch(o){throw o instanceof Error?console.log(" This is the concept by category and character direct api error message: ",o.message,e,t,n.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",o,e,t,n.GetConceptByCharacterAndCategoryDirectUrl()),o}finally{Me.delete(e+t)}})))();return Me.set(e+t,i),i}))}var je=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function We(e){return je(this,void 0,void 0,(function*(){let t=b();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=W(e);if(o.length>1){let n=1,i=yield We(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return je(this,void 0,void 0,(function*(){let n=yield M.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield He(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return je(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacterAndTypeLocal(e,49);return 0==t.id&&(t=yield Ge(e)),t}))}(e):o[0]==e&&(t=yield function(e){return je(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Ge(e)),t}))}(e));return t}))}var Je=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const ze=new Map,qe=new Map;function Ke(e,t){return Je(this,void 0,void 0,(function*(){let t=b();if(qe.has(e))return qe.get(e);if(ze.has(e))return ze.get(e)||t;const o=(()=>Je(this,void 0,void 0,(function*(){try{if(t=yield We(e),0==t.id||4==t.typeId){var o=yield z("application/x-www-form-urlencoded");const i=yield h(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${e}`});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();t=r,t.id>0&&M.AddConcept(t)}return t.id>0&&qe.set(e,t),t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{ze.delete(e)}})))();return ze.set(e,o),o}))}var Qe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};let Ye=!1,Xe=[];const Ze=()=>{Xe.length>0&&!Ye&&Xe.shift()()};function et(e){return Qe(this,void 0,void 0,(function*(){return new Promise(((t,o)=>{Xe.push((()=>Qe(this,void 0,void 0,(function*(){try{if(Ye)return;if(Ye=!0,!e&&at.connectionIds.length>10)return Ye=!1,Ze(),t();const o=e?`${n.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(e)}).toString()}`:n.GetReservedConnectionIdUrl();var i=yield z("application/x-www-form-urlencoded");const c=yield h(o,{method:"GET",headers:i});if(!c.ok)throw Q(c),new Error(`Error! status: ${c.status}`);const s=yield c.json();for(var r=0;r<s.length;r++)at.AddId(s[r]);t()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),o(e)}finally{Ye=!1,Ze()}})))),Ze()}))}))}var tt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};let nt=!1,ot=[];const it=()=>{ot.length>0&&!nt&&ot.shift()()};function rt(){return tt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{ot.push((()=>tt(this,void 0,void 0,(function*(){try{if(nt)return;if(nt=!0,st.ids.length>10)return nt=!1,it(),e();var o=yield z("application/x-www-form-urlencoded");const t=yield h(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!t.ok)throw Q(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)st.AddId(r[i]);e()}catch(e){t(e)}finally{nt=!1,it()}})))),it()}))}))}var ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class st{static getId(){return ct(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield rt()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((e=>console.error("Reserved ID refill failed:",e))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield rt()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.ids.includes(e)&&this.ids.push(e)}}st.ids=[],st.pendingFetch=null;class at{static getId(){return ct(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.connectionIds.includes(e)&&this.connectionIds.push(e)}static warmUp(e){return ct(this,void 0,void 0,(function*(){const t=e-this.connectionIds.length;t<=0||(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et(t)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}at.connectionIds=[],at.pendingFetch=null;function lt(e){return{id:e.id,userId:e.userId,characterValue:e.characterValue,typeId:e.typeId,categoryId:e.categoryId,accessId:e.accessId,referentId:e.referentId,sessionInformationId:e.sessionInformationId}}function dt(e){return t=this,o=void 0,r=function*(){let t=b();try{var o=yield z();const i=function(e){return Array.isArray(e)?e.map((e=>lt(e))):lt(e)}(e),r=yield f(n.CreateTheConceptUrl(),o,i);if(!r.ok)throw Y(r),new Error(`Error! status: ${r.status}`);return t=yield r.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((i=void 0)||(i=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,o||[])).next())}));var t,o,i,r}function ut(e){return t=this,o=void 0,r=function*(){let t=new ee(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield z();const i=function(e){return e.map((e=>function(e){return{id:e.id,ofTheConceptId:e.ofTheConceptId,toTheConceptId:e.toTheConceptId,ofTheConceptUserId:e.ofTheConceptUserId,toTheConceptUserId:e.toTheConceptUserId,typeId:e.typeId,userId:e.userId,orderId:e.orderId,accessId:e.accessId,sessionInformationId:e.sessionInformationId}}(e)))}(e),r=yield f(n.CreateTheConnectionUrl(),o,i);if(!r.ok)throw console.log("Create the connection error message: ",r),Y(r),new Error(`Error! status: ${r.status}`);return t=yield r.json(),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((i=void 0)||(i=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,o||[])).next())}));var t,o,i,r}var ht=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ft(e){return e?`[SyncData:${e}]`:"[SyncData]"}function yt(e,t){console.log(`${ft(t)} ${e}`)}function pt(e,t,n,o,i){o<100&&n!==o||n!==o&&1!==n&&n%100!=0||console.log(`${ft(i)} ${e} ${t}: ${n}/${o} done, ${o-n} remaining`)}class vt{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(e){return ht(this,void 0,void 0,(function*(){try{let t=[],n=[];if(e&&this.transactionCollections.some((t=>t.id==e))){const o=this.transactionCollections.find((t=>t.id==e));if(this.transactionCollections=this.transactionCollections.filter((t=>t.id==e||new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;t=o.data.concepts.slice(),n=o.data.connections.slice(),yt(`starting online sync with ${t.length} concepts and ${n.length} connections`,e),t.length>0&&(yt(`sending ${t.length} concepts to backend`,e),yield dt(t),pt("synced","concepts",t.length,t.length,e)),n.length>0&&(yt(`sending ${n.length} connections to backend`,e),yield ut(n),pt("synced","connections",n.length,n.length,e)),this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e)),yt("online sync complete",e)}else{const e=this.conceptsSyncArray.length,o=this.connectionSyncArray.length;yt(`starting online sync with ${e} queued concepts and ${o} queued connections`);for(let t=0;t<this.conceptsSyncArray.length;t++)M.AddConcept(this.conceptsSyncArray[t]),pt("prepared local cache for","concepts",t+1,e);for(let e=0;e<this.connectionSyncArray.length;e++)se.AddConnection(this.connectionSyncArray[e]),pt("prepared local cache for","connections",e+1,o);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),yt(`sending ${t.length} concepts to backend`),yield dt(t),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.some((t=>t.id===e.id)))),pt("synced","concepts",t.length,t.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),yt(`sending ${n.length} connections to backend`),yield ut(n),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!n.some((t=>t.id===e.id)))),pt("synced","connections",n.length,n.length)),yt(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return ht(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections.push({id:e,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(e){console.log("error in initializeTransaction",e)}}))}static markTransactionActions(e,t){return ht(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==e?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(t))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.concepts.some((t=>t.id==e.id||t.ghostId==e.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!t.connections.some((t=>t.id==e.id||t.ghostId==e.id))))}catch(e){console.log("error in markTransactionActions",e)}}))}static rollbackTransaction(e,t){return ht(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e))}catch(e){console.log("LocalSyncData, roll",e)}}))}static syncDataLocalDb(){return ht(this,void 0,void 0,(function*(){if(yt(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const e=this.conceptsSyncArray.length;for(let t=0;t<this.conceptsSyncArray.length;t++)k("localconcept",this.conceptsSyncArray[t]),pt("stored locally","concepts",t+1,e);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const e=this.connectionSyncArray.length;for(let t=0;t<this.connectionSyncArray.length;t++)k("localconnection",this.connectionSyncArray[t]),pt("stored locally","connections",t+1,e);this.connectionSyncArray=[]}return yt("local sync complete"),"done"}))}}function gt(e,t){const n=Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${t} must be a positive finite number. Received ${JSON.stringify(e)}.`);return n}vt.conceptsSyncArray=[],vt.connectionSyncArray=[],vt.transactionCollections=[];var Ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function mt(e,t,n,o,i,r,c){return Ct(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s=1,a=4,l=999,d={concepts:[],connections:[]}){const u=function(e,t){const n=gt(e,"ofTheConceptId"),o=gt(t,"toTheConceptId");if(n===o)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:o}}(e,n);e=u.ofTheConceptId,n=u.toTheConceptId;let h=t,f=t,y=t;999!=l&&(y=l);let p=t,v=t,g=yield at.getId(),C=new ee(g,e,n,t,o,y,i,f,s,h,0,p,a,v,r,c);return C.toUpdate=!0,C.isTemp=!1,vt.AddConnection(C),d.connections.push(C),C}))}function Tt(e,t,n){return Ct(this,arguments,void 0,(function*(e,t,n,o={concepts:[],connections:[]}){let i=yield Ke(n),r=e.userId;return yield mt(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,r,o)}))}var wt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const It=new Map;function Nt(e,t){return wt(this,void 0,void 0,(function*(){let o=yield M.GetConceptByCharacterAndTypeLocal(e,t),i=e+t;if(It.has(i))return It.get(i)||o;const r=(()=>wt(this,void 0,void 0,(function*(){try{if(null==o||0==o.id){var r={character_value:`${e}`,type_id:t},c=JSON.stringify(r),s=yield z();const i=yield h(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:s,body:c});if(i.ok){let e=yield i.json();o=e,M.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),Q(i)}return o}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{It.delete(i)}})))();return It.set(i,r),r}))}function At(e){return wt(this,void 0,void 0,(function*(){let t=[],o=JSON.stringify(e);var i=yield z();const r=yield h(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let e=yield r.json();t=yield le(e)}else console.log("This is the concept by type and character error",r.status),Q(r);return t}))}var kt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function St(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return kt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield st.getId();let v=new Date,g=new Date;var C=new F(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!0,v,g);return C.isTemp=!1,vt.AddConcept(C),y.concepts.push(C),C}))}function xt(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return kt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield st.getId();let v=new Date,g=new Date;var C=new F(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!1,v,g);return M.AddConcept(C),C.updateRecursion=!0,vt.AddConcept(C),y.concepts.push(C),C}))}var _t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Rt(e,t){return _t(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0,s={concepts:[],connections:[]}){let a,l=r,d=o=n?o:999,u=o,h=i,f=o,y=e.startsWith("the_")?e:"the_"+e,p=b();return n?(p=yield Ke(e),a=yield St(t,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,s)):(p=yield Ke(y),a=yield Nt(t,p.id),0==a.id&&0==a.userId&&(a=yield xt(t,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,s))),a.type=p,a}))}var Et=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Bt(e){return Et(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var s=null!=i?i:999,a=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=b();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=p=yield Rt(o,"",!0,s,a,l),h=p.id,d=p.id,yield Bt(e[o],p.id,p.userId,h,i,r,c)}else{var f=null!=t?t:999,y=null!=n?n:999;h=d,u=p=yield Rt(o,"",!0,s,a,l),yield mt(f,y,p.id,p.userId,h,l,p.userId),yield Bt(e[o],p.id,p.userId,h,i,r,c)}else{f=null!=t?t:999,y=null!=n?n:10267,h=d;var p=yield Rt(o,e[o].toString(),!1,s,a,l);yield mt(f,y,p.id,p.userId,h,l,p.userId)}return u}))}var Ut=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Lt(e,t,o){return Ut(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("ofTheConceptId",`${t}`),s.append("userId",`${o}`),s.append("inpage",`${i}`),s.append("page",`${r}`);var a=yield z("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Pt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Gt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Ft=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},bt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Dt(e){return bt(this,void 0,void 0,(function*(){var t=yield se.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var o=yield function(e){return Ft(this,void 0,void 0,(function*(){var t=yield se.GetConnection(e);try{if(0!=t.id)return t;{var o=yield z("application/x-www-form-urlencoded");const i=yield h(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${e}`});return i.ok?(t=yield i.json(),se.AddConnection(t)):(console.log("Get Connection Error",i.status),Q(i)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=o}return t}))}var $t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ot(e){return $t(this,arguments,void 0,(function*(e,t=""){let o=!1;var i=yield Dt(e);return o=yield function(e){return Gt(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield yield q("",t),r=yield{Authorization:i.Authorization,Accept:"application/json"};const c=new URLSearchParams;c.append("id",e.toString()),c.append("apiKey","nodeserver");const s=yield h(n.DeleteTheConnectionUrl(),{method:"POST",headers:r,body:c,redirect:"follow"});s.ok?o=(yield s.json()).success:(console.log("Delete connection error status: ",s.status),Q(s))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return o}))}(e,t),_("connection",e),oe.removeNodeFromTree(e),re.removeTypeConcept(i.typeId,e),o}))}function Vt(e){return $t(this,void 0,void 0,(function*(){let t=yield function(e){return Pt(this,void 0,void 0,(function*(){let t=!1;try{let o=yield q();const i=yield h(n.DeleteTheConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});i.ok?t=(yield i.json()).success:(console.log("Delete connection Bulk Api error status: ",i.status),Q(i))}catch(e){e instanceof Error?console.log("Delete connection Bulk Api error message: ",e.message):console.log("Delete connection Bulk Api unexpected error: ",e)}return t}))}(e);if(t)for(let t=0;t<e.length;t++){let n=e[t];n>0&&oe.removeNodeFromTree(n)}return t}))}var Mt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ht(e){return Mt(this,arguments,void 0,(function*(e,t=999){var n=b();if(e<0)return ri(yield zo(t,e));if(null!=(n=yield M.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield me(e)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var o=yield M.GetConcept(n.typeId);if(0!=o.id)n.type=o;else{var i=yield me(n.typeId);0!=i.id&&(n.type=i)}}return n}))}var jt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Wt=999,Jt=4,zt=999,qt=999,Kt=1e3;function Qt(e){const t=`${null!=e?e:""}`.trim();if(0===t.length)throw new Error("Cannot create a typed connection without a linker name.");return t}function Yt(e,t){return jt(this,void 0,void 0,(function*(){var n,o,i;if(null==e||null==e.id||0===e.id)throw new Error(`Cannot create a typed connection: ${t} must be a persisted concept.`);const r=e.type;if(null===(n=null==r?void 0:r.characterValue)||void 0===n?void 0:n.trim())return r.characterValue.trim();const c=(yield Ht(e.id,e.userId)).type;if(null===(o=null==c?void 0:c.characterValue)||void 0===o?void 0:o.trim())return e.type=c,c.characterValue.trim();if(null!=e.typeId&&0!==e.typeId){const t=yield Ht(e.typeId,e.typeUserId);if(0!==t.id&&(null===(i=t.characterValue)||void 0===i?void 0:i.trim()))return e.type=t,t.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${t} concept ${e.id} has no resolvable type.`)}))}function Xt(e){return jt(this,void 0,void 0,(function*(){return yield Rt("connection",e,!1,Wt,Wt,zt)}))}function Zt(e,t,n){return jt(this,void 0,void 0,(function*(){return yield mt(e.id,e.userId,t.id,t.userId,n.id,zt,qt,Kt,Jt)}))}function en(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){const r=Qt(n),c=e.userId;if(o){const n=yield function(e,t){return jt(this,void 0,void 0,(function*(){return`${yield Yt(e,"toTheConcept")}_s_${t}_by`}))}(t,r);i&&(yield nn(`${r}_by`,t,c));const o=yield Xt(n);yield Zt(t,e,o)}const s=yield function(e,t){return jt(this,void 0,void 0,(function*(){return`${yield Yt(e,"ofTheConcept")}_s_${t}_s`}))}(e,r);i&&(yield nn(`${r}_s`,e,c));const a=yield Xt(s);return yield Zt(e,t,a)}))}function tn(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){return yield en(e,t,n,o,i)}))}function nn(e,t){return jt(this,arguments,void 0,(function*(e,t,n=null){for(var o=t,i=null!=n?n:t.userId,r=999,c=Qt(e)+"_count",s=(yield Yt(t,"concept"))+"_s_"+c,a=yield Rt("connection",s,!1,i,4,r),l=yield Lt(a.id,t.id,i,10,1),d=[],u=b(),h=0;h<l.length;h++){let e=yield Ht(l[h].toTheConceptId);d.push(e)}if(d.length<1)u=yield Rt("count","1",!1,i,4,r);else{var f=d[0];let e=Number(f.characterValue),t=Number.isFinite(e)?e+1:1;u=yield Rt("count",t.toString(),!1,i,4,r);for(let e=0;e<l.length;e++)yield Ot(l[e].id)}yield mt(o.id,o.userId,u.id,u.userId,a.id,r,qt,Kt,4,i)}))}function on(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){return yield en(e,t,n,o,i)}))}var rn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function cn(e){return encodeURIComponent(String(e))}function sn(e,t){return rn(this,arguments,void 0,(function*(e,t,o=("number"==typeof e?999:e.userId),i=("number"==typeof e?4:e.accessId),r=999){const c="number"==typeof e?e:e.id,s="number"==typeof e?o:e.userId,a=yield z("application/x-www-form-urlencoded"),l=[`character_value=${cn(t)}`,`type_id=${cn(c)}`,`type_user_id=${cn(s)}`,`access_id=${cn(i)}`,`session_information_id=${cn(r)}`].join("&"),d=yield h(n.CreateTypeConceptUrl(),{method:"POST",headers:a,body:l});if(!d.ok)throw Q(d),new Error(`Error! status: ${d.status}`);const u=yield d.json();return"number"!=typeof e&&(u.type=e),M.AddConcept(u),u}))}var an=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ln(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ht(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield Nt(s,16);if(a.id>0){for(var l=yield Lt(a.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield ve(d),u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield Ht(e),n=yield _e(t.id);r.push(n)}}return r}))}function dn(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ht(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield Nt(s,16);if(a.id>0){for(var l=yield Lt(a.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield Ht(e);r.push(t)}}return r}))}class un{constructor(e,t,n,o,i,r,c,s=!1,a,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function hn(){let e=new Date,t=new Date;return new un(0,0,0,0,0,"0","0",!1,e,t,0)}class fn{constructor(e,t,n,o,i,r,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class yn{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new fn(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}yn.characterData=[];class pn{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Cn(e,t,o,i,r){return gn(this,void 0,void 0,(function*(){return new fn(t,e,o,t,i,t,r,t,"",!1),yield function(){return vn(this,void 0,void 0,(function*(){var e;try{if(0==(e=yn.GetCharacter(e.data)).id){var t=yield z();const i=yield h(n.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new fn(r.userId,e.data,0,0,4,4,999,999,"",!1);return o.id=r.id,yn.AddCharacter(o),r}return new pn(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Tn(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return mn(this,void 0,void 0,(function*(){var y=yield Nt(e,i),p=y;return 0==p.id&&(p=y=yield St(e,t,n,o,i,r,c,s,a,l,d,u,h,f)),p}))}var wn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},In=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Nn(e,t,n,o){return In(this,arguments,void 0,(function*(e,t,n,o,i={concepts:[],connections:[]}){var r=yield be(e);if(r&&(0==r.id||0==r.userId)){var c=W(e);if(c.length>0)if(c[0]==e){var s=yield function(e,t,n,o,i,r){return wn(this,void 0,void 0,(function*(){var i,c=t,s=t;i=t;var a,l=t,d=t,u=t;if(1==e.length){var h=e.charCodeAt(0);yield Cn(e,t,n,o,r),a=yield Tn(e,t,4,c,49,l,h,u,n,s,o,i,r,d)}else{var f=yield Cn(e,t,n,o,r);f.isNew,a=yield Tn(e,t,4,c,51,l,f.id,f.userId,n,s,o,i,r,d)}return a}))}(e,o,999,999,0,t);r=s}else{var a=yield Nn(c[0],t,n,o,i),l=yield Nn(c[1],t,n,o,i);l&&(r=yield xt(e,o,a.id,o,l.id,o,999,o,999,o,999,o,t,o,i))}}return r}))}var An=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function kn(e){return An(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield z("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield h(`${n.GetAllLinkerConnectionOfConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(s.ok){const e=yield s.json();for(var i=0;i<e.length;i++){var r=e[i];t.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),Q(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var Sn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function xn(e){return Sn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield z("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield h(`${n.GetAllLinkerConnectionToConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(s.ok){const e=yield s.json();for(var i=0;i<e.length;i++){var r=e[i];t.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),Q(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var _n=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Rn(e){return _n(this,void 0,void 0,(function*(){for(var t=yield kn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ht(o);e.type=i}return t}))}function En(e){return _n(this,void 0,void 0,(function*(){for(var t=yield xn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ht(o);e.type=i}return t}))}var Bn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Un=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n},Ln=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Pn(e){return Ln(this,arguments,void 0,(function*(e,t=""){var o=yield Ht(e);yield G.removeNodeFromTree(e);var i=o.typeId,r=o.characterValue;yield O.removeTypeConcept(i,e),yield L.removeNodeByCharacter(r,e),_("concept",e);let c=yield function(e){return Bn(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield yield yield q("application/x-www-form-urlencoded",t);const r=new FormData;r.append("id",e.toString()),r.append("apiKey","nodeserver");const{"Content-Type":c}=i,s=Un(i,["Content-Type"]),a=yield h(n.DeleteConceptUrl(),{method:"POST",headers:s,body:r});if(!a.ok)throw Q(a),new Error(`Error! status: ${a.status}`);o=(yield a.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return o}))}(e,t);return c}))}var Gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Fn(e,t){return Gn(this,void 0,void 0,(function*(){try{const o=new Headers;o.append("Authorization","Bearer "+t);const i=new FormData;i.append("id",e.toString());const r=yield h(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw Q(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var bn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Dn(e,t,n,o){return bn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,s=n,a=n,l=e.startsWith("the_"),d=b();return r=l?e:"the_"+e,d=yield Ke(r),yield Tn(t,n,4,n,d.id,d.userId,0,999,999,c,o,a,i,s)}))}class $n{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var On=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Vn(){return On(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield se.GetConnection(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=yield z();const e=yield T("/api/get_connection_bulk",{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let o=n[e];t.push(o),se.AddConnection(o)}yield ue(t)}}else console.log("Get Connection Bulk error",e.status),Q(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var Mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Hn(){return Mn(this,arguments,void 0,(function*(e=[]){yield ve(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Se(e[o]);t.push(n)}return t}))}function jn(){return Mn(this,arguments,void 0,(function*(e=[]){yield ve(e);var t=[];for(let o=0;o<e.length;o++){var n=yield xe(e[o]);t.push(n)}return t}))}function Wn(){return Mn(this,arguments,void 0,(function*(e=[],t=[]){yield Vn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||se.RemoveConnection(t[n])}(t,yield fe(e));var n=[];for(let t=0;t<e.length;t++){var o=yield xe(e[t]);n.push(o)}return n}))}function Jn(){return Mn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],o={};for(let o=0;o<(null==e?void 0:e.length);o++){let i=yield se.GetConnection(e[o]);0==i.id?t.push(e[o]):n.push(i)}for(let n=0;n<t.length;n++)o[e[n]]=!1;let i=[],r=yield Vn(t);n=[...n,...r];for(let e=0;e<n.length;e++)i.push(n[e].ofTheConceptId),i.push(n[e].toTheConceptId),i.push(n[e].typeId);return yield le(i),n}))}function zn(){return Mn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],o=[];for(let e=0;e<t.length;e++){let i=yield se.GetConnection(t[e]);0==i.id?n.push(t[e]):o.push(i)}let i=yield Vn(n);for(let e=0;e<i.length;e++)o.push(i[e]);let r={},c=[];for(var s=0;s<o.length;s++)c.includes(o[s].ofTheConceptId)||c.push(o[s].ofTheConceptId);for(let t=0;t<e.length;t++){let n=yield Ee(e[t],o,c);r[e[t]]=n}return r}))}var qn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Kn(){return qn(this,arguments,void 0,(function*(e=0,t=[],o="",i=[]){var r=[];try{var c=new $n;c.composition=e,c.listLinkers=t,c.textSearch=o,c.fullLinkers=i;var s=JSON.stringify(c),a=yield z();const u=yield h(n.RecursiveSearchUrl(),{method:"POST",headers:a,body:s});if(u.ok){const e=yield u.json();var l=e.compositionIds,d=e.internalConnections;e.externalConnections,r=yield Wn(l,d)}else console.log("recursive search error ",u.status),Q(u);return r}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var Qn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Yn(e,t){return Qn(this,void 0,void 0,(function*(){try{var i={email:e,password:t},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(i);const s=yield h(n.LoginUrl(),{method:"POST",headers:r,body:c});if(s.ok){const e=yield s.json();return o.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",s.status),Q(s)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var Xn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Zn(e){return Xn(this,void 0,void 0,(function*(){const t=yield function(){return Xn(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield h(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:Q(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(n.SignupUrl(),e);return t}))}var eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function to(e){return eo(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let o={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=n.LoginUrl();try{const e=yield h(r,{method:"POST",headers:i,body:t,redirect:"follow"}),n=yield e.json();return e.ok?o={message:"success",status:!0,statusCode:200,data:null==n?void 0:n.data}:Q(e),o}catch(e){throw console.log("Sign in api error",e),e}}))}function no(e,t){return-1===e.indexOf(t)&&e.push(t),e}function oo(e=[],t){var n,o;let i=[],r=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(o=e[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&r!=c||i.push(e[n])}return i}function io(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function ro(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function co(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class so{constructor(e,t,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(lo.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ao=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class lo{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new so(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return ao(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return ao(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}lo.root=null;var uo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ho(e,t,n,o){return uo(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let s={};const a=[];if(0==e)return"";let l=fo(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Ht(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=fo(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Ht(e),l.type=t)}if(!o.includes(e))return null==l?void 0:l.characterValue;if(i.includes(e))return"";i.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const d=t[l].toTheConceptId;if(o.includes(e)){let e=fo(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield Ht(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield M.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Ht(t),e.type=n)}const l="the_",u=(null!==(c=null===(r=null==e?void 0:e.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const e=yield ho(d,t,n,o,i);s[u]=e}}else{const e=yield ho(d,t,n,o,i);a[u]=e,s=a}}}return s}))}function fo(e,t){let n=b();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class yo{constructor(){this.id=0,this.mainConcept=b(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,o=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield ho(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}));var e,t,n,o}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),n.MQTT_CONNECTION&&n.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const o={};o[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function vo(e){return po(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null,s=null){const a=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=b();null==s&&(s=new yo);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield Rt(o,"",!0,a,l,d);if(null==t&&null==n){let t=u;h=f,t=f.id,u=f.id,s.concepts.push(f),s.id=f.id,yield vo(e[o],f.id,f.userId,t,i,r,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,y=u;h=f,s.concepts.push(f);const p=yield mt(a,l,f.id,f.userId,y,d,f.userId);s.connections.push(p),yield vo(e[o],f.id,f.userId,y,i,r,c,s)}null!=e[o]&&null!=e[o]&&s.subcompositions.push(f.id)}else{const i=null!=t?t:999,r=null!=n?n:999,c=u,h=yield Rt(o,e[o],!1,a,l,d);s.concepts.push(h);const f=yield mt(i,r,h.id,h.userId,c,d,h.userId);s.connections.push(f)}return h}))}var go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Co(e){return go(this,void 0,void 0,(function*(){try{const t=yield z(),o=yield h(n.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),Q(o),new Error(`GetConnectionsBetweenApi error: ${o.status}`);return yield o.json()}catch(e){throw e instanceof Error?console.log("GetConnectionsBetweenApi error message: ",e.message):console.log("GetConnectionsBetweenApi unexpected error: ",e),e}}))}function mo(e){var t,n,o,i,r,c,s;return{ofTheConceptId:null!==(t=e.ofTheConceptId)&&void 0!==t?t:0,toTheConceptId:null!==(n=e.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(o=e.typeId)&&void 0!==o?o:0,type:null!==(i=e.type)&&void 0!==i?i:"",oldType:null!==(r=e.oldType)&&void 0!==r?r:"",reverse:null!==(c=e.reverse)&&void 0!==c&&c,isComposition:null!==(s=e.isComposition)&&void 0!==s&&s,connectionIds:[]}}var To=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class wo{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return To(this,void 0,void 0,(function*(){yield vt.initializeTransaction(this.transactionId)}))}markAction(){return To(this,void 0,void 0,(function*(){yield vt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return To(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield vt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return To(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield vt.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Vt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return To(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return To(this,arguments,void 0,(function*(e,t=[]){try{if(!this.success)throw Error("Query Transaction Expired");const n=[...t];if(e.length>0){const t=e.map(mo),o=yield Co(t);for(const e of o)n.push(...e.connectionIds)}return this.pendingConnectionDeletions.push(...n),n}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return To(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield Rt(e,t,n,o,i,r,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTypeConcept(e,t){return To(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),o=("number"==typeof e?4:e.accessId),i=999){try{if(!this.success)throw Error("Query Transaction Expired");return yield sn(e,t,n,o,i)}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return To(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Tt(e,t,n,this.actions);return yield this.markAction(),o}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheTypeConcept(e,t,n,o){return To(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield Nn(e,t,n,o,this.actions);return yield this.markAction(),i}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,o,i,r,c){return To(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield mt(e,t,n,o,i,r,c,s,a,l,this.actions);return yield this.markAction(),d}catch(e){throw console.log(e),this.success=!1,e}}))}}var Io=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function No(e){return Io(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=b(),s=b();const a=[];let l=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(l<0){let e=yield Ht(l,t);if(!(e.id>0))return null;l=e.id}const h=new wo;yield h.initialize();try{i=yield we(l);const f=[],y=new yo,p=[];y.id=l,y.isUpdating();let v=[];for(let e=0;e<i.length;e++)no(p,i[e].ofTheConceptId),no(f,i[e].ofTheConceptId),no(f,i[e].toTheConceptId),v.push(i[e].ofTheConceptId);y.subcompositions=p,y.connections=i;for(let e=0;e<f.length;e++){const t=yield Ht(f[e]);l==f[e]&&(c=t),d==f[e]&&(s=t),r.push(t)}const g=e.patchObject;for(const e in g){let i=b();const l=g[e];let d=c;if(s.id>0&&(d=s),Array.isArray(l)||"object"==typeof l){i=yield h.MakeTheInstanceConcept(e,"",!0,c.userId,4,999),y.subcompositions.push(i.id);const t=oo(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=io(y.connections,t[e].id);u=u.concat(n),a.push(t[e])}yield vo(g[e],i.id,i.userId,c.id,c.userId,4,999,y)}else{i=yield h.MakeTheInstanceConcept(e,l,!1,t,o,n);const c=oo(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=io(y.connections,c[e].id);u=u.concat(t),a.push(c[e])}}const f=yield h.CreateTheConnectionGeneral(d.id,d.userId,i.id,i.userId,c.id,n,t);r.push(i),y.connections.push(f)}for(let e=0;e<u.length;e++)co(y.connections,u[e]);u.length>0&&(yield h.DeleteConnectionsBetweenBulk([],u.map((e=>e.id))));for(let e=0;e<a.length;e++)ro(r,a[e]);return y.concepts=y.concepts.concat(r),y.mainConcept=c,y.id=c.id,yield h.commitTransaction(),yield y.updateCache(),lo.addCompositionToTree(y),y.GetDataCache()}catch(e){throw yield h.rollbackTransaction(),e}}))}var Ao=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ko(e,t,o,i){return Ao(this,arguments,void 0,(function*(e,t,o,i,r=10,c=1){var s=yield q("application/x-www-form-urlencoded",i),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",o),a.append("inpage",r.toString()),a.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield h(l,{method:"GET",headers:s});if(e.ok)return yield e.json();Q(e)}catch(e){throw e}}))}var So=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function xo(e){return So(this,arguments,void 0,(function*(e,t=""){var o=yield q("application/json",t);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();Q(e)}catch(e){throw e}}))}var _o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ro(e){return _o(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},s={};const a=[];let l=yield M.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield me(e));let d=[];d=t.length>0?Eo(e,t):yield we(e),i=d;for(let e=0;e<i.length;e++)a.includes(i[e].ofTheConceptId)||(a.push(i[e].ofTheConceptId),r.push(i[e].ofTheConceptId)),r.includes(i[e].toTheConceptId)||r.push(i[e].toTheConceptId);return s=yield Ue(e,i,a,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s,0==l.id?"":c}))}function Eo(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function Bo(e){return _o(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let s;const a={},l=[];let d=yield M.GetConcept(e);0==d.id&&null!=e&&null!=e&&(d=yield me(e));let u=[];u=t.length>0?Eo(e,t):yield we(e),r=u;for(let e=0;e<r.length;e++)l.includes(r[e].ofTheConceptId)||(l.push(r[e].ofTheConceptId),c.push(r[e].ofTheConceptId)),c.includes(r[e].toTheConceptId)||c.push(r[e].toTheConceptId);return s=yield Ue(e,r,l),a[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s,i.created_at=d.entryTimeStamp,i.data=a,i.id=e,0==d.id?"":i}))}function Uo(e,t){return _o(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Vn(t);for(let t=0;t<e.length;t++){const i=yield Bo(e[t],n);i&&o.push(i)}return o}))}var Lo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Po(e){return Lo(this,void 0,void 0,(function*(){try{var t=yield z();const o=JSON.stringify(e),i=yield h(n.CreateSessionId(),{method:"POST",headers:t,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),Q(i),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Fo(e,t){return Go(this,void 0,void 0,(function*(){try{var o=yield z("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",e.toString()),i.append("url",t);const r=yield h(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),Q(r),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var bo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Do(e,t,o){return bo(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("toTheConceptId",`${t}`),s.append("userId",`${o}`),s.append("inpage",`${i}`),s.append("page",`${r}`);var a=yield z("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var $o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Oo(e,t){return $o(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ht(e),s=yield We(t);if(s.id>0){let e=[],t=[];if(i){t=yield Do(s.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield ve(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield Ht(n),i=yield _e(o.id);r.push(i)}}else{t=yield Lt(s.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield ve(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield Ht(n),i=yield _e(o.id);r.push(i)}}}return r}))}function Vo(e,t){return $o(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ht(e),s=yield We(t),a=[],l=[];if(s.id>0){if(i){a=yield Do(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield Lt(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}r=yield le(l)}return r}))}class Mo{constructor(e,t,n){this.value=new Map,this.connectionValue=new Map,this.key=e,t.id>0&&this.value.set(t.ghostId,t),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Ho{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=hn(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=o,this.ghostId=e,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=D(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var jo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Wo{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return jo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isDataLoaded)return e("done");setTimeout(Wo.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){const o=this.compositeKey(t,n,e.applicationId),i=this.nodeMap.get(o);i?e.id>0&&i.value.set(e.ghostId,e):this.nodeMap.set(o,new Mo(o,e,new Ho(0,0,0,0,0,0)))}static addConnectionToTree(e,t,n=999){const o=this.compositeKey(t,n,e.applicationId),i=this.nodeMap.get(o);i?e.id>0&&i.connectionValue.set(e.ghostId,e):this.nodeMap.set(o,new Mo(o,hn(),e))}static getNodeFromTree(e,t){return jo(this,arguments,void 0,(function*(e,t,n=999){var o;const i=this.compositeKey(e,t,n);return null!==(o=this.nodeMap.get(i))&&void 0!==o?o:null}))}static removeNodeFromTree(e){return jo(this,arguments,void 0,(function*(e,t=999,n=999){const o=this.compositeKey(e,t,n);this.nodeMap.delete(o)}))}static countNumberOfNodes(){return this.nodeMap.size}}Wo.nodeMap=new Map;var Jo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function zo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999,o=999){var i;let r=yield Wo.getNodeFromTree(e,n,o),c=hn();return r&&(c=null!==(i=r.value.get(t))&&void 0!==i?i:c),c}))}function qo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999,o=999){var i;let r=yield Wo.getNodeFromTree(e,n,o),c=new Ho(0,0,0,0,0,0);return r&&(c=null!==(i=r.connectionValue.get(t))&&void 0!==i?i:c),c}))}function Ko(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999){Wo.addConceptToTree(e,t,n)}))}function Qo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999){Wo.addConnectionToTree(e,t,n)}))}var Yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Xo(e){return Yo(this,arguments,void 0,(function*(e,t=""){var o=yield q("application/json",t);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();Q(e)}catch(e){throw e}}))}var Zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ei(e){return Zo(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield Xo(e,t),i=e[0].composition;const r=o;let c=r.compositionIds,s=r.internalConnections,a=r.linkers,l=r.reverse;return n=yield zn(c,s),yield ti(a,n,i,l)}))}function ti(e,t,n){return Zo(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield Vn(e);for(let e=0;e<r.length;e++){let n=!1;if(o.includes(r[e].id)&&(n=!0),1==n){if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].toTheConceptId],o=yield Ht(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(t[r[e].ofTheConceptId])}catch(e){}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield Ht(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(t[r[e].toTheConceptId])}catch(e){}}}return i=t[n],i}))}var ni=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},oi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ii(e){return oi(this,void 0,void 0,(function*(){var t;let o=yield function(e){return ni(this,void 0,void 0,(function*(){let t=[];try{var o=yield z();const i=yield h(n.ViewInternalDataUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});if(i.ok){let e=yield i.json(),n={};for(let o=0;o<e.length;o++){let i=e[o].concepts;t=e[o].connections;let r=e[o].id;yield le(i),n[r]=t}return n}return console.log("View Internal Data error",i.status),Q(i),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),i=[];for(let n=0;n<e.length;n++){let r=e[n],c=o[r];if(r&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield Ue(r,c,e);t.data=n,t.id=r,i.push(t)}else{let e={};e.id=r;let n=yield Ht(r),o={};n.type&&(o[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=o,i.push(e))}}return i}))}function ri(e){const t=b();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}var ci=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},si=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ai(e){return si(this,arguments,void 0,(function*(e,t=""){var o=yield function(e){return ci(this,arguments,void 0,(function*(e,t=""){var o,i,r,c,s,a,l=yield q("application/json",t);const d=new URLSearchParams({composition:String(null!==(o=e.composition)&&void 0!==o?o:""),search:String(null!==(i=e.search)&&void 0!==i?i:""),internalComposition:String(null!==(r=e.internalComposition)&&void 0!==r?r:""),type:String(null!==(c=e.type)&&void 0!==c?c:""),inpage:String(null!==(s=e.inpage)&&void 0!==s?s:""),page:String(null!==(a=e.page)&&void 0!==a?a:"")}),u=`${n.SearchInternalWithAuthenticatedCcsUrl()}?${d.toString()}`;try{const e=yield h(u,{method:"GET",headers:l});if(e.ok)return yield e.json();Q(e)}catch(e){throw e}}))}(e,t);return yield ii(o)}))}var li=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function di(e,t){return li(this,void 0,void 0,(function*(){let n=!0,o=yield kn(e),i=yield At(t),r=[];for(let e=0;e<o.length;e++)for(let t=0;t<i.length;t++)o[e].typeId==i[t].id&&r.push(o[e].id);for(let e=0;e<r.length;e++){let t=yield Ot(r[e]);n=n&&t}return n}))}function ui(e,t){return li(this,void 0,void 0,(function*(){let n=yield kn(e),o=yield At(t),i=[];for(let e=0;e<n.length;e++)for(let t=0;t<o.length;t++)n[e].typeId==o[t].id&&i.push(n[e].id);return i}))}class hi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class fi{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class yi{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class pi{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}function vi(e){if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()));if("string"!=typeof e)return[];const t=e.trim();if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()))}catch(e){}return t.split(",").map((e=>e.trim())).filter(Boolean)}class gi{constructor(e){var t;this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],this.accessToken="",this.enableAi=!0,this.enableAccessControl=!1,e&&(Object.assign(this,e),this.cacheServers=vi(null!==(t=e.cacheServers)&&void 0!==t?t:e.cache_servers),this.cacheServerUrl=e.cacheServerUrl||e.cacheServer||this.cacheServerUrl)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(e,t=!1){var n,o;return null!==(o=null===(n=this.flags)||void 0===n?void 0:n[e])&&void 0!==o?o:t}getParameter(e,t=""){var n,o;return null!==(o=null===(n=this.parameters)||void 0===n?void 0:n[e])&&void 0!==o?o:t}setFlag(e,t){this.flags||(this.flags={}),this.flags[e]=t}setParameter(e,t){this.parameters||(this.parameters={}),this.parameters[e]=t}}var Ci=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class mi{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),(0!=e.id||e.isTemp)&&k("localconnection",e),this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return Ci(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isLocalConnectionLoaded)return e("done");setTimeout(mi.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return Ci(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}mi.connectionArray=[],mi.connectionDictionary=[];var Ti=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function wi(){return Ti(this,void 0,void 0,(function*(){yield function(){return Ti(this,void 0,void 0,(function*(){var e=yield x("connection");if(Array.isArray(e))for(var t=0;t<e.length;t++)se.AddConnectionToMemory(e[t])}))}()}))}function Ii(){return Ti(this,void 0,void 0,(function*(){yield function(){return Ti(this,void 0,void 0,(function*(){var e=yield R("localconnection");if(Array.isArray(e))for(var t=0;t<e.length;t++)mi.AddConnection(e[t])}))}()}))}class Ni{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Ai=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class ki{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new Ni(e.id,e,null,null);new Ni(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return Ai(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isLocalDataLoaded)return e("done");setTimeout(ki.checkFlag,1e3,e)}static getNodeFromTree(e){return Ai(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return Ai(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}ki.root=null;var Si=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class xi{static waitForDataToLoad(){return Si(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isLocalCharacterLoaded)return e("done");setTimeout(xi.checkFlag,1e3,e)}static addNodeToTree(e){return Si(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new Ni(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return Si(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}xi.LocalCharacterRoot=null;var _i=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Ri{static addNodeToTree(e){return _i(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new Ni(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return _i(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(E.isLocalTypeLoaded)return e("done");setTimeout(Ri.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return _i(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}Ri.LocalTypeRoot=null;var Ei=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Bi{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(k("localconcept",e),ki.addConceptToTree(e),xi.addConceptToTree(e),Ri.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(ki.addConceptToTree(e),xi.addConceptToTree(e),Ri.addConceptToTree(e))}static GetConcept(e){return Ei(this,void 0,void 0,(function*(){var t=hn(),n=yield ki.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return Ei(this,void 0,void 0,(function*(){var t=hn(),n=xi.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Ei(this,void 0,void 0,(function*(){var n=hn(),o=yield xi.getCharacterAndTypeFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return Ei(this,void 0,void 0,(function*(){let n=[];return n=yield Ri.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Bi.localconceptsArray=[];var Ui=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Li(){return Ui(this,void 0,void 0,(function*(){var e=yield R("localconcept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Bi.AddConceptToMemory(n)}}))}var Pi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Gi{}Gi.isUpdated=!1,Gi.isOnlineSync=!1;var Fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class bi{constructor(){this.accessCache=new Map,this.accessIndex=new Map,this.entityIndex=new Map,this.setCounter=0}generateKey(e,t,n){return`${e}:${t.toLowerCase()}:${null!=n?n:0}`}get(e,t,n){const o=this.generateKey(e,t,n),i=this.accessCache.get(o);return void 0===i?null:Date.now()>i.expiresAt?(this.accessCache.delete(o),null):i.value}set(e,t,n,o){const i=this.generateKey(e,t,n);this.accessCache.set(i,{value:o,expiresAt:Date.now()+3e5}),this.accessIndex.has(e)||this.accessIndex.set(e,new Set),this.accessIndex.get(e).add(i);const r=null!=n?n:0;this.entityIndex.has(r)||this.entityIndex.set(r,new Set),this.entityIndex.get(r).add(i),this.setCounter++,this.setCounter>=100&&(this.setCounter=0,this.sweepExpired())}remove(e,t,n){const o=this.generateKey(e,t,n);this.accessCache.delete(o);const i=this.accessIndex.get(e);i&&i.delete(o);const r=null!=n?n:0,c=this.entityIndex.get(r);c&&c.delete(o)}clear(){this.accessCache.clear(),this.accessIndex.clear(),this.entityIndex.clear(),this.setCounter=0}sweepExpired(){const e=Date.now();for(const[t,n]of this.accessCache)if(e>n.expiresAt){this.accessCache.delete(t);const e=t.split(":"),n=parseInt(e[0]),o=parseInt(e[2]),i=this.accessIndex.get(n);i&&(i.delete(t),0===i.size&&this.accessIndex.delete(n));const r=this.entityIndex.get(o);r&&(r.delete(t),0===r.size&&this.entityIndex.delete(o))}for(const[t,n]of bi.superAdminCache)e>n.expiresAt&&bi.superAdminCache.delete(t)}getPermissionsByAccessAndEntity(e,t){const n=new Map,o=this.accessIndex.get(e),i=Date.now();if(o){const e=null!=t?t:0;for(const t of o){const o=this.accessCache.get(t);if(o&&i<=o.expiresAt){const i=t.split(":");parseInt(i[2])===e&&n.set(i[1],o.value)}}}return n}getPermissionsByAccess(e){const t=new Map,n=this.accessIndex.get(e),o=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&o<=n.expiresAt){const o=e.split(":"),i=parseInt(o[2]),r=o[1];t.set(`${i}:${r}`,n.value)}}return t}getPermissionsByEntity(e){const t=new Map,n=this.entityIndex.get(e),o=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&o<=n.expiresAt){const o=e.split(":"),i=parseInt(o[0]),r=o[1];t.set(`${i}:${r}`,n.value)}}return t}getSuperAdmin(e){const t=bi.superAdminCache.get(e);return void 0===t?null:Date.now()>t.expiresAt?(bi.superAdminCache.delete(e),null):t.value}setSuperAdmin(e,t){bi.superAdminCache.set(e,{value:t,expiresAt:Date.now()+6e5})}clearSuperAdminCache(){bi.superAdminCache.clear()}}bi.superAdminCache=new Map;var Di,$i=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Oi{constructor(e){if(this.baseUrl=e||process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("Access Control base URL is not configured")}getAsync(e){return $i(this,void 0,void 0,(function*(){const t=yield fetch(`${this.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`GET '${e}' failed with status ${t.status}`);const n=yield t.json();if(null==n)throw new Error(`The response for GET '${e}' returned null.`);return n}))}postAsync(e,t){return $i(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST '${e}' failed with status ${n.status}`);const o=yield n.json();if(null==o)throw new Error(`The response for POST '${e}' returned null.`);return o}))}deleteAsync(e,t){return $i(this,void 0,void 0,(function*(){const n={method:"DELETE",headers:{"Content-Type":"application/json"}};null!=t&&(n.body=JSON.stringify(t));const o=yield fetch(`${this.baseUrl}/${e}`,n);if(!o.ok)throw new Error(`DELETE '${e}' failed with status ${o.status}`);const i=yield o.json();if(null==i)throw new Error(`The response for DELETE '${e}' returned null.`);return i}))}assignAccessAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/assign",e)}))}checkAccessAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/check",e)}))}revokeAccessAsync(e){return $i(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke",e)}))}assignAccessBulkAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/assign/bulk",e)}))}revokeAccessBulkAsync(e){return $i(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke/bulk",e)}))}checkAccessBulkAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/check/bulk",e)}))}getAccessByIdAsync(e){return $i(this,void 0,void 0,(function*(){return this.getAsync(`access/${e}`)}))}setAccessInheritanceAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance",e)}))}getAccessInheritanceStatusAsync(e){return $i(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/status?accessId=${e}&connectionTypeId=${t}`)}))}assignSuperAdminAccessAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin",e)}))}revokeSuperAdminAccessAsync(e){return $i(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin",e)}))}checkSuperAdminStatusAsync(e){return $i(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin?accessId=${e}`)}))}setParentAccessInheritanceAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent",e)}))}removeParentAccessInheritanceAsync(e,t){return $i(this,void 0,void 0,(function*(){let n=`access/inheritance/parent?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.deleteAsync(n)}))}hasParentAccessInheritanceAsync(e,t){return $i(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/status?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.getAsync(n)}))}getParentAccessIdAsync(e){return $i(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent?accessId=${e}`)}))}setParentAccessInheritanceByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept",e)}))}setParentAccessInheritanceBulkByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept/bulk",e)}))}removeParentAccessInheritanceByConceptAsync(e,t){return $i(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.deleteAsync(n)}))}removeParentAccessInheritanceBulkByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.deleteAsync("access/inheritance/parent/concept/bulk",e)}))}hasParentAccessInheritanceByConceptAsync(e,t){return $i(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept/status?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.getAsync(n)}))}getParentAccessIdByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent/concept?childConceptId=${e}`)}))}assignSuperAdminByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin/concept",e)}))}revokeSuperAdminByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin/concept",e)}))}checkSuperAdminByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin/concept?conceptId=${e}`)}))}setAccessInheritanceByConceptAsync(e){return $i(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/concept",e)}))}getAccessInheritanceStatusByConceptAsync(e){return $i(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/concept/status?conceptId=${e}&connectionTypeId=${t}`)}))}}!function(e){e[e.None=0]="None",e[e.Read=1]="Read",e[e.Write=2]="Write",e[e.Execute=4]="Execute",e[e.Delete=8]="Delete"}(Di||(Di={}));var Vi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Mi{static initialize(){console.log("AccessControlService initialized with access control disabled by default.")}static setEnabled(e){this.isAccessControlEnabled=e}static getEnabled(){return this.isAccessControlEnabled}static setBaseUrl(e){this.apiClient=new Oi(e)}static checkAccess(e,t,n){return Vi(this,void 0,void 0,(function*(){var o;if(t===Di.None)throw new Error("Permission is required");return null!==(o=(yield this.checkAccessBulk([e],t,n)).get(e))&&void 0!==o&&o}))}static checkAccessBulk(e,t,o){return Vi(this,void 0,void 0,(function*(){var i,r,c,s,a,l;if(t===Di.None)throw new Error("Permission is required");const d=this.permissionSetToString(t),u=new Map;if(!e||0===e.length)return u;if(!this.isAccessControlEnabled){for(const t of e)u.set(t,!0);return u}if(null!=o&&o>0)try{if(yield this.isSuperAdmin(o)){for(const t of e)u.set(t,!0);return u}}catch(e){}const f=[],y=new Set,p=new Map;let v=null;if(null!=o&&o>0)try{v=yield Ht(o)}catch(e){}let g=0;try{const e=yield function(){return e=this,t=void 0,i=function*(){let e=b();try{var t=yield z("application/x-www-form-urlencoded");const o=yield h(n.GetConceptByCharacterAndCategoryUrl(),{method:"POST",headers:t,body:"character_value=the_parent_access_inheritance"});return o.ok?(e=yield o.json(),M.AddConcept(e)):(console.log("This is the concept by category and character error",o.status),Q(o)),e}catch(e){throw e instanceof Error?console.log(" This is the concept by category and character error message: ",e.message):console.log(" This is the concept by category and character unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(n,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((i=i.apply(e,t||[])).next())}));var e,t,o,i}();e&&e.id&&(g=e.id)}catch(e){}const C=yield le(e),m=new Map;for(const e of C)m.set(e.id,e);const T=new Map;for(const t of e){const e=null!==(i=m.get(t))&&void 0!==i?i:yield Ht(t);if(!e||0===e.id){u.set(t,!1);continue}const n=null!==(r=e.accessId)&&void 0!==r?r:0,o=null!==(c=e.typeId)&&void 0!==c?c:0;if(v&&v.userId&&v.userId===e.userId){u.set(t,!0);continue}if(n<1e4){u.set(t,!0);continue}let a=0;if(o>0){let e=T.get(o);if(!e)try{e=yield Ht(o),T.set(o,e)}catch(e){}e&&(a=null!==(s=e.accessId)&&void 0!==s?s:0)}f.push({conceptId:t,accessId:n,typeAccessId:a}),n>0&&(y.add(n),p.set(n,t)),a>0&&y.add(a)}if(0===f.length)return u;const w=yield this.resolveBulkInheritanceGraph(y,g,p),I=[],N=new Set;for(const e of w.values())for(const t of e)N.has(t)||(N.add(t),I.push(t));const A=yield this.resolveSubjects(o),k=yield this.resolveBulkDecisions(I,d,A);for(const e of f){const t=null!==(a=w.get(e.accessId))&&void 0!==a?a:[e.accessId],n=e.typeAccessId>0?null!==(l=w.get(e.typeAccessId))&&void 0!==l?l:[e.typeAccessId]:[],o=this.hasAnyGrant(t,n,A,k);u.set(e.conceptId,o)}return u}))}static getConceptIdsWithPermission(e,t,n){return Vi(this,void 0,void 0,(function*(){if(e===Di.None)throw new Error("Permission is required");if(!t||0===t.length)return[];if(!this.isAccessControlEnabled)return t;const o=yield this.checkAccessBulk(t,e,n);return t.filter((e=>!0===o.get(e)))}))}static resolveBulkInheritanceGraph(e,t,n){return Vi(this,void 0,void 0,(function*(){var o;const i=new Map,r=new Set;let c=new Set(e),s=0;for(;c.size>0;){if(s>=10){console.warn("[AccessControl] BFS depth limit (10) reached. Stopping inheritance traversal.");break}s++;const e=new Set;for(const e of c)r.add(e);const a=Array.from(c);if(t>0)for(const t of a)try{const n=yield ui(t,["the_parent_access_inheritance"]);if(n&&n.length>0){const o=yield Vn(n);for(const n of o){const o=n.toTheConceptId;o&&o>0&&!r.has(o)&&(i.has(t)||i.set(t,[]),i.get(t).push(o),e.add(o))}}}catch(e){}for(const t of a)try{const n=yield this.apiClient.getParentAccessIdAsync(t);if(!0===(null==n?void 0:n.status)&&void 0!==n.data&&null!==n.data){const o=this.parseIntData(n);null!==o&&o>0&&!r.has(o)&&(i.has(t)||i.set(t,[]),i.get(t).push(o),e.add(o))}}catch(e){}for(const c of a)try{const s=yield this.apiClient.getAccessInheritanceStatusAsync(c);if(!this.parseBoolData(s))continue;const a=n.get(c);if(!a||0===a)continue;const l=yield kn(a);if(!l||0===l.length)continue;for(const s of l){if(s.ofTheConceptId!==a)continue;if(t>0&&s.typeId!==t)continue;const l=s.toTheConceptId;if(l&&0!==l)try{const t=yield Ht(l),s=null!==(o=null==t?void 0:t.accessId)&&void 0!==o?o:0;s>0&&!r.has(s)&&(i.has(c)||i.set(c,[]),i.get(c).push(s),n.set(s,l),e.add(s))}catch(e){}}}catch(e){}for(const t of r)e.delete(t);c=e}const a=new Map;for(const t of e){const e=[t],n=new Set([t]),o=[t];for(;o.length>0&&e.length<100;){const t=o.shift(),r=i.get(t);if(r)for(const t of r)n.has(t)||(n.add(t),e.push(t),o.push(t))}a.set(t,e)}return a}))}static resolveBulkDecisions(e,t,n){return Vi(this,void 0,void 0,(function*(){var o;const i=new Map,r=new Map;for(let o=0;o<n.length;o++){const c=n[o];for(const n of e){const e=this.cacheService.get(n,t,c),s=`${n}:${null!=c?c:0}`;null!==e?i.set(s,e):(r.has(o)||r.set(o,[]),r.get(o).push(n))}}for(const[e,c]of r){if(0===c.length)continue;const r=n[e];try{const e={accessIds:c,permission:t,entityId:r},n=yield this.apiClient.checkAccessBulkAsync(e);if(!0===(null==n?void 0:n.status)&&n.data&&Array.isArray(n.data)){const e=new Map;for(const t of n.data)e.set(t.accessId,t.hasAccess);for(const n of c){const c=null!==(o=e.get(n))&&void 0!==o&&o;this.cacheService.set(n,t,r,c),i.set(`${n}:${null!=r?r:0}`,c)}}else for(const e of c)this.cacheService.set(e,t,r,!1),i.set(`${e}:${null!=r?r:0}`,!1)}catch(e){for(const e of c)i.set(`${e}:${null!=r?r:0}`,!1)}}return i}))}static resolveSubjects(e){return Vi(this,void 0,void 0,(function*(){const t=[null];if(null!=e&&e>0){t.push(e);try{const n=yield ui(e,["the_entity_s_group"]);if(n&&n.length>0){const e=yield Vn(n);for(const n of e)n.toTheConceptId&&n.toTheConceptId>0&&t.push(n.toTheConceptId)}}catch(e){}}return t}))}static hasAnyGrant(e,t,n,o){for(const t of e)for(const e of n){const n=`${t}:${null!=e?e:0}`;if(!0===o.get(n))return!0}for(const e of t)for(const t of n){const n=`${e}:${null!=t?t:0}`;if(!0===o.get(n))return!0}return!1}static assignAccess(e,t,n){return Vi(this,void 0,void 0,(function*(){var o;if(t===Di.None)throw new Error("Permission is required");try{const i=null!==(o=(yield Ht(e)).accessId)&&void 0!==o?o:0,r=this.permissionSetToString(t),c=yield this.apiClient.assignAccessAsync({accessId:i,permission:r,entityId:n});if(!0===(null==c?void 0:c.status)&&c.data){const e=c.data;return this.cacheService.set(e.accessId,e.permission,e.entityId,e.hasAccess),!0}return!1}catch(o){throw new Error(`Error assigning access for conceptId ${e}, permission '${t}', entityId ${n}: ${o}`)}}))}static assignAccessBulk(e){return Vi(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{const n=yield this.apiClient.assignAccessBulkAsync(e);if(!0!==(null==n?void 0:n.status))throw new Error((null==n?void 0:n.message)||"Failed to assign bulk access");const o=[];for(const n of e.targets)for(const i of n.permissions){const r=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(r,i,n.entityId,!0),o.push({accessId:r,permission:i,entityId:n.entityId,hasAccess:!0})}return o}catch(e){throw console.error("Failed to assign bulk access:",e),e}}))}static revokeAccess(e,t,n){return Vi(this,void 0,void 0,(function*(){var o;try{const i=null!==(o=(yield Ht(e)).accessId)&&void 0!==o?o:0,r=this.permissionSetToString(t);if(0===i)throw new Error(`Concept with ID ${e} does not have a valid accessId`);const c=yield this.apiClient.revokeAccessAsync({accessId:i,permission:r,entityId:n}),s=!0===(null==c?void 0:c.status);return this.cacheService.set(i,r,n,!s),s}catch(o){throw new Error(`Error revoking access for concept ${e}, permission '${t}', entityId ${n}: ${o}`)}}))}static revokeAccessBulk(e){return Vi(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{yield this.apiClient.revokeAccessBulkAsync(e);const n=[];for(const o of e.targets)for(const i of o.permissions){const r=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(r,i,o.entityId,!1),n.push({accessId:r,permission:i,entityId:o.entityId,hasAccess:!1})}return n}catch(e){throw console.error("Failed to revoke bulk access:",e),e}}))}static setAccessInheritance(e){return Vi(this,void 0,void 0,(function*(){var t;try{const n=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,connectionTypeId:999});return null!==(t=null==n?void 0:n.status)&&void 0!==t&&t}catch(t){throw new Error(`Error setting access inheritance for conceptId ${e}: ${t}`)}}))}static getAccessInheritanceStatus(e){return Vi(this,arguments,void 0,(function*(e,t=999){try{const n=yield this.apiClient.getAccessInheritanceStatusByConceptAsync(e,t);return this.parseBoolData(n)}catch(n){throw new Error(`Error getting access inheritance status for conceptId ${e}, connectionTypeId ${t}: ${n}`)}}))}static setAccessInheritanceStatus(e,t){return Vi(this,arguments,void 0,(function*(e,t,n=999){var o;try{const i=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,enable:t,connectionTypeId:n});return null!==(o=null==i?void 0:i.status)&&void 0!==o&&o}catch(t){throw new Error(`Error setting access inheritance status for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritance(e,t){return Vi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceByConceptAsync({parentConceptId:t,childConceptId:e});if(!0===(null==n?void 0:n.status)){const e=this.parseIntData(n);if(null!==e&&e>0)return e}return 0}catch(t){throw new Error(`Error setting parent access inheritance for conceptId ${e}: ${t}`)}}))}static removeParentAccessInheritance(e,t){return Vi(this,void 0,void 0,(function*(){var n;try{const o=yield this.apiClient.removeParentAccessInheritanceByConceptAsync(e,t);return null!==(n=null==o?void 0:o.message)&&void 0!==n?n:"Parent access inheritance removal failed"}catch(t){throw new Error(`Error removing parent access inheritance for conceptId ${e}: ${t}`)}}))}static hasParentAccessInheritance(e,t){return Vi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.hasParentAccessInheritanceByConceptAsync(e,t);return this.parseBoolData(n)}catch(t){throw new Error(`Error checking parent access inheritance for conceptId ${e}: ${t}`)}}))}static getParentAccessId(e){return Vi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.getParentAccessIdByConceptAsync(e);return this.parseIntData(t)}catch(t){throw new Error(`Error getting parent access ID for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritanceBulk(e,t){return Vi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceBulkByConceptAsync({parentConceptId:t,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error setting bulk parent access inheritance for parentConceptId ${t}: ${e}`)}}))}static removeParentAccessInheritanceBulk(e,t){return Vi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.removeParentAccessInheritanceBulkByConceptAsync({parentConceptId:null!=t?t:0,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error removing bulk parent access inheritance: ${e}`)}}))}static isSuperAdmin(e){return Vi(this,void 0,void 0,(function*(){try{if(0===e)return!1;const t=this.cacheService.getSuperAdmin(e);if(null!==t)return t;const n=yield this.apiClient.checkSuperAdminByConceptAsync(e);if(!0===(null==n?void 0:n.status)&&void 0!==n.data){const t=this.parseBoolData(n);return this.cacheService.setSuperAdmin(e,t),t}return!1}catch(t){throw new Error(`Error checking super admin status for entityId ${e}: ${t}`)}}))}static assignSuperAdmin(e){return Vi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.assignSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&void 0!==t.data?(this.cacheService.setSuperAdmin(e,!0),e):0}catch(t){throw new Error(`Failed to assign super admin for entityId ${e}: ${t}`)}}))}static revokeSuperAdmin(e){return Vi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.revokeSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&t.message?(this.cacheService.setSuperAdmin(e,!1),t.message):"Super admin access deletion failed"}catch(t){throw new Error(`Failed to revoke super admin for entityId ${e}: ${t}`)}}))}static parseBoolData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return!1;const t=e.data;if("boolean"==typeof t)return t;if("string"==typeof t)return"true"===t.toLowerCase();if("number"==typeof t)return 0!==t;if("object"==typeof t)for(const e of["enabled","Enabled","isEnabled","IsEnabled","status","Status","hasAccess","HasAccess"])if(e in t){const n=t[e];if("boolean"==typeof n)return n;if("string"==typeof n)return"true"===n.toLowerCase()}return!1}static parseIntData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return null;const t=e.data;if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?null:e}if("object"==typeof t)for(const e of["id","Id","accessId","AccessId","parentAccessId","ParentAccessId"])if(e in t){const n=t[e];if("number"==typeof n)return n;if("string"==typeof n){const e=parseInt(n,10);if(!isNaN(e))return e}}return null}static permissionSetToString(e){return function(e){const t=[];return e&Di.Read&&t.push("read"),e&Di.Write&&t.push("write"),e&Di.Execute&&t.push("execute"),e&Di.Delete&&t.push("delete"),t}(e)[0]||"read"}static clearCache(){this.cacheService.clear()}static clearSuperAdminCache(){this.cacheService.clearSuperAdminCache()}static updateAccessCache(e,t,n,o){this.cacheService.set(e,t,n,o)}static updateSuperAdminCache(e,t){this.cacheService.setSuperAdmin(e,t)}}Mi.cacheService=new bi,Mi.apiClient=new Oi,Mi.isAccessControlEnabled=!1,Mi.initialize();var Hi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const ji=1,Wi=2,Ji=3,zi=4,qi=5,Ki=6,Qi=7,Yi=8;class Xi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var Zi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function er(e){return Zi(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield me(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]||(t[e[n].conceptId]=[]),t[e[n].conceptId].push(e[n])}return t}))}function tr(e){const t=e.split("_");if(3===t.length){let e=new Xi;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function nr(e){return e.startsWith("the_")?e.slice(4):e}var or=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ir(e,t,n){if(e in t){const o=Array.isArray(t[e])?t[e]:[t[e]];for(const e of o)e&&(n[e.connectionType+"_count"]=e.count)}}var rr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},cr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function sr(e,t,n){return cr(this,void 0,void 0,(function*(){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ht(e[u].ofTheConceptId),y=yield Ht(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[s]={},t[e[u].toTheConceptId]=n);let a=yield Ht(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;a.characterValue,a.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ht(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}var ar=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function lr(e,t="DESC"){return"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var dr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};var ur=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function hr(e,t){return ur(this,void 0,void 0,(function*(){let o=e.outputFormat;e.outputFormat=Ki;let i,r=yield function(e){return Hi(this,arguments,void 0,(function*(e,t=""){var o=yield q("application/json",t);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();Q(e)}catch(e){!function(e,t=""){if(e.status){let n=new K(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new K(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,i)}}))}(e,t),c=r.conceptIds,s=(r.internalConnections,r.linkers),a=r.reverse,l=r.mainCompositionIds,d=r.countinfo,u=e.order,f=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let o=tr(e[n]);t.push(o)}return t}(d);return i=o==Wi?yield function(e,t,n,o,i){return dr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield er(i);c=lr(c,r);let a=[];a=yield function(e,t){return rr(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ht(e[u].ofTheConceptId),y=yield Ht(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Ht(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(s.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ht(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}(c,a,o),a=yield function(e,t){return rr(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ht(e[u].ofTheConceptId),y=yield Ht(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Ht(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=nr(o));let i={id:f.id,data:{[e]:t}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ht(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=e,r=nr(r),c=!0);let s={id:y.id,data:{[e]:t}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s))}catch(e){}}}return t}))}(c,a,o);let l=yield function(e,t,n,o){return rr(this,arguments,void 0,(function*(e,t,n,o,i=[],r){var c,s,a,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let o=!1,f=yield Ht(e[n].ofTheConceptId),y=yield Ht(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=f.id&&0!=y.id&&y.id in t){let o,i=yield Ht(e[n].typeId),a=null!==(s=null===(c=y.type)||void 0===c?void 0:c.characterValue)&&void 0!==s?s:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},t[e[n].toTheConceptId]=o),ir(y.id,r,o);try{if(t[e[n].ofTheConceptId]){let r={id:f.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(e){}}}else if(0!=f.id&&0!=y.id&&f.id in t){let o,i=yield Ht(e[n].typeId),c=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),ir(f.id,r,o);let p=!0,v=i.characterValue;""==v&&(v=y.characterValue,p=!0),""==v&&(v=null!==(u=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==y?void 0:y.type)||void 0===h||h.characterValue;let s=t[e[n].toTheConceptId];if(s){let a={id:y.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(s):Array.isArray(o[c][v])?o[c][i.characterValue].push(a):v.includes("_s_")?(o[c][v]=[],o[c][v].push(a)):o[c][v]=a,ir(y.id,r,a)}}catch(e){}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e];let i=yield Ht(n.id);n.data=t[o[e]],n.created_on=i.entryTimeStamp,f.push(n)}return f}))}(c,a,[],n,o,s);return l}))}(s,c,l,a,f,u):o==Ji?yield function(e,t,n,o,i){return dr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield er(i);c=lr(c,r);let a=[];a=yield sr(c,a,o),a=yield function(e,t){return or(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ht(e[u].ofTheConceptId),y=yield Ht(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Ht(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=nr(o));let i={id:f.id,[e]:t},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ht(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,s=!1;""==c&&(c=t,c=nr(c),s=!0);let a={};a[t]={id:y.id,data:r,created_on:e[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=s?a[t]:a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a[t]))}catch(e){}}}return t}))}(c,a,o);let l=yield function(e,t,n){return or(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,s,a,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,y=yield Ht(e[n].ofTheConceptId),p=yield Ht(e[n].toTheConceptId);if(o.includes(e[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in t){let o,i=yield Ht(e[n].typeId),s=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let r=t[e[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let c=i.characterValue+"_reverse";Array.isArray(o[s][c])?o[s][c].push(r):c.includes("_s_")?(o[s][c]=[],o[s][c].push(r)):o[s][c]=r}}catch(e){}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield Ht(e[n].typeId),c=null!==(a=null===(s=y.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),ir(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",s=t[e[n].toTheConceptId];if(s){let t={};t[r]={data:s[r],id:p.id,created_on:e[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(s[g]):o[c].push(s):Array.isArray(o[c][g])?o[c][g].push(t):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(t[r]):o[c][g].push(t)):o[c][g]=v?t[r]:t,ir(p.id,i,t)}}catch(e){}}}for(let e=0;e<n.length;e++){let o={};o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,a,n,o,s);return l}))}(s,c,l,a,f,u):o==Yi?yield function(e,t,n,o,i){return dr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield er(i);c=lr(c,r);let a={};a=yield function(e){return ar(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,s;for(const a of e){const e=n.includes(a.id),l=yield Ht(a.ofTheConceptId),d=yield Ht(a.toTheConceptId),u=yield Ht(a.typeId);if(0===l.id||0===d.id)continue;const h=e?d:l,f=e?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(s=u.characterValue)||void 0===s?void 0:s.includes("_s_");t[h.id]||(t[h.id]={}),t[h.id][y]||(t[h.id][y]={}),g&&(t[f.id]||(t[f.id]={}),t[f.id][p]=v)}return t}))}(c,a,o),a=yield function(e){return ar(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,s;for(const a of e){const e=n.includes(a.id),l=yield Ht(a.ofTheConceptId),d=yield Ht(a.toTheConceptId),u=yield Ht(a.typeId);if(0===l.id||0===d.id)continue;const h=e?d:l,f=e?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=u.characterValue)&&void 0!==s?s:"";let C=""===g?nr(p):g;const m=C.includes("_s_"),T=!isNaN(Number(C)),w={id:f.id,data:{[p]:v}};t[h.id]||(t[h.id]={}),y in t[h.id]&&"string"!=typeof t[h.id][y]||(t[h.id][y]=T?[]:{});try{if(m)continue;T?t[h.id][y].push(w):t[h.id][y][e?`${C}_reverse`:C]=w}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,o);let l=yield function(e,t,n){return ar(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,s;const a=[];for(const n of e){const e=o.includes(n.id),a=yield Ht(n.ofTheConceptId),l=yield Ht(n.toTheConceptId),d=yield Ht(n.typeId);if(0===a.id||0===l.id)continue;const u=e?l:a,h=e?a:l,f=u.id,y=h.id,p=null!==(c=null===(r=u.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",v=d.characterValue+"_reverse",g=d.characterValue||h.characterValue||(null===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const o=t[f][p],r=t[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};ir(f,i,t[f]);try{e?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(r):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],ir(y,i,c)}catch(e){console.error("Error processing connection:",e)}}}for(const e of n){const n=yield Ht(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,o,s);return l}))}(s,c,l,a,f,u):yield function(e,t,n,o){return dr(this,void 0,void 0,(function*(){let t=yield Jn(e);t=lr(t);let i=[];i=yield sr(t,i,o),i=yield function(e,t,n){return cr(this,void 0,void 0,(function*(){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ht(e[u].ofTheConceptId),y=yield Ht(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[u].toTheConceptId]=n);let a=yield Ht(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=nr(o));let i={[e]:t},l=o+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ht(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=e,r=nr(r),c=!0);let s={[e]:t};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?t:s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){}}}return t}))}(t,i,o);let r=yield function(){return cr(this,arguments,void 0,(function*(e=[],t=[],n=[],o,i=[]){var r,c,s,a,l,d;let u=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let o=!1;i.includes(e[n].id)&&(o=!0);let u=yield Ht(e[n].ofTheConceptId),h=yield Ht(e[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in t){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?o=t[e[n].toTheConceptId]:(o={},o[i]={},t[e[n].toTheConceptId]=o);let s=yield Ht(e[n].typeId);try{let r=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):s.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(e){}}}else if(0!=u.id&&0!=h.id&&u.id in t){let o,i=null!==(a=null===(s=u.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},t[e[n].ofTheConceptId]=o);let r=!1,c=(yield Ht(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(o[i])?r?o[i].push(s[c]):o[i].push(s):Array.isArray(o[i][c])?o[i][c].push(s):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(s[c]):o[i][c].push(s)):o[i][c]=r?s[c]:s)}catch(e){}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],u.push(o))}return u}))}(t,i,n,[],o);return r}))}(s,0,l,a),i}))}class fr{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=ji,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var yr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function pr(e,t){return yr(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield xn(e),i=yield Ke(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield kn(e);for(let e=0;e<n.length;e++)se.AddConnection(n[e]);let i=yield Ke(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function vr(e,t,n){return yr(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield pr(t,n,o):yield pr(e,n,o),o)for(let t=0;t<i.length;t++)i[t].ofTheConceptId==e&&r.push(i[t]);else for(let e=0;e<i.length;e++)i[e].toTheConceptId==t&&r.push(i[e]);return r}))}var gr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Cr(e=""){o.BearerAccessToken=e}function mr(){return gr(this,arguments,void 0,(function*(e="",t="",i="CCSApp",c){var s,a;const l=c||new gi;Mi.setBaseUrl(l.accessControlBaseUrl),Mi.setEnabled(l.enableAccessControl),n.BASE_URL=e,n.AI_URL=l.aiUrl,t&&(n.NODE_URL=t);const d=l.cacheServers.length>0?l.cacheServers:vi(null!==(a=null===(s=l.parameters)||void 0===s?void 0:s.cacheServers)&&void 0!==a?a:l.getParameter("cacheServers",""));n.setCacheServers(d);const u=l.cacheServerUrl||l.getParameter("cacheServerUrl","");if(u?n.setNodeCacheUrl(u):0===d.length&&n.setNodeCacheUrl(""),l.hasOAuthCredentials()){const e=l.applicationName||i;o.setOAuthCredentials(l.clientId,l.clientSecret,e);const t=yield r(l.clientId,l.clientSecret,e,!0);if(!t.success)throw new Error(`OAuth token request failed: ${t.error||"unknown error"}`)}else l.hasAccessToken()&&(o.BearerAccessToken=l.accessToken);E.isDataLoaded=!1,E.isCharacterLoaded=!1,E.isTypeLoaded=!1,E.isLocalDataLoaded=!1,E.isLocalTypeLoaded=!1,E.isLocalCharacterLoaded=!1,E.isConnectionLoaded=!1,E.isConnectionTypeLoaded=!1,E.isLocalConnectionLoaded=!1,yield function(){return Fi(this,void 0,void 0,(function*(){return yield A("settings")[0]||new w(!0),yield function(){return Pi(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([j().then((()=>{E.isDataLoaded=!0,E.isCharacterLoaded=!0,E.isTypeLoaded=!0})),Li().then((()=>{E.isLocalDataLoaded=!0,E.isLocalTypeLoaded=!0,E.isLocalCharacterLoaded=!0})),Ii().then((()=>{E.isLocalConnectionLoaded=!0})),wi().then((()=>{E.isConnectionLoaded=!0,E.isConnectionTypeLoaded=!0}))])}))}module.exports=t})();
|
|
1
|
+
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
+
(()=>{var e={144:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},181:e=>{"use strict";e.exports=require("buffer")},270:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},560:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>new r(e,n).compare(new r(t,n))},855:(e,t,n)=>{var r=n(6585);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var o=r(e);if(void 0===o)return;return Math.floor(n+o/1e3)}return"number"==typeof e?n+e:void 0}},909:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>{const o=new r(e,n),i=new r(t,n);return o.compare(i)||o.compareBuild(i)}},1045:(e,t,n)=>{"use strict";var r=n(181).Buffer,o=n(181).SlowBuffer;function i(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,o=0;o<e.length;o++)n|=e[o]^t[o];return 0===n}e.exports=i,i.install=function(){r.prototype.equal=o.prototype.equal=function(e){return i(this,e)}};var c=r.prototype.equal,s=o.prototype.equal;i.restore=function(){r.prototype.equal=c,o.prototype.equal=s}},1123:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},1261:(e,t,n)=>{const r=n(3908),o=n(8311),i=n(5580);e.exports=(e,t)=>{e=new o(e,t);let n=new r("0.0.0");if(e.test(n))return n;if(n=new r("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t<e.set.length;++t){const o=e.set[t];let c=null;o.forEach((e=>{const t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":c&&!i(t,c)||(c=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!c||n&&!i(n,c)||(n=c)}return n&&e.test(n)?n:null}},1691:(e,t,n)=>{const r=n(1741),o=n(3726),i=n(8980),c=n(7260),s=n(855),a=n(7019),l=n(4977),u=n(5747),{KeyObject:d,createSecretKey:h,createPublicKey:f}=n(6982),p=["RS256","RS384","RS512"],y=["ES256","ES384","ES512"],v=["RS256","RS384","RS512"],g=["HS256","HS384","HS512"];l&&(p.splice(p.length,0,"PS256","PS384","PS512"),v.splice(v.length,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,l){let m;if("function"!=typeof n||l||(l=n,n={}),n||(n={}),n=Object.assign({},n),m=l||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return m(new r("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return m(new r("nonce must be a non-empty string"));if(void 0!==n.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof n.allowInvalidAsymmetricKeyTypes)return m(new r("allowInvalidAsymmetricKeyTypes must be a boolean"));const C=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return m(new r("jwt must be provided"));if("string"!=typeof e)return m(new r("jwt must be a string"));const w=e.split(".");if(3!==w.length)return m(new r("jwt malformed"));let T;try{T=c(e,{complete:!0})}catch(e){return m(e)}if(!T)return m(new r("invalid token"));const I=T.header;let N;if("function"==typeof t){if(!l)return m(new r("verify must be called asynchronous if secret or public key is provided as a callback"));N=t}else N=function(e,n){return n(null,t)};return N(I,(function(t,c){if(t)return m(new r("error in secret or public key callback: "+t.message));const l=""!==w[2].trim();if(!l&&c)return m(new r("jwt signature is required"));if(l&&!c)return m(new r("secret or public key must be provided"));if(!l&&!n.algorithms)return m(new r('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=c&&!(c instanceof d))try{c=f(c)}catch(e){try{c=h("string"==typeof c?Buffer.from(c):c)}catch(e){return m(new r("secretOrPublicKey is not valid key material"))}}if(n.algorithms||("secret"===c.type?n.algorithms=g:["rsa","rsa-pss"].includes(c.asymmetricKeyType)?n.algorithms=v:"ec"===c.asymmetricKeyType?n.algorithms=y:n.algorithms=p),-1===n.algorithms.indexOf(T.header.alg))return m(new r("invalid algorithm"));if(I.alg.startsWith("HS")&&"secret"!==c.type)return m(new r(`secretOrPublicKey must be a symmetric key when using ${I.alg}`));if(/^(?:RS|PS|ES)/.test(I.alg)&&"public"!==c.type)return m(new r(`secretOrPublicKey must be an asymmetric key when using ${I.alg}`));if(!n.allowInvalidAsymmetricKeyTypes)try{a(I.alg,c)}catch(e){return m(e)}let N;try{N=u.verify(e,T.header.alg,c)}catch(e){return m(e)}if(!N)return m(new r("invalid signature"));const A=T.payload;if(void 0!==A.nbf&&!n.ignoreNotBefore){if("number"!=typeof A.nbf)return m(new r("invalid nbf value"));if(A.nbf>C+(n.clockTolerance||0))return m(new o("jwt not active",new Date(1e3*A.nbf)))}if(void 0!==A.exp&&!n.ignoreExpiration){if("number"!=typeof A.exp)return m(new r("invalid exp value"));if(C>=A.exp+(n.clockTolerance||0))return m(new i("jwt expired",new Date(1e3*A.exp)))}if(n.audience){const e=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(A.aud)?A.aud:[A.aud]).some((function(t){return e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))})))return m(new r("jwt audience invalid. expected: "+e.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&A.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(A.iss)))return m(new r("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&A.sub!==n.subject)return m(new r("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&A.jti!==n.jwtid)return m(new r("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&A.nonce!==n.nonce)return m(new r("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof A.iat)return m(new r("iat required when maxAge is specified"));const e=s(n.maxAge,A.iat);if(void 0===e)return m(new r('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(C>=e+(n.clockTolerance||0))return m(new i("maxAge exceeded",new Date(1e3*e)))}if(!0===n.complete){const e=T.signature;return m(null,{header:I,payload:A,signature:e})}return m(null,A)}))}},1729:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},1741:e=>{var t=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(t.prototype=Object.create(Error.prototype)).constructor=t,e.exports=t},1763:(e,t,n)=>{const r=n(560);e.exports=(e,t)=>r(e,t,!0)},1832:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,null,!0),o=r(t,null,!0),i=n.compare(o);if(0===i)return null;const c=i>0,s=c?n:o,a=c?o:n,l=!!s.prerelease.length;if(a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(0===a.compareMain(s))return a.minor&&!a.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==o.major?u+"major":n.minor!==o.minor?u+"minor":n.patch!==o.patch?u+"patch":"prerelease"}},1977:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=15.7.0")},2010:(e,t,n)=>{"use strict";var r=n(2861).Buffer,o=n(3527);function i(e){if(r.isBuffer(e))return e;if("string"==typeof e)return r.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function c(e,t,n){for(var r=0;t+r<n&&0===e[t+r];)++r;return e[t+r]>=128&&--r,r}e.exports={derToJose:function(e,t){e=i(e);var n=o(t),c=n+1,s=e.length,a=0;if(48!==e[a++])throw new Error('Could not find expected "seq"');var l=e[a++];if(129===l&&(l=e[a++]),s-a<l)throw new Error('"seq" specified length of "'+l+'", only "'+(s-a)+'" remaining');if(2!==e[a++])throw new Error('Could not find expected "int" for "r"');var u=e[a++];if(s-a-2<u)throw new Error('"r" specified length of "'+u+'", only "'+(s-a-2)+'" available');if(c<u)throw new Error('"r" specified length of "'+u+'", max of "'+c+'" is acceptable');var d=a;if(a+=u,2!==e[a++])throw new Error('Could not find expected "int" for "s"');var h=e[a++];if(s-a!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(s-a)+'"');if(c<h)throw new Error('"s" specified length of "'+h+'", max of "'+c+'" is acceptable');var f=a;if((a+=h)!==s)throw new Error('Expected to consume entire buffer, but "'+(s-a)+'" bytes remain');var p=n-u,y=n-h,v=r.allocUnsafe(p+u+y+h);for(a=0;a<p;++a)v[a]=0;e.copy(v,a,d+Math.max(-p,0),d+u);for(var g=a=n;a<g+y;++a)v[a]=0;return e.copy(v,a,f+Math.max(-y,0),f+h),(v=v.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=i(e);var n=o(t),s=e.length;if(s!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+s+'"');var a=c(e,0,n),l=c(e,n,e.length),u=n-a,d=n-l,h=2+u+1+1+d,f=h<128,p=r.allocUnsafe((f?2:3)+h),y=0;return p[y++]=48,f?p[y++]=h:(p[y++]=129,p[y++]=255&h),p[y++]=2,p[y++]=u,a<0?(p[y++]=0,y+=e.copy(p,y,0,n)):y+=e.copy(p,y,a,n),p[y++]=2,p[y++]=d,l<0?(p[y++]=0,e.copy(p,y,n)):e.copy(p,y,n+l),p}}},2111:(e,t,n)=>{const r=n(4641),o=n(3999),i=n(5580),c=n(4089),s=n(7059),a=n(5200);e.exports=(e,t,n,l)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return r(e,n,l);case"!=":return o(e,n,l);case">":return i(e,n,l);case">=":return c(e,n,l);case"<":return s(e,n,l);case"<=":return a(e,n,l);default:throw new TypeError(`Invalid operator: ${t}`)}}},2203:e=>{"use strict";e.exports=require("stream")},2525:(e,t,n)=>{const r=n(7638),o=n(560);e.exports=(e,t,n)=>{const i=[];let c=null,s=null;const a=e.sort(((e,t)=>o(e,t,n)));for(const e of a)r(e,t,n)?(s=e,c||(c=e)):(s&&i.push([c,s]),s=null,c=null);c&&i.push([c,null]);const l=[];for(const[e,t]of i)e===t?l.push(e):t||e!==a[0]?t?e===a[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`):l.push("*");const u=l.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},2851:(e,t,n)=>{var r=n(181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||r.isBuffer(e)?e.toString():JSON.stringify(e)}},2861:(e,t,n)=>{var r=n(181),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function c(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=c),c.prototype=Object.create(o.prototype),i(o,c),c.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},c.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},c.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},c.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},2938:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).major},3007:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n,o,i)=>{"string"==typeof n&&(i=o,o=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,o,i).version}catch(e){return null}}},3387:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023);function l(e,t){return r.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){var t=e.header,n=e.payload,r=e.secret||e.privateKey,o=e.encoding,c=i(t.alg),u=function(e,t,n){n=n||"utf8";var r=l(s(e),"binary"),o=l(s(t),n);return a.format("%s.%s",r,o)}(t,n,o),d=c.sign(u,r);return a.format("%s.%s",u,d)}function d(e){var t=e.secret||e.privateKey||e.key,n=new o(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new o(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}a.inherits(d,c),d.prototype.sign=function(){try{var e=u({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=u,e.exports=d},3527:e=>{"use strict";function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},3639:e=>{var t=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==t.call(e)}},3726:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="NotBeforeError",this.date=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},3874:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},3904:(e,t,n)=>{const r=Symbol("SemVer ANY");class o{static get ANY(){return r}constructor(e,t){if(t=i(t),e instanceof o){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),l("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===r?this.value="":this.value=this.operator+this.semver.version,l("comp",this)}parse(e){const t=this.options.loose?c[s.COMPARATORLOOSE]:c[s.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new u(n[2],this.options.loose):this.semver=r}toString(){return this.value}test(e){if(l("Comparator.test",e,this.options.loose),this.semver===r||e===r)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return a(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=i(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(a(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(a(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}e.exports=o;const i=n(8587),{safeRe:c,t:s}=n(9718),a=n(2111),l=n(7272),u=n(3908),d=n(8311)},3908:(e,t,n)=>{const r=n(7272),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(6874),{safeRe:c,safeSrc:s,t:a}=n(9718),l=n(8587),{compareIdentifiers:u}=n(1123);class d{constructor(e,t){if(t=l(t),e instanceof d){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?c[a.LOOSE]:c[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof d)){if("string"==typeof e&&e===this.version)return 0;e=new d(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof d||(e=new d(e,this.options)),u(this.major,e.major)||u(this.minor,e.minor)||u(this.patch,e.patch)}comparePre(e){if(e instanceof d||(e=new d(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof d||(e=new d(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=new RegExp(`^${this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]}$`),n=`-${t}`.match(e);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];!1===n&&(r=[t]),0===u(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=d},3927:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(e,n,t)))},3999:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0!==r(e,t,n)},4040:(e,t,n)=>{e.exports={decode:n(7260),verify:n(1691),sign:n(7651),JsonWebTokenError:n(1741),NotBeforeError:n(3726),TokenExpiredError:n(8980)}},4089:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>=0},4277:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(n,e,t)))},4493:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).patch},4623:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=16.9.0")},4641:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0===r(e,t,n)},4977:(e,t,n)=>{var r=n(9589);e.exports=r.satisfies(process.version,"^6.12.0 || >=8.0.0")},5032:(e,t,n)=>{const r=n(8311),o=n(3904),{ANY:i}=o,c=n(7638),s=n(560),a=[new o(">=0.0.0-0")],l=[new o(">=0.0.0")],u=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===i){if(1===t.length&&t[0].semver===i)return!0;e=n.includePrerelease?a:l}if(1===t.length&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}const r=new Set;let o,u,f,p,y,v,g;for(const t of e)">"===t.operator||">="===t.operator?o=d(o,t,n):"<"===t.operator||"<="===t.operator?u=h(u,t,n):r.add(t.semver);if(r.size>1)return null;if(o&&u){if(f=s(o.semver,u.semver,n),f>0)return null;if(0===f&&(">="!==o.operator||"<="!==u.operator))return null}for(const e of r){if(o&&!c(e,String(o),n))return null;if(u&&!c(e,String(u),n))return null;for(const r of t)if(!c(e,String(r),n))return!1;return!0}let m=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver,C=!(!o||n.includePrerelease||!o.semver.prerelease.length)&&o.semver;m&&1===m.prerelease.length&&"<"===u.operator&&0===m.prerelease[0]&&(m=!1);for(const e of t){if(g=g||">"===e.operator||">="===e.operator,v=v||"<"===e.operator||"<="===e.operator,o)if(C&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===C.major&&e.semver.minor===C.minor&&e.semver.patch===C.patch&&(C=!1),">"===e.operator||">="===e.operator){if(p=d(o,e,n),p===e&&p!==o)return!1}else if(">="===o.operator&&!c(o.semver,String(e),n))return!1;if(u)if(m&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch&&(m=!1),"<"===e.operator||"<="===e.operator){if(y=h(u,e,n),y===e&&y!==u)return!1}else if("<="===u.operator&&!c(u.semver,String(e),n))return!1;if(!e.operator&&(u||o)&&0!==f)return!1}return!(o&&v&&!u&&0!==f||u&&g&&!o&&0!==f||C||m)},d=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},h=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let o=!1;e:for(const r of e.set){for(const e of t.set){const t=u(r,e,n);if(o=o||null!==t,t)continue e}if(o)return!1}return!0}},5200:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<=0},5342:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,"<",n)},5571:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,">",n)},5580:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>0},5747:(e,t,n)=>{var r=n(3387),o=n(7599);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=r.sign,t.verify=o.verify,t.decode=o.decode,t.isValid=o.isValid,t.createSign=function(e){return new r(e)},t.createVerify=function(e){return new o(e)}},5931:e=>{var t=Object.prototype.toString,n=Array.isArray;e.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==t.call(e)}},6111:e=>{var t=1/0,n=9007199254740991,r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=/^(?:0|[1-9]\d*)$/,a=parseInt;function l(e){return e!=e}var u,d,h=Object.prototype,f=h.hasOwnProperty,p=h.toString,y=h.propertyIsEnumerable,v=(u=Object.keys,d=Object,function(e){return u(d(e))}),g=Math.max;function m(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||s.test(e))&&e>-1&&e%1==0&&e<t}var C=Array.isArray;function w(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=T(e)?p.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function T(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function I(e){return!!e&&"object"==typeof e}e.exports=function(e,n,s,u){var d;e=w(e)?e:(d=e)?function(e,t){return function(t){for(var n=-1,r=t?t.length:0,o=Array(r);++n<r;)o[n]=(i=t[n],e[i]);var i;return o}(t)}(d,function(e){return w(e)?function(e,t){var n=C(e)||function(e){return function(e){return I(e)&&w(e)}(e)&&f.call(e,"callee")&&(!y.call(e,"callee")||"[object Arguments]"==p.call(e))}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var i in e)!t&&!f.call(e,i)||o&&("length"==i||m(i,r))||n.push(i);return n}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||h))return v(e);var t,n,r=[];for(var o in Object(e))f.call(e,o)&&"constructor"!=o&&r.push(o);return r}(e)}(d)):[],s=s&&!u?function(e){var n=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||I(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(T(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=T(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=i.test(e);return n||c.test(e)?a(e.slice(2),n?2:8):o.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),s=n%1;return n==n?s?n-s:n:0}(s):0;var N=e.length;return s<0&&(s=g(N+s,0)),function(e){return"string"==typeof e||!C(e)&&I(e)&&"[object String]"==p.call(e)}(e)?s<=N&&e.indexOf(n,s)>-1:!!N&&function(e,t,n){if(t!=t)return function(e,t,n){for(var r=e.length,o=n+-1;++o<r;)if(t(e[o],o,e))return o;return-1}(e,l,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}(e,n,s)>-1}},6170:(e,t,n)=>{const r=n(3908),o=n(144),{safeRe:i,t:c}=n(9718);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const r=t.includePrerelease?i[c.COERCERTLFULL]:i[c.COERCERTL];let o;for(;(o=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&o.index+o[0].length===n.index+n[0].length||(n=o),r.lastIndex=o.index+o[1].length+o[2].length;r.lastIndex=-1}else n=e.match(t.includePrerelease?i[c.COERCEFULL]:i[c.COERCE]);if(null===n)return null;const s=n[2],a=n[3]||"0",l=n[4]||"0",u=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return o(`${s}.${a}.${l}${u}${d}`,t)}},6254:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).minor},6585:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o;function c(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,s){s=s||{};var a,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(c){var s=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return s*i;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===u&&isFinite(e))return s.long?(a=e,(l=Math.abs(a))>=o?c(a,l,o,"day"):l>=r?c(a,l,r,"hour"):l>=n?c(a,l,n,"minute"):l>=t?c(a,l,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},6780:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},6874:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},6953:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n?n.version:null}},6982:e=>{"use strict";e.exports=require("crypto")},7019:(e,t,n)=>{const r=n(1977),o=n(4623),i={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},c={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};e.exports=function(e,t){if(!e||!t)return;const n=t.asymmetricKeyType;if(!n)return;const s=i[n];if(!s)throw new Error(`Unknown key type "${n}".`);if(!s.includes(e))throw new Error(`"alg" parameter for "${n}" key type must be one of: ${s.join(", ")}.`);if(r)switch(n){case"ec":const n=t.asymmetricKeyDetails.namedCurve,r=c[e];if(n!==r)throw new Error(`"alg" parameter "${e}" requires curve "${r}".`);break;case"rsa-pss":if(o){const n=parseInt(e.slice(-3),10),{hashAlgorithm:r,mgf1HashAlgorithm:o,saltLength:i}=t.asymmetricKeyDetails;if(r!==`sha${n}`||o!==r)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==i&&i>n>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}}},7059:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<0},7075:(e,t,n)=>{const r=n(3908),o=n(3904),{ANY:i}=o,c=n(8311),s=n(7638),a=n(5580),l=n(7059),u=n(5200),d=n(4089);e.exports=(e,t,n,h)=>{let f,p,y,v,g;switch(e=new r(e,h),t=new c(t,h),n){case">":f=a,p=u,y=l,v=">",g=">=";break;case"<":f=l,p=d,y=a,v="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(e,t,h))return!1;for(let n=0;n<t.set.length;++n){const r=t.set[n];let c=null,s=null;if(r.forEach((e=>{e.semver===i&&(e=new o(">=0.0.0")),c=c||e,s=s||e,f(e.semver,c.semver,h)?c=e:y(e.semver,s.semver,h)&&(s=e)})),c.operator===v||c.operator===g)return!1;if((!s.operator||s.operator===v)&&p(e,s.semver))return!1;if(s.operator===g&&y(e,s.semver))return!1}return!0}},7083:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return function(e,l){var u;if("function"!=typeof l)throw new TypeError("Expected a function");return e=function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e),function(){return--e>0&&(u=l.apply(this,arguments)),e<=1&&(l=void 0),u}}(2,e)}},7260:(e,t,n)=>{var r=n(5747);e.exports=function(e,t){t=t||{};var n=r.decode(e,t);if(!n)return null;var o=n.payload;if("string"==typeof o)try{var i=JSON.parse(o);null!==i&&"object"==typeof i&&(o=i)}catch(e){}return!0===t.complete?{header:n.header,payload:o,signature:n.signature}:o}},7272:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},7414:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},7599:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023),l=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){var t=e.split(".",1)[0];return function(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}(r.from(t,"base64").toString("binary"))}function d(e){return e.split(".")[2]}function h(e){return l.test(e)&&!!u(e)}function f(e,t,n){if(!t){var r=new Error("Missing algorithm parameter for jws.verify");throw r.code="MISSING_ALGORITHM",r}var o=d(e=s(e)),c=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(c,o,n)}function p(e,t){if(t=t||{},!h(e=s(e)))return null;var n=u(e);if(!n)return null;var o=function(e,t){t=t||"utf8";var n=e.split(".")[1];return r.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(o=JSON.parse(o,t.encoding)),{header:n,payload:o,signature:d(e)}}function y(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new o(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new o(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}a.inherits(y,c),y.prototype.verify=function(){try{var e=f(this.signature.buffer,this.algorithm,this.key.buffer),t=p(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},y.decode=p,y.isValid=h,y.verify=f,e.exports=y},7631:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},7638:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>{try{t=new r(t,n)}catch(e){return!1}return t.test(e)}},7651:(e,t,n)=>{const r=n(855),o=n(4977),i=n(7019),c=n(5747),s=n(6111),a=n(7914),l=n(8928),u=n(3639),d=n(9001),h=n(5931),f=n(7083),{KeyObject:p,createSecretKey:y,createPrivateKey:v}=n(6982),g=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];o&&g.splice(3,0,"PS256","PS384","PS512");const m={expiresIn:{isValid:function(e){return l(e)||h(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return l(e)||h(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return h(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:s.bind(null,g),message:'"algorithm" must be a valid string enum value'},header:{isValid:d,message:'"header" must be an object'},encoding:{isValid:h,message:'"encoding" must be a string'},issuer:{isValid:h,message:'"issuer" must be a string'},subject:{isValid:h,message:'"subject" must be a string'},jwtid:{isValid:h,message:'"jwtid" must be a string'},noTimestamp:{isValid:a,message:'"noTimestamp" must be a boolean'},keyid:{isValid:h,message:'"keyid" must be a string'},mutatePayload:{isValid:a,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:a,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:a,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},C={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function w(e,t,n,r){if(!d(n))throw new Error('Expected "'+r+'" to be a plain object.');Object.keys(n).forEach((function(o){const i=e[o];if(i){if(!i.isValid(n[o]))throw new Error(i.message)}else if(!t)throw new Error('"'+o+'" is not allowed in "'+r+'"')}))}const T={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},I=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,t,n,o){"function"==typeof n?(o=n,n={}):n=n||{};const s="object"==typeof e&&!Buffer.isBuffer(e),a=Object.assign({alg:n.algorithm||"HS256",typ:s?"JWT":void 0,kid:n.keyid},n.header);function l(e){if(o)return o(e);throw e}if(!t&&"none"!==n.algorithm)return l(new Error("secretOrPrivateKey must have a value"));if(null!=t&&!(t instanceof p))try{t=v(t)}catch(e){try{t=y("string"==typeof t?Buffer.from(t):t)}catch(e){return l(new Error("secretOrPrivateKey is not valid key material"))}}if(a.alg.startsWith("HS")&&"secret"!==t.type)return l(new Error(`secretOrPrivateKey must be a symmetric key when using ${a.alg}`));if(/^(?:RS|PS|ES)/.test(a.alg)){if("private"!==t.type)return l(new Error(`secretOrPrivateKey must be an asymmetric key when using ${a.alg}`));if(!n.allowInsecureKeySizes&&!a.alg.startsWith("ES")&&void 0!==t.asymmetricKeyDetails&&t.asymmetricKeyDetails.modulusLength<2048)return l(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`))}if(void 0===e)return l(new Error("payload is required"));if(s){try{!function(e){w(C,!0,e,"payload")}(e)}catch(e){return l(e)}n.mutatePayload||(e=Object.assign({},e))}else{const t=I.filter((function(e){return void 0!==n[e]}));if(t.length>0)return l(new Error("invalid "+t.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return l(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return l(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){w(m,!1,e,"options")}(n)}catch(e){return l(e)}if(!n.allowInvalidAsymmetricKeyTypes)try{i(a.alg,t)}catch(e){return l(e)}const u=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:s&&(e.iat=u),void 0!==n.notBefore){try{e.nbf=r(n.notBefore,u)}catch(e){return l(e)}if(void 0===e.nbf)return l(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=r(n.expiresIn,u)}catch(e){return l(e)}if(void 0===e.exp)return l(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(T).forEach((function(t){const r=T[t];if(void 0!==n[t]){if(void 0!==e[r])return l(new Error('Bad "options.'+t+'" option. The payload already has an "'+r+'" property.'));e[r]=n[t]}}));const d=n.encoding||"utf8";if("function"!=typeof o){let r=c.sign({header:a,payload:e,secret:t,encoding:d});if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&r.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`);return r}o=o&&f(o),c.createSign({header:a,privateKey:t,payload:e,encoding:d}).once("error",o).once("done",(function(e){if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&e.length<256)return o(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`));o(null,e)}))}},7914:e=>{var t=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==t.call(e)}},8311:(e,t,n)=>{const r=/\s+/g;class o{constructor(e,t){if(t=c(t),e instanceof o)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new o(e.raw,t);if(e instanceof s)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(r," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&y)|(this.options.loose&&v))+":"+e,n=i.get(t);if(n)return n;const r=this.options.loose,o=r?u[d.HYPHENRANGELOOSE]:u[d.HYPHENRANGE];e=e.replace(o,b(this.options.includePrerelease)),a("hyphen replace",e),e=e.replace(u[d.COMPARATORTRIM],h),a("comparator trim",e),e=e.replace(u[d.TILDETRIM],f),a("tilde trim",e),e=e.replace(u[d.CARETTRIM],p),a("caret trim",e);let c=e.split(" ").map((e=>w(e,this.options))).join(" ").split(/\s+/).map((e=>x(e,this.options)));r&&(c=c.filter((e=>(a("loose invalid filter",e,this.options),!!e.match(u[d.COMPARATORLOOSE]))))),a("range list",c);const l=new Map,m=c.map((e=>new s(e,this.options)));for(const e of m){if(g(e))return[e];l.set(e.value,e)}l.size>1&&l.has("")&&l.delete("");const C=[...l.values()];return i.set(t,C),C}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Range is required");return this.set.some((n=>C(n,t)&&e.set.some((e=>C(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if($(this.set[t],e,this.options))return!0;return!1}}e.exports=o;const i=new(n(8794)),c=n(8587),s=n(3904),a=n(7272),l=n(3908),{safeRe:u,t:d,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:p}=n(9718),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:v}=n(6874),g=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,C=(e,t)=>{let n=!0;const r=e.slice();let o=r.pop();for(;n&&r.length;)n=r.every((e=>o.intersects(e,t))),o=r.pop();return n},w=(e,t)=>(a("comp",e,t),e=A(e,t),a("caret",e),e=I(e,t),a("tildes",e),e=S(e,t),a("xrange",e),e=R(e,t),a("stars",e),e),T=e=>!e||"x"===e.toLowerCase()||"*"===e,I=(e,t)=>e.trim().split(/\s+/).map((e=>N(e,t))).join(" "),N=(e,t)=>{const n=t.loose?u[d.TILDELOOSE]:u[d.TILDE];return e.replace(n,((t,n,r,o,i)=>{let c;return a("tilde",e,t,n,r,o,i),T(n)?c="":T(r)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:T(o)?c=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:i?(a("replaceTilde pr",i),c=`>=${n}.${r}.${o}-${i} <${n}.${+r+1}.0-0`):c=`>=${n}.${r}.${o} <${n}.${+r+1}.0-0`,a("tilde return",c),c}))},A=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{a("caret",e,t);const n=t.loose?u[d.CARETLOOSE]:u[d.CARET],r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,o,i,c)=>{let s;return a("caret",e,t,n,o,i,c),T(n)?s="":T(o)?s=`>=${n}.0.0${r} <${+n+1}.0.0-0`:T(i)?s="0"===n?`>=${n}.${o}.0${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.0${r} <${+n+1}.0.0-0`:c?(a("replaceCaret pr",c),s="0"===n?"0"===o?`>=${n}.${o}.${i}-${c} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}-${c} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i}-${c} <${+n+1}.0.0-0`):(a("no pr"),s="0"===n?"0"===o?`>=${n}.${o}.${i}${r} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i} <${+n+1}.0.0-0`),a("caret return",s),s}))},S=(e,t)=>(a("replaceXRanges",e,t),e.split(/\s+/).map((e=>k(e,t))).join(" ")),k=(e,t)=>{e=e.trim();const n=t.loose?u[d.XRANGELOOSE]:u[d.XRANGE];return e.replace(n,((n,r,o,i,c,s)=>{a("xRange",e,n,r,o,i,c,s);const l=T(o),u=l||T(i),d=u||T(c),h=d;return"="===r&&h&&(r=""),s=t.includePrerelease?"-0":"",l?n=">"===r||"<"===r?"<0.0.0-0":"*":r&&h?(u&&(i=0),c=0,">"===r?(r=">=",u?(o=+o+1,i=0,c=0):(i=+i+1,c=0)):"<="===r&&(r="<",u?o=+o+1:i=+i+1),"<"===r&&(s="-0"),n=`${r+o}.${i}.${c}${s}`):u?n=`>=${o}.0.0${s} <${+o+1}.0.0-0`:d&&(n=`>=${o}.${i}.0${s} <${o}.${+i+1}.0-0`),a("xRange return",n),n}))},R=(e,t)=>(a("replaceStars",e,t),e.trim().replace(u[d.STAR],"")),x=(e,t)=>(a("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?d.GTE0PRE:d.GTE0],"")),b=e=>(t,n,r,o,i,c,s,a,l,u,d,h)=>`${n=T(r)?"":T(o)?`>=${r}.0.0${e?"-0":""}`:T(i)?`>=${r}.${o}.0${e?"-0":""}`:c?`>=${n}`:`>=${n}${e?"-0":""}`} ${a=T(l)?"":T(u)?`<${+l+1}.0.0-0`:T(d)?`<${l}.${+u+1}.0-0`:h?`<=${l}.${u}.${d}-${h}`:e?`<${l}.${u}.${+d+1}-0`:`<=${a}`}`.trim(),$=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(a(e[n].semver),e[n].semver!==s.ANY&&e[n].semver.prerelease.length>0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}},8587:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},8789:(e,t,n)=>{var r=n(1045),o=n(2861).Buffer,i=n(6982),c=n(2010),s=n(9023),a="secret must be a string or buffer",l="key must be a string or a buffer",u="function"==typeof i.createPublicKey;function d(e){if(!o.isBuffer(e)&&"string"!=typeof e){if(!u)throw y(l);if("object"!=typeof e)throw y(l);if("string"!=typeof e.type)throw y(l);if("string"!=typeof e.asymmetricKeyType)throw y(l);if("function"!=typeof e.export)throw y(l)}}function h(e){if(!o.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw y("key must be a string, a buffer or an object")}function f(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function y(e){var t=[].slice.call(arguments,1),n=s.format.bind(s,e).apply(null,t);return new TypeError(n)}function v(e){var t;return t=e,o.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function g(e){return function(t,n){!function(e){if(!o.isBuffer(e)){if("string"==typeof e)return e;if(!u)throw y(a);if("object"!=typeof e)throw y(a);if("secret"!==e.type)throw y(a);if("function"!=typeof e.export)throw y(a)}}(n),t=v(t);var r=i.createHmac("sha"+e,n);return f((r.update(t),r.digest("base64")))}}function m(e){return function(t,n,i){var c=g(e)(t,i);return r(o.from(n),o.from(c))}}function C(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign(n,"base64")))}}function w(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify(r,n,"base64")}}function T(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign({key:n,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function I(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify({key:r,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function N(e){var t=C(e);return function(){var n=t.apply(null,arguments);return c.derToJose(n,"ES"+e)}}function A(e){var t=w(e);return function(n,r,o){return r=c.joseToDer(r,"ES"+e).toString("base64"),t(n,r,o)}}function E(){return function(){return""}}function S(){return function(e,t){return""===t}}u&&(l+=" or a KeyObject",a+="or a KeyObject"),e.exports=function(e){var t={hs:g,rs:C,ps:T,es:N,none:E},n={hs:m,rs:w,ps:I,es:A,none:S},r=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!r)throw y('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var o=(r[1]||r[3]).toLowerCase(),i=r[2];return{sign:t[o](i),verify:n[o](i)}}},8794:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},8928:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e)}},8948:(e,t,n)=>{var r=n(2861).Buffer,o=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=r.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=r.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(9023).inherits(i,o),i.prototype.write=function(e){this.buffer=r.concat([this.buffer,r.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},8980:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},9001:e=>{var t,n,r=Function.prototype,o=Object.prototype,i=r.toString,c=o.hasOwnProperty,s=i.call(Object),a=o.toString,l=(t=Object.getPrototypeOf,n=Object,function(e){return t(n(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var n=c.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&i.call(n)==s}},9023:e=>{"use strict";e.exports=require("util")},9589:(e,t,n)=>{const r=n(9718),o=n(6874),i=n(3908),c=n(1123),s=n(144),a=n(6953),l=n(7414),u=n(3007),d=n(1832),h=n(2938),f=n(6254),p=n(4493),y=n(1729),v=n(560),g=n(9970),m=n(1763),C=n(909),w=n(3927),T=n(4277),I=n(5580),N=n(7059),A=n(4641),E=n(3999),S=n(4089),k=n(5200),R=n(2111),x=n(6170),b=n(3904),$=n(8311),L=n(7638),_=n(7631),P=n(9628),O=n(270),U=n(1261),B=n(3874),D=n(7075),F=n(5571),G=n(5342),j=n(6780),V=n(2525),M=n(5032);e.exports={parse:s,valid:a,clean:l,inc:u,diff:d,major:h,minor:f,patch:p,prerelease:y,compare:v,rcompare:g,compareLoose:m,compareBuild:C,sort:w,rsort:T,gt:I,lt:N,eq:A,neq:E,gte:S,lte:k,cmp:R,coerce:x,Comparator:b,Range:$,satisfies:L,toComparators:_,maxSatisfying:P,minSatisfying:O,minVersion:U,validRange:B,outside:D,gtr:F,ltr:G,intersects:j,simplifyRange:V,subset:M,SemVer:i,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}},9628:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&-1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},9718:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(6874),c=n(7272),s=(t=e.exports={}).re=[],a=t.safeRe=[],l=t.src=[],u=t.safeSrc=[],d=t.t={};let h=0;const f="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[f,o]],y=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;c(e,o,t),d[e]=o,l[o]=t,u[o]=r,s[o]=new RegExp(t,n?"g":void 0),a[o]=new RegExp(r,n?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${l[d.NUMERICIDENTIFIER]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${l[d.NUMERICIDENTIFIERLOOSE]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASE",`(?:-(${l[d.PRERELEASEIDENTIFIER]}(?:\\.${l[d.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${l[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[d.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${l[d.BUILDIDENTIFIER]}(?:\\.${l[d.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${l[d.MAINVERSION]}${l[d.PRERELEASE]}?${l[d.BUILD]}?`),y("FULL",`^${l[d.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${l[d.MAINVERSIONLOOSE]}${l[d.PRERELEASELOOSE]}?${l[d.BUILD]}?`),y("LOOSE",`^${l[d.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${l[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${l[d.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:${l[d.PRERELEASE]})?${l[d.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:${l[d.PRERELEASELOOSE]})?${l[d.BUILD]}?)?)?`),y("XRANGE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),y("COERCE",`${l[d.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",l[d.COERCEPLAIN]+`(?:${l[d.PRERELEASE]})?`+`(?:${l[d.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",l[d.COERCE],!0),y("COERCERTLFULL",l[d.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${l[d.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${l[d.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${l[d.LONECARET]}${l[d.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${l[d.LONECARET]}${l[d.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${l[d.GTLT]}\\s*(${l[d.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]}|${l[d.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${l[d.XRANGEPLAIN]})\\s+-\\s+(${l[d.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${l[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[d.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},9970:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(t,e,n)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{ALLID:()=>ei,AccessControlService:()=>Xo,AddGhostConcept:()=>Zr,AddGhostConnection:()=>eo,BaseUrl:()=>o,BinaryTree:()=>F,CCSConfig:()=>Io,Composition:()=>mr,CompositionBinaryTree:()=>pr,CompositionNode:()=>hr,Concept:()=>G,ConceptsData:()=>K,Connection:()=>oe,ConnectionData:()=>de,CreateComposition:()=>Ut,CreateConnection:()=>Et,CreateConnectionBetweenTwoConcepts:()=>sn,CreateConnectionBetweenTwoConceptsGeneral:()=>ln,CreateDefaultConcept:()=>j,CreateDefaultLConcept:()=>gn,CreateSession:()=>Dr,CreateSessionVisit:()=>Gr,CreateTheCompositionWithCache:()=>wr,CreateTheConnectionGeneral:()=>At,CreateTypeConcept:()=>hn,DATAID:()=>Jo,DATAIDDATE:()=>Qo,DATAV2:()=>ni,DeleteConceptById:()=>Fn,DeleteConnectionById:()=>Wt,DeleteConnectionByIdBulk:()=>Kt,DeleteConnectionByTypeBulk:()=>yo,FilterSearch:()=>Co,FormatFromConnections:()=>io,FreeSchemaResponse:()=>Z,FreeschemaQuery:()=>mi,GetAllConnectionsOfComposition:()=>Ee,GetAllConnectionsOfCompositionBulk:()=>we,GetAllTheConnectionsByTypeAndOfTheConcept:()=>wi,GetComposition:()=>Re,GetCompositionBulk:()=>qn,GetCompositionBulkWithDataId:()=>zn,GetCompositionFromConnectionsWithDataId:()=>Jn,GetCompositionFromConnectionsWithDataIdInObject:()=>Qn,GetCompositionList:()=>Me,GetCompositionListWithId:()=>He,GetCompositionWithAllIds:()=>xe,GetCompositionWithCache:()=>_r,GetCompositionWithDataIdBulk:()=>Ur,GetCompositionWithDataIdWithCache:()=>Or,GetCompositionWithId:()=>Oe,GetCompositionWithIdFromMemory:()=>$e,GetCompositionWithIdFromMemoryFromConnections:()=>_e,GetConceptBulk:()=>fe,GetConceptByCharacter:()=>je,GetConceptByCharacterAndCategoryDirectApi:()=>Xe,GetConceptByCharacterAndType:()=>Rt,GetConceptByTypeBulk:()=>xt,GetConnectionBulk:()=>Kn,GetConnectionById:()=>Mt,GetConnectionByTypeBulk:()=>vo,GetConnectionOfTheConcept:()=>Dt,GetConnectionsBetweenApi:()=>Ir,GetLink:()=>pn,GetLinkRaw:()=>yn,GetLinkerConnectionFromConcepts:()=>Pn,GetLinkerConnectionToConcepts:()=>On,GetRelation:()=>Hr,GetRelationRaw:()=>Wr,GetRequestHeader:()=>Y,GetRequestHeaderWithAuthorization:()=>Q,GetTheConcept:()=>qt,GetUserGhostConnectionId:()=>Qr,GetUserGhostId:()=>Yr,GiveConnection:()=>Ti,HandleHttpError:()=>ee,HttpResponse:()=>h,JUSTDATA:()=>Yo,LConcept:()=>vn,LConnection:()=>Xr,LISTNORMAL:()=>ti,LoginToBackend:()=>nr,MakeTheInstanceConcept:()=>Pt,MakeTheTimestamp:()=>Mn,MakeTheTypeConcept:()=>Rn,MakeTheTypeConceptApi:()=>Ze,NORMAL:()=>zo,PatcherStructure:()=>go,PermissionSet:()=>Mo,RAW:()=>Zo,RecursiveSearchApi:()=>er,ReservedConnectionIds:()=>ht,ReservedIds:()=>dt,SchemaQueryListener:()=>gi,SearchAllConcepts:()=>xr,SearchLinkInternal:()=>fo,SearchLinkMultipleAll:()=>oo,SearchLinkMultipleApi:()=>no,SearchQuery:()=>Hn,SearchStructure:()=>wo,SearchWithLinker:()=>$r,SessionData:()=>mo,Signin:()=>cr,Signup:()=>or,SplitStrings:()=>z,SyncData:()=>wt,TokenRefreshError:()=>d,TokenStorage:()=>i,Transaction:()=>Er,TrashTheConcept:()=>jn,UpdateComposition:()=>kr,UserBinaryTree:()=>zr,ViewInternalData:()=>ao,buildFetchConnection:()=>Nr,convertFromLConceptToConcept:()=>lo,deleteWithRetry:()=>w,fetchWithCacheServerFallback:()=>A,fetchWithRetry:()=>v,getFromDatabaseWithType:()=>b,getFromDatabaseWithTypeOld:()=>$,getOAuthToken:()=>a,getWithRetry:()=>m,init:()=>Ai,patchWithRetry:()=>T,postWithRetry:()=>g,putWithRetry:()=>C,recursiveFetch:()=>Ue,recursiveFetchNew:()=>vr,refreshOAuthToken:()=>l,requestWithRetry:()=>y,storeToDatabase:()=>x,updateAccessToken:()=>Ni});var e=n(4040),t=n.n(e);class o{static setNodeCacheUrl(e=""){this.NODE_CACHE_URL=e,this.isNearestCache=!0}static setCacheServers(e=[]){this.CACHE_SERVERS=e.filter((e=>"string"==typeof e&&""!==e.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetNodeBaseUrl(){return this.NODE_URL&&""!==this.NODE_URL.trim()?this.NODE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const e=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.GetNodeBaseUrl(),this.BASE_URL].filter((e=>"string"==typeof e&&""!==e.trim())).map((e=>e.trim()));return Array.from(new Set(e))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static CreateTypeConceptUrl(){return this.BASE_URL+"/api/create_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}o.BASE_URL="https://localhost:7053/",o.NODE_CACHE_URL="",o.CACHE_SERVERS=[],o.isNearestCache=!0,o.AI_URL="https://ai.freeschema.com",o.MQTT_URL="192.168.1.249",o.NODE_URL="";class i{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(e,t){this.BearerAccessToken=e,this.TOKEN_EXPIRY=t&&t>0?Date.now()+1e3*t:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const e=Date.now(),t=this.TOKEN_EXPIRY-e;return t>0?Math.floor(t/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(e,t,n){this.CLIENT_ID=e,this.CLIENT_SECRET=t,this.APPLICATION_NAME=n}static setDefaultIdentity(e,t,n,r){this.DEFAULT_USER_ID=e,this.DEFAULT_USER_CONCEPT_ID=t,this.DEFAULT_ENTITY_ID=n,this.DEFAULT_SESSION_ID=r}}i.BearerAccessToken="",i.CLIENT_ID="",i.CLIENT_SECRET="",i.APPLICATION_NAME="",i.TOKEN_EXPIRY=0,i.EXPIRY_BUFFER_MS=3e5,i.DEFAULT_USER_ID=0,i.DEFAULT_USER_CONCEPT_ID=0,i.DEFAULT_ENTITY_ID=0,i.DEFAULT_SESSION_ID=0;var c=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function s(e){try{const n=t().decode(e);if(!n)return;i.setDefaultIdentity(Number(n.unique_name)||0,Number(n.upn)||0,Number(n.EntityId)||0,Number(n.primarysid)||0)}catch(e){}}function a(e,t,n){return c(this,arguments,void 0,(function*(e,t,n,r=!0){try{const c=o.OAuthTokenUrl(),a=new URLSearchParams;a.append("client_id",e),a.append("client_secret",t),a.append("application_name",n);const l=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(l.ok){let e="",t="Bearer",n=0;const o=l.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield l.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield l.text()}else e=yield l.text();return e?(r&&(i.setToken(e,n),s(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield l.text();return{success:!1,error:`HTTP ${l.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}function l(e,t,n){return c(this,arguments,void 0,(function*(e,t,n,r=!0){try{const c=o.OAuthRefreshUrl(),a=new URLSearchParams;a.append("client_id",e),a.append("client_secret",t),a.append("refresh_token",n),a.append("grant_type","refresh_token");const l=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(l.ok){let e="",t="Bearer",n=0;const o=l.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield l.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield l.text()}else e=yield l.text();return e?(r&&(i.setToken(e,n),s(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield l.text();return{success:!1,error:`HTTP ${l.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}var u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class d extends Error{constructor(e){super(e),this.name="TokenRefreshError"}}class h{constructor(e,t,n){this.status=e,this.body=t,this.headers=n}json(){return u(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return u(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function f(){return u(this,void 0,void 0,(function*(){if(!i.hasOAuthCredentials())return!1;try{return(yield a(i.CLIENT_ID,i.CLIENT_SECRET,i.APPLICATION_NAME,!0)).success}catch(e){return console.error("Token refresh failed:",e),!1}}))}const p=3e4;function y(e,t,n,r){return u(this,arguments,void 0,(function*(e,t,n,r,o=1,c=p){var s,a;const l=Object.assign(Object.assign({},n),i.getAuthHeader()),u=["GET","HEAD","OPTIONS"].includes(e.toUpperCase());for(let n=0;n<=o;n++){const p=new AbortController,y=setTimeout((()=>p.abort()),c);try{const c={method:e,headers:l,signal:p.signal};if(void 0!==r){const e=r instanceof URLSearchParams||"undefined"!=typeof FormData&&r instanceof FormData||"undefined"!=typeof Blob&&r instanceof Blob||r instanceof ArrayBuffer||ArrayBuffer.isView(r);"object"!=typeof r||e?c.body=r:(l["Content-Type"]||l["content-type"]||(l["Content-Type"]="application/json"),(null===(s=l["Content-Type"])||void 0===s?void 0:s.includes("application/json"))||(null===(a=l["content-type"])||void 0===a?void 0:a.includes("application/json"))?c.body=JSON.stringify(r):c.body=r)}c.headers=l;const u=yield fetch(t,c),y=yield u.text(),v={};if(u.headers.forEach(((e,t)=>{v[t]=e})),401!==u.status)return new h(u.status,y,v);if(n<o){if(yield f()){Object.assign(l,i.getAuthHeader());continue}throw new d("Token refresh failed. Please check OAuth credentials.")}return new h(u.status,y,v)}catch(e){if(e instanceof d)throw e;if(n>=o||!u)throw e;console.error(`Request failed (attempt ${n+1}/${o+1}):`,e)}finally{clearTimeout(y)}}throw new Error("Request failed after all retry attempts")}))}function v(e){return u(this,arguments,void 0,(function*(e,t={},n=1){return y(t.method||"GET",e,function(e){if(e){if(e instanceof Headers){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}return Array.isArray(e)?e.reduce(((e,[t,n])=>(e[t]=n,e)),{}):e}}(t.headers),t.body,n)}))}function g(e,t,n){return u(this,void 0,void 0,(function*(){return y("POST",e,t,n)}))}function m(e,t,n){return u(this,void 0,void 0,(function*(){let r=e;if(n){const t=[];for(const e in n)n.hasOwnProperty(e)&&t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n[e]))}`);t.length>0&&(r=`${e}?${t.join("&")}`)}return y("GET",r,t)}))}function C(e,t,n){return u(this,void 0,void 0,(function*(){return y("PUT",e,t,n)}))}function w(e,t){return u(this,void 0,void 0,(function*(){return y("DELETE",e,t)}))}function T(e,t,n){return u(this,void 0,void 0,(function*(){return y("PATCH",e,t,n)}))}var I=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function N(e,t){return`${e.replace(/\/+$/,"")}${t}`}function A(e){return I(this,arguments,void 0,(function*(e,t={},n=1){const r=o.GetReadBaseUrlCandidates();let i;for(const c of r){try{const r=yield v(N(c,e),t,n);if(c.replace(/\/+$/,"")===o.BASE_URL.replace(/\/+$/,""))return r;if(r.ok)return o.NODE_CACHE_URL=c,r;i=new Error(`Cache server ${c} returned status ${r.status}`)}catch(e){i=e}o.isNearestCache=!1}throw i instanceof Error?i:new Error("All cache servers failed")}))}class E{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var S=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const k={};function R(e){return k[e]||(k[e]=[]),k[e]}function x(e,t){const n=R(e);if(t&&"number"==typeof t.id){const e=n.findIndex((e=>e&&e.id===t.id));if(e>=0)return void(n[e]=t)}n.push(t)}function b(e,t,n){return S(this,void 0,void 0,(function*(){return R(e).filter((e=>e&&e[t]===n))}))}function $(e){return S(this,void 0,void 0,(function*(){return R(e).slice()}))}function L(e,t){const n=R(e),r=n.findIndex((e=>e&&e.id===t));r>=0&&n.splice(r,1)}function _(e){return S(this,void 0,void 0,(function*(){return R(e).slice()}))}class P{}P.isTypeLoaded=!1,P.isCharacterLoaded=!1,P.isDataLoaded=!1,P.isLocalDataLoaded=!1,P.isLocalCharacterLoaded=!1,P.isLocalTypeLoaded=!1,P.isConnectionLoaded=!1,P.isConnectionTypeLoaded=!1,P.isLocalConnectionLoaded=!1;class O{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var U=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class B{static waitForDataToLoad(){return U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isCharacterLoaded)return e("done");setTimeout(B.checkFlag,1e3,e)}static addNodeToTree(e){return U(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return U(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new O(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}B.characterRoot=null;var D=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class F{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return D(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isDataLoaded)return e("done");setTimeout(F.checkFlag,1e3,e)}static addConceptToTree(e){var t=new O(e.id,e,null,null),n=new O(e.characterValue,e,null,null);B.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return D(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return D(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}F.root=null;class G{constructor(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=r,this.ghostId=e,this.categoryId=o,this.categoryUserId=i,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,this.securityId=l,this.securityUserId=u,this.accessId=d,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=p,this.x=0,this.y=0,this.type=null,this.isNew=y,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function j(){let e=V(new Date),t=V(new Date);return new G(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function V(e){const t=e.getMonth()+1,n=e.getDate(),r=e.getFullYear();let o=e.getHours();const i=e.getMinutes(),c=e.getSeconds(),s=o>=12?"PM":"AM";o%=12,o=o||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${r} ${o}:${a(i)}:${a(c)} ${s}`}var M=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class H{static addNodeToTree(e){return M(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new O(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return M(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isTypeLoaded)return e("done");setTimeout(H.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return M(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)if(r.variants[e].value.userId==t){var o=!1;for(let t=0;t<n.length;t++)n[t].id==r.variants[e].value.id&&(o=!0);o||n.push(r.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return M(this,void 0,void 0,(function*(){let n=j();var r=this.getNodeFromTree(t);if(r){r.value.characterValue==e&&(n=r.value);for(let t=0;t<r.variants.length;t++)r.variants[t].value.characterValue==e&&(n=r.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}H.typeRoot=null;var W=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class K{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(e=Date.now()){this.NPC=this.NPC.filter((t=>{const n=this.NPCMeta.get(t);return n&&n.expiresAt>e}))}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){var t;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(e)||this.NPC.push(e);const r=this.NPCMeta.get(e),o=(null!==(t=null==r?void 0:r.attempts)&&void 0!==t?t:0)+1;this.NPCMeta.set(e,{attempts:o,expiresAt:n+o*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(e){const t=Date.now();this.RemoveExpiredNpc(t);const n=this.NPCMeta.get(e);return!!(n&&n.expiresAt>t)}static AddConceptToStorage(e){e.id>0&&x("concept",e)}static AddConcept(e){e.id>0&&(x("concept",e),F.addConceptToTree(e),H.addConceptToTree(e),B.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(F.addConceptToTree(e),H.addConceptToTree(e),B.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);F.removeNodeFromTree(e.id),L("concept",e.id)}static GetConcept(e){return W(this,void 0,void 0,(function*(){var t=j(),n=yield F.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return W(this,void 0,void 0,(function*(){var t=j(),n=B.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return W(this,void 0,void 0,(function*(){var t=j(),n=B.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return W(this,void 0,void 0,(function*(){return j(),yield H.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return W(this,void 0,void 0,(function*(){var n=j(),r=yield B.getCharacterAndCategoryFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return W(this,void 0,void 0,(function*(){let n=[];return n=yield H.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return B.characterRoot}getName(){return this.name}}K.conceptsArray=[],K.NPC=[],K.NPCMeta=new Map,K.NPC_BACKOFF_SECONDS=30,K.conceptDictionary=[];var X=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function q(){return X(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield $("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];K.AddConceptToMemory(n)}(new Date).getTime()}))}function z(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var J=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Y(){return J(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(i.isTokenExpiredOrNearExpiry()&&i.hasOAuthCredentials()){const e=yield a(i.CLIENT_ID,i.CLIENT_SECRET,i.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+i.BearerAccessToken,Accept:t}}))}function Q(){return J(this,arguments,void 0,(function*(e="application/json",t="",n="application/json"){if(""!==t)return{"Content-Type":e,Authorization:"Bearer "+t,Accept:n};if(i.isTokenExpiredOrNearExpiry()&&i.hasOAuthCredentials()){const e=yield a(i.CLIENT_ID,i.CLIENT_SECRET,i.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+i.BearerAccessToken,Accept:n}}))}class Z{constructor(e,t,n,r){this.url=o.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=r}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function ee(e){if(!e.ok){const t=e instanceof h,n=t?e.body||`HTTP error ${e.status}`:e.statusText||`HTTP error ${e.status}`;let r=new Z(n,!1,e.status,"");throw r.setUrl(t?e.headers.url||"":e.url),r}}function te(e){if(!e.ok){const t=e.body||`HTTP error ${e.status}`;let n=new Z(t,!1,e.status,e.body);throw n.setUrl(e.headers.url||""),n}}var ne=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function re(e,t){return ne(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.toString());var r=yield Y("application/x-www-form-urlencoded");const c=yield v(o.GetAllConceptsByTypeUrl(),{method:"POST",headers:r,body:n});if(c.ok){const e=yield c.json();for(var i=0;i<e.length;i++)K.AddConcept(e[i])}console.log("GetAllConceptsByType error",c.status),ee(c)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class oe{constructor(e=0,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y){this.isTemp=!1,this.toUpdate=!1,this.type=j(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=r,this.toTheConceptUserId=o,this.userId=i,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=u,this.securityUserId=d,this.accessId=h,this.accessUserId=f,this.sessionInformationId=p,this.sessionInformationUserId=y,this.entryTimeStamp=V(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class ie{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ce=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class se{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new ie(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return ce(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isConnectionLoaded)return e("done");setTimeout(se.checkFlag,1e3,e)}static removeNodeFromTree(e){return ce(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return ce(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}se.connectionroot=null;var ae=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class le{static addNodeToTree(e){return ae(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return ae(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isConnectionTypeLoaded)return e("done");setTimeout(le.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new ie(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return ae(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return ae(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}le.connectionTypeRoot=null;var ue=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class de{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){x("connection",e)}static AddConnection(e){e.isTemp||(x("connection",e),se.addConnectionToTree(e),le.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(se.addConnectionToTree(e),le.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(L("connection",e.id),se.removeNodeFromTree(e.id),le.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return se.connectionroot}static GetConnectionTypeTree(){return le.connectionTypeRoot}static GetConnection(e){return ue(this,void 0,void 0,(function*(){var t=new oe(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield se.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConnectionsOfCompositionLocal(e){return ue(this,void 0,void 0,(function*(){var t=[],n=yield le.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;if(r){let e=r;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}de.connectionArray=[],de.connectionDictionary=[];var he=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function fe(e){return he(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield K.GetConcept(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{const e=JSON.stringify(n);var r=yield Y();const o=yield A("/api/get_concept_bulk",{method:"POST",headers:r,body:e});if(o.ok){let e=yield o.json();if(e.length>0)for(let n=0;n<e.length;n++){let r=e[n];t.push(r),K.AddConcept(r)}}else console.log("Get Concept Bulk error",o.status),ee(o);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var pe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ye(){return pe(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield fe(t)}}))}var ve=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ge(){return ve(this,arguments,void 0,(function*(e=[]){var t=[];for(let r=0;r<e.length;r++){var n=yield de.GetConnectionsOfCompositionLocal(e[r]);t.push(...n)}return t}))}function me(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||de.RemoveConnection(t[n]))}var Ce=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function we(){return Ce(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield ge(e),r=yield function(){return Ce(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=yield Y();const i=yield v(o.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(i.ok){const e=yield i.json();for(var r=0;r<e.length;r++)de.AddConnection(e[r]),t.push(e[r])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),ee(i);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return me(t=r,n),yield ye(t),t}))}var Te=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Ie=new Map;function Ne(e){return Te(this,void 0,void 0,(function*(){let t=j();if(Ie.has(e))return Ie.get(e)||t;const n=(()=>Te(this,void 0,void 0,(function*(){try{var n=yield K.GetConcept(e);let i=K.GetNpc(e);if(0!=n.id||i)return n;{var r=yield Y("application/x-www-form-urlencoded");const n=yield v(o.GetConceptUrl(),{method:"POST",headers:r,body:`id=${e}`});return n.ok?(t=yield n.json(),t.id>0?K.AddConcept(t):K.AddNpc(e)):(console.log("Get the concept error",n.status,e),ee(n)),t}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message,e):console.log("Get the concept unexpected error: ",t,e),t}finally{Ie.delete(e)}})))();return Ie.set(e,n),n}))}var Ae=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ee(e){return Ae(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield de.GetConnectionsOfCompositionLocal(e)).length)t=yield Se(e);else{var n=yield Se(e);me(n,t),t=n}return t}))}function Se(e){return Ae(this,void 0,void 0,(function*(){var t=[];try{var n=yield Y("application/x-www-form-urlencoded");const i=yield v(o.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});if(!i.ok)throw ee(i),new Error(`Error! status: ${i.status}`);const c=yield i.json();for(var r=0;r<c.length;r++)de.AddConnection(c[r]),t.push(c[r]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var ke=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Re(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield Ee(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function xe(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield Ee(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Be(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function be(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield de.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function $e(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield de.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Le(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield de.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l.created_at=s.entryTimeStamp,l}))}function _e(e,t){return ke(this,void 0,void 0,(function*(){for(var n,r,o={},i=[],c=0;c<t.length;c++)i.includes(t[c].ofTheConceptId)||i.push(t[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,t,i);o[null!==(r=null===(n=null==s?void 0:s.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Pe(e,t){return ke(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i={},c=yield K.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield Ne(e));var s=yield Ue(e,t,n);i[null!==(o=null===(r=null==c?void 0:c.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=i,a.id=e,a}))}function Oe(e){return ke(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield Ee(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield K.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Ne(e));var a=yield Ue(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l}))}function Ue(e,t,n){return ke(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield K.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Ne(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield K.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Ne(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield K.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Ne(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield K.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Ne(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Ue(f,t,n,r);s[y]=e}}else{const e=yield Ue(f,t,n,r);a[y]=e,s=a}}return s}))}function Be(e,t,n){return ke(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield K.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Ne(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield K.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Ne(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e),s.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield K.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Ne(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield K.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Ne(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Be(f,t,n);s[y]=e}}else{const e=yield Be(f,t,n);a[y]=e,s=a}}return s}))}var De=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Fe(e){return De(this,void 0,void 0,(function*(){let t=j();try{var n=yield Y("application/x-www-form-urlencoded");const r=yield v(o.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return r.ok?(t=yield r.json(),t.id>0&&K.AddConcept(t)):(console.log("Error in Getting concept by character value Error",r.status),ee(r)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var Ge=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function je(e){return Ge(this,void 0,void 0,(function*(){var t=yield K.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Fe(e),t=yield K.GetConceptByCharacter(e)),t}))}var Ve=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Me(e,t){return Ve(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield je(e),i=[];if(o){yield re(e,t);for(var c=yield K.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield we(a),l=s;l<s+n;l++)if(c[l]){var u=yield be(c[l].id);i.push(u)}}return i}))}function He(e,t){return Ve(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield je(e),i=[];if(o){yield re(e,t);for(var c=yield K.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield we(a),l=s;l<s+n;l++)if(c[l]){var u=yield $e(c[l].id);i.push(u)}}return i}))}var We=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Ke=new Map;function Xe(e,t){return We(this,void 0,void 0,(function*(){let n=j();if(Ke.has(e+t))return Ke.get(e+t)||n;const r=(()=>We(this,void 0,void 0,(function*(){try{var r=yield Y("application/x-www-form-urlencoded");const i=yield v(o.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:r,body:`character_value=${e}&category_id=${t}`});if(i.ok){let e=yield i.json();n=e,K.AddConcept(n)}else console.log("This is the concept by category and character direct api error",i.status),ee(i);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,e,t,o.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,o.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{Ke.delete(e+t)}})))();return Ke.set(e+t,r),r}))}var qe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ze(e){return qe(this,void 0,void 0,(function*(){let t=j();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var r=z(e);if(r.length>1){let n=1,o=yield ze(r[0]);0!=o.id&&(n=o.id),t=yield function(e,t){return qe(this,void 0,void 0,(function*(){let n=yield K.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield Xe(e,t)),n}))}(e,n)}else r[0]==e&&1==n?t=yield function(e){return qe(this,void 0,void 0,(function*(){var t=yield K.GetConceptByCharacterAndTypeLocal(e,49);return 0==t.id&&(t=yield Fe(e)),t}))}(e):r[0]==e&&(t=yield function(e){return qe(this,void 0,void 0,(function*(){var t=yield K.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Fe(e)),t}))}(e));return t}))}var Je=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Ye=new Map,Qe=new Map;function Ze(e,t){return Je(this,void 0,void 0,(function*(){let t=j();if(Qe.has(e))return Qe.get(e);if(Ye.has(e))return Ye.get(e)||t;const n=(()=>Je(this,void 0,void 0,(function*(){try{if(t=yield ze(e),0==t.id||4==t.typeId){var n=yield Y("application/x-www-form-urlencoded");const r=yield v(o.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!r.ok)throw ee(r),new Error(`Error! status: ${r.status}`);let i=yield r.json();t=i,t.id>0&&K.AddConcept(t)}return t.id>0&&Qe.set(e,t),t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{Ye.delete(e)}})))();return Ye.set(e,n),n}))}var et=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let tt=!1,nt=[];const rt=()=>{nt.length>0&&!tt&&nt.shift()()};function ot(e){return et(this,void 0,void 0,(function*(){return new Promise(((t,n)=>{nt.push((()=>et(this,void 0,void 0,(function*(){try{if(tt)return;if(tt=!0,!e&&ht.connectionIds.length>10)return tt=!1,rt(),t();const n=e?`${o.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(e)}).toString()}`:o.GetReservedConnectionIdUrl();var r=yield Y("application/x-www-form-urlencoded");const c=yield v(n,{method:"GET",headers:r});if(!c.ok)throw ee(c),new Error(`Error! status: ${c.status}`);const s=yield c.json();for(var i=0;i<s.length;i++)ht.AddId(s[i]);t()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),n(e)}finally{tt=!1,rt()}})))),rt()}))}))}var it=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let ct=!1,st=[];const at=()=>{st.length>0&&!ct&&st.shift()()};function lt(){return it(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{st.push((()=>it(this,void 0,void 0,(function*(){try{if(ct)return;if(ct=!0,dt.ids.length>10)return ct=!1,at(),e();var n=yield Y("application/x-www-form-urlencoded");const t=yield v(o.GetReservedIdUrl(),{method:"GET",headers:n});if(!t.ok)throw ee(t),new Error(`Error! status: ${t.status}`);const i=yield t.json();for(var r=0;r<i.length;r++)dt.AddId(i[r]);e()}catch(e){t(e)}finally{ct=!1,at()}})))),at()}))}))}var ut=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class dt{static getId(){return ut(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ut(this,void 0,void 0,(function*(){try{yield lt()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((e=>console.error("Reserved ID refill failed:",e))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ut(this,void 0,void 0,(function*(){try{yield lt()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.ids.includes(e)&&this.ids.push(e)}}dt.ids=[],dt.pendingFetch=null;class ht{static getId(){return ut(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ut(this,void 0,void 0,(function*(){try{yield ot()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ut(this,void 0,void 0,(function*(){try{yield ot()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.connectionIds.includes(e)&&this.connectionIds.push(e)}static warmUp(e){return ut(this,void 0,void 0,(function*(){const t=e-this.connectionIds.length;t<=0||(this.pendingFetch||(this.pendingFetch=(()=>ut(this,void 0,void 0,(function*(){try{yield ot(t)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}ht.connectionIds=[],ht.pendingFetch=null;function ft(e){return{id:e.id,userId:e.userId,characterValue:e.characterValue,typeId:e.typeId,categoryId:e.categoryId,accessId:e.accessId,referentId:e.referentId,sessionInformationId:e.sessionInformationId}}function pt(e){return t=this,n=void 0,i=function*(){let t=j();try{var n=yield Y();const r=function(e){return Array.isArray(e)?e.map((e=>ft(e))):ft(e)}(e),i=yield g(o.CreateTheConceptUrl(),n,r);if(!i.ok)throw te(i),new Error(`Error! status: ${i.status}`);return t=yield i.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,o){function c(e){try{a(i.next(e))}catch(e){o(e)}}function s(e){try{a(i.throw(e))}catch(e){o(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((i=i.apply(t,n||[])).next())}));var t,n,r,i}function yt(e){return t=this,n=void 0,i=function*(){let t=new oe(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=yield Y();const r=function(e){return e.map((e=>function(e){return{id:e.id,ofTheConceptId:e.ofTheConceptId,toTheConceptId:e.toTheConceptId,ofTheConceptUserId:e.ofTheConceptUserId,toTheConceptUserId:e.toTheConceptUserId,typeId:e.typeId,userId:e.userId,orderId:e.orderId,accessId:e.accessId,sessionInformationId:e.sessionInformationId}}(e)))}(e),i=yield g(o.CreateTheConnectionUrl(),n,r);if(!i.ok)throw console.log("Create the connection error message: ",i),te(i),new Error(`Error! status: ${i.status}`);return t=yield i.json(),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,o){function c(e){try{a(i.next(e))}catch(e){o(e)}}function s(e){try{a(i.throw(e))}catch(e){o(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((i=i.apply(t,n||[])).next())}));var t,n,r,i}var vt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function gt(e){return e?`[SyncData:${e}]`:"[SyncData]"}function mt(e,t){console.log(`${gt(t)} ${e}`)}function Ct(e,t,n,r,o){r<100&&n!==r||n!==r&&1!==n&&n%100!=0||console.log(`${gt(o)} ${e} ${t}: ${n}/${r} done, ${r-n} remaining`)}class wt{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(e){return vt(this,void 0,void 0,(function*(){try{let t=[],n=[];if(e&&this.transactionCollections.some((t=>t.id==e))){const r=this.transactionCollections.find((t=>t.id==e));if(this.transactionCollections=this.transactionCollections.filter((t=>t.id==e||new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!r)return;t=r.data.concepts.slice(),n=r.data.connections.slice(),mt(`starting online sync with ${t.length} concepts and ${n.length} connections`,e),t.length>0&&(mt(`sending ${t.length} concepts to backend`,e),yield pt(t),Ct("synced","concepts",t.length,t.length,e)),n.length>0&&(mt(`sending ${n.length} connections to backend`,e),yield yt(n),Ct("synced","connections",n.length,n.length,e)),this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e)),mt("online sync complete",e)}else{const e=this.conceptsSyncArray.length,r=this.connectionSyncArray.length;mt(`starting online sync with ${e} queued concepts and ${r} queued connections`);for(let t=0;t<this.conceptsSyncArray.length;t++)K.AddConcept(this.conceptsSyncArray[t]),Ct("prepared local cache for","concepts",t+1,e);for(let e=0;e<this.connectionSyncArray.length;e++)de.AddConnection(this.connectionSyncArray[e]),Ct("prepared local cache for","connections",e+1,r);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),mt(`sending ${t.length} concepts to backend`),yield pt(t),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.some((t=>t.id===e.id)))),Ct("synced","concepts",t.length,t.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),mt(`sending ${n.length} connections to backend`),yield yt(n),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!n.some((t=>t.id===e.id)))),Ct("synced","connections",n.length,n.length)),mt(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return vt(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections.push({id:e,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(e){console.log("error in initializeTransaction",e)}}))}static markTransactionActions(e,t){return vt(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==e?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(t))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.concepts.some((t=>t.id==e.id||t.ghostId==e.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!t.connections.some((t=>t.id==e.id||t.ghostId==e.id))))}catch(e){console.log("error in markTransactionActions",e)}}))}static rollbackTransaction(e,t){return vt(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e))}catch(e){console.log("LocalSyncData, roll",e)}}))}static syncDataLocalDb(){return vt(this,void 0,void 0,(function*(){if(mt(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const e=this.conceptsSyncArray.length;for(let t=0;t<this.conceptsSyncArray.length;t++)x("localconcept",this.conceptsSyncArray[t]),Ct("stored locally","concepts",t+1,e);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const e=this.connectionSyncArray.length;for(let t=0;t<this.connectionSyncArray.length;t++)x("localconnection",this.connectionSyncArray[t]),Ct("stored locally","connections",t+1,e);this.connectionSyncArray=[]}return mt("local sync complete"),"done"}))}}function Tt(e,t){const n=Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${t} must be a positive finite number. Received ${JSON.stringify(e)}.`);return n}function It(e){return e||(i.DEFAULT_USER_ID?i.DEFAULT_USER_ID:999)}wt.conceptsSyncArray=[],wt.connectionSyncArray=[],wt.transactionCollections=[];var Nt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function At(e,t,n,r,o,i,c){return Nt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999,u={concepts:[],connections:[]}){const d=function(e,t){const n=Tt(e,"ofTheConceptId"),r=Tt(t,"toTheConceptId");if(n===r)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:r}}(e,n);e=d.ofTheConceptId,n=d.toTheConceptId;let h=t,f=t,p=t;999!=l&&(p=l);let y=t,v=t,g=yield ht.getId(),m=new oe(g,e,n,t,r,p,o,f,s,h,0,y,a,v,i,c);return m.toUpdate=!0,m.isTemp=!1,wt.AddConnection(m),u.connections.push(m),m}))}function Et(e,t,n){return Nt(this,arguments,void 0,(function*(e,t,n,r={concepts:[],connections:[]}){let o=It(e.userId),i=yield Ze(n);return yield At(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,o,r)}))}var St=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const kt=new Map;function Rt(e,t){return St(this,void 0,void 0,(function*(){let n=yield K.GetConceptByCharacterAndTypeLocal(e,t),r=e+t;if(kt.has(r))return kt.get(r)||n;const i=(()=>St(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var i={character_value:`${e}`,type_id:t},c=JSON.stringify(i),s=yield Y();const r=yield v(o.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:s,body:c});if(r.ok){let e=yield r.json();n=e,K.AddConcept(n)}else console.log("This is the concept by type and character error",r.status),ee(r)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{kt.delete(r)}})))();return kt.set(r,i),i}))}function xt(e){return St(this,void 0,void 0,(function*(){let t=[],n=JSON.stringify(e);var r=yield Y();const i=yield v(o.GetConceptConnectionByType(),{method:"POST",headers:r,body:n});if(i.ok){let e=yield i.json();t=yield fe(e)}else console.log("This is the concept by type and character error",i.status),ee(i);return t}))}var bt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $t(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return bt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield dt.getId();let v=new Date,g=new Date;var m=new G(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!0,v,g);return m.isTemp=!1,wt.AddConcept(m),p.concepts.push(m),m}))}function Lt(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return bt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield dt.getId();let v=new Date,g=new Date;var m=new G(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!1,v,g);return K.AddConcept(m),m.updateRecursion=!0,wt.AddConcept(m),p.concepts.push(m),m}))}var _t=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Pt(e,t){return _t(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0,s={concepts:[],connections:[]}){let a,l=i,u=r=It(r),d=r,h=o,f=r,p=e.startsWith("the_")?e:"the_"+e,y=j();return n?(y=yield Ze(e),a=yield $t(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s)):(y=yield Ze(p),a=yield Rt(t,y.id),0==a.id&&0==a.userId&&(a=yield Lt(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s))),a.type=y,a}))}var Ot=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ut(e){return Ot(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null){var s=null!=o?o:999,a=null!=i?i:4,l=null!=c?c:999,u=null!=r?r:0,d=j();for(const r in e)if("string"!=typeof e[r]&&"number"!=typeof e[r])if(null==t&&null==n){var h=u;d=y=yield Pt(r,"",!0,s,a,l),h=y.id,u=y.id,yield Ut(e[r],y.id,y.userId,h,o,i,c)}else{var f=null!=t?t:999,p=null!=n?n:999;h=u,d=y=yield Pt(r,"",!0,s,a,l),yield At(f,p,y.id,y.userId,h,l,y.userId),yield Ut(e[r],y.id,y.userId,h,o,i,c)}else{f=null!=t?t:999,p=null!=n?n:10267,h=u;var y=yield Pt(r,e[r].toString(),!1,s,a,l);yield At(f,p,y.id,y.userId,h,l,y.userId)}return d}))}var Bt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Dt(e,t,n){return Bt(this,arguments,void 0,(function*(e,t,n,r=10,i=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("ofTheConceptId",`${t}`),s.append("userId",`${n}`),s.append("inpage",`${r}`),s.append("page",`${i}`);var a=yield Y("application/x-www-form-urlencoded");const l=yield v(o.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),ee(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Ft=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Gt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},jt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Vt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Mt(e){return Vt(this,void 0,void 0,(function*(){var t=yield de.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return jt(this,void 0,void 0,(function*(){var t=yield de.GetConnection(e);try{if(0!=t.id)return t;{var n=yield Y("application/x-www-form-urlencoded");const r=yield v(o.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return r.ok?(t=yield r.json(),de.AddConnection(t)):(console.log("Get Connection Error",r.status),ee(r)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var Ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Wt(e){return Ht(this,arguments,void 0,(function*(e,t=""){let n=!1;var r=yield Mt(e);return n=yield function(e){return Gt(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield Q("",t),i=yield{Authorization:r.Authorization,Accept:"application/json"};const c=new URLSearchParams;c.append("id",e.toString()),c.append("apiKey","nodeserver");const s=yield v(o.DeleteTheConnectionUrl(),{method:"POST",headers:i,body:c,redirect:"follow"});s.ok?n=(yield s.json()).success:(console.log("Delete connection error status: ",s.status),ee(s))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),L("connection",e),se.removeNodeFromTree(e),le.removeTypeConcept(r.typeId,e),n}))}function Kt(e){return Ht(this,void 0,void 0,(function*(){let t=yield function(e){return Ft(this,void 0,void 0,(function*(){let t=!1;try{let n=yield Q();const r=yield v(o.DeleteTheConnectionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});r.ok?t=(yield r.json()).success:(console.log("Delete connection Bulk Api error status: ",r.status),ee(r))}catch(e){e instanceof Error?console.log("Delete connection Bulk Api error message: ",e.message):console.log("Delete connection Bulk Api unexpected error: ",e)}return t}))}(e);if(t)for(let t=0;t<e.length;t++){let n=e[t];n>0&&se.removeNodeFromTree(n)}return t}))}var Xt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function qt(e){return Xt(this,arguments,void 0,(function*(e,t=999){var n=j();if(e<0)return lo(yield Yr(t,e));if(null!=(n=yield K.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield Ne(e)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var r=yield K.GetConcept(n.typeId);if(0!=r.id)n.type=r;else{var o=yield Ne(n.typeId);0!=o.id&&(n.type=o)}}return n}))}var zt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Jt=999,Yt=4,Qt=999,Zt=999,en=1e3;function tn(e){const t=`${null!=e?e:""}`.trim();if(0===t.length)throw new Error("Cannot create a typed connection without a linker name.");return t}function nn(e,t){return zt(this,void 0,void 0,(function*(){var n,r,o;if(null==e||null==e.id||0===e.id)throw new Error(`Cannot create a typed connection: ${t} must be a persisted concept.`);const i=e.type;if(null===(n=null==i?void 0:i.characterValue)||void 0===n?void 0:n.trim())return i.characterValue.trim();const c=(yield qt(e.id,e.userId)).type;if(null===(r=null==c?void 0:c.characterValue)||void 0===r?void 0:r.trim())return e.type=c,c.characterValue.trim();if(null!=e.typeId&&0!==e.typeId){const t=yield qt(e.typeId,e.typeUserId);if(0!==t.id&&(null===(o=t.characterValue)||void 0===o?void 0:o.trim()))return e.type=t,t.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${t} concept ${e.id} has no resolvable type.`)}))}function rn(e){return zt(this,void 0,void 0,(function*(){return yield Pt("connection",e,!1,Jt,Jt,Qt)}))}function on(e,t,n){return zt(this,void 0,void 0,(function*(){return yield At(e.id,e.userId,t.id,t.userId,n.id,Qt,Zt,en,Yt)}))}function cn(e,t,n){return zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){const i=tn(n),c=e.userId;if(r){const n=yield function(e,t){return zt(this,void 0,void 0,(function*(){return`${yield nn(e,"toTheConcept")}_s_${t}_by`}))}(t,i);o&&(yield an(`${i}_by`,t,c));const r=yield rn(n);yield on(t,e,r)}const s=yield function(e,t){return zt(this,void 0,void 0,(function*(){return`${yield nn(e,"ofTheConcept")}_s_${t}_s`}))}(e,i);o&&(yield an(`${i}_s`,e,c));const a=yield rn(s);return yield on(e,t,a)}))}function sn(e,t,n){return zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield cn(e,t,n,r,o)}))}function an(e,t){return zt(this,arguments,void 0,(function*(e,t,n=null){for(var r=t,o=null!=n?n:t.userId,i=999,c=tn(e)+"_count",s=(yield nn(t,"concept"))+"_s_"+c,a=yield Pt("connection",s,!1,o,4,i),l=yield Dt(a.id,t.id,o,10,1),u=[],d=j(),h=0;h<l.length;h++){let e=yield qt(l[h].toTheConceptId);u.push(e)}if(u.length<1)d=yield Pt("count","1",!1,o,4,i);else{var f=u[0];let e=Number(f.characterValue),t=Number.isFinite(e)?e+1:1;d=yield Pt("count",t.toString(),!1,o,4,i);for(let e=0;e<l.length;e++)yield Wt(l[e].id)}yield At(r.id,r.userId,d.id,d.userId,a.id,i,Zt,en,4,o)}))}function ln(e,t,n){return zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield cn(e,t,n,r,o)}))}var un=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function dn(e){return encodeURIComponent(String(e))}function hn(e,t){return un(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),i=999){const c="number"==typeof e?e:e.id,s="number"==typeof e?n:e.userId,a=yield Y("application/x-www-form-urlencoded"),l=[`character_value=${dn(t)}`,`type_id=${dn(c)}`,`type_user_id=${dn(s)}`,`access_id=${dn(r)}`,`session_information_id=${dn(i)}`].join("&"),u=yield v(o.CreateTypeConceptUrl(),{method:"POST",headers:a,body:l});if(!u.ok)throw ee(u),new Error(`Error! status: ${u.status}`);const d=yield u.json();return"number"!=typeof e&&(d.type=e),K.AddConcept(d),d}))}var fn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function pn(e,t){return fn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield qt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield Rt(s,16);if(a.id>0){for(var l=yield Dt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(yield we(u),d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield qt(e),n=yield Le(t.id);i.push(n)}}return i}))}function yn(e,t){return fn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield qt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield Rt(s,16);if(a.id>0){for(var l=yield Dt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield qt(e);i.push(t)}}return i}))}class vn{constructor(e,t,n,r,o,i,c,s=!1,a,l,u,d=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=r,this.characterValue=i,this.accessId=o,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=u,this.applicationId=d}getType(){console.log(this.typeId)}}function gn(){let e=new Date,t=new Date;return new vn(0,0,0,0,0,"0","0",!1,e,t,0)}class mn{constructor(e,t,n,r,o,i,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=r,this.accessId=o,this.accessUserId=i,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class Cn{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new mn(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}Cn.characterData=[];class wn{constructor(e,t,n,r){this.id=e,this.userId=t,this.referentId=n,this.isNew=r}}var Tn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},In=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Nn(e,t,n,r,i){return In(this,void 0,void 0,(function*(){return new mn(t,e,n,t,r,t,i,t,"",!1),yield function(){return Tn(this,void 0,void 0,(function*(){var e;try{if(0==(e=Cn.GetCharacter(e.data)).id){var t=yield Y();const r=yield v(o.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!r.ok)throw ee(r),new Error(`Error! status: ${r.status}`);const i=yield r.json();var n=new mn(i.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=i.id,Cn.AddCharacter(n),i}return new wn(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var An=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function En(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return An(this,void 0,void 0,(function*(){var p=yield Rt(e,o),y=p;return 0==y.id&&(y=p=yield $t(e,t,n,r,o,i,c,s,a,l,u,d,h,f)),y}))}var Sn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},kn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Rn(e,t,n,r){return kn(this,arguments,void 0,(function*(e,t,n,r,o={concepts:[],connections:[]}){var i=yield je(e);if(i&&(0==i.id||0==i.userId)){var c=z(e);if(c.length>0)if(c[0]==e){var s=yield function(e,t,n,r,o,i){return Sn(this,void 0,void 0,(function*(){var o,c=t,s=t;o=t;var a,l=t,u=t,d=t;if(1==e.length){var h=e.charCodeAt(0);yield Nn(e,t,n,r,i),a=yield En(e,t,4,c,49,l,h,d,n,s,r,o,i,u)}else{var f=yield Nn(e,t,n,r,i);f.isNew,a=yield En(e,t,4,c,51,l,f.id,f.userId,n,s,r,o,i,u)}return a}))}(e,r,999,999,0,t);i=s}else{var a=yield Rn(c[0],t,n,r,o),l=yield Rn(c[1],t,n,r,o);l&&(i=yield Lt(e,r,a.id,r,l.id,r,999,r,999,r,999,r,t,r,o))}}return i}))}var xn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function bn(e){return xn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield Y("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield v(`${o.GetAllLinkerConnectionOfConceptUrl()}?${c.toString()}`,{method:"GET",headers:n});if(s.ok){const e=yield s.json();for(var r=0;r<e.length;r++){var i=e[r];t.push(i)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),ee(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var $n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ln(e){return $n(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield Y("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield v(`${o.GetAllLinkerConnectionToConceptUrl()}?${c.toString()}`,{method:"GET",headers:n});if(s.ok){const e=yield s.json();for(var r=0;r<e.length;r++){var i=e[r];t.push(i)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),ee(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var _n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Pn(e){return _n(this,void 0,void 0,(function*(){for(var t=yield bn(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield qt(r);e.type=o}return t}))}function On(e){return _n(this,void 0,void 0,(function*(){for(var t=yield Ln(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield qt(r);e.type=o}return t}))}var Un=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Bn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},Dn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Fn(e){return Dn(this,arguments,void 0,(function*(e,t=""){var n=yield qt(e);yield F.removeNodeFromTree(e);var r=n.typeId,i=n.characterValue;yield H.removeTypeConcept(r,e),yield B.removeNodeByCharacter(i,e),L("concept",e);let c=yield function(e){return Un(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield yield Q("application/x-www-form-urlencoded",t);const i=new FormData;i.append("id",e.toString()),i.append("apiKey","nodeserver");const{"Content-Type":c}=r,s=Bn(r,["Content-Type"]),a=yield v(o.DeleteConceptUrl(),{method:"POST",headers:s,body:i});if(!a.ok)throw ee(a),new Error(`Error! status: ${a.status}`);n=(yield a.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t);return c}))}var Gn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function jn(e,t){return Gn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const r=new FormData;r.append("id",e.toString());const i=yield v(o.DeleteConceptUrl(),{method:"POST",body:r,headers:n});if(!i.ok)throw ee(i),new Error(`Delete composition Error! status: ${i.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var Vn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Mn(e,t,n,r){return Vn(this,arguments,void 0,(function*(e,t,n,r,o=999){var i,c=n,s=n,a=n,l=e.startsWith("the_"),u=j();return i=l?e:"the_"+e,u=yield Ze(i),yield En(t,n,4,n,u.id,u.userId,0,999,999,c,r,a,o,s)}))}class Hn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var Wn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Kn(){return Wn(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield de.GetConnection(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{var r=yield Y();const e=yield A("/api/get_connection_bulk",{method:"POST",headers:r,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let r=n[e];t.push(r),de.AddConnection(r)}yield ye(t)}}else console.log("Get Connection Bulk error",e.status),ee(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var Xn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function qn(){return Xn(this,arguments,void 0,(function*(e=[]){yield we(e);var t=[];for(let r=0;r<e.length;r++){var n=yield be(e[r]);t.push(n)}return t}))}function zn(){return Xn(this,arguments,void 0,(function*(e=[]){yield we(e);var t=[];for(let r=0;r<e.length;r++){var n=yield $e(e[r]);t.push(n)}return t}))}function Jn(){return Xn(this,arguments,void 0,(function*(e=[],t=[]){yield Kn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||de.RemoveConnection(t[n])}(t,yield ge(e));var n=[];for(let t=0;t<e.length;t++){var r=yield $e(e[t]);n.push(r)}return n}))}function Yn(){return Xn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],r={};for(let r=0;r<(null==e?void 0:e.length);r++){let o=yield de.GetConnection(e[r]);0==o.id?t.push(e[r]):n.push(o)}for(let n=0;n<t.length;n++)r[e[n]]=!1;let o=[],i=yield Kn(t);n=[...n,...i];for(let e=0;e<n.length;e++)o.push(n[e].ofTheConceptId),o.push(n[e].toTheConceptId),o.push(n[e].typeId);return yield fe(o),n}))}function Qn(){return Xn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],r=[];for(let e=0;e<t.length;e++){let o=yield de.GetConnection(t[e]);0==o.id?n.push(t[e]):r.push(o)}let o=yield Kn(n);for(let e=0;e<o.length;e++)r.push(o[e]);let i={},c=[];for(var s=0;s<r.length;s++)c.includes(r[s].ofTheConceptId)||c.push(r[s].ofTheConceptId);for(let t=0;t<e.length;t++){let n=yield Pe(e[t],r,c);i[e[t]]=n}return i}))}var Zn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function er(){return Zn(this,arguments,void 0,(function*(e=0,t=[],n="",r=[]){var i=[];try{var c=new Hn;c.composition=e,c.listLinkers=t,c.textSearch=n,c.fullLinkers=r;var s=JSON.stringify(c),a=yield Y();const d=yield v(o.RecursiveSearchUrl(),{method:"POST",headers:a,body:s});if(d.ok){const e=yield d.json();var l=e.compositionIds,u=e.internalConnections;e.externalConnections,i=yield Jn(l,u)}else console.log("recursive search error ",d.status),ee(d);return i}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var tr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function nr(e,t){return tr(this,void 0,void 0,(function*(){try{var n={email:e,password:t},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(n);const s=yield v(o.LoginUrl(),{method:"POST",headers:r,body:c});if(s.ok){const e=yield s.json();return i.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",s.status),ee(s)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var rr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function or(e){return rr(this,void 0,void 0,(function*(){const t=yield function(){return rr(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const r=yield v(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),o=yield r.json();return r.ok?n={message:"success",status:!0,statusCode:200,data:o}:ee(r),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(o.SignupUrl(),e);return t}))}var ir=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function cr(e){return ir(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const r=new Headers;r.append("Content-Type","application/json");const i=o.LoginUrl();try{const e=yield v(i,{method:"POST",headers:r,body:t,redirect:"follow"}),o=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==o?void 0:o.data}:ee(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function sr(e,t){return-1===e.indexOf(t)&&e.push(t),e}function ar(e=[],t){var n,r;let o=[],i=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==i?void 0:i.startsWith("the_"))||(i="the_"+i),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(r=e[n].type)||void 0===r?void 0:r.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&i!=c||o.push(e[n])}return o}function lr(e=[],t){let n=[];if(Array.isArray(e)){const r=e.find((e=>e.toTheConceptId==t));r&&n.push(r);const o=e.find((e=>e.ofTheConceptId==t));o&&n.push(o)}return n}function ur(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function dr(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class hr{constructor(e,t,n,r){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(pr.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var fr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class pr{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new hr(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return fr(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return fr(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}pr.root=null;var yr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function vr(e,t,n,r){return yr(this,arguments,void 0,(function*(e,t,n,r,o=[]){var i,c;let s={};const a=[];if(0==e)return"";let l=gr(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield qt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=gr(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield qt(e),l.type=t)}if(!r.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const u=t[l].toTheConceptId;if(r.includes(e)){let e=gr(n,u);if(null!=e&&0!=e.id||null==u||null==u||(e=yield qt(u)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield K.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield qt(t),e.type=n)}const l="the_",d=(null!==(c=null===(i=null==e?void 0:e.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const e=yield vr(u,t,n,r,o);s[d]=e}}else{const e=yield vr(u,t,n,r,o);a[d]=e,s=a}}}return s}))}function gr(e,t){let n=j();for(let r=0;r<e.length;r++)if(t==e[r].id)return n=e[r],n;return n}class mr{constructor(){this.id=0,this.mainConcept=j(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,r=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield vr(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),o.MQTT_CONNECTION&&o.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const r={};r[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const o={};return o.data=r,o.id=this.id,o}}var Cr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function wr(e){return Cr(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null,s=null){const a=null!=o?o:999,l=null!=i?i:4,u=null!=c?c:999;let d=null!=r?r:0,h=j();null==s&&(s=new mr);for(const r in e)if("object"==typeof e[r]||Array.isArray(e[r])){const f=yield Pt(r,"",!0,a,l,u);if(null==t&&null==n){let t=d;h=f,t=f.id,d=f.id,s.concepts.push(f),s.id=f.id,yield wr(e[r],f.id,f.userId,t,o,i,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,p=d;h=f,s.concepts.push(f);const y=yield At(a,l,f.id,f.userId,p,u,f.userId);s.connections.push(y),yield wr(e[r],f.id,f.userId,p,o,i,c,s)}null!=e[r]&&null!=e[r]&&s.subcompositions.push(f.id)}else{const o=null!=t?t:999,i=null!=n?n:999,c=d,h=yield Pt(r,e[r],!1,a,l,u);s.concepts.push(h);const f=yield At(o,i,h.id,h.userId,c,u,h.userId);s.connections.push(f)}return h}))}var Tr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ir(e){return Tr(this,void 0,void 0,(function*(){try{const t=yield Y(),n=yield v(o.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw console.log("GetConnectionsBetweenApi error status: ",n.status),ee(n),new Error(`GetConnectionsBetweenApi error: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("GetConnectionsBetweenApi error message: ",e.message):console.log("GetConnectionsBetweenApi unexpected error: ",e),e}}))}function Nr(e){var t,n,r,o,i,c,s;return{ofTheConceptId:null!==(t=e.ofTheConceptId)&&void 0!==t?t:0,toTheConceptId:null!==(n=e.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(r=e.typeId)&&void 0!==r?r:0,type:null!==(o=e.type)&&void 0!==o?o:"",oldType:null!==(i=e.oldType)&&void 0!==i?i:"",reverse:null!==(c=e.reverse)&&void 0!==c&&c,isComposition:null!==(s=e.isComposition)&&void 0!==s&&s,connectionIds:[]}}var Ar=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Er{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return Ar(this,void 0,void 0,(function*(){yield wt.initializeTransaction(this.transactionId)}))}markAction(){return Ar(this,void 0,void 0,(function*(){yield wt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Ar(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield wt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Ar(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield wt.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Kt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return Ar(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return Ar(this,arguments,void 0,(function*(e,t=[]){try{if(!this.success)throw Error("Query Transaction Expired");const n=[...t];if(e.length>0){const t=e.map(Nr),r=yield Ir(t);for(const e of r)n.push(...e.connectionIds)}return this.pendingConnectionDeletions.push(...n),n}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return Ar(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield Pt(e,t,n,r,o,i,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTypeConcept(e,t){return Ar(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),o=999){try{if(!this.success)throw Error("Query Transaction Expired");return yield hn(e,t,n,r,o)}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return Ar(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const r=yield Et(e,t,n,this.actions);return yield this.markAction(),r}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheTypeConcept(e,t,n,r){return Ar(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Rn(e,t,n,r,this.actions);return yield this.markAction(),o}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,r,o,i,c){return Ar(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const u=yield At(e,t,n,r,o,i,c,s,a,l,this.actions);return yield this.markAction(),u}catch(e){throw console.log(e),this.success=!1,e}}))}}var Sr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function kr(e){return Sr(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,r=e.accessId;let o=[];const i=[];let c=j(),s=j();const a=[];let l=e.compositionId;const u=e.ofTheCompositionId;let d=[];if(l<0){let e=yield qt(l,t);if(!(e.id>0))return null;l=e.id}const h=new Er;yield h.initialize();try{o=yield Ee(l);const f=[],p=new mr,y=[];p.id=l,p.isUpdating();let v=[];for(let e=0;e<o.length;e++)sr(y,o[e].ofTheConceptId),sr(f,o[e].ofTheConceptId),sr(f,o[e].toTheConceptId),v.push(o[e].ofTheConceptId);p.subcompositions=y,p.connections=o;for(let e=0;e<f.length;e++){const t=yield qt(f[e]);l==f[e]&&(c=t),u==f[e]&&(s=t),i.push(t)}const g=e.patchObject;for(const e in g){let o=j();const l=g[e];let u=c;if(s.id>0&&(u=s),Array.isArray(l)||"object"==typeof l){o=yield h.MakeTheInstanceConcept(e,"",!0,c.userId,4,999),p.subcompositions.push(o.id);const t=ar(i,o);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=lr(p.connections,t[e].id);d=d.concat(n),a.push(t[e])}yield wr(g[e],o.id,o.userId,c.id,c.userId,4,999,p)}else{o=yield h.MakeTheInstanceConcept(e,l,!1,t,r,n);const c=ar(i,o);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=lr(p.connections,c[e].id);d=d.concat(t),a.push(c[e])}}const f=yield h.CreateTheConnectionGeneral(u.id,u.userId,o.id,o.userId,c.id,n,t);i.push(o),p.connections.push(f)}for(let e=0;e<d.length;e++)dr(p.connections,d[e]);d.length>0&&(yield h.DeleteConnectionsBetweenBulk([],d.map((e=>e.id))));for(let e=0;e<a.length;e++)ur(i,a[e]);return p.concepts=p.concepts.concat(i),p.mainConcept=c,p.id=c.id,yield h.commitTransaction(),yield p.updateCache(),pr.addCompositionToTree(p),p.GetDataCache()}catch(e){throw yield h.rollbackTransaction(),e}}))}var Rr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function xr(e,t,n,r){return Rr(this,arguments,void 0,(function*(e,t,n,r,i=10,c=1){var s=yield Q("application/x-www-form-urlencoded",r),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",n),a.append("inpage",i.toString()),a.append("page",c.toString());const l=o.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield v(l,{method:"GET",headers:s});if(e.ok)return yield e.json();ee(e)}catch(e){throw e}}))}var br=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $r(e){return br(this,arguments,void 0,(function*(e,t=""){var n=yield Q("application/json",t);const r=o.SearchLinkMultipleAll(),i=JSON.stringify(e);try{const e=yield v(r,{method:"POST",headers:n,body:i});if(e.ok)return yield e.json();ee(e)}catch(e){throw e}}))}var Lr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function _r(e){return Lr(this,arguments,void 0,(function*(e,t=[]){var n,r;let o=[];const i=[];let c={},s={};const a=[];let l=yield K.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield Ne(e));let u=[];u=t.length>0?Pr(e,t):yield Ee(e),o=u;for(let e=0;e<o.length;e++)a.includes(o[e].ofTheConceptId)||(a.push(o[e].ofTheConceptId),i.push(o[e].ofTheConceptId)),i.includes(o[e].toTheConceptId)||i.push(o[e].toTheConceptId);return s=yield Ue(e,o,a,[]),c[null!==(r=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,0==l.id?"":c}))}function Pr(e,t){const n=[];for(let r=0;r<t.length;r++)t[r].typeId==e&&n.push(t[r]);return n}function Or(e){return Lr(this,arguments,void 0,(function*(e,t=[]){var n,r;let o={},i=[];const c=[];let s;const a={},l=[];let u=yield K.GetConcept(e);0==u.id&&null!=e&&null!=e&&(u=yield Ne(e));let d=[];d=t.length>0?Pr(e,t):yield Ee(e),i=d;for(let e=0;e<i.length;e++)l.includes(i[e].ofTheConceptId)||(l.push(i[e].ofTheConceptId),c.push(i[e].ofTheConceptId)),c.includes(i[e].toTheConceptId)||c.push(i[e].toTheConceptId);return s=yield Ue(e,i,l),a[null!==(r=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,o.created_at=u.entryTimeStamp,o.data=a,o.id=e,0==u.id?"":o}))}function Ur(e,t){return Lr(this,void 0,void 0,(function*(){let n=[];const r=[];n=yield Kn(t);for(let t=0;t<e.length;t++){const o=yield Or(e[t],n);o&&r.push(o)}return r}))}var Br=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Dr(e){return Br(this,void 0,void 0,(function*(){try{var t=yield Y();const n=JSON.stringify(e),r=yield v(o.CreateSessionId(),{method:"POST",headers:t,body:n});return r.ok?r.json():(console.log("Creating session failed",yield r.json()),ee(r),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Fr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Gr(e,t){return Fr(this,void 0,void 0,(function*(){try{var n=yield Y("application/x-www-form-urlencoded");const r=new URLSearchParams;r.append("sessionId",e.toString()),r.append("url",t);const i=yield v(o.CreateSessionVisitUrl(),{method:"POST",headers:n,body:r});return i.ok?i.json():(console.log("Creating session url failed",yield i.json()),ee(i),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var jr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Vr(e,t,n){return jr(this,arguments,void 0,(function*(e,t,n,r=10,i=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("toTheConceptId",`${t}`),s.append("userId",`${n}`),s.append("inpage",`${r}`),s.append("page",`${i}`);var a=yield Y("application/x-www-form-urlencoded");const l=yield v(o.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),ee(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Mr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Hr(e,t){return Mr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield qt(e),s=yield ze(t);if(s.id>0){let e=[],t=[];if(o){t=yield Vr(s.id,c.id,c.userId,n,r);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield we(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,r=yield qt(n),o=yield Le(r.id);i.push(o)}}else{t=yield Dt(s.id,c.id,c.userId,n,r);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield we(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,r=yield qt(n),o=yield Le(r.id);i.push(o)}}}return i}))}function Wr(e,t){return Mr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield qt(e),s=yield ze(t),a=[],l=[];if(s.id>0){if(o){a=yield Vr(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield Dt(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}i=yield fe(l)}return i}))}class Kr{constructor(e,t,n){this.value=new Map,this.connectionValue=new Map,this.key=e,t.id>0&&this.value.set(t.ghostId,t),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Xr{constructor(e=0,t,n,r,o,i,c=999){this.isTemp=!1,this.applicationId=999,this.type=gn(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=r,this.ghostId=e,this.orderId=o,this.typeCharacter="",this.accessId=i,this.entryTimeStamp=V(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var qr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class zr{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return qr(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isDataLoaded)return e("done");setTimeout(zr.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.value.set(e.ghostId,e):this.nodeMap.set(r,new Kr(r,e,new Xr(0,0,0,0,0,0)))}static addConnectionToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.connectionValue.set(e.ghostId,e):this.nodeMap.set(r,new Kr(r,gn(),e))}static getNodeFromTree(e,t){return qr(this,arguments,void 0,(function*(e,t,n=999){var r;const o=this.compositeKey(e,t,n);return null!==(r=this.nodeMap.get(o))&&void 0!==r?r:null}))}static removeNodeFromTree(e){return qr(this,arguments,void 0,(function*(e,t=999,n=999){const r=this.compositeKey(e,t,n);this.nodeMap.delete(r)}))}static countNumberOfNodes(){return this.nodeMap.size}}zr.nodeMap=new Map;var Jr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Yr(e,t){return Jr(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield zr.getNodeFromTree(e,n,r),c=gn();return i&&(c=null!==(o=i.value.get(t))&&void 0!==o?o:c),c}))}function Qr(e,t){return Jr(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield zr.getNodeFromTree(e,n,r),c=new Xr(0,0,0,0,0,0);return i&&(c=null!==(o=i.connectionValue.get(t))&&void 0!==o?o:c),c}))}function Zr(e,t){return Jr(this,arguments,void 0,(function*(e,t,n=999){zr.addConceptToTree(e,t,n)}))}function eo(e,t){return Jr(this,arguments,void 0,(function*(e,t,n=999){zr.addConnectionToTree(e,t,n)}))}var to=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function no(e){return to(this,arguments,void 0,(function*(e,t=""){var n=yield Q("application/json",t);const r=o.SearchLinkMultipleAllApiUrl(),i=JSON.stringify(e);try{const e=yield v(r,{method:"POST",headers:n,body:i});if(e.ok)return yield e.json();ee(e)}catch(e){throw e}}))}var ro=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function oo(e){return ro(this,arguments,void 0,(function*(e,t=""){let n=[],r=yield no(e,t),o=e[0].composition;const i=r;let c=i.compositionIds,s=i.internalConnections,a=i.linkers,l=i.reverse;return n=yield Qn(c,s),yield io(a,n,o,l)}))}function io(e,t,n){return ro(this,arguments,void 0,(function*(e,t,n,r=[]){let o={},i=yield Kn(e);for(let e=0;e<i.length;e++){let n=!1;if(r.includes(i[e].id)&&(n=!0),1==n){if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].toTheConceptId],r=yield qt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{let n=r.characterValue+"_reverse";"string"==typeof o&&(o={}),Array.isArray(o[c][n])||("string"==typeof o[c]&&(o[c]={}),o[c][n]=[]),o[c][n].push(t[i[e].ofTheConceptId])}catch(e){}}}else if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].ofTheConceptId],r=yield qt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{"string"==typeof o&&(o={}),Array.isArray(o[c][r.characterValue])||("string"==typeof o[c]&&(o[c]={}),o[c][r.characterValue]=[]),o[c][r.characterValue].push(t[i[e].toTheConceptId])}catch(e){}}}return o=t[n],o}))}var co=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},so=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ao(e){return so(this,void 0,void 0,(function*(){var t;let n=yield function(e){return co(this,void 0,void 0,(function*(){let t=[];try{var n=yield Y();const r=yield v(o.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(r.ok){let e=yield r.json(),n={};for(let r=0;r<e.length;r++){let o=e[r].concepts;t=e[r].connections;let i=e[r].id;yield fe(o),n[i]=t}return n}return console.log("View Internal Data error",r.status),ee(r),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),r=[];for(let o=0;o<e.length;o++){let i=e[o],c=n[i];if(i&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield Ue(i,c,e);t.data=n,t.id=i,r.push(t)}else{let e={};e.id=i;let n=yield qt(i),o={};n.type&&(o[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=o,r.push(e))}}return r}))}function lo(e){const t=j();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}var uo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},ho=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function fo(e){return ho(this,arguments,void 0,(function*(e,t=""){var n=yield function(e){return uo(this,arguments,void 0,(function*(e,t=""){var n,r,i,c,s,a,l=yield Q("application/json",t);const u=new URLSearchParams({composition:String(null!==(n=e.composition)&&void 0!==n?n:""),search:String(null!==(r=e.search)&&void 0!==r?r:""),internalComposition:String(null!==(i=e.internalComposition)&&void 0!==i?i:""),type:String(null!==(c=e.type)&&void 0!==c?c:""),inpage:String(null!==(s=e.inpage)&&void 0!==s?s:""),page:String(null!==(a=e.page)&&void 0!==a?a:"")}),d=`${o.SearchInternalWithAuthenticatedCcsUrl()}?${u.toString()}`;try{const e=yield v(d,{method:"GET",headers:l});if(e.ok)return yield e.json();ee(e)}catch(e){throw e}}))}(e,t);return yield ao(n)}))}var po=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function yo(e,t){return po(this,void 0,void 0,(function*(){let n=!0,r=yield bn(e),o=yield xt(t),i=[];for(let e=0;e<r.length;e++)for(let t=0;t<o.length;t++)r[e].typeId==o[t].id&&i.push(r[e].id);for(let e=0;e<i.length;e++){let t=yield Wt(i[e]);n=n&&t}return n}))}function vo(e,t){return po(this,void 0,void 0,(function*(){let n=yield bn(e),r=yield xt(t),o=[];for(let e=0;e<n.length;e++)for(let t=0;t<r.length;t++)n[e].typeId==r[t].id&&o.push(n[e].id);return o}))}class go{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class mo{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class Co{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class wo{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}function To(e){if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()));if("string"!=typeof e)return[];const t=e.trim();if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()))}catch(e){}return t.split(",").map((e=>e.trim())).filter(Boolean)}class Io{constructor(e){var t;this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],this.accessToken="",this.enableAi=!0,this.enableAccessControl=!1,e&&(Object.assign(this,e),this.cacheServers=To(null!==(t=e.cacheServers)&&void 0!==t?t:e.cache_servers),this.cacheServerUrl=e.cacheServerUrl||e.cacheServer||this.cacheServerUrl)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(e,t=!1){var n,r;return null!==(r=null===(n=this.flags)||void 0===n?void 0:n[e])&&void 0!==r?r:t}getParameter(e,t=""){var n,r;return null!==(r=null===(n=this.parameters)||void 0===n?void 0:n[e])&&void 0!==r?r:t}setFlag(e,t){this.flags||(this.flags={}),this.flags[e]=t}setParameter(e,t){this.parameters||(this.parameters={}),this.parameters[e]=t}}var No=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Ao{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),(0!=e.id||e.isTemp)&&x("localconnection",e),this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return No(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isLocalConnectionLoaded)return e("done");setTimeout(Ao.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return No(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}Ao.connectionArray=[],Ao.connectionDictionary=[];var Eo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function So(){return Eo(this,void 0,void 0,(function*(){yield function(){return Eo(this,void 0,void 0,(function*(){var e=yield $("connection");if(Array.isArray(e))for(var t=0;t<e.length;t++)de.AddConnectionToMemory(e[t])}))}()}))}function ko(){return Eo(this,void 0,void 0,(function*(){yield function(){return Eo(this,void 0,void 0,(function*(){var e=yield _("localconnection");if(Array.isArray(e))for(var t=0;t<e.length;t++)Ao.AddConnection(e[t])}))}()}))}class Ro{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var xo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class bo{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new Ro(e.id,e,null,null);new Ro(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return xo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isLocalDataLoaded)return e("done");setTimeout(bo.checkFlag,1e3,e)}static getNodeFromTree(e){return xo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return xo(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}bo.root=null;var $o=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Lo{static waitForDataToLoad(){return $o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isLocalCharacterLoaded)return e("done");setTimeout(Lo.checkFlag,1e3,e)}static addNodeToTree(e){return $o(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new Ro(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return $o(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}Lo.LocalCharacterRoot=null;var _o=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Po{static addNodeToTree(e){return _o(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new Ro(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return _o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(P.isLocalTypeLoaded)return e("done");setTimeout(Po.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return _o(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}Po.LocalTypeRoot=null;var Oo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Uo{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(x("localconcept",e),bo.addConceptToTree(e),Lo.addConceptToTree(e),Po.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(bo.addConceptToTree(e),Lo.addConceptToTree(e),Po.addConceptToTree(e))}static GetConcept(e){return Oo(this,void 0,void 0,(function*(){var t=gn(),n=yield bo.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return Oo(this,void 0,void 0,(function*(){var t=gn(),n=Lo.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Oo(this,void 0,void 0,(function*(){var n=gn(),r=yield Lo.getCharacterAndTypeFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return Oo(this,void 0,void 0,(function*(){let n=[];return n=yield Po.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Uo.localconceptsArray=[];var Bo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Do(){return Bo(this,void 0,void 0,(function*(){var e=yield _("localconcept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Uo.AddConceptToMemory(n)}}))}var Fo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Go{}Go.isUpdated=!1,Go.isOnlineSync=!1;var jo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Vo{constructor(){this.accessCache=new Map,this.accessIndex=new Map,this.entityIndex=new Map,this.setCounter=0}generateKey(e,t,n){return`${e}:${t.toLowerCase()}:${null!=n?n:0}`}get(e,t,n){const r=this.generateKey(e,t,n),o=this.accessCache.get(r);return void 0===o?null:Date.now()>o.expiresAt?(this.accessCache.delete(r),null):o.value}set(e,t,n,r){const o=this.generateKey(e,t,n);this.accessCache.set(o,{value:r,expiresAt:Date.now()+3e5}),this.accessIndex.has(e)||this.accessIndex.set(e,new Set),this.accessIndex.get(e).add(o);const i=null!=n?n:0;this.entityIndex.has(i)||this.entityIndex.set(i,new Set),this.entityIndex.get(i).add(o),this.setCounter++,this.setCounter>=100&&(this.setCounter=0,this.sweepExpired())}remove(e,t,n){const r=this.generateKey(e,t,n);this.accessCache.delete(r);const o=this.accessIndex.get(e);o&&o.delete(r);const i=null!=n?n:0,c=this.entityIndex.get(i);c&&c.delete(r)}clear(){this.accessCache.clear(),this.accessIndex.clear(),this.entityIndex.clear(),this.setCounter=0}sweepExpired(){const e=Date.now();for(const[t,n]of this.accessCache)if(e>n.expiresAt){this.accessCache.delete(t);const e=t.split(":"),n=parseInt(e[0]),r=parseInt(e[2]),o=this.accessIndex.get(n);o&&(o.delete(t),0===o.size&&this.accessIndex.delete(n));const i=this.entityIndex.get(r);i&&(i.delete(t),0===i.size&&this.entityIndex.delete(r))}for(const[t,n]of Vo.superAdminCache)e>n.expiresAt&&Vo.superAdminCache.delete(t)}getPermissionsByAccessAndEntity(e,t){const n=new Map,r=this.accessIndex.get(e),o=Date.now();if(r){const e=null!=t?t:0;for(const t of r){const r=this.accessCache.get(t);if(r&&o<=r.expiresAt){const o=t.split(":");parseInt(o[2])===e&&n.set(o[1],r.value)}}}return n}getPermissionsByAccess(e){const t=new Map,n=this.accessIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[2]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getPermissionsByEntity(e){const t=new Map,n=this.entityIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[0]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getSuperAdmin(e){const t=Vo.superAdminCache.get(e);return void 0===t?null:Date.now()>t.expiresAt?(Vo.superAdminCache.delete(e),null):t.value}setSuperAdmin(e,t){Vo.superAdminCache.set(e,{value:t,expiresAt:Date.now()+6e5})}clearSuperAdminCache(){Vo.superAdminCache.clear()}}Vo.superAdminCache=new Map;var Mo,Ho=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Wo{constructor(e){if(this.baseUrl=e||process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("Access Control base URL is not configured")}getAsync(e){return Ho(this,void 0,void 0,(function*(){const t=yield fetch(`${this.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`GET '${e}' failed with status ${t.status}`);const n=yield t.json();if(null==n)throw new Error(`The response for GET '${e}' returned null.`);return n}))}postAsync(e,t){return Ho(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST '${e}' failed with status ${n.status}`);const r=yield n.json();if(null==r)throw new Error(`The response for POST '${e}' returned null.`);return r}))}deleteAsync(e,t){return Ho(this,void 0,void 0,(function*(){const n={method:"DELETE",headers:{"Content-Type":"application/json"}};null!=t&&(n.body=JSON.stringify(t));const r=yield fetch(`${this.baseUrl}/${e}`,n);if(!r.ok)throw new Error(`DELETE '${e}' failed with status ${r.status}`);const o=yield r.json();if(null==o)throw new Error(`The response for DELETE '${e}' returned null.`);return o}))}assignAccessAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/assign",e)}))}checkAccessAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/check",e)}))}revokeAccessAsync(e){return Ho(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke",e)}))}assignAccessBulkAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/assign/bulk",e)}))}revokeAccessBulkAsync(e){return Ho(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke/bulk",e)}))}checkAccessBulkAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/check/bulk",e)}))}getAccessByIdAsync(e){return Ho(this,void 0,void 0,(function*(){return this.getAsync(`access/${e}`)}))}setAccessInheritanceAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance",e)}))}getAccessInheritanceStatusAsync(e){return Ho(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/status?accessId=${e}&connectionTypeId=${t}`)}))}assignSuperAdminAccessAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin",e)}))}revokeSuperAdminAccessAsync(e){return Ho(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin",e)}))}checkSuperAdminStatusAsync(e){return Ho(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin?accessId=${e}`)}))}setParentAccessInheritanceAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent",e)}))}removeParentAccessInheritanceAsync(e,t){return Ho(this,void 0,void 0,(function*(){let n=`access/inheritance/parent?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.deleteAsync(n)}))}hasParentAccessInheritanceAsync(e,t){return Ho(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/status?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.getAsync(n)}))}getParentAccessIdAsync(e){return Ho(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent?accessId=${e}`)}))}setParentAccessInheritanceByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept",e)}))}setParentAccessInheritanceBulkByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept/bulk",e)}))}removeParentAccessInheritanceByConceptAsync(e,t){return Ho(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.deleteAsync(n)}))}removeParentAccessInheritanceBulkByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.deleteAsync("access/inheritance/parent/concept/bulk",e)}))}hasParentAccessInheritanceByConceptAsync(e,t){return Ho(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept/status?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.getAsync(n)}))}getParentAccessIdByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent/concept?childConceptId=${e}`)}))}assignSuperAdminByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin/concept",e)}))}revokeSuperAdminByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin/concept",e)}))}checkSuperAdminByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin/concept?conceptId=${e}`)}))}setAccessInheritanceByConceptAsync(e){return Ho(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/concept",e)}))}getAccessInheritanceStatusByConceptAsync(e){return Ho(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/concept/status?conceptId=${e}&connectionTypeId=${t}`)}))}}!function(e){e[e.None=0]="None",e[e.Read=1]="Read",e[e.Write=2]="Write",e[e.Execute=4]="Execute",e[e.Delete=8]="Delete"}(Mo||(Mo={}));var Ko=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Xo{static initialize(){console.log("AccessControlService initialized with access control disabled by default.")}static setEnabled(e){this.isAccessControlEnabled=e}static getEnabled(){return this.isAccessControlEnabled}static setBaseUrl(e){this.apiClient=new Wo(e)}static checkAccess(e,t,n){return Ko(this,void 0,void 0,(function*(){var r;if(t===Mo.None)throw new Error("Permission is required");return null!==(r=(yield this.checkAccessBulk([e],t,n)).get(e))&&void 0!==r&&r}))}static checkAccessBulk(e,t,n){return Ko(this,void 0,void 0,(function*(){var r,i,c,s,a,l;if(t===Mo.None)throw new Error("Permission is required");const u=this.permissionSetToString(t),d=new Map;if(!e||0===e.length)return d;if(!this.isAccessControlEnabled){for(const t of e)d.set(t,!0);return d}if(null!=n&&n>0)try{if(yield this.isSuperAdmin(n)){for(const t of e)d.set(t,!0);return d}}catch(e){}const h=[],f=new Set,p=new Map;let y=null;if(null!=n&&n>0)try{y=yield qt(n)}catch(e){}let g=0;try{const e=yield function(){return e=this,t=void 0,r=function*(){let e=j();try{var t=yield Y("application/x-www-form-urlencoded");const n=yield v(o.GetConceptByCharacterAndCategoryUrl(),{method:"POST",headers:t,body:"character_value=the_parent_access_inheritance"});return n.ok?(e=yield n.json(),K.AddConcept(e)):(console.log("This is the concept by category and character error",n.status),ee(n)),e}catch(e){throw e instanceof Error?console.log(" This is the concept by category and character error message: ",e.message):console.log(" This is the concept by category and character unexpected error: ",e),e}},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}();e&&e.id&&(g=e.id)}catch(e){}const m=yield fe(e),C=new Map;for(const e of m)C.set(e.id,e);const w=new Map;for(const t of e){const e=null!==(r=C.get(t))&&void 0!==r?r:yield qt(t);if(!e||0===e.id){d.set(t,!1);continue}const n=null!==(i=e.accessId)&&void 0!==i?i:0,o=null!==(c=e.typeId)&&void 0!==c?c:0;if(y&&y.userId&&y.userId===e.userId){d.set(t,!0);continue}if(n<1e4){d.set(t,!0);continue}let a=0;if(o>0){let e=w.get(o);if(!e)try{e=yield qt(o),w.set(o,e)}catch(e){}e&&(a=null!==(s=e.accessId)&&void 0!==s?s:0)}h.push({conceptId:t,accessId:n,typeAccessId:a}),n>0&&(f.add(n),p.set(n,t)),a>0&&f.add(a)}if(0===h.length)return d;const T=yield this.resolveBulkInheritanceGraph(f,g,p),I=[],N=new Set;for(const e of T.values())for(const t of e)N.has(t)||(N.add(t),I.push(t));const A=yield this.resolveSubjects(n),E=yield this.resolveBulkDecisions(I,u,A);for(const e of h){const t=null!==(a=T.get(e.accessId))&&void 0!==a?a:[e.accessId],n=e.typeAccessId>0?null!==(l=T.get(e.typeAccessId))&&void 0!==l?l:[e.typeAccessId]:[],r=this.hasAnyGrant(t,n,A,E);d.set(e.conceptId,r)}return d}))}static getConceptIdsWithPermission(e,t,n){return Ko(this,void 0,void 0,(function*(){if(e===Mo.None)throw new Error("Permission is required");if(!t||0===t.length)return[];if(!this.isAccessControlEnabled)return t;const r=yield this.checkAccessBulk(t,e,n);return t.filter((e=>!0===r.get(e)))}))}static resolveBulkInheritanceGraph(e,t,n){return Ko(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Set;let c=new Set(e),s=0;for(;c.size>0;){if(s>=10){console.warn("[AccessControl] BFS depth limit (10) reached. Stopping inheritance traversal.");break}s++;const e=new Set;for(const e of c)i.add(e);const a=Array.from(c);if(t>0)for(const t of a)try{const n=yield vo(t,["the_parent_access_inheritance"]);if(n&&n.length>0){const r=yield Kn(n);for(const n of r){const r=n.toTheConceptId;r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}}catch(e){}for(const t of a)try{const n=yield this.apiClient.getParentAccessIdAsync(t);if(!0===(null==n?void 0:n.status)&&void 0!==n.data&&null!==n.data){const r=this.parseIntData(n);null!==r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}catch(e){}for(const c of a)try{const s=yield this.apiClient.getAccessInheritanceStatusAsync(c);if(!this.parseBoolData(s))continue;const a=n.get(c);if(!a||0===a)continue;const l=yield bn(a);if(!l||0===l.length)continue;for(const s of l){if(s.ofTheConceptId!==a)continue;if(t>0&&s.typeId!==t)continue;const l=s.toTheConceptId;if(l&&0!==l)try{const t=yield qt(l),s=null!==(r=null==t?void 0:t.accessId)&&void 0!==r?r:0;s>0&&!i.has(s)&&(o.has(c)||o.set(c,[]),o.get(c).push(s),n.set(s,l),e.add(s))}catch(e){}}}catch(e){}for(const t of i)e.delete(t);c=e}const a=new Map;for(const t of e){const e=[t],n=new Set([t]),r=[t];for(;r.length>0&&e.length<100;){const t=r.shift(),i=o.get(t);if(i)for(const t of i)n.has(t)||(n.add(t),e.push(t),r.push(t))}a.set(t,e)}return a}))}static resolveBulkDecisions(e,t,n){return Ko(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Map;for(let r=0;r<n.length;r++){const c=n[r];for(const n of e){const e=this.cacheService.get(n,t,c),s=`${n}:${null!=c?c:0}`;null!==e?o.set(s,e):(i.has(r)||i.set(r,[]),i.get(r).push(n))}}for(const[e,c]of i){if(0===c.length)continue;const i=n[e];try{const e={accessIds:c,permission:t,entityId:i},n=yield this.apiClient.checkAccessBulkAsync(e);if(!0===(null==n?void 0:n.status)&&n.data&&Array.isArray(n.data)){const e=new Map;for(const t of n.data)e.set(t.accessId,t.hasAccess);for(const n of c){const c=null!==(r=e.get(n))&&void 0!==r&&r;this.cacheService.set(n,t,i,c),o.set(`${n}:${null!=i?i:0}`,c)}}else for(const e of c)this.cacheService.set(e,t,i,!1),o.set(`${e}:${null!=i?i:0}`,!1)}catch(e){for(const e of c)o.set(`${e}:${null!=i?i:0}`,!1)}}return o}))}static resolveSubjects(e){return Ko(this,void 0,void 0,(function*(){const t=[null];if(null!=e&&e>0){t.push(e);try{const n=yield vo(e,["the_entity_s_group"]);if(n&&n.length>0){const e=yield Kn(n);for(const n of e)n.toTheConceptId&&n.toTheConceptId>0&&t.push(n.toTheConceptId)}}catch(e){}}return t}))}static hasAnyGrant(e,t,n,r){for(const t of e)for(const e of n){const n=`${t}:${null!=e?e:0}`;if(!0===r.get(n))return!0}for(const e of t)for(const t of n){const n=`${e}:${null!=t?t:0}`;if(!0===r.get(n))return!0}return!1}static assignAccess(e,t,n){return Ko(this,void 0,void 0,(function*(){var r;if(t===Mo.None)throw new Error("Permission is required");try{const o=null!==(r=(yield qt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t),c=yield this.apiClient.assignAccessAsync({accessId:o,permission:i,entityId:n});if(!0===(null==c?void 0:c.status)&&c.data){const e=c.data;return this.cacheService.set(e.accessId,e.permission,e.entityId,e.hasAccess),!0}return!1}catch(r){throw new Error(`Error assigning access for conceptId ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static assignAccessBulk(e){return Ko(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{const n=yield this.apiClient.assignAccessBulkAsync(e);if(!0!==(null==n?void 0:n.status))throw new Error((null==n?void 0:n.message)||"Failed to assign bulk access");const r=[];for(const n of e.targets)for(const o of n.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,n.entityId,!0),r.push({accessId:i,permission:o,entityId:n.entityId,hasAccess:!0})}return r}catch(e){throw console.error("Failed to assign bulk access:",e),e}}))}static revokeAccess(e,t,n){return Ko(this,void 0,void 0,(function*(){var r;try{const o=null!==(r=(yield qt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t);if(0===o)throw new Error(`Concept with ID ${e} does not have a valid accessId`);const c=yield this.apiClient.revokeAccessAsync({accessId:o,permission:i,entityId:n}),s=!0===(null==c?void 0:c.status);return this.cacheService.set(o,i,n,!s),s}catch(r){throw new Error(`Error revoking access for concept ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static revokeAccessBulk(e){return Ko(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{yield this.apiClient.revokeAccessBulkAsync(e);const n=[];for(const r of e.targets)for(const o of r.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,r.entityId,!1),n.push({accessId:i,permission:o,entityId:r.entityId,hasAccess:!1})}return n}catch(e){throw console.error("Failed to revoke bulk access:",e),e}}))}static setAccessInheritance(e){return Ko(this,void 0,void 0,(function*(){var t;try{const n=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,connectionTypeId:999});return null!==(t=null==n?void 0:n.status)&&void 0!==t&&t}catch(t){throw new Error(`Error setting access inheritance for conceptId ${e}: ${t}`)}}))}static getAccessInheritanceStatus(e){return Ko(this,arguments,void 0,(function*(e,t=999){try{const n=yield this.apiClient.getAccessInheritanceStatusByConceptAsync(e,t);return this.parseBoolData(n)}catch(n){throw new Error(`Error getting access inheritance status for conceptId ${e}, connectionTypeId ${t}: ${n}`)}}))}static setAccessInheritanceStatus(e,t){return Ko(this,arguments,void 0,(function*(e,t,n=999){var r;try{const o=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,enable:t,connectionTypeId:n});return null!==(r=null==o?void 0:o.status)&&void 0!==r&&r}catch(t){throw new Error(`Error setting access inheritance status for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritance(e,t){return Ko(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceByConceptAsync({parentConceptId:t,childConceptId:e});if(!0===(null==n?void 0:n.status)){const e=this.parseIntData(n);if(null!==e&&e>0)return e}return 0}catch(t){throw new Error(`Error setting parent access inheritance for conceptId ${e}: ${t}`)}}))}static removeParentAccessInheritance(e,t){return Ko(this,void 0,void 0,(function*(){var n;try{const r=yield this.apiClient.removeParentAccessInheritanceByConceptAsync(e,t);return null!==(n=null==r?void 0:r.message)&&void 0!==n?n:"Parent access inheritance removal failed"}catch(t){throw new Error(`Error removing parent access inheritance for conceptId ${e}: ${t}`)}}))}static hasParentAccessInheritance(e,t){return Ko(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.hasParentAccessInheritanceByConceptAsync(e,t);return this.parseBoolData(n)}catch(t){throw new Error(`Error checking parent access inheritance for conceptId ${e}: ${t}`)}}))}static getParentAccessId(e){return Ko(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.getParentAccessIdByConceptAsync(e);return this.parseIntData(t)}catch(t){throw new Error(`Error getting parent access ID for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritanceBulk(e,t){return Ko(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceBulkByConceptAsync({parentConceptId:t,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error setting bulk parent access inheritance for parentConceptId ${t}: ${e}`)}}))}static removeParentAccessInheritanceBulk(e,t){return Ko(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.removeParentAccessInheritanceBulkByConceptAsync({parentConceptId:null!=t?t:0,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error removing bulk parent access inheritance: ${e}`)}}))}static isSuperAdmin(e){return Ko(this,void 0,void 0,(function*(){try{if(0===e)return!1;const t=this.cacheService.getSuperAdmin(e);if(null!==t)return t;const n=yield this.apiClient.checkSuperAdminByConceptAsync(e);if(!0===(null==n?void 0:n.status)&&void 0!==n.data){const t=this.parseBoolData(n);return this.cacheService.setSuperAdmin(e,t),t}return!1}catch(t){throw new Error(`Error checking super admin status for entityId ${e}: ${t}`)}}))}static assignSuperAdmin(e){return Ko(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.assignSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&void 0!==t.data?(this.cacheService.setSuperAdmin(e,!0),e):0}catch(t){throw new Error(`Failed to assign super admin for entityId ${e}: ${t}`)}}))}static revokeSuperAdmin(e){return Ko(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.revokeSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&t.message?(this.cacheService.setSuperAdmin(e,!1),t.message):"Super admin access deletion failed"}catch(t){throw new Error(`Failed to revoke super admin for entityId ${e}: ${t}`)}}))}static parseBoolData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return!1;const t=e.data;if("boolean"==typeof t)return t;if("string"==typeof t)return"true"===t.toLowerCase();if("number"==typeof t)return 0!==t;if("object"==typeof t)for(const e of["enabled","Enabled","isEnabled","IsEnabled","status","Status","hasAccess","HasAccess"])if(e in t){const n=t[e];if("boolean"==typeof n)return n;if("string"==typeof n)return"true"===n.toLowerCase()}return!1}static parseIntData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return null;const t=e.data;if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?null:e}if("object"==typeof t)for(const e of["id","Id","accessId","AccessId","parentAccessId","ParentAccessId"])if(e in t){const n=t[e];if("number"==typeof n)return n;if("string"==typeof n){const e=parseInt(n,10);if(!isNaN(e))return e}}return null}static permissionSetToString(e){return function(e){const t=[];return e&Mo.Read&&t.push("read"),e&Mo.Write&&t.push("write"),e&Mo.Execute&&t.push("execute"),e&Mo.Delete&&t.push("delete"),t}(e)[0]||"read"}static clearCache(){this.cacheService.clear()}static clearSuperAdminCache(){this.cacheService.clearSuperAdminCache()}static updateAccessCache(e,t,n,r){this.cacheService.set(e,t,n,r)}static updateSuperAdminCache(e,t){this.cacheService.setSuperAdmin(e,t)}}Xo.cacheService=new Vo,Xo.apiClient=new Wo,Xo.isAccessControlEnabled=!1,Xo.initialize();var qo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const zo=1,Jo=2,Yo=3,Qo=4,Zo=5,ei=6,ti=7,ni=8;class ri{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var oi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ii(e){return oi(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let r=yield Ne(e[n].connectionTypeId);e[n].connectionType=r.characterValue,t[e[n].conceptId]||(t[e[n].conceptId]=[]),t[e[n].conceptId].push(e[n])}return t}))}function ci(e){const t=e.split("_");if(3===t.length){let e=new ri;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function si(e){return e.startsWith("the_")?e.slice(4):e}var ai=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function li(e,t,n){if(e in t){const r=Array.isArray(t[e])?t[e]:[t[e]];for(const e of r)e&&(n[e.connectionType+"_count"]=e.count)}}var ui=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},di=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function hi(e,t,n){return di(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield qt(e[d].ofTheConceptId),p=yield qt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield qt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;a.characterValue,a.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield qt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;o.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}var fi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function pi(e,t="DESC"){return"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var yi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};var vi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function gi(e,t){return vi(this,void 0,void 0,(function*(){let n=e.outputFormat;e.outputFormat=ei;let r,i=yield function(e){return qo(this,arguments,void 0,(function*(e,t=""){var n=yield Q("application/json",t);const r=o.FreeschemaQueryUrl(),i=JSON.stringify(e);try{const e=yield v(r,{method:"POST",headers:n,body:i});if(e.ok)return yield e.json();ee(e)}catch(e){!function(e,t=""){if(e.status){let n=new Z(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new Z(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,r)}}))}(e,t),c=i.conceptIds,s=(i.internalConnections,i.linkers),a=i.reverse,l=i.mainCompositionIds,u=i.countinfo,d=e.order,h=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let r=ci(e[n]);t.push(r)}return t}(u);return r=n==Jo?yield function(e,t,n,r,o){return yi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield Yn(e),s=yield ii(o);c=pi(c,i);let a=[];a=yield function(e,t){return ui(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield qt(e[d].ofTheConceptId),p=yield qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(s.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;r.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}(c,a,r),a=yield function(e,t){return ui(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield qt(e[d].ofTheConceptId),p=yield qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=si(r));let o={id:f.id,data:{[e]:t}},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=r.characterValue,c=!1;""==i&&(i=e,i=si(i),c=!0);let s={id:p.id,data:{[e]:t}};isNaN(Number(i))?i.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i]=s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(s))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n,r){return ui(this,arguments,void 0,(function*(e,t,n,r,o=[],i){var c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let r=!1,f=yield qt(e[n].ofTheConceptId),p=yield qt(e[n].toTheConceptId);if(o.includes(e[n].id)&&(r=!0),1==r){if(0!=f.id&&0!=p.id&&p.id in t){let r,o=yield qt(e[n].typeId),a=null!==(s=null===(c=p.type)||void 0===c?void 0:c.characterValue)&&void 0!==s?s:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[a]&&(r[a]={})):(r={},r[a]={},t[e[n].toTheConceptId]=r),li(p.id,i,r);try{if(t[e[n].ofTheConceptId]){let i={id:f.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},c=o.characterValue+"_reverse";Array.isArray(r[a][c])?r[a][c].push(i):c.includes("_s_")?(r[a][c]=[],r[a][c].push(i)):r[a][c]=i}}catch(e){}}}else if(0!=f.id&&0!=p.id&&f.id in t){let r,o=yield qt(e[n].typeId),c=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),li(f.id,i,r);let y=!0,v=o.characterValue;""==v&&(v=p.characterValue,y=!0),""==v&&(v=null!==(d=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==d?d:"");try{null===(h=null==p?void 0:p.type)||void 0===h||h.characterValue;let s=t[e[n].toTheConceptId];if(s){let a={id:p.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(r[c])?r[c].push(s):Array.isArray(r[c][v])?r[c][o.characterValue].push(a):v.includes("_s_")?(r[c][v]=[],r[c][v].push(a)):r[c][v]=a,li(p.id,i,a)}}catch(e){}}}for(let e=0;e<r.length;e++){let n={};n.id=r[e];let o=yield qt(n.id);n.data=t[r[e]],n.created_on=o.entryTimeStamp,f.push(n)}return f}))}(c,a,[],n,r,s);return l}))}(s,c,l,a,h,d):n==Yo?yield function(e,t,n,r,o){return yi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield Yn(e),s=yield ii(o);c=pi(c,i);let a=[];a=yield hi(c,a,r),a=yield function(e,t){return ai(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield qt(e[d].ofTheConceptId),p=yield qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=si(r));let o={id:f.id,[e]:t},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let t=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",i=p.characterValue,c=r.characterValue,s=!1;""==c&&(c=t,c=si(c),s=!0);let a={};a[t]={id:p.id,data:i,created_on:e[d].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][c]=s?a[t]:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(a[t]))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n){return ai(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,p=yield qt(e[n].ofTheConceptId),y=yield qt(e[n].toTheConceptId);if(r.includes(e[n].id)&&(f=!0),1==f){if(0!=p.id&&0!=y.id&&y.id in t){let r,o=yield qt(e[n].typeId),s=null!==(c=null===(i=y.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[s]&&(r[s]={})):(r={},r[s]={},t[e[n].toTheConceptId]=r);try{if(t[e[n].ofTheConceptId]){let i=t[e[n].ofTheConceptId];i&&(i.id=p.id,i.created_on=p.entryTimeStamp);let c=o.characterValue+"_reverse";Array.isArray(r[s][c])?r[s][c].push(i):c.includes("_s_")?(r[s][c]=[],r[s][c].push(i)):r[s][c]=i}}catch(e){}}}else if(0!=p.id&&0!=y.id&&p.id in t){let r,i=yield qt(e[n].typeId),c=null!==(a=null===(s=p.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),li(p.id,o,r);let v=!1,g=i.characterValue;""==g&&(g=y.characterValue,v=!0),""==g&&(g=null!==(u=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let i=null!==(h=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"none",s=t[e[n].toTheConceptId];if(s){let t={};t[i]={data:s[i],id:y.id,created_on:e[n].entryTimeStamp},Array.isArray(r[c])?v?r[c].push(s[g]):r[c].push(s):Array.isArray(r[c][g])?r[c][g].push(t):g.includes("_s_")?(r[c][g]=[],v?r[c][g].push(t[i]):r[c][g].push(t)):r[c][g]=v?t[i]:t,li(y.id,o,t)}}catch(e){}}}for(let e=0;e<n.length;e++){let r={};r=t[n[e]],r&&(r.id=n[e]),f.push(r)}return f}))}(c,a,n,r,s);return l}))}(s,c,l,a,h,d):n==ni?yield function(e,t,n,r,o){return yi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield Yn(e),s=yield ii(o);c=pi(c,i);let a={};a=yield function(e){return fi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield qt(a.ofTheConceptId),u=yield qt(a.toTheConceptId),d=yield qt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(s=d.characterValue)||void 0===s?void 0:s.includes("_s_");t[h.id]||(t[h.id]={}),t[h.id][p]||(t[h.id][p]={}),g&&(t[f.id]||(t[f.id]={}),t[f.id][y]=v)}return t}))}(c,a,r),a=yield function(e){return fi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield qt(a.ofTheConceptId),u=yield qt(a.toTheConceptId),d=yield qt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=d.characterValue)&&void 0!==s?s:"";let m=""===g?si(y):g;const C=m.includes("_s_"),w=!isNaN(Number(m)),T={id:f.id,data:{[y]:v}};t[h.id]||(t[h.id]={}),p in t[h.id]&&"string"!=typeof t[h.id][p]||(t[h.id][p]=w?[]:{});try{if(C)continue;w?t[h.id][p].push(T):t[h.id][p][e?`${m}_reverse`:m]=T}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,r);let l=yield function(e,t,n){return fi(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s;const a=[];for(const n of e){const e=r.includes(n.id),a=yield qt(n.ofTheConceptId),l=yield qt(n.toTheConceptId),u=yield qt(n.typeId);if(0===a.id||0===l.id)continue;const d=e?l:a,h=e?a:l,f=d.id,p=h.id,y=null!==(c=null===(i=d.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",v=u.characterValue+"_reverse",g=u.characterValue||h.characterValue||(null===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const r=t[f][y],i=t[p],c={id:h.id,data:i,created_on:n.entryTimeStamp};li(f,o,t[f]);try{e?Array.isArray(r[v])?r[v].push(c):r[v]=[c]:Array.isArray(r)?r.push(i):Array.isArray(r[g])?r[g].push(c):g.includes("_s_")?(r[g]=[],r[g].push(c)):r[g]=[c],li(p,o,c)}catch(e){console.error("Error processing connection:",e)}}}for(const e of n){const n=yield qt(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,r,s);return l}))}(s,c,l,a,h,d):yield function(e,t,n,r){return yi(this,void 0,void 0,(function*(){let t=yield Yn(e);t=pi(t);let o=[];o=yield hi(t,o,r),o=yield function(e,t,n){return di(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield qt(e[d].ofTheConceptId),p=yield qt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield qt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=a.characterValue;""==r&&(r=e,r=si(r));let o={[e]:t},l=r+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],r in n||(n[r]={})):(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield qt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=o.characterValue,c=(o.characterValue,!1);""==i&&(i=e,i=si(i),c=!0);let s={[e]:t};isNaN(Number(i))?o.characterValue.includes("_s_")||("string"==typeof n[r]&&(n[r]={}),n[r][i]=c?t:s):(Array.isArray(n[r])||(n[r]=[]),n[r].push(t))}catch(e){}}}return t}))}(t,o,r);let i=yield function(){return di(this,arguments,void 0,(function*(e=[],t=[],n=[],r,o=[]){var i,c,s,a,l,u;let d=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let r=!1;o.includes(e[n].id)&&(r=!0);let d=yield qt(e[n].ofTheConceptId),h=yield qt(e[n].toTheConceptId);if(1==r){if(0!=d.id&&0!=h.id&&h.id in t){let r,o=null!==(c=null===(i=h.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?r=t[e[n].toTheConceptId]:(r={},r[o]={},t[e[n].toTheConceptId]=r);let s=yield qt(e[n].typeId);try{let i=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(r[o][i])?r[o][i].push(c):s.characterValue.includes("_s_")?(r[o][i]=[],r[o][i].push(c)):r[o][i]=c)}catch(e){}}}else if(0!=d.id&&0!=h.id&&d.id in t){let r,o=null!==(a=null===(s=d.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[o]&&(r[o]={})):(r={},r[o]={},t[e[n].ofTheConceptId]=r);let i=!1,c=(yield qt(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,i=!0),""==c&&(c=null!==(u=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(r[o])?i?r[o].push(s[c]):r[o].push(s):Array.isArray(r[o][c])?r[o][c].push(s):c.includes("_s_")?(r[o][c]=[],i?r[o][c].push(s[c]):r[o][c].push(s)):r[o][c]=i?s[c]:s)}catch(e){}}}for(let e=0;e<n.length;e++){let r=t[n[e]];r&&(r.id=n[e],d.push(r))}return d}))}(t,o,n,[],r);return i}))}(s,0,l,a),r}))}class mi{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=zo,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var Ci=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function wi(e,t){return Ci(this,arguments,void 0,(function*(e,t,n=!1){let r=[];if(n){let n=yield Ln(e),o=yield Ze(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}else{let n=yield bn(e);for(let e=0;e<n.length;e++)de.AddConnection(n[e]);let o=yield Ze(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}return r}))}function Ti(e,t,n){return Ci(this,arguments,void 0,(function*(e,t,n,r=!1){let o=[],i=[];if(o=r?yield wi(t,n,r):yield wi(e,n,r),r)for(let t=0;t<o.length;t++)o[t].ofTheConceptId==e&&i.push(o[t]);else for(let e=0;e<o.length;e++)o[e].toTheConceptId==t&&i.push(o[e]);return i}))}var Ii=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ni(e=""){i.BearerAccessToken=e}function Ai(){return Ii(this,arguments,void 0,(function*(e="",t="",n="CCSApp",r){var c,s;const l=r||new Io;Xo.setBaseUrl(l.accessControlBaseUrl),Xo.setEnabled(l.enableAccessControl),o.BASE_URL=e,o.AI_URL=l.aiUrl,t&&(o.NODE_URL=t);const u=l.cacheServers.length>0?l.cacheServers:To(null!==(s=null===(c=l.parameters)||void 0===c?void 0:c.cacheServers)&&void 0!==s?s:l.getParameter("cacheServers",""));o.setCacheServers(u);const d=l.cacheServerUrl||l.getParameter("cacheServerUrl","");if(d?o.setNodeCacheUrl(d):0===u.length&&o.setNodeCacheUrl(""),l.hasOAuthCredentials()){const e=l.applicationName||n;i.setOAuthCredentials(l.clientId,l.clientSecret,e);const t=yield a(l.clientId,l.clientSecret,e,!0);if(!t.success)throw new Error(`OAuth token request failed: ${t.error||"unknown error"}`)}else l.hasAccessToken()&&(i.BearerAccessToken=l.accessToken);P.isDataLoaded=!1,P.isCharacterLoaded=!1,P.isTypeLoaded=!1,P.isLocalDataLoaded=!1,P.isLocalTypeLoaded=!1,P.isLocalCharacterLoaded=!1,P.isConnectionLoaded=!1,P.isConnectionTypeLoaded=!1,P.isLocalConnectionLoaded=!1,yield function(){return jo(this,void 0,void 0,(function*(){return yield R("settings")[0]||new E(!0),yield function(){return Fo(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([q().then((()=>{P.isDataLoaded=!0,P.isCharacterLoaded=!0,P.isTypeLoaded=!0})),Do().then((()=>{P.isLocalDataLoaded=!0,P.isLocalTypeLoaded=!0,P.isLocalCharacterLoaded=!0})),ko().then((()=>{P.isLocalConnectionLoaded=!0})),So().then((()=>{P.isConnectionLoaded=!0,P.isConnectionTypeLoaded=!0}))])}))}})(),module.exports=r})();
|