mftsccs-node 0.0.62 → 0.0.63
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 +1 -1
- package/dist/bundle.js.map +1 -0
- package/dist/types/Api/GetConnections/GetConnectionsBetweenApi.d.ts +8 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +5 -0
- package/dist/types/DataStructures/FetchConnection.d.ts +21 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +30 -0
- package/dist/types/DataStructures/Transaction/Transaction.d.ts +23 -0
- package/dist/types/Services/AccessControl/AccessControlCacheService.d.ts +19 -0
- package/dist/types/Services/AccessControl/AccessControlService.d.ts +267 -0
- package/dist/types/Services/AccessControl/PermissionSet.d.ts +8 -0
- package/dist/types/Services/Security/GetRequestHeader.d.ts +58 -10
- package/dist/types/Services/auth/AuthService.d.ts +0 -0
- package/dist/types/app.d.ts +4 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ALLID:()=>_i,AddGhostConcept:()=>Jo,AddGhostConnection:()=>Qo,BaseUrl:()=>n,BinaryTree:()=>R,CCSConfig:()=>gi,Composition:()=>go,CompositionBinaryTree:()=>fo,CompositionNode:()=>uo,Concept:()=>_,ConceptsData:()=>F,Connection:()=>$,ConnectionData:()=>X,CreateComposition:()=>Re,CreateConnection:()=>We,CreateConnectionBetweenTwoConcepts:()=>tn,CreateConnectionBetweenTwoConceptsGeneral:()=>nn,CreateDefaultConcept:()=>L,CreateDefaultLConcept:()=>bt,CreateSession:()=>Go,CreateSessionVisit:()=>Vo,CreateTheCompositionLocal:()=>Oe,CreateTheCompositionWithCache:()=>mo,CreateTheConnection:()=>ie,CreateTheConnectionGeneral:()=>je,CreateTheConnectionLocal:()=>Le,DATAID:()=>Ai,DATAIDDATE:()=>Si,DATAV2:()=>Ui,DeleteConceptById:()=>Fn,DeleteConnectionById:()=>Ke,DeleteConnectionByTypeBulk:()=>ui,FilterSearch:()=>pi,FormatFromConnections:()=>Xo,FreeSchemaResponse:()=>b,FreeschemaQuery:()=>Qi,GetAllConnectionsOfComposition:()=>ht,GetAllConnectionsOfCompositionBulk:()=>at,GetAllTheConnectionsByTypeAndOfTheConcept:()=>qi,GetComposition:()=>pt,GetCompositionBulk:()=>Wn,GetCompositionBulkWithDataId:()=>$n,GetCompositionFromConnectionsWithDataId:()=>Jn,GetCompositionFromConnectionsWithDataIdInObject:()=>zn,GetCompositionList:()=>Lt,GetCompositionListLocal:()=>Xt,GetCompositionListLocalWithId:()=>Zt,GetCompositionListWithId:()=>Ut,GetCompositionLocal:()=>Jt,GetCompositionLocalWithId:()=>Qt,GetCompositionWithAllIds:()=>vt,GetCompositionWithCache:()=>So,GetCompositionWithDataIdBulk:()=>Lo,GetCompositionWithDataIdWithCache:()=>_o,GetCompositionWithId:()=>wt,GetCompositionWithIdFromMemory:()=>Ct,GetCompositionWithIdFromMemoryFromConnections:()=>Tt,GetConceptBulk:()=>tt,GetConceptByCharacter:()=>Rt,GetConceptByCharacterAndCategoryDirectApi:()=>Tn,GetConceptByCharacterAndType:()=>se,GetConceptByTypeBulk:()=>le,GetConnectionBulk:()=>Mn,GetConnectionById:()=>ze,GetConnectionByTypeBulk:()=>hi,GetConnectionOfTheConcept:()=>He,GetLink:()=>rn,GetLinkRaw:()=>cn,GetLinkerConnectionFromConcepts:()=>Un,GetLinkerConnectionToConcepts:()=>Gn,GetRelation:()=>Do,GetRelationRaw:()=>Oo,GetTheConcept:()=>Xe,GetUserGhostConnectionId:()=>$o,GetUserGhostId:()=>Wo,GiveConnection:()=>Ki,HandleHttpError:()=>H,HttpResponse:()=>l,JUSTDATA:()=>xi,LConcept:()=>Ot,LConnection:()=>_e,LISTNORMAL:()=>Li,LoginToBackend:()=>Xn,MakeTheInstanceConcept:()=>xe,MakeTheInstanceConceptLocal:()=>Ee,MakeTheTimestamp:()=>On,MakeTheTypeConcept:()=>gn,MakeTheTypeConceptApi:()=>An,NORMAL:()=>ki,PatcherStructure:()=>fi,RAW:()=>Ri,RecursiveSearchApi:()=>Kn,SchemaQueryListener:()=>Ji,SearchAllConcepts:()=>Io,SearchLinkInternal:()=>li,SearchLinkMultipleAll:()=>Yo,SearchLinkMultipleApi:()=>qo,SearchQuery:()=>bn,SearchStructure:()=>vi,SearchWithLinker:()=>Ao,SessionData:()=>yi,Signin:()=>no,Signup:()=>to,SplitStrings:()=>E,SyncData:()=>oe,TokenRefreshError:()=>s,TokenStorage:()=>o,Transaction:()=>Xi,TrashTheConcept:()=>En,UpdateComposition:()=>No,UpdateCompositionLocal:()=>oi,UserBinaryTree:()=>Mo,ViewInternalData:()=>ci,convertFromLConceptToConcept:()=>ti,deleteWithRetry:()=>p,getFromDatabaseWithType:()=>T,getFromDatabaseWithTypeOld:()=>N,getOAuthToken:()=>r,getWithRetry:()=>f,init:()=>tr,patchWithRetry:()=>v,postWithRetry:()=>h,putWithRetry:()=>y,recursiveFetch:()=>It,recursiveFetchNew:()=>po,refreshOAuthToken:()=>c,requestWithRetry:()=>u,storeToDatabase:()=>m,updateAccessToken:()=>Zi});class n{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/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 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 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.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="http://localhost:5001/";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(t,e,n){this.CLIENT_ID=t,this.CLIENT_SECRET=e,this.APPLICATION_NAME=n}}o.BearerAccessToken="",o.CLIENT_ID="",o.CLIENT_SECRET="",o.APPLICATION_NAME="";var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function r(t,e,r,c=!0){return i(this,void 0,void 0,(function*(){try{const i=n.OAuthTokenUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("application_name",r);const s=yield fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(c&&(o.BearerAccessToken=t),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}function c(t,e,r,c=!0){return i(this,void 0,void 0,(function*(){try{const i=n.OAuthRefreshUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("refresh_token",r),a.append("grant_type","refresh_token");const s=yield fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(c&&(o.BearerAccessToken=t),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}var a=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class s extends Error{constructor(t){super(t),this.name="TokenRefreshError"}}class l{constructor(t,e,n){this.status=t,this.body=e,this.headers=n}json(){return a(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return a(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return a(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(t){return console.error("Token refresh failed:",t),!1}}))}function u(t,e,n,i,r=1){var c,u;return a(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},n),o.getAuthHeader());for(let n=0;n<=r;n++)try{const h={method:t,headers:a};void 0!==i&&("object"==typeof i?(a["Content-Type"]||a["content-type"]||(a["Content-Type"]="application/json"),(null===(c=a["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(u=a["content-type"])||void 0===u?void 0:u.includes("application/json"))?h.body=JSON.stringify(i):h.body=i):h.body=i),h.headers=a;const f=yield fetch(e,h),y=yield f.text(),p={};if(f.headers.forEach(((t,e)=>{p[e]=t})),401!==f.status)return new l(f.status,y,p);if(n<r){if(console.log("Received 401 Unauthorized, attempting token refresh..."),yield d()){console.log("Token refreshed successfully, retrying request..."),Object.assign(a,o.getAuthHeader());continue}throw new s("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(t){if(t instanceof s)throw t;if(n>=r)throw t;console.error(`Request failed (attempt ${n+1}/${r+1}):`,t)}throw new Error("Request failed after all retry attempts")}))}function h(t,e,n){return a(this,void 0,void 0,(function*(){return u("POST",t,e,n)}))}function f(t,e,n){return a(this,void 0,void 0,(function*(){let o=t;if(n){const e=[];for(const t in n)n.hasOwnProperty(t)&&e.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(n[t]))}`);e.length>0&&(o=`${t}?${e.join("&")}`)}return u("GET",o,e)}))}function y(t,e,n){return a(this,void 0,void 0,(function*(){return u("PUT",t,e,n)}))}function p(t,e){return a(this,void 0,void 0,(function*(){return u("DELETE",t,e)}))}function v(t,e,n){return a(this,void 0,void 0,(function*(){return u("PATCH",t,e,n)}))}class g{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}var C=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function m(t,e){}function T(t,e,n){return C(this,void 0,void 0,(function*(){}))}function N(t){return C(this,void 0,void 0,(function*(){}))}function w(t){return C(this,void 0,void 0,(function*(){}))}class I{}I.isTypeLoaded=!1,I.isCharacterLoaded=!1,I.isDataLoaded=!1,I.isLocalDataLoaded=!1,I.isLocalCharacterLoaded=!1,I.isLocalTypeLoaded=!1,I.isConnectionLoaded=!1,I.isConnectionTypeLoaded=!1,I.isLocalConnectionLoaded=!1;class k{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getCharacterFromNodeUpdated(t,e){var n;return e?t==e.key||51==(null===(n=e.value)||void 0===n?void 0:n.typeId)?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var A=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class x{static waitForDataToLoad(){return A(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isCharacterLoaded)return t("done");setTimeout(x.checkFlag,1e3,t)}static addNodeToTree(t){return A(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=t,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(t,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(t,e){return A(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new k(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return A(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return A(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}x.characterRoot=null;var S=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class R{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return S(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isDataLoaded)return t("done");setTimeout(R.checkFlag,1e3,t)}static addConceptToTree(t){var e=new k(t.id,t,null,null),n=new k(t.characterValue,t,null,null);x.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return S(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return S(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}R.root=null;class _{constructor(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=t,this.userId=e,this.typeId=n,this.typeUserId=o,this.ghostId=t,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=a,this.characterValue=`${s}`,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 L(){let t=U(new Date),e=U(new Date);return new _(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function U(t){const e=t.getMonth()+1,n=t.getDate(),o=t.getFullYear();let i=t.getHours();const r=t.getMinutes(),c=t.getSeconds(),a=i>=12?"PM":"AM";i%=12,i=i||12;const s=t=>t.toString().padStart(2,"0");return`${e}/${n}/${o} ${i}:${s(r)}:${s(c)} ${a}`}var G=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class P{static addNodeToTree(t){return G(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=t,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(t,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new k(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,t,e))}static getNodeFromTree(t){return this.typeRoot?this.typeRoot.getFromNode(t,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return G(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isTypeLoaded)return t("done");setTimeout(P.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return G(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)if(o.variants[t].value.userId==e){var i=!1;for(let e=0;e<n.length;e++)n[e].id==o.variants[t].value.id&&(i=!0);i||n.push(o.variants[t].value)}}return n}))}static getTypeVariantsWithCharacterValue(t,e){return G(this,void 0,void 0,(function*(){let n=L();var o=this.getNodeFromTree(e);if(o){o.value.characterValue==t&&(n=o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.characterValue==t&&(n=o.variants[e].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}P.typeRoot=null;var V=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class F{constructor(){this.name="conceptsArray"}static CheckContains(t){for(var e=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==t.id&&(e=!0);return e}static AddNpc(t){this.NPC.includes(t)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(t))}static GetNpc(t){return!!this.NPC.includes(t)}static AddConceptToStorage(t){t.id}static AddConcept(t){t.id>0&&(R.addConceptToTree(t),P.addConceptToTree(t),x.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(R.addConceptToTree(t),P.addConceptToTree(t),x.addConceptToTree(t))}static AddConceptTemporary(t){var e=this.CheckContains(t);this.conceptDictionary[t.id]=t,e&&this.RemoveConcept(t),this.conceptsArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsArray.length;e++)this.conceptsArray[e].id==t.id&&this.conceptsArray.splice(e,1);R.removeNodeFromTree(t.id),t.id}static GetConcept(t){return V(this,void 0,void 0,(function*(){var e=L(),n=yield R.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return V(this,void 0,void 0,(function*(){var e=L(),n=x.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return V(this,void 0,void 0,(function*(){var e=L(),n=x.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return V(this,void 0,void 0,(function*(){return L(),yield P.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return V(this,void 0,void 0,(function*(){var n=L(),o=yield x.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return V(this,void 0,void 0,(function*(){let n=[];return n=yield P.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return x.characterRoot}getName(){return this.name}}F.conceptsArray=[],F.NPC=[],F.conceptDictionary=[];var B=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function E(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}function D(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+o.BearerAccessToken,Accept:e}}function O(t="application/json",e="",n="application/json"){return""==e&&(e=o.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}class b{constructor(t,e,o,i){this.url=n.BASE_URL,this.message=t,this.ok=e,this.status=o,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function H(t){if(401==t.status){let e=new b(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}function M(t){if(401==t.status){let e=new b(t.body,!1,t.status,"");throw e.setUrl(t.headers.url),e}}var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function W(t,e){return j(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",t),o.append("user_id",e.toString());var i=D("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)F.AddConcept(t[r])}console.log("GetAllConceptsByType error",c.status),H(c)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class ${constructor(t=0,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=L(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=t,this.typeUserId=a,this.orderId=s,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=U(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class J{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;t.value.id==e.value.id&&(n=!0);for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class z{static addNodeToTree(t){if(null==this.connectionroot)return this.connectionroot=t,this.connectionroot;this.connectionroot=this.connectionroot.addNode(t,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(t){var e=new J(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return Q(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isConnectionLoaded)return t("done");setTimeout(z.checkFlag,1e3,t)}static removeNodeFromTree(t){return Q(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return Q(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}z.connectionroot=null;var q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class K{static addNodeToTree(t){return q(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=t,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(t,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return q(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isConnectionTypeLoaded)return t("done");setTimeout(K.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new J(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,t,e))}static getNodeFromTree(t){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(t,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(t){return q(this,void 0,void 0,(function*(){var e=[],n=this.getNodeFromTree(t);if(n){e.push(null==n?void 0:n.value);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value);return e}}))}static getTypeVariantsFromTreeWithUserId(t,e){return q(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}K.connectionTypeRoot=null;var Y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class X{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){}static AddConnection(t){t.isTemp||(z.addConnectionToTree(t),K.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(z.addConnectionToTree(t),K.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(t.id,z.removeNodeFromTree(t.id),K.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return z.connectionroot}static GetConnectionTypeTree(){return K.connectionTypeRoot}static GetConnection(t){return Y(this,void 0,void 0,(function*(){var e=new $(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield z.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return Y(this,void 0,void 0,(function*(){var e=[],n=yield K.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;if(o){let t=o;e.push(t);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value)}}return e}))}getName(){return this.name}}X.connectionArray=[],X.connectionDictionary=[];var Z=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tt(t){return Z(this,void 0,void 0,(function*(){let e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield F.GetConcept(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=D();const t=yield fetch(n.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){let n=yield t.json();if(n.length>0)for(let t=0;t<n.length;t++){let o=n[t];e.push(o),F.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),H(t);return e}}catch(t){throw t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),t}}))}var et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function nt(t=[]){return et(this,void 0,void 0,(function*(){var e=[];if(t.length>0){for(let n=0;n<t.length;n++)e.includes(t[n].ofTheConceptId)||e.push(t[n].ofTheConceptId),e.includes(t[n].toTheConceptId)||e.push(t[n].toTheConceptId);yield tt(e)}}))}var ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function it(t=[]){return ot(this,void 0,void 0,(function*(){var e=[];for(let o=0;o<t.length;o++){var n=yield X.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function rt(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||X.RemoveConnection(e[n]))}var ct=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function at(t=[]){return ct(this,void 0,void 0,(function*(){var e=[];if(t.length<=0)return e;var o=yield it(t),i=yield function(t=[]){return ct(this,void 0,void 0,(function*(){var e=[];try{var o=D();const r=yield fetch(n.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)X.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),H(r);return e}catch(t){throw t instanceof Error?console.log("Get all connections of composition bulk error message: ",t.message):console.log("Get all connections of composition bulk unexpected error: ",t),t}}))}(t);return rt(e=i,o),yield nt(e),e}))}var st=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const lt=new Map;function dt(t){return st(this,void 0,void 0,(function*(){let e=L();if(lt.has(t))return lt.get(t)||e;const o=(()=>st(this,void 0,void 0,(function*(){try{var o=yield F.GetConcept(t);let r=F.GetNpc(t);if(0!=o.id||r)return o;{var i=D("application/x-www-form-urlencoded");const o=yield fetch(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${t}`});return o.ok?(e=yield o.json(),e.id>0?F.AddConcept(e):F.AddNpc(t)):(console.log("Get the concept error",o.status,t),H(o)),e}}catch(e){throw e instanceof Error?console.log("Get the concept error message: ",e.message,t):console.log("Get the concept unexpected error: ",e,t),e}finally{lt.delete(t)}})))();return lt.set(t,o),o}))}var ut=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ht(t){return ut(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield X.GetConnectionsOfCompositionLocal(t)).length)e=yield ft(t);else{var n=yield ft(t);rt(n,e),e=n}return e}))}function ft(t){return ut(this,void 0,void 0,(function*(){var e=[];try{var o=D("application/x-www-form-urlencoded");const r=yield fetch(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${t}`});if(!r.ok)throw H(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)X.AddConnection(c[i]),e.push(c[i]);return e}catch(t){throw t instanceof Error?console.log("Get all connection of composition error : ",t.message):console.log("Get all connection of composition error : ",t),t}}))}var yt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function pt(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield ht(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function vt(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield ht(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield kt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function gt(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield X.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function Ct(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield X.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function mt(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield X.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l.created_at=a.entryTimeStamp,l}))}function Tt(t,e){var n,o;return yt(this,void 0,void 0,(function*(){for(var i={},r=[],c=0;c<e.length;c++)r.includes(e[c].ofTheConceptId)||r.push(e[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,e,r);i[null!==(o=null===(n=null==a?void 0:a.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function Nt(t,e,n=[]){var o,i;return yt(this,void 0,void 0,(function*(){var r={},c=yield F.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield dt(t));var a=yield It(t,e,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a;var s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=t,s}))}function wt(t){var e,n;return yt(this,void 0,void 0,(function*(){var o,i={};o=yield ht(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield F.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield dt(t));var s=yield It(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l}))}function It(t,e,n,o=[]){var i,r,c;return yt(this,void 0,void 0,(function*(){var a={},s=[];if(0==t)return null;var l=yield F.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield dt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield F.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield dt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i||i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield F.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield dt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield F.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield dt(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 t=yield It(f,e,n,o);a[p]=t}}else{const t=yield It(f,e,n,o);s[p]=t,a=s}}return a}))}function kt(t,e,n,o=[]){var i,r,c;return yt(this,void 0,void 0,(function*(){var a={},s=[];if(0==t)return null;var l=yield F.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield dt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield F.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield dt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i||i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield F.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield dt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield F.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield dt(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 t=yield kt(f,e,n);a[p]=t}}else{const t=yield kt(f,e,n);s[p]=t,a=s}}return a}))}var At=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xt(t){return At(this,void 0,void 0,(function*(){let e=L();try{var o=D("application/x-www-form-urlencoded");const i=yield fetch(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${t}`});return i.ok?(e=yield i.json(),e.id>0&&F.AddConcept(e)):(console.log("Error in Getting concept by character value Error",i.status),H(i)),e}catch(t){throw t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),t}}))}var St=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Rt(t){return St(this,void 0,void 0,(function*(){var e=yield F.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield xt(t),e=yield F.GetConceptByCharacter(t)),e}))}var _t=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Lt(t,e,n=10,o=1){return _t(this,void 0,void 0,(function*(){var i=yield Rt(t),r=[];if(i){yield W(t,e);for(var c=yield F.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield at(s),l=a;l<a+n;l++)if(c[l]){var d=yield gt(c[l].id);r.push(d)}}return r}))}function Ut(t,e,n=10,o=1){return _t(this,void 0,void 0,(function*(){var i=yield Rt(t),r=[];if(i){yield W(t,e);for(var c=yield F.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield at(s),l=a;l<a+n;l++)if(c[l]){var d=yield Ct(c[l].id);r.push(d)}}return r}))}class Gt{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Vt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new Gt(t.id,t,null,null);new Gt(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return Pt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isLocalDataLoaded)return t("done");setTimeout(Vt.checkFlag,1e3,t)}static getNodeFromTree(t){return Pt(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static removeNodeFromTree(t){return Pt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}Vt.root=null;var Ft=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Bt{static waitForDataToLoad(){return Ft(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isLocalCharacterLoaded)return t("done");setTimeout(Bt.checkFlag,1e3,t)}static addNodeToTree(t){return Ft(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=t,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(t,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(t){if(""!=t.characterValue){var e=new Gt(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(t,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(t,e){return Ft(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}Bt.LocalCharacterRoot=null;var Et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Dt{static addNodeToTree(t){return Et(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=t,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(t,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new Gt(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeConceptType(t,e){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,t,e))}static getNodeFromTree(t){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(t,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return Et(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isLocalTypeLoaded)return t("done");setTimeout(Dt.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return Et(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}Dt.LocalTypeRoot=null;class Ot{constructor(t,e,n,o,i,r,c,a=!1,s,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=a,this.typeCharacter=c,this.entryTimeStamp=s,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function bt(){let t=new Date,e=new Date;return new Ot(0,0,0,0,0,"0","0",!1,t,e,0)}var Ht=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Mt{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(Vt.addConceptToTree(t),Bt.addConceptToTree(t),Dt.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(Vt.addConceptToTree(t),Bt.addConceptToTree(t),Dt.addConceptToTree(t))}static GetConcept(t){return Ht(this,void 0,void 0,(function*(){var e=bt(),n=yield Vt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return Ht(this,void 0,void 0,(function*(){var e=bt(),n=Bt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return Ht(this,void 0,void 0,(function*(){var n=bt(),o=yield Bt.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return Ht(this,void 0,void 0,(function*(){let n=[];return n=yield Dt.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}Mt.localconceptsArray=[];var jt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Wt{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),0!=t.id||t.isTemp,this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return jt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isLocalConnectionLoaded)return t("done");setTimeout(Wt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return jt(this,void 0,void 0,(function*(){var e=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}getName(){return this.name}}Wt.connectionArray=[],Wt.connectionDictionary=[];var $t=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jt(t){var e,n;return $t(this,void 0,void 0,(function*(){var o,i={};o=yield Wt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Mt.GetConcept(t),s=yield zt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=s,i}))}function Qt(t){var e,n;return $t(this,void 0,void 0,(function*(){var o,i={};o=yield Wt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Mt.GetConcept(t);if(0!=a.id){var s=yield zt(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=s;var l={}}return l.data=i,l.id=t,l}))}function zt(t,e,n,o=[]){var i,r,c;return $t(this,void 0,void 0,(function*(){var a={},s=[],l=yield Mt.GetConcept(t);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield Mt.GetConcept(d);l.type=u}if(null===(i=null==l?void 0:l.type)||void 0===i||i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield Mt.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield Mt.GetConcept(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:"top").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield zt(f,e,n);a[p]=t}}else{const t=yield zt(f,e,n);s[p]=t,a=s}}return a}))}var qt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kt(t){return qt(this,void 0,void 0,(function*(){return yield Mt.GetConceptByCharacter(t)}))}var Yt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xt(t,e){return Yt(this,void 0,void 0,(function*(){var n=yield Kt(t),o=[];if(n)for(var i=yield Mt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Jt(i[r].id);o.push(c)}return o}))}function Zt(t,e){return Yt(this,void 0,void 0,(function*(){var n=yield Kt(t),o=[];if(n)for(var i=yield Mt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Qt(i[r].id);o.push(c)}return o}))}function te(t){return e=this,o=void 0,r=function*(){let e=L();try{var o=D();const i=yield h(n.CreateTheConceptUrl(),o,JSON.stringify(t));if(!i.ok)throw M(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t):console.log("Create the concept api unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}function ee(t){return e=this,o=void 0,r=function*(){let e=new $(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=D(),i=JSON.stringify(t);const r=yield h(n.CreateTheConnectionUrl(),o,i);return r.ok?yield r.json():(console.log("Create the connection error message: ",r),M(r)),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}var ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class oe{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(t){return ne(this,void 0,void 0,(function*(){try{let e=[],n=[];if(t&&this.transactionCollections.some((e=>e.id==t))){const o=this.transactionCollections.find((e=>e.id==t));if(this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t)),this.transactionCollections=this.transactionCollections.filter((t=>new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;e=o.data.concepts.slice(),n=o.data.connections.slice(),e.length>0&&(yield te(e)),n.length>0&&(yield ee(n))}else{for(let t=0;t<this.conceptsSyncArray.length;t++)F.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)X.AddConnection(this.connectionSyncArray[t]);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield te(e)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield ee(n))}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return ne(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections.push({id:t,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(t){console.log("error in initializeTransaction",t)}}))}static markTransactionActions(t,e){return ne(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==t?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(e))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.concepts.some((e=>e.id==t.id||e.ghostId==t.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!e.connections.some((e=>e.id==t.id||e.ghostId==t.id))))}catch(t){console.log("error in markTransactionActions",t)}}))}static rollbackTransaction(t,e){return ne(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t))}catch(t){console.log("LocalSyncData, roll",t)}}))}static syncDataLocalDb(){return ne(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t];this.connectionSyncArray=[]}return"done"}))}}function ie(t,e,n,o,i,r,c){var a=new $(0,t,n,e,o,e,i,e,1,e,0,e,4,e,r,c);return t==n?(a.ofTheConceptId=0,a.toTheConceptId=1,a):(a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),oe.AddConnection(a),a)}oe.conceptsSyncArray=[],oe.connectionSyncArray=[],oe.transactionCollections=[];var re=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ce=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const ae=new Map;function se(t,e){return ce(this,void 0,void 0,(function*(){let o=yield F.GetConceptByCharacterAndTypeLocal(t,e),i=t+e;if(ae.has(i))return ae.get(i)||o;const r=(()=>ce(this,void 0,void 0,(function*(){try{if(null==o||0==o.id){var r={character_value:`${t}`,type_id:e},c=JSON.stringify(r),a=D();const i=yield fetch(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:a,body:c});if(i.ok){let t=yield i.json();o=t,F.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),H(i)}return o}catch(t){throw t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),t}finally{ae.delete(i)}})))();return ae.set(i,r),r}))}function le(t){return ce(this,void 0,void 0,(function*(){let e=[],o=JSON.stringify(t);var i=D();const r=yield fetch(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let t=yield r.json();e=yield tt(t)}else console.log("This is the concept by type and character error",r.status),H(r);return e}))}class de{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.userId=t,this.data=e,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let he=!1,fe=[];const ye=()=>{fe.length>0&&!he&&fe.shift()()};var pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let ve=!1,ge=[];const Ce=()=>{ge.length>0&&!ve&&ge.shift()()};var me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Te{static getId(){return me(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return pe(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{console.log("trying to fetch more concepts"),ge.push((()=>pe(this,void 0,void 0,(function*(){try{if(ve)return;if(ve=!0,Te.ids.length>10)return console.log("Enough IDs available, skipping fetch."),ve=!1,Ce(),t();var o=D("application/x-www-form-urlencoded");const e=yield fetch(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!e.ok)throw H(e),new Error(`Error! status: ${e.status}`);const r=yield e.json();for(var i=0;i<r.length;i++)Te.AddId(r[i]);console.log("Ids Fetch Success"),t()}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message,n.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",t),e(t)}finally{ve=!1,Ce()}})))),Ce()}))}))}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}Te.ids=[];class Ne{static getId(){return me(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return ue(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{fe.push((()=>ue(this,void 0,void 0,(function*(){try{if(he)return;if(he=!0,Ne.connectionIds.length>10)return he=!1,ye(),t();var o=D("application/x-www-form-urlencoded");const e=yield fetch(n.GetReservedConnectionIdUrl(),{method:"GET",headers:o});if(!e.ok)throw H(e),new Error(`Error! status: ${e.status}`);const r=yield e.json();for(var i=0;i<r.length;i++)Ne.AddId(r[i]);t()}catch(t){t instanceof Error?console.log("get reserved connection ids error message: ",t.message):console.log("get reserved connection ids unexpected error: ",t),e(t)}finally{he=!1,ye()}})))),ye()}))}))}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}Ne.connectionIds=[];var we=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ie(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){return we(this,void 0,void 0,(function*(){var p=yield Te.getId();let v=new Date,g=new Date;var C=new _(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,oe.AddConcept(C),y.concepts.push(C),C}))}function ke(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){return we(this,void 0,void 0,(function*(){var p=yield Te.getId();let v=new Date,g=new Date;var C=new _(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,v,g);return F.AddConcept(C),C.updateRecursion=!0,oe.AddConcept(C),y.concepts.push(C),C}))}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xe(t,e,o=!1,i,r,c=999,a=0,s={concepts:[],connections:[]}){return Ae(this,void 0,void 0,(function*(){let l,d=c,u=999,h=i,f=i,y=r,p=i,v="",g=e.length,C=L();v=t.startsWith("the_")?t:"the_"+t;(new Date).getTime();if(o)C=yield An(t),l=yield Ie(e,i,4,i,C.id,C.userId,a,999,u,h,y,p,d,f,s),(new Date).getTime();else if(g>255)C=yield An(v),l=yield Ie(e,i,4,i,C.id,C.userId,a,999,u,h,y,p,d,f,s),function(t){re(this,void 0,void 0,(function*(){try{var e=D();const o=yield fetch(n.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw H(o),new Error(`Error! status: ${o.status}`);return yield o.json()}catch(t){throw t instanceof Error?console.log("Create the text error message: ",t.message):console.log("Create the text unexpected error: ",t),t}}))}(new de(i,e,u,h,y,p,d,f,Date.now().toString(),!0)),(new Date).getTime();else{C=yield An(v);let t=yield se(e,C.id);l=t,0==t.id&&0==t.userId&&(l=yield ke(e,i,4,i,C.id,C.userId,12,12,u,h,y,p,d,f,s)),(new Date).getTime()}return l.type=C,l}))}var Se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Re(t,e=null,n=null,o=null,i=null,r=null,c=null){return Se(this,void 0,void 0,(function*(){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=L();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=p=yield xe(o,"",!0,a,s,l),h=p.id,d=p.id,yield Re(t[o],p.id,p.userId,h,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;h=d,u=p=yield xe(o,"",!0,a,s,l),yield ie(f,y,p.id,p.userId,h,l,p.userId),yield Re(t[o],p.id,p.userId,h,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,h=d;var p=yield xe(o,t[o].toString(),!1,a,s,l);yield ie(f,y,p.id,p.userId,h,l,p.userId)}return u}))}class _e{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=bt(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=o,this.ghostId=t,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=U(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function Le(t,e,n,o=1){Math.floor(1e8*Math.random());let i=0,r=0,c=0;i=t,r=e,c=n;let a=new _e(0,0,0,0,0,0);return t!=e&&(a=new _e(0,t,e,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Wt.AddConnection(a)),a}var Ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ge(t,e,n,o,i,r,c=0){return Ue(this,void 0,void 0,(function*(){var a=Math.floor(1e8*Math.random());let s=new Date,l=new Date;var d=new Ot(a,n,i,o,r,t,e,!0,s,l,c);return d.isTemp=!0,Mt.AddConcept(d),d}))}var Pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Ve=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fe(t,e,n,o){return Ve(this,void 0,void 0,(function*(){var i=yield Kt(t);if(i&&(0==i.id||0==i.userId)){var r=E(t);if(r[0]==t){var c=yield function(t,e,n,o,i){return Pe(this,void 0,void 0,(function*(){var e=yield Mt.GetConceptByCharacterAndTypeLocal(t,51),o=e;return 0==o.id&&(o=e=yield Ge(t,"the",n,4,51,4)),o}))}(t,0,o);i=c}else{var a=yield Fe(r[0],e,n,o),s=yield Fe(r[1],e,n,o);s&&(i=c=yield Ge(t,r[1],o,a.id,s.id,4))}}return i}))}var Be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ee(t,e,n=!1,o,i,r=999,c=0){return Be(this,void 0,void 0,(function*(){var i,r,a,s=o,l=e.length;if(a=t.startsWith("the_")?t:"the_"+t,n)i=yield Fe(t,999,o,o),r=yield Ge(e,t,o,4,i.id,4,c);else if(l>255)i=yield Fe(a,999,s,o),r=yield Ge(e,a,o,4,i.id,4);else{i=yield Fe(a,999,s,o);var d=yield Mt.GetConceptByCharacterAndTypeLocal(e,i.id);r=d,0==d.id&&0==d.userId&&(r=yield Ge(e,a,o,4,i.id,4))}return r.type=i,r}))}var De=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oe(t,e=null,n=null,o=null,i=null,r=null,c=null){return De(this,void 0,void 0,(function*(){var a=null!=i?i:999,s=null!=c?c:4,l=null!=o?o:0,d=bt();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var u=l;d=f=yield Ee(o,"",!0,a,0,s),u=f.id,l=f.id,yield Oe(t[o],f.id,f.userId,u,i,r,c)}else{var h=null!=e?e:999,f=(u=l,yield Ee(o,"",!0,a,0,s));yield Le(h,f.id,u),yield Oe(t[o],f.id,f.userId,u,i,r,c)}else h=null!=e?e:999,u=l,f=yield Ee(o,t[o].toString(),!1,a,0,s),yield Le(h,f.id,u);return d}))}var be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function He(t,e,o,i=10,r=1){return be(this,void 0,void 0,(function*(){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=D("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),H(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var Me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function je(t,e,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){return Me(this,void 0,void 0,(function*(){let u=e,h=e,f=e;999!=l&&(f=l);let y=e,p=e,v=yield Ne.getId(),g=new $(v,t,n,e,o,f,i,h,a,u,0,y,s,p,r,c);return t==n?(g.ofTheConceptId=0,g.toTheConceptId=1,g):(g.toUpdate=!0,g.isTemp=!1,oe.AddConnection(g),d.connections.push(g),g)}))}function We(t,e,n,o={concepts:[],connections:[]}){return Me(this,void 0,void 0,(function*(){let i=yield An(n),r=t.userId;return yield je(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}var $e=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Je=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Qe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ze(t){return Qe(this,void 0,void 0,(function*(){var e=yield X.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var o=yield function(t){return Je(this,void 0,void 0,(function*(){var e=yield X.GetConnection(t);try{if(0!=e.id)return e;{var o=D("application/x-www-form-urlencoded");const i=yield fetch(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${t}`});return i.ok?(e=yield i.json(),X.AddConnection(e)):(console.log("Get Connection Error",i.status),H(i)),e}}catch(t){throw t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),t}}))}(t);e=o}return e}))}var qe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ke(t,e=""){return qe(this,void 0,void 0,(function*(){let o=!1;var i=yield ze(t);return o=yield function(t,e=""){return $e(this,void 0,void 0,(function*(){let o=!1;try{const i=new FormData;let r=D("application/x-www-form-urlencoded");""!=e&&(r=O("application/x-www-form-urlencoded",e)),i.append("id",t.toString()),i.append("apiKey","nodeserver");const c=yield fetch(n.DeleteTheConnectionUrl(),{method:"POST",body:i,redirect:"follow"});c.ok?o=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),H(c))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}return o}))}(t,e),z.removeNodeFromTree(t),K.removeTypeConcept(i.typeId,t),o}))}var Ye=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xe(t,e=999){return Ye(this,void 0,void 0,(function*(){var n=L();if(t<0)return ti(yield Wo(e,t));if(null!=(n=yield F.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield dt(t)),0!=n.id&&null==n.type&&null==(yield F.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield dt(n.typeId);n.type=o}return n}))}var Ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tn(t,e,n,o=!1,i=!1){var r,c;return Ze(this,void 0,void 0,(function*(){var a=t.userId,s=a,l=a;if(o){let o=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s",c=n+"_by",u=o+"_"+c;i&&(yield en(c,e,a));var d=yield xe("connection",u,!1,999,999,999);let h=new $(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);oe.AddConnection(h)}let u=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s",h=n+"_s",f=u+"_"+h;i&&(yield en(h,t,a));var y=yield xe("connection",f,!1,999,999,999);let p=new $(0,t.id,e.id,t.userId,e.userId,t.userId,y.id,y.userId,1e3,a,999,s,4,l,999,999);return oe.AddConnection(p),p}))}function en(t,e,n=null){var o;return Ze(this,void 0,void 0,(function*(){for(var i=e,r=null!=n?n:e.userId,c=r,a=r,s=999,l=t+"_count",d=(null===(o=e.type)||void 0===o?void 0:o.characterValue)+"_s_"+l,u=yield xe("connection",d,!1,r,4,s),h=yield He(u.id,e.id,r,10,1),f=[],y=L(),p=0;p<h.length;p++){let t=yield Xe(h[p].toTheConceptId);f.push(t)}if(f.length<1)y=yield xe("count","1",!1,r,4,s);else{var v=f[0];let t=0;try{t=Number(v.characterValue)}catch(e){t=0}t+=1,y=yield xe("count",t.toString(),!1,r,4,s);for(let t=0;t<h.length;t++)Ke(h[t].id)}let g=new $(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,a,s,999);yield oe.AddConnection(g)}))}function nn(t,e,n,o=!1,i=!1){var r,c;return Ze(this,void 0,void 0,(function*(){var a=t.userId,s=a,l=a;if(o){let o=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s",c=n+"_by",u=o+"_"+c;i&&(yield en(c,e,a));var d=yield xe("connection",u,!1,999,999,999);let h=new $(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);oe.AddConnection(h)}let u=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s",h=n+"_s",f=u+"_"+h;i&&(yield en(h,t,a));var y=yield xe("connection",f,!1,999,999,999);return yield je(t.id,t.userId,e.id,e.userId,y.id,999,999,1e3,4)}))}var on=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function rn(t,e,n=10,o=1){var i;return on(this,void 0,void 0,(function*(){var r=[],c=yield Xe(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield se(a,16);if(s.id>0){for(var l=yield He(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield at(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield Xe(t),n=yield mt(e.id);r.push(n)}}return r}))}function cn(t,e,n=10,o=1){var i;return on(this,void 0,void 0,(function*(){var r=[],c=yield Xe(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield se(a,16);if(s.id>0){for(var l=yield He(s.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 t=l[u].toTheConceptId,e=yield Xe(t);r.push(e)}}return r}))}class an{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class sn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new an(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}sn.characterData=[];class ln{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var dn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},un=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function hn(t,e,o,i,r){return un(this,void 0,void 0,(function*(){var c=new an(e,t,o,e,i,e,r,e,"",!1);return yield function(t){return dn(this,void 0,void 0,(function*(){try{if(0==(t=sn.GetCharacter(t.data)).id){var e=D();const i=yield fetch(n.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw H(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new an(r.userId,t.data,0,0,4,4,999,999,"",!1);return o.id=r.id,sn.AddCharacter(o),r}return new ln(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}(c)}))}var fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yn(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return fn(this,void 0,void 0,(function*(){var y=yield se(t,i),p=y;return 0==p.id&&(p=y=yield Ie(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gn(t,e,n,o,i={concepts:[],connections:[]}){return vn(this,void 0,void 0,(function*(){var r=o,c=yield Rt(t);if(c&&(0==c.id||0==c.userId)){var a=E(t);if(a.length>0)if(console.log(a),a[0]==t){var s=yield function(t,e,n,o,i,r){return pn(this,void 0,void 0,(function*(){var c=e,a=e;i=e;var s,l=e,d=e,u=e;if(1==t.length){var h=t.charCodeAt(0);yield hn(t,e,n,o,r),s=yn(t,e,4,c,h,u,49,l,n,a,o,i,r,d)}else{var f=yield hn(t,e,n,o,r);f.isNew,s=yield yn(t,e,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(t,o,999,999,r,e);c=s}else{var l=yield gn(a[0],e,n,o,i),d=yield gn(a[1],e,n,o,i);d&&(c=yield ke(t,o,l.id,o,d.id,o,999,o,999,o,999,o,e,o,i))}}return c}))}var Cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const mn=new Map;function Tn(t,e){return Cn(this,void 0,void 0,(function*(){let o=L();if(mn.has(t+e))return mn.get(t+e)||o;const i=(()=>Cn(this,void 0,void 0,(function*(){try{var i=D("application/x-www-form-urlencoded");const r=yield fetch(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});if(r.ok){let t=yield r.json();o=t,F.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),H(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,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",o,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()),o}finally{mn.delete(t+e)}})))();return mn.set(t+e,i),i}))}var Nn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wn(t){return Nn(this,void 0,void 0,(function*(){let e=L();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=t.length;var o=E(t);if(o.length>1){let n=1,i=yield wn(o[0]);0!=i.id&&(n=i.id),e=yield function(t,e){return Nn(this,void 0,void 0,(function*(){let n=yield F.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield Tn(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return Nn(this,void 0,void 0,(function*(){console.log("inside the character length function",t);var e=yield F.GetConceptByCharacterAndTypeLocal(t,49);return console.log("inside the character length function after",e),0==e.id&&(e=yield xt(t)),e}))}(t):o[0]==t&&(e=yield function(t){return Nn(this,void 0,void 0,(function*(){var e=yield F.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield xt(t)),e}))}(t));return e}))}var In=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const kn=new Map;function An(t,e){return In(this,void 0,void 0,(function*(){let e=L();if(kn.has(t))return kn.get(t)||e;const o=(()=>In(this,void 0,void 0,(function*(){try{if(e=yield wn(t),0==e.id||4==e.typeId){var o=D("application/x-www-form-urlencoded");const i=yield fetch(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${t}`});if(!i.ok)throw H(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();e=r,e.id>0&&F.AddConcept(e)}return e}catch(t){throw t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),t}finally{kn.delete(t)}})))();return kn.set(t,o),o}))}var xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Sn(t){return xn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=D("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:o});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),H(c);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),t}}))}var Rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t){return Rn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=D("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:o});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),H(c);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),t}}))}var Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Un(t){return Ln(this,void 0,void 0,(function*(){for(var e=yield Sn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Xe(o);t.type=i}return e}))}function Gn(t){return Ln(this,void 0,void 0,(function*(){for(var e=yield _n(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Xe(o);t.type=i}return e}))}var Pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fn(t,e=""){return Vn(this,void 0,void 0,(function*(){var o=yield Xe(t);yield R.removeNodeFromTree(t);var i=o.typeId,r=o.characterValue;yield P.removeTypeConcept(i,t),yield x.removeNodeByCharacter(r,t);let c=yield function(t,e=""){return Pn(this,void 0,void 0,(function*(){let o=!1;try{let i=D("application/x-www-form-urlencoded");""!=e&&(i=O("application/x-www-form-urlencoded",e));const r=new FormData;r.append("id",t.toString()),r.append("apiKey","nodeserver");const c=yield fetch(n.DeleteConceptUrl(),{method:"POST",body:r});if(!c.ok)throw H(c),new Error(`Error! status: ${c.status}`);o=(yield c.json()).success}catch(t){throw t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),t}return o}))}(t,e);return c}))}var Bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function En(t,e){return Bn(this,void 0,void 0,(function*(){try{const o=new Headers;o.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield fetch(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw H(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){throw t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),t}}))}var Dn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function On(t,e,n,o,i=999){return Dn(this,void 0,void 0,(function*(){var o,i=n,r=n,c=n,a=t.startsWith("the_"),s=L();return o=a?t:"the_"+t,s=yield An(o),yield yn(e,n,4,n,s.id,s.userId,0,999,999,i,4,c,999,r)}))}class bn{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 Hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mn(t=[]){return Hn(this,void 0,void 0,(function*(){var e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield X.GetConnection(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=D();const t=yield fetch(n.GetConnectionBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){const n=yield t.json();if(n.length>0){for(let t=0;t<n.length;t++){let o=n[t];e.push(o),X.AddConnection(o)}yield nt(e)}}else console.log("Get Connection Bulk error",t.status),H(t);return e}}catch(t){throw t instanceof Error?console.log("Get Connection Bulk error message: ",t.message):console.log("Get Connection Bulk unexpected error: ",t),t}}))}var jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Wn(t=[]){return jn(this,void 0,void 0,(function*(){yield at(t);var e=[];for(let o=0;o<t.length;o++){var n=yield gt(t[o]);e.push(n)}return e}))}function $n(t=[]){return jn(this,void 0,void 0,(function*(){yield at(t);var e=[];for(let o=0;o<t.length;o++){var n=yield Ct(t[o]);e.push(n)}return e}))}function Jn(t=[],e=[]){return jn(this,void 0,void 0,(function*(){yield Mn(e);var n=yield it(t);!function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||X.RemoveConnection(e[n])}(e,n);var o=[];for(let e=0;e<t.length;e++){var i=yield Ct(t[e]);o.push(i)}return o}))}function Qn(t=[]){return jn(this,void 0,void 0,(function*(){let e=[],n=[],o={};for(let o=0;o<(null==t?void 0:t.length);o++){let i=yield X.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}for(let n=0;n<e.length;n++)o[t[n]]=!1;let i=[],r=yield Mn(e);n=[...n,...r];for(let t=0;t<n.length;t++)i.push(n[t].ofTheConceptId),i.push(n[t].toTheConceptId),i.push(n[t].typeId);return yield tt(i),n}))}function zn(t=[],e=[]){return jn(this,void 0,void 0,(function*(){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield X.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Mn(n);for(let t=0;t<i.length;t++)o.push(i[t]);let r={},c=[];for(var a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);console.time("start");for(let e=0;e<t.length;e++){let n=yield Nt(t[e],o,c);r[t[e]]=n}return console.timeEnd("start"),r}))}var qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kn(t=0,e=[],o=""){return qn(this,void 0,void 0,(function*(){var i=[];try{var r=new bn;r.composition=t,r.listLinkers=e,r.textSearch=o;var c=JSON.stringify(r),a=D();const d=yield fetch(n.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const t=yield d.json();var s=t.compositionIds,l=t.internalConnections;t.externalConnections,i=yield Jn(s,l)}else console.log("recursive search error ",d.status),H(d);return i}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}var Yn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xn(t,e){return Yn(this,void 0,void 0,(function*(){try{var i={email:t,password:e},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(i);const a=yield fetch(n.LoginUrl(),{method:"POST",headers:r,body:c});if(a.ok){const t=yield a.json();return o.BearerAccessToken=t.data.token,t}console.log("Login tsccs error message: ",a.status),H(a)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}var Zn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function to(t){return Zn(this,void 0,void 0,(function*(){return yield function(t="",e={}){return Zn(this,void 0,void 0,(function*(){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(t,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:H(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(n.SignupUrl(),t)}))}var eo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function no(t){return eo(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.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 t=yield fetch(r,{method:"POST",headers:i,body:e,redirect:"follow"}),n=yield t.json();return t.ok?o={message:"success",status:!0,statusCode:200,data:null==n?void 0:n.data}:H(t),o}catch(t){throw console.log("Sign in api error",t),t}}))}function oo(t,e){return-1===t.indexOf(e)&&t.push(e),t}function io(t=[],e){var n,o;let i=[],r=null===(n=e.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(t))for(let n=0;n<t.length;n++){let c=null===(o=t[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),e.typeId!=t[n].typeId&&r!=c||i.push(t[n])}return i}function ro(t=[],e){let n=[],o=e.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(t))for(let i=0;i<t.length;i++){let r=t[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),e.typeId!=t[i].typeId&&o!=r||n.push(t[i])}return n}function co(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function ao(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function so(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function lo(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class uo{constructor(t,e,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}isValid(){const t=new Date(Date.now());return!(this.expiryTime<t&&(fo.removeNodeFromTree(this.key),1))}saveToCache(t){this.value.cached=t}addNode(t,e,n){if(null==e)return t;const o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return this.isValid(),t;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));const r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return this.isValid(),e}rightRotate(t){if(t){const e=t.leftNode;if(e){const n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){const e=t.rightNode;if(e){const n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key&&e.isValid()?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){const e=t.rightNode;return t=null,e}if(null==t.rightNode){const e=t.leftNode;return t=null,e}{const e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.rightNode=this.removeNode(t.rightNode,e.key),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class fo{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addCompositionToTree(t){const e=new uo(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return ho(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return ho(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}fo.root=null;var yo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function po(t,e,n,o,i=[]){var r,c;return yo(this,void 0,void 0,(function*(){let a={};const s=[];if(0==t)return"";let l=vo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Xe(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=vo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield Xe(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=vo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield Xe(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield F.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield Xe(e),t.type=n)}const l="the_",u=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const t=yield po(d,e,n,o,i);a[u]=t}}else{const t=yield po(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function vo(t,e){let n=L();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class go{constructor(){this.id=0,this.mainConcept=L(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield po(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&("compositionUpdate",e=null===(t=this.id)||void 0===t?void 0:t.toString(),n.MQTT_CONNECTION&&n.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Co=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mo(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){return Co(this,void 0,void 0,(function*(){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=L();null==a&&(a=new go);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield xe(o,"",!0,s,l,d);if(null==e&&null==n){let e=u;h=f,e=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield mo(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield ie(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield mo(t[o],f.id,f.userId,y,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=u,h=yield xe(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield ie(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var To=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function No(t){return To(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=L(),a=L();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield Xe(l,e);if(!(t.id>0))return null;l=t.id}i=yield ht(l);const h=[],f=new go,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)oo(y,i[t].ofTheConceptId),oo(h,i[t].ofTheConceptId),oo(h,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<h.length;t++){const e=yield Xe(h[t]);l==h[t]&&(c=e),d==h[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=L();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield xe(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=io(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=co(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield mo(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield xe(t,l,!1,e,o,n);const c=io(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=co(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield ie(d.id,d.userId,i.id,i.userId,c.id,n,e);r.push(i),f.connections.push(h)}for(let t=0;t<u.length;t++)lo(f.connections,u[t]),Ke(u[t].id);for(let t=0;t<s.length;t++)so(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),fo.addCompositionToTree(f),yield oe.SyncDataOnline(),f.GetDataCache()}))}var wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Io(t,e,o,i,r=10,c=1){return wo(this,void 0,void 0,(function*(){var a=O("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",o),s.append("inpage",r.toString()),s.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield fetch(l,{method:"GET",headers:a});return t.ok?yield t.json():(H(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ao(t,e=""){return ko(this,void 0,void 0,(function*(){var o=O("application/json",e);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:o,body:r});return t.ok?yield t.json():(console.log("This is the searching error",t.status),H(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var xo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function So(t,e=[]){var n,o;return xo(this,void 0,void 0,(function*(){let i=[];const r=[];let c={},a={};const s=[];let l=yield F.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield dt(t));let d=[];d=e.length>0?Ro(t,e):yield ht(t),i=d;for(let t=0;t<i.length;t++)s.includes(i[t].ofTheConceptId)||(s.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);return a=yield It(t,i,s,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,0==l.id?"":c}))}function Ro(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function _o(t,e=[]){var n,o;return xo(this,void 0,void 0,(function*(){let i={},r=[];const c=[];let a;const s={},l=[];let d=yield F.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield dt(t));let u=[];u=e.length>0?Ro(t,e):yield ht(t),r=u;for(let t=0;t<r.length;t++)l.includes(r[t].ofTheConceptId)||(l.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);return a=yield It(t,r,l),s[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=d.entryTimeStamp,i.data=s,i.id=t,0==d.id?"":i}))}function Lo(t,e){return xo(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Mn(e);for(let e=0;e<t.length;e++){const i=yield _o(t[e],n);i&&o.push(i)}return o}))}var Uo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Go(t){return Uo(this,void 0,void 0,(function*(){try{var e=D();const o=JSON.stringify(t),i=yield fetch(n.CreateSessionId(),{method:"POST",headers:e,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),H(i),null)}catch(t){throw console.log("Creating session failed",t),t}}))}var Po=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Vo(t,e){return Po(this,void 0,void 0,(function*(){try{var o=D("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield fetch(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),H(r),null)}catch(t){throw console.log("Creating session url failed",t),t}}))}var Fo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bo(t,e,o,i=10,r=1){return Fo(this,void 0,void 0,(function*(){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("toTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=D("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),H(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var Eo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Do(t,e,n=10,o=1,i=!1){return Eo(this,void 0,void 0,(function*(){let r=[],c=yield Xe(t),a=yield wn(e);if(a.id>0){let t=[],e=[];if(i){e=yield Bo(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield at(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield Xe(n),i=yield mt(o.id);r.push(i)}}else{e=yield He(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield at(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield Xe(n),i=yield mt(o.id);r.push(i)}}}return r}))}function Oo(t,e,n=10,o=1,i=!1){return Eo(this,void 0,void 0,(function*(){let r=[],c=yield Xe(t),a=yield wn(e),s=[],l=[];if(a.id>0){if(i){s=yield Bo(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield He(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield tt(l)}return r}))}class bo{constructor(t,e,n,o,i){this.connectionValue=[],this.value=[],this.height=1,this.key=t,e.id>0&&this.value.push(e),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=i}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e.value.push(...t.value),e.connectionValue.push(...t.connectionValue),e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.rightNode=this.removeNode(t.rightNode,n.key),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Mo{static compositeKey(t,e,n=999){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return Ho(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(I.isDataLoaded)return t("done");setTimeout(Mo.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=new _e(0,0,0,0,0,0);var r=new bo(o,t,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=bt();var r=new bo(o,i,t,null,null);this.addNodeToTree(r)}static getNodeFromTree(t,e,n=999){return Ho(this,void 0,void 0,(function*(){let o=this.compositeKey(t,e,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(t,e=999,n=999){return Ho(this,void 0,void 0,(function*(){if(this.root){let o=this.compositeKey(t,e,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Mo.root=null;var jo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Wo(t,e,n=999,o=999){return jo(this,void 0,void 0,(function*(){let i=yield Mo.getNodeFromTree(t,n,o),r=bt();if(i)for(let t=0;t<i.value.length;t++){let n=i.value[t];n.ghostId==e&&(r=n)}return r}))}function $o(t,e,n=999,o=999){return jo(this,void 0,void 0,(function*(){let i=yield Mo.getNodeFromTree(t,n,o),r=new _e(0,0,0,0,0,0);if(i)for(let t=0;t<i.connectionValue.length;t++){let n=i.connectionValue[t];n.ghostId==e&&(r=n)}return r}))}function Jo(t,e,n=999){return jo(this,void 0,void 0,(function*(){Mo.addConceptToTree(t,e,n)}))}function Qo(t,e,n=999){return jo(this,void 0,void 0,(function*(){Mo.addConnectionToTree(t,e,n)}))}var zo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qo(t,e=""){return zo(this,void 0,void 0,(function*(){var o=O("application/json",e);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:o,body:r});return t.ok?yield t.json():(console.log("This is the searching multiple error",t.status),H(t),[])}catch(t){throw console.log("This is the searching multiple error",t),t}}))}var Ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yo(t,e=""){return Ko(this,void 0,void 0,(function*(){let n=[],o=yield qo(t,e),i=t[0].composition;const r=o;let c=r.compositionIds,a=r.internalConnections,s=r.linkers,l=r.reverse;return n=yield zn(c,a),yield Xo(s,n,i,l)}))}function Xo(t,e,n,o=[]){return Ko(this,void 0,void 0,(function*(){let i={},r=yield Mn(t);for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield Xe(r[t].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(e[r[t].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield Xe(r[t].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(e[r[t].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function Zo(t){var e,n;const o=bt();return o.id=t.id,o.ghostId=t.ghostId,o.userId=t.userId,o.accessId=t.accessId,o.categoryId=t.categoryId,o.characterValue=t.characterValue,o.entryTimeStamp=t.entryTimeStamp,o.typeId=t.typeId,o.type=t.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(e=null==t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"",o}function ti(t){const e=L();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e.characterValue=t.characterValue,e}function ei(t){const e=new _e(0,0,0,0,0,0);return e.id=t.id,e.ghostId=t.ghostId,e.accessId=t.accessId,e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.isTemp=!1,e}var ni=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function oi(t){return ni(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId;t.accessId;let o=[];const i=[];let r=bt(),c=bt();const a=[],s=t.compositionId,l=t.ofTheCompositionId;let d=[],u=yield ht(s);for(let t=0;t<u.length;t++)o.push(ei(u[t]));const h=[],f=[];let y=[];for(let t=0;t<o.length;t++)oo(f,o[t].ofTheConceptId),oo(h,o[t].ofTheConceptId),oo(h,o[t].toTheConceptId),y.push(o[t].ofTheConceptId);for(let t=0;t<h.length;t++){const e=yield Xe(h[t]);s==h[t]&&(r=Zo(e)),l==h[t]&&(c=Zo(e)),i.push(Zo(e))}const p=t.patchObject;for(const t in p){let s=bt();const l=p[t];let u=r;c.id>0&&(u=c),Array.isArray(l)||"object"==typeof l?(s=yield Ee(t,"",!0,r.userId,0,999),yield Oe(p[t],s.id,s.userId,r.id,r.userId,4,999)):s=yield Ee(t,l,!1,e,0,n);const h=ro(i,s);for(let t=0;t<h.length;t++)if(h[t].id>0){const e=ao(o,h[t].id);d=d.concat(e),a.push(h[t])}yield Le(u.id,s.id,r.id,2),i.push(s)}for(let t=0;t<d.length;t++)Ke(d[t].id);oe.SyncDataOnline()}))}var ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ci(t){var e;return ri(this,void 0,void 0,(function*(){let o=yield function(t){return ii(this,void 0,void 0,(function*(){let e=[];try{var o=D();const i=yield fetch(n.ViewInternalDataUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;tt(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),H(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}(t),i=[];for(let n=0;n<t.length;n++){let r=t[n],c=o[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield It(r,c,t);e.data=n,e.id=r,i.push(e)}else{let t={};t.id=r;let n=yield Xe(r),o={};n.type&&(o[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=o,i.push(t))}}return i}))}var ai=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},si=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function li(t,e=""){return si(this,void 0,void 0,(function*(){var o=yield function(t,e=""){return ai(this,void 0,void 0,(function*(){var o=O("application/json",e);let i=n.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(i,{method:"GET",headers:o});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),H(t),[])}catch(t){throw console.log("This is the searching internal error",t),t}}))}(t,e);return yield ci(o)}))}var di=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ui(t,e){return di(this,void 0,void 0,(function*(){let n=!0,o=yield Sn(t),i=yield le(e),r=[];for(let t=0;t<o.length;t++)for(let e=0;e<i.length;e++)o[t].typeId==i[e].id&&r.push(o[t].id);for(let t=0;t<r.length;t++){let e=yield Ke(r[t]);n=n&&e}return n}))}function hi(t,e){return di(this,void 0,void 0,(function*(){let n=yield Sn(t),o=yield le(e),i=[];for(let t=0;t<n.length;t++)for(let e=0;e<o.length;e++)n[t].typeId==o[e].id&&i.push(n[t].id);return i}))}class fi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class yi{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 pi{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class vi{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class gi{constructor(t){this.aiUrl="https://ai.freeschema.com",this.accessToken="",this.enableAi=!0,t&&Object.assign(this,t)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(t,e=!1){var n,o;return null!==(o=null===(n=this.flags)||void 0===n?void 0:n[t])&&void 0!==o?o:e}getParameter(t,e=""){var n,o;return null!==(o=null===(n=this.parameters)||void 0===n?void 0:n[t])&&void 0!==o?o:e}setFlag(t,e){this.flags||(this.flags={}),this.flags[t]=e}setParameter(t,e){this.parameters||(this.parameters={}),this.parameters[t]=e}}var Ci=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var mi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Ti=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ni{}Ni.isUpdated=!1,Ni.isOnlineSync=!1;var wi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var Ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const ki=1,Ai=2,xi=3,Si=4,Ri=5,_i=6,Li=7,Ui=8;class Gi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var Pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Vi(t){return Pi(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield dt(t[n].connectionTypeId);t[n].connectionType=o.characterValue,e[t[n].conceptId]=t[n]}return e}))}function Fi(t){const e=t.split("_");if(3===e.length){let t=new Gi;return t.conceptId=Number(e[0]),t.connectionTypeId=Number(e[1]),t.count=Number(e[2]),t}throw new Error("Input string must contain exactly three parts separated by underscores.")}function Bi(t){return t.startsWith("the_")?t.slice(4):t}var Ei=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Di=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oi(t,e,n){var o,i,r,c,a,s,l,d;return Di(this,void 0,void 0,(function*(){let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield Xe(t[u].ofTheConceptId),y=yield Xe(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield Xe(t[u].typeId);try{let t=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,s.characterValue.includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield Xe(t[u].typeId);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",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){console.log("this is error",t)}}}return e}))}var bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Hi(t,e,n){if(t in e){let o=e[t];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}var Mi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ji(t,e="DESC"){return console.log("this is the order",e),"ASC"==e?t.sort((function(t,e){return t.id-e.id})):t.sort((function(t,e){return e.id-t.id})),t}var Wi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var $i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ji(t,e){return $i(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=_i;let o,i=yield function(t,e=""){return Ii(this,void 0,void 0,(function*(){var o=O("application/json",e);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:o,body:r});return t.ok?yield t.json():(H(t),console.log("This is the freeschema query error",t.status),[])}catch(t){console.log("This is the freeschema query error others",t),function(t,e=""){if(t.status){let n=new b(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new b(t.message,!1,500,t.stack);throw n.setUrl(e),n}}(t,i)}}))}(t,""),r=(i.conceptIds,i.internalConnections,i.linkers),c=i.reverse,a=i.mainCompositionIds,s=i.countinfo,l=t.order,d=function(t=[]){let e=[];if(t.length>0)for(let n=0;n<(null==t?void 0:t.length);n++){let o=Fi(t[n]);e.push(o)}return e}(s);return o=e==Ai?yield function(t,e,n,o,i,r="DESC"){return Wi(this,void 0,void 0,(function*(){let e=yield Qn(t);yield Vi(i),e=ji(e,r);let c=[];c=yield function(t,e,n=[]){var o,i,r,c,a,s,l,d;return Ei(this,void 0,void 0,(function*(){let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Xe(t[u].ofTheConceptId),y=yield Xe(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Xe(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=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+"_reverse").includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Xe(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[i]={},e[t[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",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){console.log("this is error",t)}}}return e}))}(e,c,o),c=yield function(t,e,n=[]){var o,i,r,c,a,s,l,d;return Ei(this,void 0,void 0,(function*(){let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Xe(t[u].ofTheConceptId),y=yield Xe(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Xe(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Bi(o));let i={id:f.id,data:{[t]:e}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Xe(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[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",e=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=t,r=Bi(r),c=!0);let a={id:y.id,data:{[t]:e}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(t){console.log("this is error",t)}}}return e}))}(e,c,o);let a=yield function(t,e,n,o,i=[],r){var c,a,s,l,d,u,h;return Ei(this,void 0,void 0,(function*(){(new Date).getTime();let n=[],r=[];for(let e=0;e<t.length;e++)r.push(t[e].toTheConceptId),r.push(t[e].ofTheConceptId),r.push(t[e].typeId);for(let n=0;n<t.length;n++){let o=!1,r=yield Xe(t[n].ofTheConceptId),f=yield Xe(t[n].toTheConceptId);if(i.includes(t[n].id)&&(o=!0),1==o){if(0!=r.id&&0!=f.id&&f.id in e){let o,i=yield Xe(t[n].typeId),s=null!==(a=null===(c=f.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",l=!1;t[n].toTheConceptId in e&&(l=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let c={id:r.id,data:e[t[n].ofTheConceptId],created_on:t[n].entryTimeStamp},a=i.characterValue+"_reverse";Array.isArray(o[s][a])?o[s][a].push(c):a.includes("_s_")?(o[s][a]=[],o[s][a].push(c)):o[s][a]=c}}catch(t){console.log("this is error",t)}}}else if(0!=r.id&&0!=f.id&&r.id in e){let o,i=yield Xe(t[n].typeId),c=null!==(l=null===(s=r.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"self",a=!1;t[n].toTheConceptId in e&&(a=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o);let y=!0,p=i.characterValue;""==p&&(p=f.characterValue,y=!0),""==p&&(p=null!==(u=null===(d=null==f?void 0:f.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let r=e[t[n].toTheConceptId];if(r){let a={id:f.id,data:e[t[n].toTheConceptId],created_on:t[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(r):Array.isArray(o[c][p])?o[c][i.characterValue].push(a):p.includes("_s_")?(o[c][p]=[],o[c][p].push(a)):o[c][p]=a}}catch(t){console.log("this is error",t)}}}for(let t=0;t<o.length;t++){let i={};i.id=o[t],i.data=e[o[t]],n.push(i)}return n}))}(e,c,0,n,o);return a}))}(r,0,a,c,d,l):e==xi?yield function(t,e,n,o,i,r="DESC"){return Wi(this,void 0,void 0,(function*(){let e=yield Qn(t),c=yield Vi(i);e=ji(e,r);let a=[];a=yield Oi(e,a,o),a=yield function(t,e,n=[]){var o,i,r,c,a,s,l,d;return bi(this,void 0,void 0,(function*(){let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Xe(t[u].ofTheConceptId),y=yield Xe(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Xe(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Bi(o));let i={id:f.id,[t]:e},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Xe(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[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",r=y.characterValue,c=o.characterValue,a=!1;""==c&&(c=e,c=Bi(c),a=!0);let s={};s[e]={id:y.id,data:r,created_on:t[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=a?s[e]:s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s[e]))}catch(t){console.log("this is error",t)}}}return e}))}(e,a,o);let s=yield function(t,e,n,o=[],i){var r,c,a,s,l,d,u,h;return bi(this,void 0,void 0,(function*(){(new Date).getTime();let f=[],y=[];for(let e=0;e<t.length;e++)y.push(t[e].toTheConceptId),y.push(t[e].ofTheConceptId),y.push(t[e].typeId);for(let n=0;n<t.length;n++){let f=!1,y=yield Xe(t[n].ofTheConceptId),p=yield Xe(t[n].toTheConceptId);if(o.includes(t[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in e){let o,i=yield Xe(t[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;t[n].toTheConceptId in e&&(s=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let r=e[t[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let 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(t){console.log("this is error",t)}}}else if(0!=y.id&&0!=p.id&&y.id in e){let o,r=yield Xe(t[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",f=!1;t[n].toTheConceptId in e&&(f=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Hi(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",a=e[t[n].toTheConceptId];if(a){let e={};e[r]={data:a[r],id:p.id,created_on:t[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(e):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(e[r]):o[c][g].push(e)):o[c][g]=v?e[r]:e,Hi(p.id,i,e)}}catch(t){console.log("this is error",t)}}}console.log("this is the main compositions",n);for(let t=0;t<n.length;t++){let o={};console.log("this is the main compositions DATA",e[n[t]]),o=e[n[t]],o&&(o.id=n[t]),f.push(o)}return f}))}(e,a,n,o,c);return s}))}(r,0,a,c,d,l):e==Ui?yield function(t,e,n,o,i,r="DESC"){return Wi(this,void 0,void 0,(function*(){let e=yield Qn(t),c=yield Vi(i);e=ji(e,r);let a={};a=yield function(t,e={},n=[]){var o,i,r,c,a;return Mi(this,void 0,void 0,(function*(){for(const s of t){const t=n.includes(s.id),l=yield Xe(s.ofTheConceptId),d=yield Xe(s.toTheConceptId),u=yield Xe(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?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;null===(a=u.characterValue)||void 0===a||a.includes("_s_"),e[h.id]||(e[h.id]={}),e[h.id][y]||(e[h.id][y]={}),e[f.id]||(e[f.id]={}),e[f.id][p]=v}return e}))}(e,a,o),a=yield function(t,e={},n=[]){var o,i,r,c,a;return Mi(this,void 0,void 0,(function*(){for(const s of t){const t=n.includes(s.id),l=yield Xe(s.ofTheConceptId),d=yield Xe(s.toTheConceptId),u=yield Xe(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?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!==(a=u.characterValue)&&void 0!==a?a:"";let C=""===g?Bi(p):g;const m=C.includes("_s_"),T=!isNaN(Number(C)),N={id:f.id,data:{[p]:v}};e[h.id]||(e[h.id]={}),y in e[h.id]&&"string"!=typeof e[h.id][y]||(e[h.id][y]=T?[]:{});try{if(m)continue;T?e[h.id][y].push(N):e[h.id][y][t?`${C}_reverse`:C]=N}catch(t){console.error("Error formatting concept data:",t)}}return e}))}(e,a,o);let s=yield function(t,e,n,o=[],i){var r,c,a;return Mi(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=o.includes(n.id),s=yield Xe(n.ofTheConceptId),l=yield Xe(n.toTheConceptId),d=yield Xe(n.typeId);if(0===s.id||0===l.id)continue;const u=t?l:s,h=t?s: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===(a=h.type)||void 0===a?void 0:a.characterValue)||"";if(e[f]){const o=e[f][p],r=e[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Hi(f,i,e[f]);try{t?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],Hi(y,i,c)}catch(t){console.error("Error processing connection:",t)}}else console.log("This is the error in the source")}for(const t of n){const n=yield Xe(t);s.push({id:t,data:e[t],created_on:n.entryTimeStamp})}return s}))}(e,a,n,o,c);return s}))}(r,0,a,c,d,l):yield function(t,e,n,o,i){return Wi(this,void 0,void 0,(function*(){let e=yield Qn(t);e=ji(e);let i=[];i=yield Oi(e,i,o),i=yield function(t,e,n){var o,i,r,c,a,s,l,d;return Di(this,void 0,void 0,(function*(){let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield Xe(t[u].ofTheConceptId),y=yield Xe(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield Xe(t[u].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=s.characterValue;""==o&&(o=t,o=Bi(o));let i={[t]:e},l=o+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield Xe(t[u].typeId);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",e=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=t,r=Bi(r),c=!0);let a={[t]:e};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?e:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(e))}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o);let r=yield function(t=[],e=[],n=[],o,i=[]){var r,c,a,s,l,d;return Di(this,void 0,void 0,(function*(){let o=[],u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;i.includes(t[n].id)&&(o=!0);let u=yield Xe(t[n].ofTheConceptId),h=yield Xe(t[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in e){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[i]={},e[t[n].toTheConceptId]=o);let a=yield Xe(t[n].typeId);try{let r=a.characterValue+"_reverse",c=e[t[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(t){console.log("this is error",t)}}}else if(0!=u.id&&0!=h.id&&u.id in e){let o,i=null!==(s=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},e[t[n].ofTheConceptId]=o);let r=!1,c=(yield Xe(t[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 a=e[t[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(t){console.log("this is error",t)}}}for(let t=0;t<n.length;t++){let i=e[n[t]];i&&(i.id=n[t],o.push(i))}return o}))}(e,i,n,0,o);return r}))}(r,0,a,c),o}))}class Qi{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=ki,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var zi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qi(t,e,n=!1){return zi(this,void 0,void 0,(function*(){let o=[];if(n){let n=yield _n(t),i=yield An(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield Sn(t);for(let t=0;t<n.length;t++)X.AddConnection(n[t]);let i=yield An(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function Ki(t,e,n,o=!1){return zi(this,void 0,void 0,(function*(){let i=[],r=[];if(i=o?yield qi(e,n,o):yield qi(t,n,o),o)for(let e=0;e<i.length;e++)i[e].ofTheConceptId==t&&r.push(i[e]);else for(let t=0;t<i.length;t++)i[t].toTheConceptId==e&&r.push(i[t]);return r}))}var Yi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Xi{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.transactionId=Math.random().toString().substring(5)}initialize(){return Yi(this,void 0,void 0,(function*(){yield oe.initializeTransaction(this.transactionId)}))}markAction(){return Yi(this,void 0,void 0,(function*(){yield oe.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Yi(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},yield oe.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Yi(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield oe.SyncDataOnline(this.transactionId),this.actions={concepts:[],connections:[]},this.success=!1}))}MakeTheInstanceConcept(t,e,n=!1,o,i,r=999,c=0){return Yi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const a=yield xe(t,e,n,o,i,r,c,this.actions);return yield this.markAction(),a}catch(t){throw console.log(t),this.success=!1,t}}))}CreateConnection(t,e,n){return Yi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield We(t,e,n,this.actions);return yield this.markAction(),o}catch(t){throw console.log(t),this.success=!1,t}}))}MakeTheTypeConcept(t,e,n,o){return Yi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield gn(t,e,n,o,this.actions);return yield this.markAction(),i}catch(t){throw console.log(t),this.success=!1,t}}))}CreateTheConnectionGeneral(t,e,n,o,i,r,c,a=1,s=4,l=999){return Yi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield je(t,e,n,o,i,r,c,a,s,l,this.actions);return yield this.markAction(),d}catch(t){throw console.log(t),this.success=!1,t}}))}}function Zi(t=""){o.BearerAccessToken=t}function tr(t="",e="",i="CCSApp",c){const a=c||new gi;if(n.BASE_URL=t,n.AI_URL=a.aiUrl,e&&(n.NODE_URL=e),console.log("This is the base url",n.BASE_URL),a.hasOAuthCredentials()){const t=a.applicationName||i;o.setOAuthCredentials(a.clientId,a.clientSecret,t),r(a.clientId,a.clientSecret,t,!0)}else a.hasAccessToken()&&(o.BearerAccessToken=a.accessToken);(function(){return wi(this,void 0,void 0,(function*(){return yield new g(!0),yield function(){return Ti(this,void 0,void 0,(function*(){}))}(),!0}))})().then((()=>{const t=(new Date).getTime();(function(){return B(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield N();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];F.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{I.isDataLoaded=!0,I.isCharacterLoaded=!0,I.isTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare concept data is ",e)})),function(){return mi(this,void 0,void 0,(function*(){var t=yield w();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];Mt.AddConceptToMemory(n)}}))}().then((()=>{I.isLocalDataLoaded=!0,I.isLocalTypeLoaded=!0,I.isLocalCharacterLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare local concept ",e)})),function(){return Ci(this,void 0,void 0,(function*(){!function(){Ci(this,void 0,void 0,(function*(){var t=yield w();if(Array.isArray(t))for(var e=0;e<t.length;e++)Wt.AddConnection(t[e])}))}()}))}().then((()=>{I.isLocalConnectionLoaded=!0})),function(){return Ci(this,void 0,void 0,(function*(){!function(){Ci(this,void 0,void 0,(function*(){var t=yield N();if(Array.isArray(t))for(var e=0;e<t.length;e++)X.AddConnectionToMemory(t[e])}))}()}))}().then((()=>{I.isConnectionLoaded=!0,I.isConnectionTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare connections ",e)}))}))}var er=exports;for(var nr in e)er[nr]=e[nr];e.__esModule&&Object.defineProperty(er,"__esModule",{value:!0})})();
|
|
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:()=>Ui,AddGhostConcept:()=>zo,AddGhostConnection:()=>qo,BaseUrl:()=>n,BinaryTree:()=>R,CCSConfig:()=>mi,Composition:()=>mo,CompositionBinaryTree:()=>vo,CompositionNode:()=>yo,Concept:()=>_,ConceptsData:()=>B,Connection:()=>J,ConnectionData:()=>Z,CreateComposition:()=>_t,CreateConnection:()=>$t,CreateConnectionBetweenTwoConcepts:()=>on,CreateConnectionBetweenTwoConceptsGeneral:()=>cn,CreateDefaultConcept:()=>L,CreateDefaultLConcept:()=>Me,CreateSession:()=>Bo,CreateSessionVisit:()=>Vo,CreateTheCompositionLocal:()=>bt,CreateTheCompositionWithCache:()=>wo,CreateTheConnection:()=>rt,CreateTheConnectionGeneral:()=>Wt,CreateTheConnectionLocal:()=>Gt,DATAID:()=>Ri,DATAIDDATE:()=>Li,DATAV2:()=>Ei,DeleteConceptById:()=>Dn,DeleteConnectionById:()=>Xt,DeleteConnectionByIdBulk:()=>Zt,DeleteConnectionByTypeBulk:()=>yi,FilterSearch:()=>Ci,FormatFromConnections:()=>ti,FreeSchemaResponse:()=>M,FreeschemaQuery:()=>qi,GetAllConnectionsOfComposition:()=>fe,GetAllConnectionsOfCompositionBulk:()=>se,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Xi,GetComposition:()=>ve,GetCompositionBulk:()=>Qn,GetCompositionBulkWithDataId:()=>Kn,GetCompositionFromConnectionsWithDataId:()=>zn,GetCompositionFromConnectionsWithDataIdInObject:()=>Yn,GetCompositionList:()=>Ge,GetCompositionListLocal:()=>Ze,GetCompositionListLocalWithId:()=>et,GetCompositionListWithId:()=>Ue,GetCompositionLocal:()=>Qe,GetCompositionLocalWithId:()=>Ke,GetCompositionWithAllIds:()=>ge,GetCompositionWithCache:()=>Lo,GetCompositionWithDataIdBulk:()=>Po,GetCompositionWithDataIdWithCache:()=>Uo,GetCompositionWithId:()=>Ie,GetCompositionWithIdFromMemory:()=>Te,GetCompositionWithIdFromMemoryFromConnections:()=>Ne,GetConceptBulk:()=>te,GetConceptByCharacter:()=>_e,GetConceptByCharacterAndCategoryDirectApi:()=>In,GetConceptByCharacterAndType:()=>lt,GetConceptByTypeBulk:()=>dt,GetConnectionBulk:()=>$n,GetConnectionById:()=>qt,GetConnectionByTypeBulk:()=>pi,GetConnectionOfTheConcept:()=>Ht,GetConnectionsBetweenApi:()=>tr,GetLink:()=>sn,GetLinkRaw:()=>ln,GetLinkerConnectionFromConcepts:()=>En,GetLinkerConnectionToConcepts:()=>Bn,GetRelation:()=>Mo,GetRelationRaw:()=>Ho,GetRequestHeader:()=>O,GetRequestHeaderWithAuthorization:()=>b,GetTheConcept:()=>tn,GetUserGhostConnectionId:()=>Ko,GetUserGhostId:()=>Qo,GiveConnection:()=>Zi,HandleHttpError:()=>H,HttpResponse:()=>l,JUSTDATA:()=>_i,LConcept:()=>be,LConnection:()=>Lt,LISTNORMAL:()=>Pi,LoginToBackend:()=>to,MakeTheInstanceConcept:()=>St,MakeTheInstanceConceptLocal:()=>Dt,MakeTheTimestamp:()=>Hn,MakeTheTypeConcept:()=>mn,MakeTheTypeConceptApi:()=>Rn,NORMAL:()=>Si,PatcherStructure:()=>vi,RAW:()=>Gi,RecursiveSearchApi:()=>Zn,SchemaQueryListener:()=>zi,SearchAllConcepts:()=>xo,SearchLinkInternal:()=>hi,SearchLinkMultipleAll:()=>ei,SearchLinkMultipleApi:()=>Xo,SearchQuery:()=>jn,SearchStructure:()=>Ti,SearchWithLinker:()=>Ro,SessionData:()=>gi,Signin:()=>ro,Signup:()=>oo,SplitStrings:()=>V,SyncData:()=>it,TokenRefreshError:()=>s,TokenStorage:()=>o,Transaction:()=>ir,TrashTheConcept:()=>bn,UpdateComposition:()=>ko,UpdateCompositionLocal:()=>ci,UserBinaryTree:()=>$o,ViewInternalData:()=>li,buildFetchConnection:()=>nr,convertFromLConceptToConcept:()=>oi,deleteWithRetry:()=>p,getFromDatabaseWithType:()=>m,getFromDatabaseWithTypeOld:()=>N,getOAuthToken:()=>r,getWithRetry:()=>f,init:()=>cr,patchWithRetry:()=>v,postWithRetry:()=>h,putWithRetry:()=>y,recursiveFetch:()=>ke,recursiveFetchNew:()=>Co,refreshOAuthToken:()=>c,requestWithRetry:()=>u,storeToDatabase:()=>T,updateAccessToken:()=>rr});class n{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/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 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.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="http://localhost:5001/";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{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((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(),a=new URLSearchParams;a.append("client_id",e),a.append("client_secret",t),a.append("application_name",i);const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let e="",t="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield s.text()}else e=yield s.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 s.text();return{success:!1,error:`HTTP ${s.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(),a=new URLSearchParams;a.append("client_id",e),a.append("client_secret",t),a.append("refresh_token",i),a.append("grant_type","refresh_token");const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let e="",t="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield s.text()}else e=yield s.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 s.text();return{success:!1,error:`HTTP ${s.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 a=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class s 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 a(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return a(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return a(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 a(this,arguments,void 0,(function*(e,t,n,i,r=1){var c,a;const u=Object.assign(Object.assign({},n),o.getAuthHeader());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===(a=u["content-type"])||void 0===a?void 0:a.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(console.log("Received 401 Unauthorized, attempting token refresh..."),yield d()){console.log("Token refreshed successfully, retrying request..."),Object.assign(u,o.getAuthHeader());continue}throw new s("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(e){if(e instanceof s)throw e;if(n>=r)throw e;console.error(`Request failed (attempt ${n+1}/${r+1}):`,e)}throw new Error("Request failed after all retry attempts")}))}function h(e,t,n){return a(this,void 0,void 0,(function*(){return u("POST",e,t,n)}))}function f(e,t,n){return a(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 y(e,t,n){return a(this,void 0,void 0,(function*(){return u("PUT",e,t,n)}))}function p(e,t){return a(this,void 0,void 0,(function*(){return u("DELETE",e,t)}))}function v(e,t,n){return a(this,void 0,void 0,(function*(){return u("PATCH",e,t,n)}))}class g{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var C=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function T(e,t){}function m(e,t,n){return C(this,void 0,void 0,(function*(){}))}function N(e){return C(this,void 0,void 0,(function*(){}))}function w(e){return C(this,void 0,void 0,(function*(){}))}class I{}I.isTypeLoaded=!1,I.isCharacterLoaded=!1,I.isDataLoaded=!1,I.isLocalDataLoaded=!1,I.isLocalCharacterLoaded=!1,I.isLocalTypeLoaded=!1,I.isConnectionLoaded=!1,I.isConnectionTypeLoaded=!1,I.isLocalConnectionLoaded=!1;class k{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(e.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 A=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class x{static waitForDataToLoad(){return A(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isCharacterLoaded)return e("done");setTimeout(x.checkFlag,1e3,e)}static addNodeToTree(e){return A(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 A(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 k(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 A(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return A(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))}}x.characterRoot=null;var S=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class R{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 S(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isDataLoaded)return e("done");setTimeout(R.checkFlag,1e3,e)}static addConceptToTree(e){var t=new k(e.id,e,null,null),n=new k(e.characterValue,e,null,null);x.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return S(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return S(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}}R.root=null;class _{constructor(e,t,n,o,i,r,c,a,s,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=a,this.characterValue=`${s}`,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 L(){let e=G(new Date),t=G(new Date);return new _(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function G(e){const t=e.getMonth()+1,n=e.getDate(),o=e.getFullYear();let i=e.getHours();const r=e.getMinutes(),c=e.getSeconds(),a=i>=12?"PM":"AM";i%=12,i=i||12;const s=e=>e.toString().padStart(2,"0");return`${t}/${n}/${o} ${i}:${s(r)}:${s(c)} ${a}`}var U=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class P{static addNodeToTree(e){return U(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 k(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 U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isTypeLoaded)return e("done");setTimeout(P.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return U(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 U(this,void 0,void 0,(function*(){let n=L();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}}P.typeRoot=null;var E=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class B{constructor(){this.name="conceptsArray"}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){this.NPC.includes(e)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(e))}static GetNpc(e){return!!this.NPC.includes(e)}static AddConceptToStorage(e){e.id}static AddConcept(e){e.id>0&&(R.addConceptToTree(e),P.addConceptToTree(e),x.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(R.addConceptToTree(e),P.addConceptToTree(e),x.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);R.removeNodeFromTree(e.id),e.id}static GetConcept(e){return E(this,void 0,void 0,(function*(){var t=L(),n=yield R.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return E(this,void 0,void 0,(function*(){var t=L(),n=x.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return E(this,void 0,void 0,(function*(){var t=L(),n=x.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return E(this,void 0,void 0,(function*(){return L(),yield P.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return E(this,void 0,void 0,(function*(){var n=L(),o=yield x.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 E(this,void 0,void 0,(function*(){let n=[];return n=yield P.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return x.characterRoot}getName(){return this.name}}B.conceptsArray=[],B.NPC=[],B.conceptDictionary=[];var F=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function V(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var D=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function O(){return D(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){console.log("Token expired or near expiry, refreshing...");const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success?console.log("Token refreshed successfully"):console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:t}}))}function b(){return D(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()){console.log("Token expired or near expiry, refreshing...");const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success?console.log("Token refreshed successfully"):console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class M{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 H(e){if(401==e.status){let t=new M(e.statusText,!1,e.status,"");throw t.setUrl(e.url),t}}function j(e){if(401==e.status){let t=new M(e.body,!1,e.status,"");throw t.setUrl(e.headers.url),t}}var W=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function $(e,t){return W(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",e),o.append("user_id",t.toString());var i=yield O("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++)B.AddConcept(e[r])}console.log("GetAllConceptsByType error",c.status),H(c)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class J{constructor(e=0,t,n,o,i,r,c,a,s,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=L(),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=a,this.orderId=s,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class Q{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(e.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 K=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class z{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 Q(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return K(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isConnectionLoaded)return e("done");setTimeout(z.checkFlag,1e3,e)}static removeNodeFromTree(e){return K(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return K(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}z.connectionroot=null;var q=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Y{static addNodeToTree(e){return q(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 q(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isConnectionTypeLoaded)return e("done");setTimeout(Y.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new Q(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 q(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 q(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}))}}Y.connectionTypeRoot=null;var X=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Z{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){}static AddConnection(e){e.isTemp||(z.addConnectionToTree(e),Y.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(z.addConnectionToTree(e),Y.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(e.id,z.removeNodeFromTree(e.id),Y.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return z.connectionroot}static GetConnectionTypeTree(){return Y.connectionTypeRoot}static GetConnection(e){return X(this,void 0,void 0,(function*(){var t=new J(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield z.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return X(this,void 0,void 0,(function*(){var t=[],n=yield Y.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}}Z.connectionArray=[],Z.connectionDictionary=[];var ee=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function te(e){return ee(this,void 0,void 0,(function*(){let t=[];try{var o=[];for(let n=0;n<e.length;n++){let i=yield B.GetConcept(e[n]);0==i.id?o.push(e[n]):t.push(i)}if(0==o.length)return t;{var i=yield O();const e=yield fetch(n.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(e.ok){let n=yield e.json();if(n.length>0)for(let e=0;e<n.length;e++){let o=n[e];t.push(o),B.AddConcept(o)}}else console.log("Get Concept Bulk error",e.status),H(e);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 ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function oe(){return ne(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 te(t)}}))}var ie=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function re(){return ie(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield Z.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function ce(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||Z.RemoveConnection(t[n]))}var ae=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function se(){return ae(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var o=yield re(e),i=yield function(){return ae(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=yield O();const r=yield fetch(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++)Z.AddConnection(e[i]),t.push(e[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),H(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 ce(t=i,o),yield oe(t),t}))}var le=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const de=new Map;function ue(e){return le(this,void 0,void 0,(function*(){let t=L();if(de.has(e))return de.get(e)||t;const o=(()=>le(this,void 0,void 0,(function*(){try{var o=yield B.GetConcept(e);let r=B.GetNpc(e);if(0!=o.id||r)return o;{var i=yield O("application/x-www-form-urlencoded");const o=yield fetch(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${e}`});return o.ok?(t=yield o.json(),t.id>0?B.AddConcept(t):B.AddNpc(e)):(console.log("Get the concept error",o.status,e),H(o)),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{de.delete(e)}})))();return de.set(e,o),o}))}var he=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function fe(e){return he(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield Z.GetConnectionsOfCompositionLocal(e)).length)t=yield ye(e);else{var n=yield ye(e);ce(n,t),t=n}return t}))}function ye(e){return he(this,void 0,void 0,(function*(){var t=[];try{var o=yield O("application/x-www-form-urlencoded");const r=yield fetch(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${e}`});if(!r.ok)throw H(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)Z.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 pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ve(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function ge(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield Ae(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function Ce(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function Te(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=e,l}))}function me(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=e,l.created_at=a.entryTimeStamp,l}))}function Ne(e,t){return pe(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 a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,t,r);i[null!==(o=null===(n=null==a?void 0:a.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=e,l}))}function we(e,t){return pe(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r={},c=yield B.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield ue(e));var a=yield ke(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:""]=a;var s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=e,s}))}function Ie(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield B.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield ue(e));var s=yield ke(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=e,l}))}function ke(e,t,n){return pe(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[];if(0==e)return null;var l=yield B.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield ue(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield B.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 B.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield ue(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield B.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 ke(f,t,n,o);a[p]=e}}else{const e=yield ke(f,t,n,o);s[p]=e,a=s}}return a}))}function Ae(e,t,n){return pe(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[];if(0==e)return null;var l=yield B.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield ue(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield B.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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),a.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield B.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield ue(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield B.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 Ae(f,t,n);a[p]=e}}else{const e=yield Ae(f,t,n);s[p]=e,a=s}}return a}))}var xe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Se(e){return xe(this,void 0,void 0,(function*(){let t=L();try{var o=yield O("application/x-www-form-urlencoded");const i=yield fetch(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${e}`});return i.ok?(t=yield i.json(),t.id>0&&B.AddConcept(t)):(console.log("Error in Getting concept by character value Error",i.status),H(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 Re=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function _e(e){return Re(this,void 0,void 0,(function*(){var t=yield B.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Se(e),t=yield B.GetConceptByCharacter(e)),t}))}var Le=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ge(e,t){return Le(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield _e(e),r=[];if(i){yield $(e,t);for(var c=yield B.GetConceptsByTypeIdAndUser(i.id,t),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield se(s),l=a;l<a+n;l++)if(c[l]){var d=yield Ce(c[l].id);r.push(d)}}return r}))}function Ue(e,t){return Le(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield _e(e),r=[];if(i){yield $(e,t);for(var c=yield B.GetConceptsByTypeIdAndUser(i.id,t),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield se(s),l=a;l<a+n;l++)if(c[l]){var d=yield Te(c[l].id);r.push(d)}}return r}))}class Pe{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(e.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 Ee=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Be{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 Pe(e.id,e,null,null);new Pe(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return Ee(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalDataLoaded)return e("done");setTimeout(Be.checkFlag,1e3,e)}static getNodeFromTree(e){return Ee(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 Ee(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Be.root=null;var Fe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Ve{static waitForDataToLoad(){return Fe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalCharacterLoaded)return e("done");setTimeout(Ve.checkFlag,1e3,e)}static addNodeToTree(e){return Fe(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 Pe(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 Fe(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))}}Ve.LocalCharacterRoot=null;var De=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Oe{static addNodeToTree(e){return De(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 Pe(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 De(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalTypeLoaded)return e("done");setTimeout(Oe.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return De(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}))}}Oe.LocalTypeRoot=null;class be{constructor(e,t,n,o,i,r,c,a=!1,s,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=a,this.typeCharacter=c,this.entryTimeStamp=s,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function Me(){let e=new Date,t=new Date;return new be(0,0,0,0,0,"0","0",!1,e,t,0)}var He=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class je{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(Be.addConceptToTree(e),Ve.addConceptToTree(e),Oe.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Be.addConceptToTree(e),Ve.addConceptToTree(e),Oe.addConceptToTree(e))}static GetConcept(e){return He(this,void 0,void 0,(function*(){var t=Me(),n=yield Be.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return He(this,void 0,void 0,(function*(){var t=Me(),n=Ve.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return He(this,void 0,void 0,(function*(){var n=Me(),o=yield Ve.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 He(this,void 0,void 0,(function*(){let n=[];return n=yield Oe.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}je.localconceptsArray=[];var We=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class $e{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,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 We(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalConnectionLoaded)return e("done");setTimeout($e.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return We(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}}$e.connectionArray=[],$e.connectionDictionary=[];var Je=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Qe(e){return Je(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield $e.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield je.GetConcept(e),s=yield ze(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=s,i}))}function Ke(e){return Je(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield $e.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield je.GetConcept(e);if(0!=a.id){var s=yield ze(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=s;var l={}}return l.data=i,l.id=e,l}))}function ze(e,t,n){return Je(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[],l=yield je.GetConcept(e);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield je.GetConcept(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 je.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield je.GetConcept(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:"top").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield ze(f,t,n);a[p]=e}}else{const e=yield ze(f,t,n);s[p]=e,a=s}}return a}))}var qe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ye(e){return qe(this,void 0,void 0,(function*(){return yield je.GetConceptByCharacter(e)}))}var Xe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ze(e,t){return Xe(this,void 0,void 0,(function*(){var n=yield Ye(e),o=[];if(n)for(var i=yield je.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Qe(i[r].id);o.push(c)}return o}))}function et(e,t){return Xe(this,void 0,void 0,(function*(){var n=yield Ye(e),o=[];if(n)for(var i=yield je.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Ke(i[r].id);o.push(c)}return o}))}function tt(e){return t=this,o=void 0,r=function*(){let t=L();try{var o=yield O();const i=yield h(n.CreateTheConceptUrl(),o,JSON.stringify(e));if(!i.ok)throw j(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((i=void 0)||(i=Promise))((function(e,n){function c(e){try{s(r.next(e))}catch(e){n(e)}}function a(e){try{s(r.throw(e))}catch(e){n(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,a)}s((r=r.apply(t,o||[])).next())}));var t,o,i,r}function nt(e){return t=this,o=void 0,r=function*(){let t=new J(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield O(),i=JSON.stringify(e);const r=yield h(n.CreateTheConnectionUrl(),o,i);return r.ok?yield r.json():(console.log("Create the connection error message: ",r),j(r)),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{s(r.next(e))}catch(e){n(e)}}function a(e){try{s(r.throw(e))}catch(e){n(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,a)}s((r=r.apply(t,o||[])).next())}));var t,o,i,r}var ot=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class it{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 ot(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)),this.transactionCollections=this.transactionCollections.filter((e=>new Date(e.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;t=o.data.concepts.slice(),n=o.data.connections.slice(),t.length>0&&(yield tt(t)),n.length>0&&(yield nt(n))}else{for(let e=0;e<this.conceptsSyncArray.length;e++)B.AddConcept(this.conceptsSyncArray[e]);for(let e=0;e<this.connectionSyncArray.length;e++)Z.AddConnection(this.connectionSyncArray[e]);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield tt(t)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield nt(n))}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return ot(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 ot(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 ot(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 ot(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e];this.connectionSyncArray=[]}return"done"}))}}function rt(e,t,n,o,i,r,c){var a=new J(0,e,n,t,o,t,i,t,1,t,0,t,4,t,r,c);return e==n?(a.ofTheConceptId=0,a.toTheConceptId=1,a):(a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),it.AddConnection(a),a)}it.conceptsSyncArray=[],it.connectionSyncArray=[],it.transactionCollections=[];var ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},at=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const st=new Map;function lt(e,t){return at(this,void 0,void 0,(function*(){let o=yield B.GetConceptByCharacterAndTypeLocal(e,t),i=e+t;if(st.has(i))return st.get(i)||o;const r=(()=>at(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),a=yield O();const i=yield fetch(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:a,body:c});if(i.ok){let e=yield i.json();o=e,B.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),H(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{st.delete(i)}})))();return st.set(i,r),r}))}function dt(e){return at(this,void 0,void 0,(function*(){let t=[],o=JSON.stringify(e);var i=yield O();const r=yield fetch(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let e=yield r.json();t=yield te(e)}else console.log("This is the concept by type and character error",r.status),H(r);return t}))}class ut{constructor(e,t,n,o,i,r,c,a,s,l){this.id=0,this.userId=e,this.data=t,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var ht=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};let ft=!1,yt=[];const pt=()=>{yt.length>0&&!ft&&yt.shift()()};var vt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};let gt=!1,Ct=[];const Tt=()=>{Ct.length>0&&!gt&&Ct.shift()()};var mt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Nt{static getId(){return mt(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return vt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{console.log("trying to fetch more concepts"),Ct.push((()=>vt(this,void 0,void 0,(function*(){try{if(gt)return;if(gt=!0,Nt.ids.length>10)return console.log("Enough IDs available, skipping fetch."),gt=!1,Tt(),e();var o=yield O("application/x-www-form-urlencoded");const t=yield fetch(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!t.ok)throw H(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)Nt.AddId(r[i]);console.log("Ids Fetch Success"),e()}catch(e){e instanceof Error?console.log("get reserved ids error message: ",e.message,n.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",e),t(e)}finally{gt=!1,Tt()}})))),Tt()}))}))}());var e=this.ids[0];return this.ids.shift(),e}))}static AddId(e){this.ids.includes(e)||this.ids.push(e)}}Nt.ids=[];class wt{static getId(){return mt(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return ht(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{yt.push((()=>ht(this,void 0,void 0,(function*(){try{if(ft)return;if(ft=!0,wt.connectionIds.length>10)return ft=!1,pt(),e();var o=yield O("application/x-www-form-urlencoded");const t=yield fetch(n.GetReservedConnectionIdUrl(),{method:"GET",headers:o});if(!t.ok)throw H(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)wt.AddId(r[i]);e()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),t(e)}finally{ft=!1,pt()}})))),pt()}))}))}());var e=this.connectionIds[0];return this.connectionIds.shift(),e}))}static AddId(e){this.connectionIds.includes(e)||this.connectionIds.push(e)}}wt.connectionIds=[];var It=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function kt(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return It(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield Nt.getId();let v=new Date,g=new Date;var C=new _(p,t,i,r,n,o,c,a,e,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,it.AddConcept(C),y.concepts.push(C),C}))}function At(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return It(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield Nt.getId();let v=new Date,g=new Date;var C=new _(p,t,i,r,n,o,c,a,e,s,l,d,u,h,f,!1,v,g);return B.AddConcept(C),C.updateRecursion=!0,it.AddConcept(C),y.concepts.push(C),C}))}var xt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function St(e,t){return xt(this,arguments,void 0,(function*(e,t,o=!1,i,r,c=999,a=0,s={concepts:[],connections:[]}){let l,d=c,u=999,h=i,f=i,y=r,p=i,v="",g=t.length,C=L();v=e.startsWith("the_")?e:"the_"+e;(new Date).getTime();if(o)C=yield Rn(e),l=yield kt(t,i,4,i,C.id,C.userId,a,999,u,h,y,p,d,f,s),(new Date).getTime();else if(g>255)C=yield Rn(v),l=yield kt(t,i,4,i,C.id,C.userId,a,999,u,h,y,p,d,f,s),function(e){ct(this,void 0,void 0,(function*(){try{var t=yield O();const o=yield fetch(n.CreateTheTextDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw H(o),new Error(`Error! status: ${o.status}`);return yield o.json()}catch(e){throw e instanceof Error?console.log("Create the text error message: ",e.message):console.log("Create the text unexpected error: ",e),e}}))}(new ut(i,t,u,h,y,p,d,f,Date.now().toString(),!0)),(new Date).getTime();else{C=yield Rn(v);let e=yield lt(t,C.id);l=e,0==e.id&&0==e.userId&&(l=yield At(t,i,4,i,C.id,C.userId,12,12,u,h,y,p,d,f,s)),(new Date).getTime()}return l.type=C,l}))}var Rt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function _t(e){return Rt(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=L();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 St(o,"",!0,a,s,l),h=p.id,d=p.id,yield _t(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 St(o,"",!0,a,s,l),yield rt(f,y,p.id,p.userId,h,l,p.userId),yield _t(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 St(o,e[o].toString(),!1,a,s,l);yield rt(f,y,p.id,p.userId,h,l,p.userId)}return u}))}class Lt{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=Me(),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=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function Gt(e,t,n,o=1){Math.floor(1e8*Math.random());let i=0,r=0,c=0;i=e,r=t,c=n;let a=new Lt(0,0,0,0,0,0);return e!=t&&(a=new Lt(0,e,t,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),$e.AddConnection(a)),a}var Ut=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Pt(e,t,n,o,i,r){return Ut(this,arguments,void 0,(function*(e,t,n,o,i,r,c=0){var a=Math.floor(1e8*Math.random());let s=new Date,l=new Date;var d=new be(a,n,i,o,r,e,t,!0,s,l,c);return d.isTemp=!0,je.AddConcept(d),d}))}var Et=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Bt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ft(e,t,n,o){return Bt(this,void 0,void 0,(function*(){var i=yield Ye(e);if(i&&(0==i.id||0==i.userId)){var r=V(e);if(r[0]==e){var c=yield function(e,t,n){return Et(this,void 0,void 0,(function*(){var t=yield je.GetConceptByCharacterAndTypeLocal(e,51),o=t;return 0==o.id&&(o=t=yield Pt(e,"the",n,4,51,4)),o}))}(e,0,o);i=c}else{var a=yield Ft(r[0],t,n,o),s=yield Ft(r[1],t,n,o);s&&(i=c=yield Pt(e,r[1],o,a.id,s.id,4))}}return i}))}var Vt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Dt(e,t){return Vt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){var a,s,l,d=o,u=t.length;if(l=e.startsWith("the_")?e:"the_"+e,n)a=yield Ft(e,999,o,o),s=yield Pt(t,e,o,4,a.id,4,c);else if(u>255)a=yield Ft(l,999,d,o),s=yield Pt(t,l,o,4,a.id,4);else{a=yield Ft(l,999,d,o);var h=yield je.GetConceptByCharacterAndTypeLocal(t,a.id);s=h,0==h.id&&0==h.userId&&(s=yield Pt(t,l,o,4,a.id,4))}return s.type=a,s}))}var Ot=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function bt(e){return Ot(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:999,l=null!=c?c:4,d=null!=o?o:0,u=Me();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=y=yield Dt(o,"",!0,a,s,l),h=y.id,d=y.id,yield bt(e[o],y.id,y.userId,h,i,r,c)}else{var f=null!=t?t:999,y=(h=d,yield Dt(o,"",!0,a,s,l));yield Gt(f,y.id,h),yield bt(e[o],y.id,y.userId,h,i,r,c)}else f=null!=t?t:999,h=d,y=yield Dt(o,e[o].toString(),!1,a,s,l),yield Gt(f,y.id,h);return u}))}var Mt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ht(e,t,o){return Mt(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${e}`),a.append("ofTheConceptId",`${t}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield O("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),H(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 jt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Wt(e,t,n,o,i,r,c){return jt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){let u=t,h=t,f=t;999!=l&&(f=l);let y=t,p=t,v=yield wt.getId(),g=new J(v,e,n,t,o,f,i,h,a,u,0,y,s,p,r,c);return e==n?(g.ofTheConceptId=0,g.toTheConceptId=1,g):(g.toUpdate=!0,g.isTemp=!1,it.AddConnection(g),d.connections.push(g),g)}))}function $t(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,o={concepts:[],connections:[]}){let i=yield Rn(n),r=e.userId;return yield Wt(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,r,o)}))}var Jt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Qt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Kt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},zt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function qt(e){return zt(this,void 0,void 0,(function*(){var t=yield Z.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var o=yield function(e){return Kt(this,void 0,void 0,(function*(){var t=yield Z.GetConnection(e);try{if(0!=t.id)return t;{var o=yield O("application/x-www-form-urlencoded");const i=yield fetch(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${e}`});return i.ok?(t=yield i.json(),Z.AddConnection(t)):(console.log("Get Connection Error",i.status),H(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 Yt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Xt(e){return Yt(this,arguments,void 0,(function*(e,t=""){let o=!1;var i=yield qt(e);return o=yield function(e){return Qt(this,arguments,void 0,(function*(e,t=""){let o=!1;try{const i=new FormData;let r=yield O("application/x-www-form-urlencoded");""!=t&&(r=yield b("application/x-www-form-urlencoded",t)),i.append("id",e.toString()),i.append("apiKey","nodeserver");const c=yield fetch(n.DeleteTheConnectionUrl(),{method:"POST",body:i,redirect:"follow"});c.ok?o=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),H(c))}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),z.removeNodeFromTree(e),Y.removeTypeConcept(i.typeId,e),o}))}function Zt(e){return Yt(this,void 0,void 0,(function*(){let t=yield function(e){return Jt(this,void 0,void 0,(function*(){let t=!1;try{let o=yield b();const i=yield fetch(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),H(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&&z.removeNodeFromTree(n)}return t}))}var en=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function tn(e){return en(this,arguments,void 0,(function*(e,t=999){var n=L();if(e<0)return oi(yield Qo(t,e));if(null!=(n=yield B.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield ue(e)),0!=n.id&&null==n.type&&null==(yield B.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield ue(n.typeId);n.type=o}return n}))}var nn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function on(e,t,n){return nn(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield rn(o,t,a));var d=yield St("connection",c,!1,999,999,999);let u=new J(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);it.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield rn(u,e,a));var f=yield St("connection",h,!1,999,999,999);let y=new J(0,e.id,t.id,e.userId,t.userId,e.userId,f.id,f.userId,1e3,a,999,s,4,l,999,999);return it.AddConnection(y),y}))}function rn(e,t){return nn(this,arguments,void 0,(function*(e,t,n=null){for(var o,i=t,r=null!=n?n:t.userId,c=r,a=r,s=999,l=e+"_count",d=(null===(o=t.type)||void 0===o?void 0:o.characterValue)+"_s_"+l,u=yield St("connection",d,!1,r,4,s),h=yield Ht(u.id,t.id,r,10,1),f=[],y=L(),p=0;p<h.length;p++){let e=yield tn(h[p].toTheConceptId);f.push(e)}if(f.length<1)y=yield St("count","1",!1,r,4,s);else{var v=f[0];let e=0;try{e=Number(v.characterValue)}catch(t){e=0}e+=1,y=yield St("count",e.toString(),!1,r,4,s);for(let e=0;e<h.length;e++)Xt(h[e].id)}let g=new J(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,a,s,999);yield it.AddConnection(g)}))}function cn(e,t,n){return nn(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield rn(o,t,a));var d=yield St("connection",c,!1,999,999,999);let u=new J(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);it.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield rn(u,e,a));var f=yield St("connection",h,!1,999,999,999);return yield Wt(e.id,e.userId,t.id,t.userId,f.id,999,999,1e3,4)}))}var an=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function sn(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield tn(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,s=yield lt(a,16);if(s.id>0){for(var l=yield Ht(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield se(d),u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield tn(e),n=yield me(t.id);r.push(n)}}return r}))}function ln(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield tn(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,s=yield lt(a,16);if(s.id>0){for(var l=yield Ht(s.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 tn(e);r.push(t)}}return r}))}class dn{constructor(e,t,n,o,i,r,c,a,s,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=a,this.isNew=l}}class un{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new dn(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}}un.characterData=[];class hn{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var fn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},yn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function pn(e,t,o,i,r){return yn(this,void 0,void 0,(function*(){return new dn(t,e,o,t,i,t,r,t,"",!1),yield function(){return fn(this,void 0,void 0,(function*(){var e;try{if(0==(e=un.GetCharacter(e.data)).id){var t=yield O();const i=yield fetch(n.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!i.ok)throw H(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new dn(r.userId,e.data,0,0,4,4,999,999,"",!1);return o.id=r.id,un.AddCharacter(o),r}return new hn(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 vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function gn(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return vn(this,void 0,void 0,(function*(){var y=yield lt(e,i),p=y;return 0==p.id&&(p=y=yield kt(e,t,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var Cn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Tn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function mn(e,t,n,o){return Tn(this,arguments,void 0,(function*(e,t,n,o,i={concepts:[],connections:[]}){var r=yield _e(e);if(r&&(0==r.id||0==r.userId)){var c=V(e);if(c.length>0)if(console.log(c),c[0]==e){var a=yield function(e,t,n,o,i,r){return Cn(this,void 0,void 0,(function*(){var i,c=t,a=t;i=t;var s,l=t,d=t,u=t;if(1==e.length){var h=e.charCodeAt(0);yield pn(e,t,n,o,r),s=gn(e,t,4,c,h,u,49,l,n,a,o,i,r,d)}else{var f=yield pn(e,t,n,o,r);f.isNew,s=yield gn(e,t,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(e,o,999,999,0,t);r=a}else{var s=yield mn(c[0],t,n,o,i),l=yield mn(c[1],t,n,o,i);l&&(r=yield At(e,o,s.id,o,l.id,o,999,o,999,o,999,o,t,o,i))}}return r}))}var Nn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const wn=new Map;function In(e,t){return Nn(this,void 0,void 0,(function*(){let o=L();if(wn.has(e+t))return wn.get(e+t)||o;const i=(()=>Nn(this,void 0,void 0,(function*(){try{var i=yield O("application/x-www-form-urlencoded");const r=yield fetch(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${e}&category_id=${t}`});if(r.ok){let e=yield r.json();o=e,B.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),H(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{wn.delete(e+t)}})))();return wn.set(e+t,i),i}))}var kn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function An(e){return kn(this,void 0,void 0,(function*(){let t=L();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=V(e);if(o.length>1){let n=1,i=yield An(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return kn(this,void 0,void 0,(function*(){let n=yield B.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield In(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return kn(this,void 0,void 0,(function*(){console.log("inside the character length function",e);var t=yield B.GetConceptByCharacterAndTypeLocal(e,49);return console.log("inside the character length function after",t),0==t.id&&(t=yield Se(e)),t}))}(e):o[0]==e&&(t=yield function(e){return kn(this,void 0,void 0,(function*(){var t=yield B.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Se(e)),t}))}(e));return t}))}var xn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const Sn=new Map;function Rn(e,t){return xn(this,void 0,void 0,(function*(){let t=L();if(Sn.has(e))return Sn.get(e)||t;const o=(()=>xn(this,void 0,void 0,(function*(){try{if(t=yield An(e),0==t.id||4==t.typeId){var o=yield O("application/x-www-form-urlencoded");const i=yield fetch(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${e}`});if(!i.ok)throw H(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();t=r,t.id>0&&B.AddConcept(t)}return 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{Sn.delete(e)}})))();return Sn.set(e,o),o}))}var _n=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ln(e){return _n(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield O("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:o});if(c.ok){const e=yield c.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"),H(c);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 Gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Un(e){return Gn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield O("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:o});if(c.ok){const e=yield c.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"),H(c);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 Pn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function En(e){return Pn(this,void 0,void 0,(function*(){for(var t=yield Ln(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield tn(o);e.type=i}return t}))}function Bn(e){return Pn(this,void 0,void 0,(function*(){for(var t=yield Un(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield tn(o);e.type=i}return t}))}var Fn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Dn(e){return Vn(this,arguments,void 0,(function*(e,t=""){var o=yield tn(e);yield R.removeNodeFromTree(e);var i=o.typeId,r=o.characterValue;yield P.removeTypeConcept(i,e),yield x.removeNodeByCharacter(r,e);let c=yield function(e){return Fn(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield O("application/x-www-form-urlencoded");""!=t&&(i=yield b("application/x-www-form-urlencoded",t));const r=new FormData;r.append("id",e.toString()),r.append("apiKey","nodeserver");const c=yield fetch(n.DeleteConceptUrl(),{method:"POST",body:r});if(!c.ok)throw H(c),new Error(`Error! status: ${c.status}`);o=(yield c.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 On=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function bn(e,t){return On(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 fetch(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw H(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 Mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Hn(e,t,n,o){return Mn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,a=n,s=n,l=e.startsWith("the_"),d=L();return r=l?e:"the_"+e,d=yield Rn(r),yield gn(t,n,4,n,d.id,d.userId,0,999,999,c,4,s,999,a)}))}class jn{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,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function $n(){return Wn(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=[];for(let n=0;n<e.length;n++){let i=yield Z.GetConnection(e[n]);0==i.id?o.push(e[n]):t.push(i)}if(0==o.length)return t;{var i=yield O();const e=yield fetch(n.GetConnectionBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});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),Z.AddConnection(o)}yield oe(t)}}else console.log("Get Connection Bulk error",e.status),H(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 Jn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Qn(){return Jn(this,arguments,void 0,(function*(e=[]){yield se(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Ce(e[o]);t.push(n)}return t}))}function Kn(){return Jn(this,arguments,void 0,(function*(e=[]){yield se(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Te(e[o]);t.push(n)}return t}))}function zn(){return Jn(this,arguments,void 0,(function*(e=[],t=[]){yield $n(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||Z.RemoveConnection(t[n])}(t,yield re(e));var n=[];for(let t=0;t<e.length;t++){var o=yield Te(e[t]);n.push(o)}return n}))}function qn(){return Jn(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 Z.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 $n(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 te(i),n}))}function Yn(){return Jn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],o=[];for(let e=0;e<t.length;e++){let i=yield Z.GetConnection(t[e]);0==i.id?n.push(t[e]):o.push(i)}let i=yield $n(n);for(let e=0;e<i.length;e++)o.push(i[e]);let r={},c=[];for(var a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);console.time("start");for(let t=0;t<e.length;t++){let n=yield we(e[t],o,c);r[e[t]]=n}return console.timeEnd("start"),r}))}var Xn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Zn(){return Xn(this,arguments,void 0,(function*(e=0,t=[],o=""){var i=[];try{var r=new jn;r.composition=e,r.listLinkers=t,r.textSearch=o;var c=JSON.stringify(r),a=yield O();const d=yield fetch(n.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const e=yield d.json();var s=e.compositionIds,l=e.internalConnections;e.externalConnections,i=yield zn(s,l)}else console.log("recursive search error ",d.status),H(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 eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function to(e,t){return eo(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 a=yield fetch(n.LoginUrl(),{method:"POST",headers:r,body:c});if(a.ok){const e=yield a.json();return o.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",a.status),H(a)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var no=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function oo(e){return no(this,void 0,void 0,(function*(){const t=yield function(){return no(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(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}:H(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(n.SignupUrl(),e);return t}))}var io=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ro(e){return io(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 fetch(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}:H(e),o}catch(e){throw console.log("Sign in api error",e),e}}))}function co(e,t){return-1===e.indexOf(t)&&e.push(t),e}function ao(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 so(e=[],t){let n=[],o=t.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(e))for(let i=0;i<e.length;i++){let r=e[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),t.typeId!=e[i].typeId&&o!=r||n.push(e[i])}return n}function lo(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 uo(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 ho(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function fo(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class yo{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&&(vo.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(e.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 po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class vo{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 yo(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return po(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return po(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}}vo.root=null;var go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Co(e,t,n,o){return go(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let a={};const s=[];if(0==e)return"";let l=To(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield tn(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=To(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield tn(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=To(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield tn(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield B.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield tn(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 Co(d,t,n,o,i);a[u]=e}}else{const e=yield Co(d,t,n,o,i);s[u]=e,a=s}}}return a}))}function To(e,t){let n=L();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class mo{constructor(){this.id=0,this.mainConcept=L(),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 Co(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((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 No=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function wo(e){return No(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=L();null==a&&(a=new mo);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield St(o,"",!0,s,l,d);if(null==t&&null==n){let t=u;h=f,t=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield wo(e[o],f.id,f.userId,t,i,r,c,a)}else{const s=null!=t?t:999,l=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield rt(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield wo(e[o],f.id,f.userId,y,i,r,c,a)}null!=e[o]&&null!=e[o]&&a.subcompositions.push(f.id)}else{const i=null!=t?t:999,r=null!=n?n:999,c=u,h=yield St(o,e[o],!1,s,l,d);a.concepts.push(h);const f=yield rt(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var Io=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ko(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=L(),a=L();const s=[];let l=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(l<0){let e=yield tn(l,t);if(!(e.id>0))return null;l=e.id}i=yield fe(l);const h=[],f=new mo,y=[];f.id=l,f.isUpdating();let p=[];for(let e=0;e<i.length;e++)co(y,i[e].ofTheConceptId),co(h,i[e].ofTheConceptId),co(h,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let e=0;e<h.length;e++){const t=yield tn(h[e]);l==h[e]&&(c=t),d==h[e]&&(a=t),r.push(t)}const v=e.patchObject;for(const e in v){let i=L();const l=v[e];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield St(e,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const t=ao(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=lo(f.connections,t[e].id);u=u.concat(n),s.push(t[e])}yield wo(v[e],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield St(e,l,!1,t,o,n);const c=ao(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=lo(f.connections,c[e].id);u=u.concat(t),s.push(c[e])}}const h=yield rt(d.id,d.userId,i.id,i.userId,c.id,n,t);r.push(i),f.connections.push(h)}for(let e=0;e<u.length;e++)fo(f.connections,u[e]),Xt(u[e].id);for(let e=0;e<s.length;e++)ho(r,s[e]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),vo.addCompositionToTree(f),yield it.SyncDataOnline(),f.GetDataCache()}))}var Ao=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function xo(e,t,o,i){return Ao(this,arguments,void 0,(function*(e,t,o,i,r=10,c=1){var a=yield b("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",e),s.append("search",t),s.append("composition",o),s.append("inpage",r.toString()),s.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+s.toString();try{const e=yield fetch(l,{method:"GET",headers:a});return e.ok?yield e.json():(H(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var So=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ro(e){return So(this,arguments,void 0,(function*(e,t=""){var o=yield b("application/json",t);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(console.log("This is the searching error",e.status),H(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var _o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Lo(e){return _o(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},a={};const s=[];let l=yield B.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield ue(e));let d=[];d=t.length>0?Go(e,t):yield fe(e),i=d;for(let e=0;e<i.length;e++)s.includes(i[e].ofTheConceptId)||(s.push(i[e].ofTheConceptId),r.push(i[e].ofTheConceptId)),r.includes(i[e].toTheConceptId)||r.push(i[e].toTheConceptId);return a=yield ke(e,i,s,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,0==l.id?"":c}))}function Go(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function Uo(e){return _o(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=[];let d=yield B.GetConcept(e);0==d.id&&null!=e&&null!=e&&(d=yield ue(e));let u=[];u=t.length>0?Go(e,t):yield fe(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 a=yield ke(e,r,l),s[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=d.entryTimeStamp,i.data=s,i.id=e,0==d.id?"":i}))}function Po(e,t){return _o(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield $n(t);for(let t=0;t<e.length;t++){const i=yield Uo(e[t],n);i&&o.push(i)}return o}))}var Eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Bo(e){return Eo(this,void 0,void 0,(function*(){try{var t=yield O();const o=JSON.stringify(e),i=yield fetch(n.CreateSessionId(),{method:"POST",headers:t,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),H(i),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Fo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Vo(e,t){return Fo(this,void 0,void 0,(function*(){try{var o=yield O("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",e.toString()),i.append("url",t);const r=yield fetch(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),H(r),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Do=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Oo(e,t,o){return Do(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${e}`),a.append("toTheConceptId",`${t}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield O("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),H(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 bo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Mo(e,t){return bo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield tn(e),a=yield An(t);if(a.id>0){let e=[],t=[];if(i){t=yield Oo(a.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield se(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield tn(n),i=yield me(o.id);r.push(i)}}else{t=yield Ht(a.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield se(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield tn(n),i=yield me(o.id);r.push(i)}}}return r}))}function Ho(e,t){return bo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield tn(e),a=yield An(t),s=[],l=[];if(a.id>0){if(i){s=yield Oo(a.id,c.id,c.userId,n,o);for(let e=0;e<s.length;e++)l.push(s[e].ofTheConceptId)}else{s=yield Ht(a.id,c.id,c.userId,n,o);for(let e=0;e<s.length;e++)l.push(s[e].toTheConceptId)}r=yield te(l)}return r}))}class jo{constructor(e,t,n,o,i){this.connectionValue=[],this.value=[],this.height=1,this.key=e,t.id>0&&this.value.push(t),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=i}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.value.push(...e.value),t.connectionValue.push(...e.connectionValue),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}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(e.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}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.rightNode=this.removeNode(e.rightNode,n.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 Wo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class $o{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 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 Wo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isDataLoaded)return e("done");setTimeout($o.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=new Lt(0,0,0,0,0,0);var r=new jo(o,e,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=Me();var r=new jo(o,i,e,null,null);this.addNodeToTree(r)}static getNodeFromTree(e,t){return Wo(this,arguments,void 0,(function*(e,t,n=999){let o=this.compositeKey(e,t,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(e){return Wo(this,arguments,void 0,(function*(e,t=999,n=999){if(this.root){let o=this.compositeKey(e,t,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}$o.root=null;var Jo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Qo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield $o.getNodeFromTree(e,n,o),r=Me();if(i)for(let e=0;e<i.value.length;e++){let n=i.value[e];n.ghostId==t&&(r=n)}return r}))}function Ko(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield $o.getNodeFromTree(e,n,o),r=new Lt(0,0,0,0,0,0);if(i)for(let e=0;e<i.connectionValue.length;e++){let n=i.connectionValue[e];n.ghostId==t&&(r=n)}return r}))}function zo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999){$o.addConceptToTree(e,t,n)}))}function qo(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999){$o.addConnectionToTree(e,t,n)}))}var Yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Xo(e){return Yo(this,arguments,void 0,(function*(e,t=""){var o=yield b("application/json",t);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(console.log("This is the searching multiple error",e.status),H(e),[])}catch(e){throw console.log("This is the searching multiple error",e),e}}))}var Zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((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,a=r.internalConnections,s=r.linkers,l=r.reverse;return n=yield Yn(c,a),yield ti(s,n,i,l)}))}function ti(e,t,n){return Zo(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield $n(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 tn(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){console.log("this is error",e)}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield tn(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){console.log("this is error",e)}}}return i=t[n],i}))}function ni(e){var t,n;const o=Me();return o.id=e.id,o.ghostId=e.ghostId,o.userId=e.userId,o.accessId=e.accessId,o.categoryId=e.categoryId,o.characterValue=e.characterValue,o.entryTimeStamp=e.entryTimeStamp,o.typeId=e.typeId,o.type=e.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"",o}function oi(e){const t=L();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}function ii(e){const t=new Lt(0,0,0,0,0,0);return t.id=e.id,t.ghostId=e.ghostId,t.accessId=e.accessId,t.ofTheConceptId=e.ofTheConceptId,t.toTheConceptId=e.toTheConceptId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.isTemp=!1,t}var ri=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ci(e){return ri(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=Me(),a=Me();const s=[],l=e.compositionId,d=e.ofTheCompositionId;let u=[],h=yield fe(l);for(let e=0;e<h.length;e++)i.push(ii(h[e]));const f=[],y=[];let p=[];for(let e=0;e<i.length;e++)co(y,i[e].ofTheConceptId),co(f,i[e].ofTheConceptId),co(f,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);for(let e=0;e<f.length;e++){const t=yield tn(f[e]);l==f[e]&&(c=ni(t)),d==f[e]&&(a=ni(t)),r.push(ni(t))}const v=e.patchObject;for(const e in v){let l=Me();const d=v[e];let h=c;a.id>0&&(h=a),Array.isArray(d)||"object"==typeof d?(l=yield Dt(e,"",!0,c.userId,4,999),yield bt(v[e],l.id,l.userId,c.id,c.userId,4,999)):l=yield Dt(e,d,!1,t,o,n);const f=so(r,l);for(let e=0;e<f.length;e++)if(f[e].id>0){const t=uo(i,f[e].id);u=u.concat(t),s.push(f[e])}yield Gt(h.id,l.id,c.id,2),r.push(l)}for(let e=0;e<u.length;e++)Xt(u[e].id);it.SyncDataOnline()}))}var ai=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},si=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function li(e){return si(this,void 0,void 0,(function*(){var t;let o=yield function(e){return ai(this,void 0,void 0,(function*(){let t=[];try{var o=yield O();const i=yield fetch(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;te(i),n[r]=t}return n}return console.log("View Internal Data error",i.status),H(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 ke(r,c,e);t.data=n,t.id=r,i.push(t)}else{let e={};e.id=r;let n=yield tn(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}))}var di=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},ui=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function hi(e){return ui(this,arguments,void 0,(function*(e,t=""){var o=yield function(e){return di(this,arguments,void 0,(function*(e,t=""){var o=yield b("application/json",t);let i=n.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+e.composition+"&search="+e.search+"&internalComposition="+e.internalComposition+"&type="+e.type+"&inpage="+e.inpage+"&page="+e.page;try{const e=yield fetch(i,{method:"GET",headers:o});return e.ok?yield e.json():(console.log("This is the searching internal error",e.status),H(e),[])}catch(e){throw console.log("This is the searching internal error",e),e}}))}(e,t);return yield li(o)}))}var fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function yi(e,t){return fi(this,void 0,void 0,(function*(){let n=!0,o=yield Ln(e),i=yield dt(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 Xt(r[e]);n=n&&t}return n}))}function pi(e,t){return fi(this,void 0,void 0,(function*(){let n=yield Ln(e),o=yield dt(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 vi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class gi{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 Ci{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Ti{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class mi{constructor(e){this.aiUrl="https://ai.freeschema.com",this.accessToken="",this.enableAi=!0,e&&Object.assign(this,e)}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 Ni=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var wi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Ii=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class ki{}ki.isUpdated=!1,ki.isOnlineSync=!1;var Ai=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var xi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const Si=1,Ri=2,_i=3,Li=4,Gi=5,Ui=6,Pi=7,Ei=8;class Bi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var Fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Vi(e){return Fi(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield ue(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]=e[n]}return t}))}function Di(e){const t=e.split("_");if(3===t.length){let e=new Bi;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 Oi(e){return e.startsWith("the_")?e.slice(4):e}var bi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Mi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Hi(e,t,n){return Mi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,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 tn(e[u].ofTheConceptId),y=yield tn(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,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);let s=yield tn(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;s.characterValue,s.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield tn(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){console.log("this is error",e)}}}return t}))}var ji=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Wi(e,t,n){if(e in t){let o=t[e];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}var $i=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ji(e,t="DESC"){return console.log("this is the order",t),"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var Qi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var Ki=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function zi(e,t){return Ki(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=Ui;let o,i=yield function(e){return xi(this,arguments,void 0,(function*(e,t=""){var o=yield b("application/json",t);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(H(e),console.log("This is the freeschema query error",e.status),[])}catch(e){console.log("This is the freeschema query error others",e),function(e,t=""){if(e.status){let n=new M(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new M(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,i)}}))}(e,""),r=i.conceptIds,c=(i.internalConnections,i.linkers),a=i.reverse,s=i.mainCompositionIds,l=i.countinfo,d=e.order,u=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let o=Di(e[n]);t.push(o)}return t}(l);return o=t==Ri?yield function(e,t,n,o,i){return Qi(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield qn(e),a=yield Vi(i);c=Ji(c,r);let s=[];s=yield function(e,t){return bi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,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 tn(e[u].ofTheConceptId),y=yield tn(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield tn(e[u].typeId),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);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+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield tn(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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){console.log("this is error",e)}}}return t}))}(c,s,o),s=yield function(e,t){return bi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,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 tn(e[u].ofTheConceptId),y=yield tn(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield tn(e[u].typeId),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);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=Oi(o));let i={id:f.id,data:{[e]:t}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield tn(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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=Oi(r),c=!0);let a={id:y.id,data:{[e]:t}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(e){console.log("this is error",e)}}}return t}))}(c,s,o);let l=yield function(e,t,n,o){return bi(this,arguments,void 0,(function*(e,t,n,o,i=[],r){var c,a,s,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,r=yield tn(e[n].ofTheConceptId),f=yield tn(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=r.id&&0!=f.id&&f.id in t){let o,i=yield tn(e[n].typeId),s=null!==(a=null===(c=f.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",l=!1;e[n].toTheConceptId in t&&(l=!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 c={id:r.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},a=i.characterValue+"_reverse";Array.isArray(o[s][a])?o[s][a].push(c):a.includes("_s_")?(o[s][a]=[],o[s][a].push(c)):o[s][a]=c}}catch(e){console.log("this is error",e)}}}else if(0!=r.id&&0!=f.id&&r.id in t){let o,i=yield tn(e[n].typeId),c=null!==(l=null===(s=r.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"self",a=!1;e[n].toTheConceptId in t&&(a=!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);let y=!0,p=i.characterValue;""==p&&(p=f.characterValue,y=!0),""==p&&(p=null!==(u=null===(d=null==f?void 0:f.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let r=t[e[n].toTheConceptId];if(r){let a={id:f.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(r):Array.isArray(o[c][p])?o[c][i.characterValue].push(a):p.includes("_s_")?(o[c][p]=[],o[c][p].push(a)):o[c][p]=a}}catch(e){console.log("this is error",e)}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e],n.data=t[o[e]],f.push(n)}return f}))}(c,s,[],n,o,a);return l}))}(c,r,s,a,u,d):t==_i?yield function(e,t,n,o,i){return Qi(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield qn(e),a=yield Vi(i);c=Ji(c,r);let s=[];s=yield Hi(c,s,o),s=yield function(e,t){return ji(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,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 tn(e[u].ofTheConceptId),y=yield tn(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield tn(e[u].typeId),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);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=Oi(o));let i={id:f.id,[e]:t},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield tn(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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,a=!1;""==c&&(c=t,c=Oi(c),a=!0);let s={};s[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]=a?s[t]:s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s[t]))}catch(e){console.log("this is error",e)}}}return t}))}(c,s,o);let l=yield function(e,t,n){return ji(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,a,s,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 tn(e[n].ofTheConceptId),p=yield tn(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 tn(e[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;e[n].toTheConceptId in t&&(s=!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);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[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(e){console.log("this is error",e)}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield tn(e[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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),Wi(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",a=t[e[n].toTheConceptId];if(a){let t={};t[r]={data:a[r],id:p.id,created_on:e[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):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,Wi(p.id,i,t)}}catch(e){console.log("this is error",e)}}}console.log("this is the main compositions",n);for(let e=0;e<n.length;e++){let o={};console.log("this is the main compositions DATA",t[n[e]]),o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):t==Ei?yield function(e,t,n,o,i){return Qi(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield qn(e),a=yield Vi(i);c=Ji(c,r);let s={};s=yield function(e){return $i(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,a;for(const s of e){const e=n.includes(s.id),l=yield tn(s.ofTheConceptId),d=yield tn(s.toTheConceptId),u=yield tn(s.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;null===(a=u.characterValue)||void 0===a||a.includes("_s_"),t[h.id]||(t[h.id]={}),t[h.id][y]||(t[h.id][y]={}),t[f.id]||(t[f.id]={}),t[f.id][p]=v}return t}))}(c,s,o),s=yield function(e){return $i(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,a;for(const s of e){const e=n.includes(s.id),l=yield tn(s.ofTheConceptId),d=yield tn(s.toTheConceptId),u=yield tn(s.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!==(a=u.characterValue)&&void 0!==a?a:"";let C=""===g?Oi(p):g;const T=C.includes("_s_"),m=!isNaN(Number(C)),N={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]=m?[]:{});try{if(T)continue;m?t[h.id][y].push(N):t[h.id][y][e?`${C}_reverse`:C]=N}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,s,o);let l=yield function(e,t,n){return $i(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,a;const s=[];for(const n of e){const e=o.includes(n.id),s=yield tn(n.ofTheConceptId),l=yield tn(n.toTheConceptId),d=yield tn(n.typeId);if(0===s.id||0===l.id)continue;const u=e?l:s,h=e?s: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===(a=h.type)||void 0===a?void 0:a.characterValue)||"";if(t[f]){const o=t[f][p],r=t[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Wi(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],Wi(y,i,c)}catch(e){console.error("Error processing connection:",e)}}else console.log("This is the error in the source")}for(const e of n){const n=yield tn(e);s.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return s}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):yield function(e,t,n,o){return Qi(this,void 0,void 0,(function*(){let t=yield qn(e);t=Ji(t);let i=[];i=yield Hi(t,i,o),i=yield function(e,t,n){return Mi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,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 tn(e[u].ofTheConceptId),y=yield tn(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,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);let s=yield tn(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=s.characterValue;""==o&&(o=e,o=Oi(o));let i={[e]:t},l=o+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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 tn(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=Oi(r),c=!0);let a={[e]:t};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?t:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){console.log("this is error",e)}}}return t}))}(t,i,o);let r=yield function(){return Mi(this,arguments,void 0,(function*(e=[],t=[],n=[],o,i=[]){var r,c,a,s,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 tn(e[n].ofTheConceptId),h=yield tn(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 a=yield tn(e[n].typeId);try{let r=a.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(e){console.log("this is error",e)}}}else if(0!=u.id&&0!=h.id&&u.id in t){let o,i=null!==(s=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"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 tn(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 a=t[e[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(e){console.log("this is error",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}))}(c,0,s,a),o}))}class qi{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=Si,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var Yi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Xi(e,t){return Yi(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield Un(e),i=yield Rn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield Ln(e);for(let e=0;e<n.length;e++)Z.AddConnection(n[e]);let i=yield Rn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function Zi(e,t,n){return Yi(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield Xi(t,n,o):yield Xi(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 er=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function tr(e){return er(this,void 0,void 0,(function*(){try{const t=yield O(),o=yield fetch(n.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),H(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 nr(e){var t,n,o,i,r,c,a;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!==(a=e.isComposition)&&void 0!==a&&a,connectionIds:[]}}var or=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class ir{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return or(this,void 0,void 0,(function*(){yield it.initializeTransaction(this.transactionId)}))}markAction(){return or(this,void 0,void 0,(function*(){yield it.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return or(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield it.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return or(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield it.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Zt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return or(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return or(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const t=e.map(nr),n=yield tr(t),o=[];for(const e of n)o.push(...e.connectionIds);return this.pendingConnectionDeletions.push(...o),o}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return or(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 a=yield St(e,t,n,o,i,r,c,this.actions);return yield this.markAction(),a}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return or(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield $t(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 or(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield mn(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 or(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a=1,s=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield Wt(e,t,n,o,i,r,c,a,s,l,this.actions);return yield this.markAction(),d}catch(e){throw console.log(e),this.success=!1,e}}))}}function rr(e=""){o.BearerAccessToken=e}function cr(e="",t="",i="CCSApp",c){const a=c||new mi;if(n.BASE_URL=e,n.AI_URL=a.aiUrl,t&&(n.NODE_URL=t),console.log("This is the base url",n.BASE_URL),a.hasOAuthCredentials()){const e=a.applicationName||i;o.setOAuthCredentials(a.clientId,a.clientSecret,e),r(a.clientId,a.clientSecret,e,!0)}else a.hasAccessToken()&&(o.BearerAccessToken=a.accessToken);(function(){return Ai(this,void 0,void 0,(function*(){return yield new g(!0),yield function(){return Ii(this,void 0,void 0,(function*(){}))}(),!0}))})().then((()=>{const e=(new Date).getTime();(function(){return F(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield N();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];B.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{I.isDataLoaded=!0,I.isCharacterLoaded=!0,I.isTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare concept data is ",t)})),function(){return wi(this,void 0,void 0,(function*(){var e=yield w();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];je.AddConceptToMemory(n)}}))}().then((()=>{I.isLocalDataLoaded=!0,I.isLocalTypeLoaded=!0,I.isLocalCharacterLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare local concept ",t)})),function(){return Ni(this,void 0,void 0,(function*(){!function(){Ni(this,void 0,void 0,(function*(){var e=yield w();if(Array.isArray(e))for(var t=0;t<e.length;t++)$e.AddConnection(e[t])}))}()}))}().then((()=>{I.isLocalConnectionLoaded=!0})),function(){return Ni(this,void 0,void 0,(function*(){!function(){Ni(this,void 0,void 0,(function*(){var e=yield N();if(Array.isArray(e))for(var t=0;t<e.length;t++)Z.AddConnectionToMemory(e[t])}))}()}))}().then((()=>{I.isConnectionLoaded=!0,I.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare connections ",t)}))}))}var ar=exports;for(var sr in t)ar[sr]=t[sr];t.__esModule&&Object.defineProperty(ar,"__esModule",{value:!0})})();
|