mftsccs-node 0.0.52 → 0.0.54
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/types/Api/DeleteConnectionApiBulk.d.ts +1 -0
- package/dist/types/Api/GetConceptByCharacterAndType.d.ts +1 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +2 -0
- package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +13 -0
- package/dist/types/Services/DeleteConnection.d.ts +1 -0
- package/dist/types/app.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bundle.js.LICENSE.txt +0 -1
- package/dist/types/Services/AccessControl/AccessControlCacheService.d.ts +0 -19
- package/dist/types/Services/AccessControl/AccessControlService.d.ts +0 -267
- package/dist/types/Services/AccessControl/PermissionSet.d.ts +0 -8
- package/dist/types/Services/auth/AuthService.d.ts +0 -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:()=>di,AddGhostConcept:()=>Go,AddGhostConnection:()=>Uo,BaseUrl:()=>I,BinaryTree:()=>f,Composition:()=>eo,CompositionBinaryTree:()=>Yn,CompositionNode:()=>Kn,Concept:()=>y,ConceptsData:()=>T,Connection:()=>G,ConnectionData:()=>E,CreateComposition:()=>fe,CreateConnection:()=>_e,CreateConnectionBetweenTwoConcepts:()=>Oe,CreateConnectionBetweenTwoConceptsGeneral:()=>Me,CreateDefaultConcept:()=>p,CreateDefaultLConcept:()=>xt,CreateSession:()=>go,CreateSessionVisit:()=>mo,CreateTheCompositionLocal:()=>ke,CreateTheCompositionWithCache:()=>oo,CreateTheConnection:()=>jt,CreateTheConnectionGeneral:()=>Re,CreateTheConnectionLocal:()=>pe,DATAID:()=>ci,DATAIDDATE:()=>si,DeleteConceptById:()=>Tn,DeleteConnectionById:()=>Pe,FilterSearch:()=>Yo,FormatFromConnections:()=>Do,FreeSchemaResponse:()=>S,FreeschemaQuery:()=>xi,GetAllConnectionsOfComposition:()=>X,GetAllConnectionsOfCompositionBulk:()=>Q,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Ri,GetComposition:()=>et,GetCompositionBulk:()=>_n,GetCompositionBulkWithDataId:()=>Ln,GetCompositionFromConnectionsWithDataId:()=>Gn,GetCompositionFromConnectionsWithDataIdInObject:()=>Fn,GetCompositionList:()=>vt,GetCompositionListLocal:()=>Et,GetCompositionListLocalWithId:()=>Ot,GetCompositionListWithId:()=>gt,GetCompositionLocal:()=>Ut,GetCompositionLocalWithId:()=>Ft,GetCompositionWithAllIds:()=>nt,GetCompositionWithCache:()=>ho,GetCompositionWithDataIdBulk:()=>po,GetCompositionWithDataIdWithCache:()=>yo,GetCompositionWithId:()=>st,GetCompositionWithIdFromMemory:()=>it,GetCompositionWithIdFromMemoryFromConnections:()=>ct,GetConceptBulk:()=>b,GetConceptByCharacter:()=>yt,GetConceptByCharacterAndCategoryDirectApi:()=>rn,GetConceptByCharacterAndType:()=>zt,GetConnectionBulk:()=>Sn,GetConnectionById:()=>Fe,GetConnectionOfTheConcept:()=>xe,GetLink:()=>We,GetLinkRaw:()=>je,GetLinkerConnectionFromConcepts:()=>vn,GetLinkerConnectionToConcepts:()=>gn,GetRelation:()=>Io,GetRelationRaw:()=>ko,GetTheConcept:()=>De,GetUserGhostConnectionId:()=>Lo,GetUserGhostId:()=>_o,GiveConnection:()=>_i,HandleHttpError:()=>R,JUSTDATA:()=>ai,LConcept:()=>At,LConnection:()=>ye,LISTNORMAL:()=>ui,LoginToBackend:()=>Dn,MakeTheInstanceConcept:()=>ue,MakeTheInstanceConceptLocal:()=>we,MakeTheTimestamp:()=>kn,MakeTheTypeConcept:()=>en,MakeTheTypeConceptApi:()=>dn,NORMAL:()=>ri,PatcherStructure:()=>Ko,RAW:()=>li,RecursiveSearchApi:()=>Pn,SchemaQueryListener:()=>Ai,SearchAllConcepts:()=>ao,SearchLinkInternal:()=>zo,SearchLinkMultipleAll:()=>Bo,SearchLinkMultipleApi:()=>Vo,SearchQuery:()=>An,SearchStructure:()=>Xo,SearchWithLinker:()=>lo,SessionData:()=>qo,Signin:()=>Mn,Signup:()=>On,SplitStrings:()=>w,SyncData:()=>Wt,Transaction:()=>Gi,TrashTheConcept:()=>wn,UpdateComposition:()=>ro,UpdateCompositionLocal:()=>Ho,UserBinaryTree:()=>So,ViewInternalData:()=>$o,convertFromLConceptToConcept:()=>Oo,getFromDatabaseWithType:()=>r,getFromDatabaseWithTypeOld:()=>c,init:()=>Fi,recursiveFetch:()=>lt,recursiveFetchNew:()=>Zn,storeToDatabase:()=>i,updateAccessToken:()=>Ui});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}var o=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 i(t,e){}function r(t,e,n){return o(this,void 0,void 0,(function*(){}))}function c(t){return o(this,void 0,void 0,(function*(){}))}function a(t){return o(this,void 0,void 0,(function*(){}))}class s{}s.isTypeLoaded=!1,s.isCharacterLoaded=!1,s.isDataLoaded=!1,s.isLocalDataLoaded=!1,s.isLocalCharacterLoaded=!1,s.isLocalTypeLoaded=!1,s.isConnectionLoaded=!1,s.isConnectionTypeLoaded=!1,s.isLocalConnectionLoaded=!1;class l{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 d=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 u{static waitForDataToLoad(){return d(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isCharacterLoaded)return t("done");setTimeout(u.checkFlag,1e3,t)}static addNodeToTree(t){return d(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 d(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 l(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 d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return d(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))}}u.characterRoot=null;var h=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{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 h(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isDataLoaded)return t("done");setTimeout(f.checkFlag,1e3,t)}static addConceptToTree(t){var e=new l(t.id,t,null,null),n=new l(t.characterValue,t,null,null);u.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return h(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return h(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}}f.root=null;class y{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 p(){let t=v(new Date),e=v(new Date);return new y(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function v(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 C{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 l(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(s.isTypeLoaded)return t("done");setTimeout(C.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=p();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}}C.typeRoot=null;var m=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 T{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&&(f.addConceptToTree(t),C.addConceptToTree(t),u.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(f.addConceptToTree(t),C.addConceptToTree(t),u.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);f.removeNodeFromTree(t.id),t.id}static GetConcept(t){return m(this,void 0,void 0,(function*(){var e=p(),n=yield f.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return m(this,void 0,void 0,(function*(){var e=p(),n=u.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return m(this,void 0,void 0,(function*(){var e=p(),n=u.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return m(this,void 0,void 0,(function*(){return p(),yield C.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return m(this,void 0,void 0,(function*(){var n=p(),o=yield u.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 m(this,void 0,void 0,(function*(){let n=[];return n=yield C.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return u.characterRoot}getName(){return this.name}}T.conceptsArray=[],T.NPC=[],T.conceptDictionary=[];var N=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){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}class I{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 FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}}I.BASE_URL="https://localhost:7053/",I.AI_URL="https://ai.freeschema.com",I.MQTT_URL="192.168.1.249",I.NODE_URL="http://localhost:5001/";class k{}function A(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+k.BearerAccessToken,Accept:e}}function x(t="application/json",e="",n="application/json"){return""==e&&(e=k.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}k.BearerAccessToken="";class S{constructor(t,e,n,o){this.url=I.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=o}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 R(t){if(401==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}var _=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 L(t,e){return _(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var o=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllConceptsByTypeUrl(),{method:"POST",headers:o,body:n});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)T.AddConcept(t[i])}console.log("GetAllConceptsByType error",r.status),R(r)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class G{constructor(t=0,e,n,o,i,r,c,a,s,l,d,u,h,f,y,g){this.isTemp=!1,this.toUpdate=!1,this.type=p(),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=g,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class U{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 F=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 V{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 U(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isConnectionLoaded)return t("done");setTimeout(V.checkFlag,1e3,t)}static removeNodeFromTree(t){return F(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return F(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}V.connectionroot=null;var P=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 B{static addNodeToTree(t){return P(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 P(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isConnectionTypeLoaded)return t("done");setTimeout(B.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new U(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 P(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 P(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}))}}B.connectionTypeRoot=null;var D=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 E{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||(V.addConnectionToTree(t),B.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(V.addConnectionToTree(t),B.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(t.id,V.removeNodeFromTree(t.id),B.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return V.connectionroot}static GetConnectionTypeTree(){return B.connectionTypeRoot}static GetConnection(t){return D(this,void 0,void 0,(function*(){var e=new G(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield V.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return D(this,void 0,void 0,(function*(){var e=[],n=yield B.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}}E.connectionArray=[],E.connectionDictionary=[];var O=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 b(t){return O(this,void 0,void 0,(function*(){let e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield T.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=A();const t=yield fetch(I.GetConceptBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});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),T.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),R(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 M=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 H(){return M(this,arguments,void 0,(function*(t=[]){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 b(e)}}))}var W=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 j(){return W(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield E.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function $(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||E.RemoveConnection(e[n]))}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 Q(){return J(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var n=yield j(t),o=yield function(){return J(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=A();const i=yield fetch(I.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();for(var o=0;o<t.length;o++)E.AddConnection(t[o]),e.push(t[o])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),R(i);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 $(e=o,n),yield H(e),e}))}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())}))};const K=new Map;function q(t){return z(this,void 0,void 0,(function*(){let e=p();if(K.has(t))return K.get(t)||e;const n=(()=>z(this,void 0,void 0,(function*(){try{var n=yield T.GetConcept(t);let i=T.GetNpc(t);if(0!=n.id||i)return n;{var o=A("application/x-www-form-urlencoded");const n=yield fetch(I.GetConceptUrl(),{method:"POST",headers:o,body:`id=${t}`});return n.ok?(e=yield n.json(),e.id>0?T.AddConcept(e):T.AddNpc(t)):(console.log("Get the concept error",n.status,t),R(n)),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{K.delete(t)}})))();return K.set(t,n),n}))}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())}))};function X(t){return Y(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield E.GetConnectionsOfCompositionLocal(t)).length)e=yield Z(t);else{var n=yield Z(t);$(n,e),e=n}return e}))}function Z(t){return Y(this,void 0,void 0,(function*(){var e=[];try{var n=A("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${t}`});if(!i.ok)throw R(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();for(var o=0;o<r.length;o++)E.AddConnection(r[o]),e.push(r[o]);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 tt=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 et(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 nt(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield dt(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 ot(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 it(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 rt(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 ct(t,e){return tt(this,void 0,void 0,(function*(){for(var n,o,i={},r=[],c=0;c<e.length;c++)r.includes(e[c].ofTheConceptId)||r.push(e[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 at(t,e){return tt(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r={},c=yield T.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield q(t));var a=yield lt(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 st(t){return tt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 lt(t,e,n){return tt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield q(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield T.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield q(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0: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 T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield q(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield T.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 lt(f,e,n,o);a[p]=t}}else{const t=yield lt(f,e,n,o);s[p]=t,a=s}}return a}))}function dt(t,e,n){return tt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield q(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield T.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield q(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0: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 T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield q(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield T.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 dt(f,e,n);a[p]=t}}else{const t=yield dt(f,e,n);s[p]=t,a=s}}return a}))}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*(){let e=p();try{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${t}`});return o.ok?(e=yield o.json(),e.id>0&&T.AddConcept(e)):(console.log("Error in Getting concept by character value Error",o.status),R(o)),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 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())}))};function yt(t){return ft(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield ht(t),e=yield T.GetConceptByCharacter(t)),e}))}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())}))};function vt(t,e){return pt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield yt(t),r=[];if(i){yield L(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield Q(s),l=a;l<a+n;l++)if(c[l]){var d=yield ot(c[l].id);r.push(d)}}return r}))}function gt(t,e){return pt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield yt(t),r=[];if(i){yield L(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield Q(s),l=a;l<a+n;l++)if(c[l]){var d=yield it(c[l].id);r.push(d)}}return r}))}class Ct{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 mt=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 Tt{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 Ct(t.id,t,null,null);new Ct(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return mt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalDataLoaded)return t("done");setTimeout(Tt.checkFlag,1e3,t)}static getNodeFromTree(t){return mt(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 mt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}Tt.root=null;var Nt=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{static waitForDataToLoad(){return Nt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalCharacterLoaded)return t("done");setTimeout(wt.checkFlag,1e3,t)}static addNodeToTree(t){return Nt(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 Ct(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 Nt(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))}}wt.LocalCharacterRoot=null;var It=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 kt{static addNodeToTree(t){return It(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 Ct(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 It(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalTypeLoaded)return t("done");setTimeout(kt.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return It(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}))}}kt.LocalTypeRoot=null;class At{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 xt(){let t=new Date,e=new Date;return new At(0,0,0,0,0,"0","0",!1,t,e,0)}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())}))};class Rt{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(Tt.addConceptToTree(t),wt.addConceptToTree(t),kt.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(Tt.addConceptToTree(t),wt.addConceptToTree(t),kt.addConceptToTree(t))}static GetConcept(t){return St(this,void 0,void 0,(function*(){var e=xt(),n=yield Tt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return St(this,void 0,void 0,(function*(){var e=xt(),n=wt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return St(this,void 0,void 0,(function*(){var n=xt(),o=yield wt.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 St(this,void 0,void 0,(function*(){let n=[];return n=yield kt.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}Rt.localconceptsArray=[];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())}))};class Lt{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 _t(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalConnectionLoaded)return t("done");setTimeout(Lt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return _t(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}}Lt.connectionArray=[],Lt.connectionDictionary=[];var Gt=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 Ut(t){return Gt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Lt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Rt.GetConcept(t),s=yield Vt(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 Ft(t){return Gt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Lt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Rt.GetConcept(t);if(0!=a.id){var s=yield Vt(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 Vt(t,e,n){return Gt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[],l=yield Rt.GetConcept(t);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield Rt.GetConcept(d);l.type=u}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0: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 Rt.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield Rt.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 Vt(f,e,n);a[p]=t}}else{const t=yield Vt(f,e,n);s[p]=t,a=s}}return a}))}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())}))};function Bt(t){return Pt(this,void 0,void 0,(function*(){return yield Rt.GetConceptByCharacter(t)}))}var Dt=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 Et(t,e){return Dt(this,void 0,void 0,(function*(){var n=yield Bt(t),o=[];if(n)for(var i=yield Rt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Ut(i[r].id);o.push(c)}return o}))}function Ot(t,e){return Dt(this,void 0,void 0,(function*(){var n=yield Bt(t),o=[];if(n)for(var i=yield Rt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Ft(i[r].id);o.push(c)}return o}))}function bt(t){return e=this,n=void 0,i=function*(){let e=p();try{var n=A();const o=yield fetch(I.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);return e=yield o.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((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}function Mt(t){return e=this,n=void 0,i=function*(){let e=new G(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=A(),o=JSON.stringify(t);const i=yield fetch(I.CreateTheConnectionUrl(),{method:"POST",headers:n,body:o});return i.ok?yield i.json():(console.log("Create the connection error message: ",i),R(i)),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((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}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 Wt{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 Ht(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 bt(e)),n.length>0&&(yield Mt(n))}else{for(let t=0;t<this.conceptsSyncArray.length;t++)T.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)E.AddConnection(this.connectionSyncArray[t]);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield bt(e)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield Mt(n))}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return Ht(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 Ht(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 Ht(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 Ht(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 jt(t,e,n,o,i,r,c){var a=new G(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()),Wt.AddConnection(a),a)}Wt.conceptsSyncArray=[],Wt.connectionSyncArray=[],Wt.transactionCollections=[];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())}))},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())}))};const Qt=new Map;function zt(t,e){return Jt(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndTypeLocal(t,e),o=t+e;if(Qt.has(o))return Qt.get(o)||n;const i=(()=>Jt(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=A();const o=yield fetch(I.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});if(o.ok){let t=yield o.json();n=t,T.AddConcept(n)}else console.log("This is the concept by type and character error",o.status),R(o)}return n}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{Qt.delete(o)}})))();return Qt.set(o,i),i}))}class Kt{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 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())}))};let Yt=!1,Xt=[];const Zt=()=>{Xt.length>0&&!Yt&&Xt.shift()()};var te=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 ee=!1,ne=[];const oe=()=>{ne.length>0&&!ee&&ne.shift()()};var ie=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 re{static getId(){return ie(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return te(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{console.log("trying to fetch more concepts"),ne.push((()=>te(this,void 0,void 0,(function*(){try{if(ee)return;if(ee=!0,re.ids.length>10)return console.log("Enough IDs available, skipping fetch."),ee=!1,oe(),t();var n=A("application/x-www-form-urlencoded");const e=yield fetch(I.GetReservedIdUrl(),{method:"GET",headers:n});if(!e.ok)throw R(e),new Error(`Error! status: ${e.status}`);const i=yield e.json();for(var o=0;o<i.length;o++)re.AddId(i[o]);console.log("Ids Fetch Success"),t()}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message,I.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",t),e(t)}finally{ee=!1,oe()}})))),oe()}))}))}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}re.ids=[];class ce{static getId(){return ie(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return qt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{Xt.push((()=>qt(this,void 0,void 0,(function*(){try{if(Yt)return;if(Yt=!0,ce.connectionIds.length>10)return Yt=!1,Zt(),t();var n=A("application/x-www-form-urlencoded");const e=yield fetch(I.GetReservedConnectionIdUrl(),{method:"GET",headers:n});if(!e.ok)throw R(e),new Error(`Error! status: ${e.status}`);const i=yield e.json();for(var o=0;o<i.length;o++)ce.AddId(i[o]);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{Yt=!1,Zt()}})))),Zt()}))}))}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}ce.connectionIds=[];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 se(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return ae(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,p={concepts:[],connections:[]}){var v=yield re.getId();let g=new Date,C=new Date;var m=new y(v,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,g,C);return m.isTemp=!1,Wt.AddConcept(m),p.concepts.push(m),m}))}function le(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return ae(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,p={concepts:[],connections:[]}){var v=yield re.getId();let g=new Date,C=new Date;var m=new y(v,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,g,C);return T.AddConcept(m),m.updateRecursion=!0,Wt.AddConcept(m),p.concepts.push(m),m}))}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 ue(t,e){return de(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0,a={concepts:[],connections:[]}){let s,l=r,d=999,u=o,h=o,f=i,y=o,v="",g=e.length,C=p();v=t.startsWith("the_")?t:"the_"+t;(new Date).getTime();if(n)C=yield dn(t),s=yield se(e,o,4,o,C.id,C.userId,c,999,d,u,f,y,l,h,a),(new Date).getTime();else if(g>255)C=yield dn(v),s=yield se(e,o,4,o,C.id,C.userId,c,999,d,u,f,y,l,h,a),function(t){$t(this,void 0,void 0,(function*(){try{var e=A();const n=yield fetch(I.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw R(n),new Error(`Error! status: ${n.status}`);return yield n.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 Kt(o,e,d,u,f,y,l,h,Date.now().toString(),!0)),(new Date).getTime();else{C=yield dn(v);let t=yield zt(e,C.id);s=t,0==t.id&&0==t.userId&&(s=yield le(e,o,4,o,C.id,C.userId,12,12,d,u,f,y,l,h,a)),(new Date).getTime()}return s.type=C,s}))}var he=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){return he(this,arguments,void 0,(function*(t,e=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=p();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=v=yield ue(o,"",!0,a,s,l),h=v.id,d=v.id,yield fe(t[o],v.id,v.userId,h,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;h=d,u=v=yield ue(o,"",!0,a,s,l),yield jt(f,y,v.id,v.userId,h,l,v.userId),yield fe(t[o],v.id,v.userId,h,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,h=d;var v=yield ue(o,t[o].toString(),!1,a,s,l);yield jt(f,y,v.id,v.userId,h,l,v.userId)}return u}))}class ye{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=xt(),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=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function pe(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 ye(0,0,0,0,0,0);return t!=e&&(a=new ye(0,t,e,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Lt.AddConnection(a)),a}var 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 ge(t,e,n,o,i,r){return ve(this,arguments,void 0,(function*(t,e,n,o,i,r,c=0){var a=Math.floor(1e8*Math.random());let s=new Date,l=new Date;var d=new At(a,n,i,o,r,t,e,!0,s,l,c);return d.isTemp=!0,Rt.AddConcept(d),d}))}var 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())}))},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 Te(t,e,n,o){return me(this,void 0,void 0,(function*(){var i=yield Bt(t);if(i&&(0==i.id||0==i.userId)){var r=w(t);if(r[0]==t){var c=yield function(t,e,n){return Ce(this,void 0,void 0,(function*(){var e=yield Rt.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 Te(r[0],e,n,o),s=yield Te(r[1],e,n,o);s&&(i=c=yield ge(t,r[1],o,a.id,s.id,4))}}return i}))}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())}))};function we(t,e){return Ne(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){var a,s,l,d=o,u=e.length;if(l=t.startsWith("the_")?t:"the_"+t,n)a=yield Te(t,999,o,o),s=yield ge(e,t,o,4,a.id,4,c);else if(u>255)a=yield Te(l,999,d,o),s=yield ge(e,l,o,4,a.id,4);else{a=yield Te(l,999,d,o);var h=yield Rt.GetConceptByCharacterAndTypeLocal(e,a.id);s=h,0==h.id&&0==h.userId&&(s=yield ge(e,l,o,4,a.id,4))}return s.type=a,s}))}var Ie=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){return Ie(this,arguments,void 0,(function*(t,e=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=xt();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=y=yield we(o,"",!0,a,s,l),h=y.id,d=y.id,yield ke(t[o],y.id,y.userId,h,i,r,c)}else{var f=null!=e?e:999,y=(h=d,yield we(o,"",!0,a,s,l));yield pe(f,y.id,h),yield ke(t[o],y.id,y.userId,h,i,r,c)}else f=null!=e?e:999,h=d,y=yield we(o,t[o].toString(),!1,a,s,l),yield pe(f,y.id,h);return u}))}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,n){return Ae(this,arguments,void 0,(function*(t,e,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${t}`),c.append("ofTheConceptId",`${e}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=A("application/x-www-form-urlencoded");const s=yield fetch(I.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:c});return s.ok?r=yield s.json():(console.log("Get connection of concept error",s.status),R(s)),r}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 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,n,o,i,r,c){return Se(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){let u=e,h=e,f=e;999!=l&&(f=l);let y=e,p=e,v=yield ce.getId(),g=new G(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,Wt.AddConnection(g),d.connections.push(g),g)}))}function _e(t,e,n){return Se(this,arguments,void 0,(function*(t,e,n,o={concepts:[],connections:[]}){let i=yield dn(n),r=t.userId;return yield Re(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}var Le=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())}))},Ge=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())}))},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 Fe(t){return Ue(this,void 0,void 0,(function*(){var e=yield E.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var n=yield function(t){return Ge(this,void 0,void 0,(function*(){var e=yield E.GetConnection(t);try{if(0!=e.id)return e;{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${t}`});return o.ok?(e=yield o.json(),E.AddConnection(e)):(console.log("Get Connection Error",o.status),R(o)),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=n}return e}))}var 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 Pe(t){return Ve(this,arguments,void 0,(function*(t,e=""){let n=!1;var o=yield Fe(t);return n=yield function(t){return Le(this,arguments,void 0,(function*(t,e=""){let n=!1;try{const o=new FormData;let i=A("application/x-www-form-urlencoded");""!=e&&(i=x("application/x-www-form-urlencoded",e)),o.append("id",t.toString()),o.append("apiKey","nodeserver");const r=yield fetch(I.DeleteTheConnectionUrl(),{method:"POST",body:o,redirect:"follow"});r.ok?n=(yield r.json()).success:(console.log("Delete connection error status: ",r.status),R(r))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}return n}))}(t,e),V.removeNodeFromTree(t),B.removeTypeConcept(o.typeId,t),n}))}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 De(t){return Be(this,arguments,void 0,(function*(t,e=999){var n=p();if(t<0)return Oo(yield _o(e,t));if(null!=(n=yield T.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield q(t)),0!=n.id&&null==n.type&&null==(yield T.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield q(n.typeId);n.type=o}return n}))}var Ee=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,n){return Ee(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield be(o,e,a));var d=yield ue("connection",c,!1,999,999,999);let u=new G(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);Wt.AddConnection(u)}let u=n+"_s",h=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield be(u,t,a));var f=yield ue("connection",h,!1,999,999,999);let y=new G(0,t.id,e.id,t.userId,e.userId,t.userId,f.id,f.userId,1e3,a,999,s,4,l,999,999);return Wt.AddConnection(y),y}))}function be(t,e){return Ee(this,arguments,void 0,(function*(t,e,n=null){for(var o,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 ue("connection",d,!1,r,4,s),h=yield xe(u.id,e.id,r,10,1),f=[],y=p(),v=0;v<h.length;v++){let t=yield De(h[v].toTheConceptId);f.push(t)}if(f.length<1)y=yield ue("count","1",!1,r,4,s);else{var g=f[0];let t=0;try{t=Number(g.characterValue)}catch(e){t=0}t+=1,y=yield ue("count",t.toString(),!1,r,4,s);for(let t=0;t<h.length;t++)Pe(h[t].id)}let C=new G(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,a,s,999);yield Wt.AddConnection(C)}))}function Me(t,e,n){return Ee(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield be(o,e,a));var d=yield ue("connection",c,!1,999,999,999);let u=new G(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);Wt.AddConnection(u)}let u=n+"_s",h=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield be(u,t,a));var f=yield ue("connection",h,!1,999,999,999);return yield Re(t.id,t.userId,e.id,e.userId,f.id,999,999,1e3,4)}))}var He=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 We(t,e){return He(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield De(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield zt(a,16);if(s.id>0){for(var l=yield xe(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield Q(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield De(t),n=yield rt(e.id);r.push(n)}}return r}))}function je(t,e){return He(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield De(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield zt(a,16);if(s.id>0){for(var l=yield xe(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 De(t);r.push(e)}}return r}))}class $e{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 Je{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new $e(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}}Je.characterData=[];class Qe{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}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())}))},Ke=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 qe(t,e,n,o,i){return Ke(this,void 0,void 0,(function*(){return new $e(e,t,n,e,o,e,i,e,"",!1),yield function(){return ze(this,void 0,void 0,(function*(){var t;try{if(0==(t=Je.GetCharacter(t.data)).id){var e=A();const o=yield fetch(I.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();var n=new $e(i.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=i.id,Je.AddCharacter(n),i}return new Qe(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}}))}()}))}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,n,o,i,r,c,a,s,l,d,u,h,f){return Ye(this,void 0,void 0,(function*(){var y=yield zt(t,i),p=y;return 0==p.id&&(p=y=yield se(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}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())}))},tn=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,n,o){return tn(this,arguments,void 0,(function*(t,e,n,o,i={concepts:[],connections:[]}){var r=yield yt(t);if(r&&(0==r.id||0==r.userId)){var c=w(t);if(c.length>0)if(console.log(c),c[0]==t){var a=yield function(t,e,n,o,i,r){return Ze(this,void 0,void 0,(function*(){var i,c=e,a=e;i=e;var s,l=e,d=e,u=e;if(1==t.length){var h=t.charCodeAt(0);yield qe(t,e,n,o,r),s=Xe(t,e,4,c,h,u,49,l,n,a,o,i,r,d)}else{var f=yield qe(t,e,n,o,r);f.isNew,s=yield Xe(t,e,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(t,o,999,999,0,e);r=a}else{var s=yield en(c[0],e,n,o,i),l=yield en(c[1],e,n,o,i);l&&(r=yield le(t,o,s.id,o,l.id,o,999,o,999,o,999,o,e,o,i))}}return r}))}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())}))};const on=new Map;function rn(t,e){return nn(this,void 0,void 0,(function*(){let n=p();if(on.has(t+e))return on.get(t+e)||n;const o=(()=>nn(this,void 0,void 0,(function*(){try{var o=A("application/x-www-form-urlencoded");const i=yield fetch(I.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:o,body:`character_value=${t}&category_id=${e}`});if(i.ok){let t=yield i.json();n=t,T.AddConcept(n)}else console.log("This is the concept by category and character direct api error",i.status),R(i);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,t,e,I.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,t,e,I.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{on.delete(t+e)}})))();return on.set(t+e,o),o}))}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())}))};function an(t){return cn(this,void 0,void 0,(function*(){let e=p();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=t.length;var o=w(t);if(o.length>1){let n=1,i=yield an(o[0]);0!=i.id&&(n=i.id),e=yield function(t,e){return cn(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield rn(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return cn(this,void 0,void 0,(function*(){console.log("inside the character length function",t);var e=yield T.GetConceptByCharacterAndTypeLocal(t,49);return console.log("inside the character length function after",e),0==e.id&&(e=yield ht(t)),e}))}(t):o[0]==t&&(e=yield function(t){return cn(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield ht(t)),e}))}(t));return e}))}var sn=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 ln=new Map;function dn(t,e){return sn(this,void 0,void 0,(function*(){let e=p();if(ln.has(t))return ln.get(t)||e;const n=(()=>sn(this,void 0,void 0,(function*(){try{if(e=yield an(t),0==e.id||4==e.typeId){var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);let i=yield o.json();e=i,e.id>0&&T.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{ln.delete(t)}})))();return ln.set(t,n),n}))}var 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){return un(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(r.ok){const t=yield r.json();for(var o=0;o<t.length;o++){var i=t[o];e.push(i)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),R(r);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 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){return fn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(r.ok){const t=yield r.json();for(var o=0;o<t.length;o++){var i=t[o];e.push(i)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),R(r);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 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())}))};function vn(t){return pn(this,void 0,void 0,(function*(){for(var e=yield hn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield De(o);t.type=i}return e}))}function gn(t){return pn(this,void 0,void 0,(function*(){for(var e=yield yn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield De(o);t.type=i}return e}))}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())}))},mn=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){return mn(this,arguments,void 0,(function*(t,e=""){var n=yield De(t);yield f.removeNodeFromTree(t);var o=n.typeId,i=n.characterValue;return yield C.removeTypeConcept(o,t),yield u.removeNodeByCharacter(i,t),yield function(t){return Cn(this,arguments,void 0,(function*(t,e=""){let n=!1;try{let o=A("application/x-www-form-urlencoded");""!=e&&(o=x("application/x-www-form-urlencoded",e));const i=new FormData;i.append("id",t.toString());const r=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:i});if(!r.ok)throw R(r),new Error(`Error! status: ${r.status}`);n=(yield r.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 n}))}(t,e)}))}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,e){return Nn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const o=new FormData;o.append("id",t.toString());const i=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:o,headers:n});if(!i.ok)throw R(i),new Error(`Delete composition Error! status: ${i.status}`)}catch(t){throw t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),t}}))}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())}))};function kn(t,e,n,o){return In(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=n,a=n,s=n,l=t.startsWith("the_"),d=p();return r=l?t:"the_"+t,d=yield dn(r),yield Xe(e,n,4,n,d.id,d.userId,0,999,999,c,4,s,999,a)}))}class An{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 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(){return xn(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield E.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=A();const t=yield fetch(I.GetConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});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),E.AddConnection(o)}yield H(e)}}else console.log("Get Connection Bulk error",t.status),R(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 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(){return Rn(this,arguments,void 0,(function*(t=[]){yield Q(t);var e=[];for(let o=0;o<t.length;o++){var n=yield ot(t[o]);e.push(n)}return e}))}function Ln(){return Rn(this,arguments,void 0,(function*(t=[]){yield Q(t);var e=[];for(let o=0;o<t.length;o++){var n=yield it(t[o]);e.push(n)}return e}))}function Gn(){return Rn(this,arguments,void 0,(function*(t=[],e=[]){yield Sn(e),function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||E.RemoveConnection(e[n])}(e,yield j(t));var n=[];for(let e=0;e<t.length;e++){var o=yield it(t[e]);n.push(o)}return n}))}function Un(){return Rn(this,arguments,void 0,(function*(t=[]){let e=[],n=[],o={};for(let o=0;o<(null==t?void 0:t.length);o++){let i=yield E.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 Sn(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 b(i),n}))}function Fn(){return Rn(this,arguments,void 0,(function*(t=[],e=[]){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield E.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Sn(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);for(let t=0;t<c.length;t++){let e=yield at(c[t],o,c);r[c[t]]=e}return r}))}var 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 Pn(){return Vn(this,arguments,void 0,(function*(t=0,e=[],n=""){var o=[];try{var i=new An;i.composition=t,i.listLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=A();const l=yield fetch(I.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(l.ok){const t=yield l.json();var a=t.compositionIds,s=t.internalConnections;t.externalConnections,o=yield Gn(a,s)}else console.log("recursive search error ",l.status),R(l);return o}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}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 Dn(t,e){return Bn(this,void 0,void 0,(function*(){try{var n={email:t,password:e},o=new Headers;o.append("Content-Type","application/json");var i=JSON.stringify(n);const r=yield fetch(I.LoginUrl(),{method:"POST",headers:o,body:i});if(r.ok){const t=yield r.json();return k.BearerAccessToken=t.data.token,t}console.log("Login tsccs error message: ",r.status),R(r)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}var En=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){return En(this,void 0,void 0,(function*(){const e=yield function(){return En(this,arguments,void 0,(function*(t="",e={}){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}:R(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(I.SignupUrl(),t);return e}))}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 Mn(t){return bn(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const o=new Headers;o.append("Content-Type","application/json");const i=I.LoginUrl();try{const t=yield fetch(i,{method:"POST",headers:o,body:e,redirect:"follow"}),r=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==r?void 0:r.data}:R(t),n}catch(t){throw console.log("Sign in api error",t),t}}))}function Hn(t,e){return-1===t.indexOf(e)&&t.push(e),t}function Wn(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 jn(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 $n(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 Jn(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 Qn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function zn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class Kn{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&&(Yn.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 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())}))};class Yn{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 Kn(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return qn(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return qn(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}}Yn.root=null;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 Zn(t,e,n,o){return Xn(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=to(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield De(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=to(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield De(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=to(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield De(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield T.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield De(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 Zn(d,e,n,o,i);a[u]=t}}else{const t=yield Zn(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function to(t,e){let n=p();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class eo{constructor(){this.id=0,this.mainConcept=p(),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 Zn(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&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),I.MQTT_CONNECTION&&I.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 no=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 oo(t){return no(this,arguments,void 0,(function*(t,e=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=p();null==a&&(a=new eo);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield ue(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 oo(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 jt(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield oo(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 ue(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield jt(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var io=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 ro(t){return io(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=p(),a=p();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield De(l,e);if(!(t.id>0))return null;l=t.id}i=yield X(l);const h=[],f=new eo,y=[];f.id=l,f.isUpdating();let v=[];for(let t=0;t<i.length;t++)Hn(y,i[t].ofTheConceptId),Hn(h,i[t].ofTheConceptId),Hn(h,i[t].toTheConceptId),v.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<h.length;t++){const e=yield De(h[t]);l==h[t]&&(c=e),d==h[t]&&(a=e),r.push(e)}const g=t.patchObject;for(const t in g){let i=p();const l=g[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield ue(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=Wn(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=$n(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield oo(g[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield ue(t,l,!1,e,o,n);const c=Wn(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=$n(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield jt(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++)zn(f.connections,u[t]),Pe(u[t].id);for(let t=0;t<s.length;t++)Qn(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),Yn.addCompositionToTree(f),yield Wt.SyncDataOnline(),f.GetDataCache()}))}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 ao(t,e,n,o){return co(this,arguments,void 0,(function*(t,e,n,o,i=10,r=1){var c=x("application/x-www-form-urlencoded",o),a=new URLSearchParams;a.append("type",t),a.append("search",e),a.append("composition",n),a.append("inpage",i.toString()),a.append("page",r.toString());const s=I.SearchCompositionsUrl()+"?"+a.toString();try{const t=yield fetch(s,{method:"GET",headers:c});return t.ok?yield t.json():(R(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var so=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 lo(t){return so(this,arguments,void 0,(function*(t,e=""){var n=x("application/json",e);const o=I.SearchLinkMultipleAll(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(console.log("This is the searching error",t.status),R(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}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 ho(t){return uo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=[];let l=yield T.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield q(t));let d=[];d=e.length>0?fo(t,e):yield X(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 lt(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 fo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function yo(t){return uo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=[];let d=yield T.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield q(t));let u=[];u=e.length>0?fo(t,e):yield X(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 lt(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 po(t,e){return uo(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Sn(e);for(let e=0;e<t.length;e++){const i=yield yo(t[e],n);i&&o.push(i)}return o}))}var vo=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 vo(this,void 0,void 0,(function*(){try{var e=A();const n=JSON.stringify(t),o=yield fetch(I.CreateSessionId(),{method:"POST",headers:e,body:n});return o.ok?o.json():(console.log("Creating session failed",yield o.json()),R(o),null)}catch(t){throw console.log("Creating session failed",t),t}}))}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){return Co(this,void 0,void 0,(function*(){try{var n=A("application/x-www-form-urlencoded");const o=new URLSearchParams;o.append("sessionId",t.toString()),o.append("url",e);const i=yield fetch(I.CreateSessionVisitUrl(),{method:"POST",headers:n,body:o});return i.ok?i.json():(console.log("Creating session url failed",yield i.json()),R(i),null)}catch(t){throw console.log("Creating session url failed",t),t}}))}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,e,n){return To(this,arguments,void 0,(function*(t,e,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${t}`),c.append("toTheConceptId",`${e}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=A("application/x-www-form-urlencoded");const s=yield fetch(I.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:c});return s.ok?r=yield s.json():(console.log("Get connection of concept error",s.status),R(s)),r}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 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){return wo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield De(t),a=yield an(e);if(a.id>0){let t=[],e=[];if(i){e=yield No(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield Q(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield De(n),i=yield rt(o.id);r.push(i)}}else{e=yield xe(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield Q(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield De(n),i=yield rt(o.id);r.push(i)}}}return r}))}function ko(t,e){return wo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield De(t),a=yield an(e),s=[],l=[];if(a.id>0){if(i){s=yield No(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield xe(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield b(l)}return r}))}class Ao{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 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())}))};class So{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 xo(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isDataLoaded)return t("done");setTimeout(So.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=new ye(0,0,0,0,0,0);var r=new Ao(o,t,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=xt();var r=new Ao(o,i,t,null,null);this.addNodeToTree(r)}static getNodeFromTree(t,e){return xo(this,arguments,void 0,(function*(t,e,n=999){let o=this.compositeKey(t,e,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(t){return xo(this,arguments,void 0,(function*(t,e=999,n=999){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}}So.root=null;var Ro=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 _o(t,e){return Ro(this,arguments,void 0,(function*(t,e,n=999,o=999){let i=yield So.getNodeFromTree(t,n,o),r=xt();if(i)for(let t=0;t<i.value.length;t++){let n=i.value[t];n.ghostId==e&&(r=n)}return r}))}function Lo(t,e){return Ro(this,arguments,void 0,(function*(t,e,n=999,o=999){let i=yield So.getNodeFromTree(t,n,o),r=new ye(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 Go(t,e){return Ro(this,arguments,void 0,(function*(t,e,n=999){So.addConceptToTree(t,e,n)}))}function Uo(t,e){return Ro(this,arguments,void 0,(function*(t,e,n=999){So.addConnectionToTree(t,e,n)}))}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 Vo(t){return Fo(this,arguments,void 0,(function*(t,e=""){var n=x("application/json",e);const o=I.SearchLinkMultipleAllApiUrl(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(console.log("This is the searching multiple error",t.status),R(t),[])}catch(t){throw console.log("This is the searching multiple error",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 Bo(t){return Po(this,arguments,void 0,(function*(t,e=""){let n=[],o=yield Vo(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 Fn(c,a),yield Do(s,n,i,l)}))}function Do(t,e,n){return Po(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Sn(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 De(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 De(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 Eo(t){var e,n;const o=xt();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 Oo(t){const e=p();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 bo(t){const e=new ye(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 Mo=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 Ho(t){return Mo(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=xt(),a=xt();const s=[],l=t.compositionId,d=t.ofTheCompositionId;let u=[],h=yield X(l);for(let t=0;t<h.length;t++)i.push(bo(h[t]));const f=[],y=[];let p=[];for(let t=0;t<i.length;t++)Hn(y,i[t].ofTheConceptId),Hn(f,i[t].ofTheConceptId),Hn(f,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);for(let t=0;t<f.length;t++){const e=yield De(f[t]);l==f[t]&&(c=Eo(e)),d==f[t]&&(a=Eo(e)),r.push(Eo(e))}const v=t.patchObject;for(const t in v){let l=xt();const d=v[t];let h=c;a.id>0&&(h=a),Array.isArray(d)||"object"==typeof d?(l=yield we(t,"",!0,c.userId,4,999),yield ke(v[t],l.id,l.userId,c.id,c.userId,4,999)):l=yield we(t,d,!1,e,o,n);const f=jn(r,l);for(let t=0;t<f.length;t++)if(f[t].id>0){const e=Jn(i,f[t].id);u=u.concat(e),s.push(f[t])}yield pe(h.id,l.id,c.id,2),r.push(l)}for(let t=0;t<u.length;t++)Pe(u[t].id);Wt.SyncDataOnline()}))}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())}))},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 $o(t){return jo(this,void 0,void 0,(function*(){var e;let n=yield function(t){return Wo(this,void 0,void 0,(function*(){let e=[];try{var n=A();const o=yield fetch(I.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(o.ok){let t=yield o.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;b(i),n[r]=e}return n}return console.log("View Internal Data error",o.status),R(o),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),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[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 lt(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield De(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}))}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())}))},Qo=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 zo(t){return Qo(this,arguments,void 0,(function*(t,e=""){var n=yield function(t){return Jo(this,arguments,void 0,(function*(t,e=""){var n=x("application/json",e);let o=I.SearchInternalWithAuthenticatedCcsUrl();o=o+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(o,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),R(t),[])}catch(t){throw console.log("This is the searching internal error",t),t}}))}(t,e);return yield $o(n)}))}class Ko{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class qo{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 Yo{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Xo{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}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())}))};var 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())}))},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())}))};class ni{}ni.isUpdated=!1,ni.isOnlineSync=!1;var oi=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 ri=1,ci=2,ai=3,si=4,li=5,di=6,ui=7;class hi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var fi=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 yi(t){return fi(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield q(t[n].connectionTypeId);t[n].connectionType=o.characterValue,e[t[n].conceptId]=t[n]}return e}))}function pi(t){const e=t.split("_");if(3===e.length){let t=new hi;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 vi(t){return t.startsWith("the_")?t.slice(4):t}var gi=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())}))},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())}))};function mi(t,e,n){return Ci(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;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 De(t[u].ofTheConceptId),y=yield De(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 De(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 De(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 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())}))};function Ni(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))}}function wi(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 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())}))};var ki=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 Ai(t,e){return ki(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=di;let n,o=yield function(t){return ii(this,arguments,void 0,(function*(t,e=""){var n=x("application/json",e);const o=I.FreeschemaQueryUrl(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(R(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 S(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new S(t.message,!1,500,t.stack);throw n.setUrl(e),n}}(t,o)}}))}(t,""),i=o.conceptIds,r=(o.internalConnections,o.linkers),c=o.reverse,a=o.mainCompositionIds,s=o.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=pi(t[n]);e.push(o)}return e}(s);return n=e==ci?yield function(t,e,n,o,i){return Ii(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Un(t),a=yield yi(i);c=wi(c,r);let s=[];s=yield function(t,e){return gi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;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 De(t[u].ofTheConceptId),y=yield De(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield De(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 De(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}))}(c,s,o),s=yield function(t,e){return gi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;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 De(t[u].ofTheConceptId),y=yield De(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield De(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=vi(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 De(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=vi(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}))}(c,s,o);let l=yield function(t,e,n,o){return gi(this,arguments,void 0,(function*(t,e,n,o,i=[],r){var c,a,s,l,d,u,h;(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 o=!1,r=yield De(t[n].ofTheConceptId),f=yield De(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 De(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 De(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 n={};n.id=o[t],n.data=e[o[t]],f.push(n)}return f}))}(c,s,[],n,o,a);return l}))}(r,i,a,c,d,l):e==ai?yield function(t,e,n,o,i){return Ii(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Un(t),a=yield yi(i);c=wi(c,r);let s=[];s=yield mi(c,s,o),s=yield function(t,e){return Ti(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;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 De(t[u].ofTheConceptId),y=yield De(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield De(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=vi(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 De(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=vi(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}))}(c,s,o);let l=yield function(t,e,n){return Ti(this,arguments,void 0,(function*(t,e,n,o=[],i){var r,c,a,s,l,d,u,h;(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 De(t[n].ofTheConceptId),p=yield De(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 De(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 De(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),Ni(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,Ni(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}))}(c,s,n,o,a);return l}))}(r,i,a,c,d,l):yield function(t,e,n,o){return Ii(this,void 0,void 0,(function*(){let e=yield Un(t);e=wi(e);let i=[];i=yield mi(e,i,o),i=yield function(t,e,n){return Ci(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;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 De(t[u].ofTheConceptId),y=yield De(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 De(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=vi(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 De(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=vi(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(){return Ci(this,arguments,void 0,(function*(t=[],e=[],n=[],o,i=[]){var r,c,a,s,l,d;let u=[],h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.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 De(t[n].ofTheConceptId),h=yield De(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 De(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 De(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 o=e[n[t]];o&&(o.id=n[t],u.push(o))}return u}))}(e,i,n,[],o);return r}))}(r,0,a,c),n}))}class xi{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=ri,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var 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 Ri(t,e){return Si(this,arguments,void 0,(function*(t,e,n=!1){let o=[];if(n){let n=yield yn(t),i=yield dn(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield hn(t);for(let t=0;t<n.length;t++)E.AddConnection(n[t]);let i=yield dn(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function _i(t,e,n){return Si(this,arguments,void 0,(function*(t,e,n,o=!1){let i=[],r=[];if(i=o?yield Ri(e,n,o):yield Ri(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 Li=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 Gi{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.transactionId=Math.random().toString().substring(5)}initialize(){return Li(this,void 0,void 0,(function*(){yield Wt.initializeTransaction(this.transactionId)}))}markAction(){return Li(this,void 0,void 0,(function*(){yield Wt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Li(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},yield Wt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Li(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield Wt.SyncDataOnline(this.transactionId),this.actions={concepts:[],connections:[]},this.success=!1}))}MakeTheInstanceConcept(t,e){return Li(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const a=yield ue(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 Li(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield _e(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 Li(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield en(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){return Li(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield Re(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 Ui(t=""){k.BearerAccessToken=t}function Fi(t="",e="",o=""){I.BASE_URL=t,I.AI_URL=e,console.log("This ist he base url",I.BASE_URL),k.BearerAccessToken=o,function(){return oi(this,void 0,void 0,(function*(){return yield new n(!0),yield function(){return ei(this,void 0,void 0,(function*(){try{(new Date).getTime();var t=x("application/x-www-form-urlencoded");const n=yield fetch(I.GetAllAiData(),{method:"GET",headers:t});n.ok||(console.log("Ai Error Message: ","Cannot get response"),R(n));const o=yield n.json();for(var e=0;e<o.length;e++)T.AddConcept(o[e])}catch(t){throw t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),t}}))}(),!0}))}().then((()=>{const t=(new Date).getTime();(function(){return N(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield c();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];T.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{s.isDataLoaded=!0,s.isCharacterLoaded=!0,s.isTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare concept data is ",e)})),function(){return ti(this,void 0,void 0,(function*(){var t=yield a();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];Rt.AddConceptToMemory(n)}}))}().then((()=>{s.isLocalDataLoaded=!0,s.isLocalTypeLoaded=!0,s.isLocalCharacterLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare local concept ",e)})),function(){return Zo(this,void 0,void 0,(function*(){!function(){Zo(this,void 0,void 0,(function*(){var t=yield a();if(Array.isArray(t))for(var e=0;e<t.length;e++)Lt.AddConnection(t[e])}))}()}))}().then((()=>{s.isLocalConnectionLoaded=!0})),function(){return Zo(this,void 0,void 0,(function*(){!function(){Zo(this,void 0,void 0,(function*(){var t=yield c();if(Array.isArray(t))for(var e=0;e<t.length;e++)E.AddConnectionToMemory(t[e])}))}()}))}().then((()=>{s.isConnectionLoaded=!0,s.isConnectionTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare connections ",e)}))}))}var Vi=exports;for(var Pi in e)Vi[Pi]=e[Pi];e.__esModule&&Object.defineProperty(Vi,"__esModule",{value:!0})})();
|
|
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:()=>yi,AddGhostConcept:()=>Uo,AddGhostConnection:()=>Fo,BaseUrl:()=>I,BinaryTree:()=>f,Composition:()=>no,CompositionBinaryTree:()=>Xn,CompositionNode:()=>qn,Concept:()=>y,ConceptsData:()=>T,Connection:()=>G,ConnectionData:()=>E,CreateComposition:()=>ye,CreateConnection:()=>Le,CreateConnectionBetweenTwoConcepts:()=>be,CreateConnectionBetweenTwoConceptsGeneral:()=>He,CreateDefaultConcept:()=>p,CreateDefaultLConcept:()=>xt,CreateSession:()=>Co,CreateSessionVisit:()=>To,CreateTheCompositionLocal:()=>Ae,CreateTheCompositionWithCache:()=>io,CreateTheConnection:()=>Wt,CreateTheConnectionGeneral:()=>_e,CreateTheConnectionLocal:()=>ve,DATAID:()=>di,DATAIDDATE:()=>hi,DeleteConceptById:()=>Nn,DeleteConnectionById:()=>Pe,DeleteConnectionByTypeBulk:()=>Yo,FilterSearch:()=>ei,FormatFromConnections:()=>Eo,FreeSchemaResponse:()=>S,FreeschemaQuery:()=>Li,GetAllConnectionsOfComposition:()=>X,GetAllConnectionsOfCompositionBulk:()=>Q,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Ui,GetComposition:()=>et,GetCompositionBulk:()=>Ln,GetCompositionBulkWithDataId:()=>Gn,GetCompositionFromConnectionsWithDataId:()=>Un,GetCompositionFromConnectionsWithDataIdInObject:()=>Vn,GetCompositionList:()=>vt,GetCompositionListLocal:()=>Et,GetCompositionListLocalWithId:()=>Ot,GetCompositionListWithId:()=>gt,GetCompositionLocal:()=>Ut,GetCompositionLocalWithId:()=>Ft,GetCompositionWithAllIds:()=>nt,GetCompositionWithCache:()=>fo,GetCompositionWithDataIdBulk:()=>vo,GetCompositionWithDataIdWithCache:()=>po,GetCompositionWithId:()=>st,GetCompositionWithIdFromMemory:()=>it,GetCompositionWithIdFromMemoryFromConnections:()=>ct,GetConceptBulk:()=>b,GetConceptByCharacter:()=>yt,GetConceptByCharacterAndCategoryDirectApi:()=>cn,GetConceptByCharacterAndType:()=>zt,GetConceptByTypeBulk:()=>Kt,GetConnectionBulk:()=>Rn,GetConnectionById:()=>Ve,GetConnectionByTypeBulk:()=>Xo,GetConnectionOfTheConcept:()=>Se,GetLink:()=>We,GetLinkRaw:()=>$e,GetLinkerConnectionFromConcepts:()=>gn,GetLinkerConnectionToConcepts:()=>Cn,GetRelation:()=>ko,GetRelationRaw:()=>Ao,GetTheConcept:()=>Ee,GetUserGhostConnectionId:()=>Go,GetUserGhostId:()=>Lo,GiveConnection:()=>Fi,HandleHttpError:()=>R,JUSTDATA:()=>ui,LConcept:()=>At,LConnection:()=>pe,LISTNORMAL:()=>pi,LoginToBackend:()=>En,MakeTheInstanceConcept:()=>he,MakeTheInstanceConceptLocal:()=>Ie,MakeTheTimestamp:()=>An,MakeTheTypeConcept:()=>nn,MakeTheTypeConceptApi:()=>un,NORMAL:()=>li,PatcherStructure:()=>Zo,RAW:()=>fi,RecursiveSearchApi:()=>Pn,SchemaQueryListener:()=>_i,SearchAllConcepts:()=>so,SearchLinkInternal:()=>Ko,SearchLinkMultipleAll:()=>Do,SearchLinkMultipleApi:()=>Bo,SearchQuery:()=>xn,SearchStructure:()=>ni,SearchWithLinker:()=>uo,SessionData:()=>ti,Signin:()=>Hn,Signup:()=>bn,SplitStrings:()=>w,SyncData:()=>jt,Transaction:()=>Bi,TrashTheConcept:()=>In,UpdateComposition:()=>co,UpdateCompositionLocal:()=>jo,UserBinaryTree:()=>Ro,ViewInternalData:()=>Jo,convertFromLConceptToConcept:()=>bo,getFromDatabaseWithType:()=>r,getFromDatabaseWithTypeOld:()=>c,init:()=>Di,recursiveFetch:()=>lt,recursiveFetchNew:()=>to,storeToDatabase:()=>i,updateAccessToken:()=>Pi});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}var o=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 i(t,e){}function r(t,e,n){return o(this,void 0,void 0,(function*(){}))}function c(t){return o(this,void 0,void 0,(function*(){}))}function a(t){return o(this,void 0,void 0,(function*(){}))}class s{}s.isTypeLoaded=!1,s.isCharacterLoaded=!1,s.isDataLoaded=!1,s.isLocalDataLoaded=!1,s.isLocalCharacterLoaded=!1,s.isLocalTypeLoaded=!1,s.isConnectionLoaded=!1,s.isConnectionTypeLoaded=!1,s.isLocalConnectionLoaded=!1;class l{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 d=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 u{static waitForDataToLoad(){return d(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isCharacterLoaded)return t("done");setTimeout(u.checkFlag,1e3,t)}static addNodeToTree(t){return d(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 d(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 l(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 d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return d(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))}}u.characterRoot=null;var h=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{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 h(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isDataLoaded)return t("done");setTimeout(f.checkFlag,1e3,t)}static addConceptToTree(t){var e=new l(t.id,t,null,null),n=new l(t.characterValue,t,null,null);u.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return h(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return h(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}}f.root=null;class y{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 p(){let t=v(new Date),e=v(new Date);return new y(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function v(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 C{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 l(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(s.isTypeLoaded)return t("done");setTimeout(C.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=p();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}}C.typeRoot=null;var m=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 T{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&&(f.addConceptToTree(t),C.addConceptToTree(t),u.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(f.addConceptToTree(t),C.addConceptToTree(t),u.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);f.removeNodeFromTree(t.id),t.id}static GetConcept(t){return m(this,void 0,void 0,(function*(){var e=p(),n=yield f.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return m(this,void 0,void 0,(function*(){var e=p(),n=u.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return m(this,void 0,void 0,(function*(){var e=p(),n=u.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return m(this,void 0,void 0,(function*(){return p(),yield C.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return m(this,void 0,void 0,(function*(){var n=p(),o=yield u.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 m(this,void 0,void 0,(function*(){let n=[];return n=yield C.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return u.characterRoot}getName(){return this.name}}T.conceptsArray=[],T.NPC=[],T.conceptDictionary=[];var N=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){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}class I{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"}}I.BASE_URL="https://localhost:7053/",I.AI_URL="https://ai.freeschema.com",I.MQTT_URL="192.168.1.249",I.NODE_URL="http://localhost:5001/";class k{}function A(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+k.BearerAccessToken,Accept:e}}function x(t="application/json",e="",n="application/json"){return""==e&&(e=k.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}k.BearerAccessToken="";class S{constructor(t,e,n,o){this.url=I.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=o}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 R(t){if(401==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}var _=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 L(t,e){return _(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var o=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllConceptsByTypeUrl(),{method:"POST",headers:o,body:n});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)T.AddConcept(t[i])}console.log("GetAllConceptsByType error",r.status),R(r)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class G{constructor(t=0,e,n,o,i,r,c,a,s,l,d,u,h,f,y,g){this.isTemp=!1,this.toUpdate=!1,this.type=p(),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=g,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class U{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 F=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 V{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 U(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isConnectionLoaded)return t("done");setTimeout(V.checkFlag,1e3,t)}static removeNodeFromTree(t){return F(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return F(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}V.connectionroot=null;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())}))};class P{static addNodeToTree(t){return B(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 B(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isConnectionTypeLoaded)return t("done");setTimeout(P.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new U(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 B(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 B(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}))}}P.connectionTypeRoot=null;var D=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 E{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||(V.addConnectionToTree(t),P.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(V.addConnectionToTree(t),P.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(t.id,V.removeNodeFromTree(t.id),P.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return V.connectionroot}static GetConnectionTypeTree(){return P.connectionTypeRoot}static GetConnection(t){return D(this,void 0,void 0,(function*(){var e=new G(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield V.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return D(this,void 0,void 0,(function*(){var e=[],n=yield P.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}}E.connectionArray=[],E.connectionDictionary=[];var O=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 b(t){return O(this,void 0,void 0,(function*(){let e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield T.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=A();const t=yield fetch(I.GetConceptBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});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),T.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),R(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 M=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 H(t=[]){return M(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 b(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=[]){return j(this,void 0,void 0,(function*(){var e=[];for(let o=0;o<t.length;o++){var n=yield E.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function $(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||E.RemoveConnection(e[n]))}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 Q(t=[]){return J(this,void 0,void 0,(function*(){var e=[];if(t.length<=0)return e;var n=yield W(t),o=yield function(t=[]){return J(this,void 0,void 0,(function*(){var e=[];try{var n=A();const i=yield fetch(I.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();for(var o=0;o<t.length;o++)E.AddConnection(t[o]),e.push(t[o])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),R(i);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 $(e=o,n),yield H(e),e}))}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())}))};const K=new Map;function q(t){return z(this,void 0,void 0,(function*(){let e=p();if(K.has(t))return K.get(t)||e;const n=(()=>z(this,void 0,void 0,(function*(){try{var n=yield T.GetConcept(t);let i=T.GetNpc(t);if(0!=n.id||i)return n;{var o=A("application/x-www-form-urlencoded");const n=yield fetch(I.GetConceptUrl(),{method:"POST",headers:o,body:`id=${t}`});return n.ok?(e=yield n.json(),e.id>0?T.AddConcept(e):T.AddNpc(t)):(console.log("Get the concept error",n.status,t),R(n)),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{K.delete(t)}})))();return K.set(t,n),n}))}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())}))};function X(t){return Y(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield E.GetConnectionsOfCompositionLocal(t)).length)e=yield Z(t);else{var n=yield Z(t);$(n,e),e=n}return e}))}function Z(t){return Y(this,void 0,void 0,(function*(){var e=[];try{var n=A("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${t}`});if(!i.ok)throw R(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();for(var o=0;o<r.length;o++)E.AddConnection(r[o]),e.push(r[o]);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 tt=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 et(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 nt(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield dt(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 ot(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 it(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 rt(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield E.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 ct(t,e){var n,o;return tt(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 T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 at(t,e,n=[]){var o,i;return tt(this,void 0,void 0,(function*(){var r={},c=yield T.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield q(t));var a=yield lt(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 st(t){var e,n;return tt(this,void 0,void 0,(function*(){var o,i={};o=yield X(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield q(t));var s=yield lt(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 lt(t,e,n,o=[]){var i,r,c;return tt(this,void 0,void 0,(function*(){var a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield q(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield T.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield q(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield T.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 lt(f,e,n,o);a[p]=t}}else{const t=yield lt(f,e,n,o);s[p]=t,a=s}}return a}))}function dt(t,e,n,o=[]){var i,r,c;return tt(this,void 0,void 0,(function*(){var a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield q(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield T.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield q(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield T.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield q(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 dt(f,e,n);a[p]=t}}else{const t=yield dt(f,e,n);s[p]=t,a=s}}return a}))}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*(){let e=p();try{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${t}`});return o.ok?(e=yield o.json(),e.id>0&&T.AddConcept(e)):(console.log("Error in Getting concept by character value Error",o.status),R(o)),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 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())}))};function yt(t){return ft(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield ht(t),e=yield T.GetConceptByCharacter(t)),e}))}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())}))};function vt(t,e,n=10,o=1){return pt(this,void 0,void 0,(function*(){var i=yield yt(t),r=[];if(i){yield L(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield Q(s),l=a;l<a+n;l++)if(c[l]){var d=yield ot(c[l].id);r.push(d)}}return r}))}function gt(t,e,n=10,o=1){return pt(this,void 0,void 0,(function*(){var i=yield yt(t),r=[];if(i){yield L(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield Q(s),l=a;l<a+n;l++)if(c[l]){var d=yield it(c[l].id);r.push(d)}}return r}))}class Ct{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 mt=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 Tt{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 Ct(t.id,t,null,null);new Ct(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return mt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalDataLoaded)return t("done");setTimeout(Tt.checkFlag,1e3,t)}static getNodeFromTree(t){return mt(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 mt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}Tt.root=null;var Nt=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{static waitForDataToLoad(){return Nt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalCharacterLoaded)return t("done");setTimeout(wt.checkFlag,1e3,t)}static addNodeToTree(t){return Nt(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 Ct(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 Nt(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))}}wt.LocalCharacterRoot=null;var It=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 kt{static addNodeToTree(t){return It(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 Ct(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 It(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalTypeLoaded)return t("done");setTimeout(kt.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return It(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}))}}kt.LocalTypeRoot=null;class At{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 xt(){let t=new Date,e=new Date;return new At(0,0,0,0,0,"0","0",!1,t,e,0)}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())}))};class Rt{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(Tt.addConceptToTree(t),wt.addConceptToTree(t),kt.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(Tt.addConceptToTree(t),wt.addConceptToTree(t),kt.addConceptToTree(t))}static GetConcept(t){return St(this,void 0,void 0,(function*(){var e=xt(),n=yield Tt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return St(this,void 0,void 0,(function*(){var e=xt(),n=wt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return St(this,void 0,void 0,(function*(){var n=xt(),o=yield wt.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 St(this,void 0,void 0,(function*(){let n=[];return n=yield kt.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}Rt.localconceptsArray=[];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())}))};class Lt{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 _t(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isLocalConnectionLoaded)return t("done");setTimeout(Lt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return _t(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}}Lt.connectionArray=[],Lt.connectionDictionary=[];var Gt=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 Ut(t){var e,n;return Gt(this,void 0,void 0,(function*(){var o,i={};o=yield Lt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Rt.GetConcept(t),s=yield Vt(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 Ft(t){var e,n;return Gt(this,void 0,void 0,(function*(){var o,i={};o=yield Lt.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Rt.GetConcept(t);if(0!=a.id){var s=yield Vt(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 Vt(t,e,n,o=[]){var i,r,c;return Gt(this,void 0,void 0,(function*(){var a={},s=[],l=yield Rt.GetConcept(t);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield Rt.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 Rt.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield Rt.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 Vt(f,e,n);a[p]=t}}else{const t=yield Vt(f,e,n);s[p]=t,a=s}}return a}))}var Bt=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){return Bt(this,void 0,void 0,(function*(){return yield Rt.GetConceptByCharacter(t)}))}var Dt=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 Et(t,e){return Dt(this,void 0,void 0,(function*(){var n=yield Pt(t),o=[];if(n)for(var i=yield Rt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Ut(i[r].id);o.push(c)}return o}))}function Ot(t,e){return Dt(this,void 0,void 0,(function*(){var n=yield Pt(t),o=[];if(n)for(var i=yield Rt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Ft(i[r].id);o.push(c)}return o}))}function bt(t){return e=this,n=void 0,i=function*(){let e=p();try{var n=A();const o=yield fetch(I.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);return e=yield o.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((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}function Mt(t){return e=this,n=void 0,i=function*(){let e=new G(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=A(),o=JSON.stringify(t);const i=yield fetch(I.CreateTheConnectionUrl(),{method:"POST",headers:n,body:o});return i.ok?yield i.json():(console.log("Create the connection error message: ",i),R(i)),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((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}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 jt{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 Ht(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 bt(e)),n.length>0&&(yield Mt(n))}else{for(let t=0;t<this.conceptsSyncArray.length;t++)T.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)E.AddConnection(this.connectionSyncArray[t]);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield bt(e)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield Mt(n))}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return Ht(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 Ht(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 Ht(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 Ht(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 Wt(t,e,n,o,i,r,c){var a=new G(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()),jt.AddConnection(a),a)}jt.conceptsSyncArray=[],jt.connectionSyncArray=[],jt.transactionCollections=[];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())}))},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())}))};const Qt=new Map;function zt(t,e){return Jt(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndTypeLocal(t,e),o=t+e;if(Qt.has(o))return Qt.get(o)||n;const i=(()=>Jt(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=A();const o=yield fetch(I.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});if(o.ok){let t=yield o.json();n=t,T.AddConcept(n)}else console.log("This is the concept by type and character error",o.status),R(o)}return n}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{Qt.delete(o)}})))();return Qt.set(o,i),i}))}function Kt(t){return Jt(this,void 0,void 0,(function*(){let e=[],n=JSON.stringify(t);var o=A();const i=yield fetch(I.GetConceptConnectionByType(),{method:"POST",headers:o,body:n});if(i.ok){let t=yield i.json();e=yield b(t)}else console.log("This is the concept by type and character error",i.status),R(i);return e}))}class qt{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 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())}))};let Xt=!1,Zt=[];const te=()=>{Zt.length>0&&!Xt&&Zt.shift()()};var ee=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 ne=!1,oe=[];const ie=()=>{oe.length>0&&!ne&&oe.shift()()};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())}))};class ce{static getId(){return re(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return ee(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{console.log("trying to fetch more concepts"),oe.push((()=>ee(this,void 0,void 0,(function*(){try{if(ne)return;if(ne=!0,ce.ids.length>10)return console.log("Enough IDs available, skipping fetch."),ne=!1,ie(),t();var n=A("application/x-www-form-urlencoded");const e=yield fetch(I.GetReservedIdUrl(),{method:"GET",headers:n});if(!e.ok)throw R(e),new Error(`Error! status: ${e.status}`);const i=yield e.json();for(var o=0;o<i.length;o++)ce.AddId(i[o]);console.log("Ids Fetch Success"),t()}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message,I.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",t),e(t)}finally{ne=!1,ie()}})))),ie()}))}))}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}ce.ids=[];class ae{static getId(){return re(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return Yt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{Zt.push((()=>Yt(this,void 0,void 0,(function*(){try{if(Xt)return;if(Xt=!0,ae.connectionIds.length>10)return Xt=!1,te(),t();var n=A("application/x-www-form-urlencoded");const e=yield fetch(I.GetReservedConnectionIdUrl(),{method:"GET",headers:n});if(!e.ok)throw R(e),new Error(`Error! status: ${e.status}`);const i=yield e.json();for(var o=0;o<i.length;o++)ae.AddId(i[o]);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{Xt=!1,te()}})))),te()}))}))}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}ae.connectionIds=[];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 le(t,e,n,o,i,r,c,a,s,l,d,u,h,f,p={concepts:[],connections:[]}){return se(this,void 0,void 0,(function*(){var v=yield ce.getId();let g=new Date,C=new Date;var m=new y(v,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,g,C);return m.isTemp=!1,jt.AddConcept(m),p.concepts.push(m),m}))}function de(t,e,n,o,i,r,c,a,s,l,d,u,h,f,p={concepts:[],connections:[]}){return se(this,void 0,void 0,(function*(){var v=yield ce.getId();let g=new Date,C=new Date;var m=new y(v,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,g,C);return T.AddConcept(m),m.updateRecursion=!0,jt.AddConcept(m),p.concepts.push(m),m}))}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 he(t,e,n=!1,o,i,r=999,c=0,a={concepts:[],connections:[]}){return ue(this,void 0,void 0,(function*(){let s,l=r,d=999,u=o,h=o,f=i,y=o,v="",g=e.length,C=p();v=t.startsWith("the_")?t:"the_"+t;(new Date).getTime();if(n)C=yield un(t),s=yield le(e,o,4,o,C.id,C.userId,c,999,d,u,f,y,l,h,a),(new Date).getTime();else if(g>255)C=yield un(v),s=yield le(e,o,4,o,C.id,C.userId,c,999,d,u,f,y,l,h,a),function(t){$t(this,void 0,void 0,(function*(){try{var e=A();const n=yield fetch(I.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw R(n),new Error(`Error! status: ${n.status}`);return yield n.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 qt(o,e,d,u,f,y,l,h,Date.now().toString(),!0)),(new Date).getTime();else{C=yield un(v);let t=yield zt(e,C.id);s=t,0==t.id&&0==t.userId&&(s=yield de(e,o,4,o,C.id,C.userId,12,12,d,u,f,y,l,h,a)),(new Date).getTime()}return s.type=C,s}))}var fe=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 ye(t,e=null,n=null,o=null,i=null,r=null,c=null){return fe(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=p();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=v=yield he(o,"",!0,a,s,l),h=v.id,d=v.id,yield ye(t[o],v.id,v.userId,h,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;h=d,u=v=yield he(o,"",!0,a,s,l),yield Wt(f,y,v.id,v.userId,h,l,v.userId),yield ye(t[o],v.id,v.userId,h,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,h=d;var v=yield he(o,t[o].toString(),!1,a,s,l);yield Wt(f,y,v.id,v.userId,h,l,v.userId)}return u}))}class pe{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=xt(),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=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function ve(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 pe(0,0,0,0,0,0);return t!=e&&(a=new pe(0,t,e,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Lt.AddConnection(a)),a}var ge=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 Ce(t,e,n,o,i,r,c=0){return ge(this,void 0,void 0,(function*(){var a=Math.floor(1e8*Math.random());let s=new Date,l=new Date;var d=new At(a,n,i,o,r,t,e,!0,s,l,c);return d.isTemp=!0,Rt.AddConcept(d),d}))}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())}))},Te=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 Ne(t,e,n,o){return Te(this,void 0,void 0,(function*(){var i=yield Pt(t);if(i&&(0==i.id||0==i.userId)){var r=w(t);if(r[0]==t){var c=yield function(t,e,n,o,i){return me(this,void 0,void 0,(function*(){var e=yield Rt.GetConceptByCharacterAndTypeLocal(t,51),o=e;return 0==o.id&&(o=e=yield Ce(t,"the",n,4,51,4)),o}))}(t,0,o);i=c}else{var a=yield Ne(r[0],e,n,o),s=yield Ne(r[1],e,n,o);s&&(i=c=yield Ce(t,r[1],o,a.id,s.id,4))}}return i}))}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=!1,o,i,r=999,c=0){return we(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 Ne(t,999,o,o),r=yield Ce(e,t,o,4,i.id,4,c);else if(l>255)i=yield Ne(a,999,s,o),r=yield Ce(e,a,o,4,i.id,4);else{i=yield Ne(a,999,s,o);var d=yield Rt.GetConceptByCharacterAndTypeLocal(e,i.id);r=d,0==d.id&&0==d.userId&&(r=yield Ce(e,a,o,4,i.id,4))}return r.type=i,r}))}var ke=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 Ae(t,e=null,n=null,o=null,i=null,r=null,c=null){return ke(this,void 0,void 0,(function*(){var a=null!=i?i:999,s=null!=c?c:4,l=null!=o?o:0,d=xt();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 Ie(o,"",!0,a,0,s),u=f.id,l=f.id,yield Ae(t[o],f.id,f.userId,u,i,r,c)}else{var h=null!=e?e:999,f=(u=l,yield Ie(o,"",!0,a,0,s));yield ve(h,f.id,u),yield Ae(t[o],f.id,f.userId,u,i,r,c)}else h=null!=e?e:999,u=l,f=yield Ie(o,t[o].toString(),!1,a,0,s),yield ve(h,f.id,u);return d}))}var xe=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 Se(t,e,n,o=10,i=1){return xe(this,void 0,void 0,(function*(){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${t}`),c.append("ofTheConceptId",`${e}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=A("application/x-www-form-urlencoded");const s=yield fetch(I.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:c});return s.ok?r=yield s.json():(console.log("Get connection of concept error",s.status),R(s)),r}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 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())}))};function _e(t,e,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){return Re(this,void 0,void 0,(function*(){let u=e,h=e,f=e;999!=l&&(f=l);let y=e,p=e,v=yield ae.getId(),g=new G(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,jt.AddConnection(g),d.connections.push(g),g)}))}function Le(t,e,n,o={concepts:[],connections:[]}){return Re(this,void 0,void 0,(function*(){let i=yield un(n),r=t.userId;return yield _e(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}var Ge=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())}))},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())}))},Fe=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 Ve(t){return Fe(this,void 0,void 0,(function*(){var e=yield E.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var n=yield function(t){return Ue(this,void 0,void 0,(function*(){var e=yield E.GetConnection(t);try{if(0!=e.id)return e;{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${t}`});return o.ok?(e=yield o.json(),E.AddConnection(e)):(console.log("Get Connection Error",o.status),R(o)),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=n}return e}))}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 Pe(t,e=""){return Be(this,void 0,void 0,(function*(){let n=!1;var o=yield Ve(t);return n=yield function(t,e=""){return Ge(this,void 0,void 0,(function*(){let n=!1;try{const o=new FormData;let i=A("application/x-www-form-urlencoded");""!=e&&(i=x("application/x-www-form-urlencoded",e)),o.append("id",t.toString()),o.append("apiKey","nodeserver");const r=yield fetch(I.DeleteTheConnectionUrl(),{method:"POST",body:o,redirect:"follow"});r.ok?n=(yield r.json()).success:(console.log("Delete connection error status: ",r.status),R(r))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}return n}))}(t,e),V.removeNodeFromTree(t),P.removeTypeConcept(o.typeId,t),n}))}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 Ee(t,e=999){return De(this,void 0,void 0,(function*(){var n=p();if(t<0)return bo(yield Lo(e,t));if(null!=(n=yield T.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield q(t)),0!=n.id&&null==n.type&&null==(yield T.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield q(n.typeId);n.type=o}return n}))}var Oe=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 be(t,e,n,o=!1,i=!1){var r,c;return Oe(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 Me(c,e,a));var d=yield he("connection",u,!1,999,999,999);let h=new G(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);jt.AddConnection(h)}let u=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s",h=n+"_s",f=u+"_"+h;i&&(yield Me(h,t,a));var y=yield he("connection",f,!1,999,999,999);let p=new G(0,t.id,e.id,t.userId,e.userId,t.userId,y.id,y.userId,1e3,a,999,s,4,l,999,999);return jt.AddConnection(p),p}))}function Me(t,e,n=null){var o;return Oe(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 he("connection",d,!1,r,4,s),h=yield Se(u.id,e.id,r,10,1),f=[],y=p(),v=0;v<h.length;v++){let t=yield Ee(h[v].toTheConceptId);f.push(t)}if(f.length<1)y=yield he("count","1",!1,r,4,s);else{var g=f[0];let t=0;try{t=Number(g.characterValue)}catch(e){t=0}t+=1,y=yield he("count",t.toString(),!1,r,4,s);for(let t=0;t<h.length;t++)Pe(h[t].id)}let C=new G(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,a,s,999);yield jt.AddConnection(C)}))}function He(t,e,n,o=!1,i=!1){var r,c;return Oe(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 Me(c,e,a));var d=yield he("connection",u,!1,999,999,999);let h=new G(0,e.id,t.id,e.userId,t.userId,e.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);jt.AddConnection(h)}let u=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s",h=n+"_s",f=u+"_"+h;i&&(yield Me(h,t,a));var y=yield he("connection",f,!1,999,999,999);return yield _e(t.id,t.userId,e.id,e.userId,y.id,999,999,1e3,4)}))}var 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())}))};function We(t,e,n=10,o=1){var i;return je(this,void 0,void 0,(function*(){var r=[],c=yield Ee(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield zt(a,16);if(s.id>0){for(var l=yield Se(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield Q(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield Ee(t),n=yield rt(e.id);r.push(n)}}return r}))}function $e(t,e,n=10,o=1){var i;return je(this,void 0,void 0,(function*(){var r=[],c=yield Ee(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield zt(a,16);if(s.id>0){for(var l=yield Se(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 Ee(t);r.push(e)}}return r}))}class Je{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 Qe{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new Je(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}}Qe.characterData=[];class ze{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var Ke=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 Ye(t,e,n,o,i){return qe(this,void 0,void 0,(function*(){var r=new Je(e,t,n,e,o,e,i,e,"",!1);return yield function(t){return Ke(this,void 0,void 0,(function*(){try{if(0==(t=Qe.GetCharacter(t.data)).id){var e=A();const o=yield fetch(I.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();var n=new Je(i.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=i.id,Qe.AddCharacter(n),i}return new ze(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}}))}(r)}))}var Xe=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,e,n,o,i,r,c,a,s,l,d,u,h,f){return Xe(this,void 0,void 0,(function*(){var y=yield zt(t,i),p=y;return 0==p.id&&(p=y=yield le(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var tn=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())}))},en=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 nn(t,e,n,o,i={concepts:[],connections:[]}){return en(this,void 0,void 0,(function*(){var r=o,c=yield yt(t);if(c&&(0==c.id||0==c.userId)){var a=w(t);if(a.length>0)if(console.log(a),a[0]==t){var s=yield function(t,e,n,o,i,r){return tn(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 Ye(t,e,n,o,r),s=Ze(t,e,4,c,h,u,49,l,n,a,o,i,r,d)}else{var f=yield Ye(t,e,n,o,r);f.isNew,s=yield Ze(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 nn(a[0],e,n,o,i),d=yield nn(a[1],e,n,o,i);d&&(c=yield de(t,o,l.id,o,d.id,o,999,o,999,o,999,o,e,o,i))}}return c}))}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())}))};const rn=new Map;function cn(t,e){return on(this,void 0,void 0,(function*(){let n=p();if(rn.has(t+e))return rn.get(t+e)||n;const o=(()=>on(this,void 0,void 0,(function*(){try{var o=A("application/x-www-form-urlencoded");const i=yield fetch(I.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:o,body:`character_value=${t}&category_id=${e}`});if(i.ok){let t=yield i.json();n=t,T.AddConcept(n)}else console.log("This is the concept by category and character direct api error",i.status),R(i);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,t,e,I.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,t,e,I.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{rn.delete(t+e)}})))();return rn.set(t+e,o),o}))}var an=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 an(this,void 0,void 0,(function*(){let e=p();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=t.length;var o=w(t);if(o.length>1){let n=1,i=yield sn(o[0]);0!=i.id&&(n=i.id),e=yield function(t,e){return an(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield cn(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return an(this,void 0,void 0,(function*(){console.log("inside the character length function",t);var e=yield T.GetConceptByCharacterAndTypeLocal(t,49);return console.log("inside the character length function after",e),0==e.id&&(e=yield ht(t)),e}))}(t):o[0]==t&&(e=yield function(t){return an(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield ht(t)),e}))}(t));return e}))}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())}))};const dn=new Map;function un(t,e){return ln(this,void 0,void 0,(function*(){let e=p();if(dn.has(t))return dn.get(t)||e;const n=(()=>ln(this,void 0,void 0,(function*(){try{if(e=yield sn(t),0==e.id||4==e.typeId){var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);let i=yield o.json();e=i,e.id>0&&T.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{dn.delete(t)}})))();return dn.set(t,n),n}))}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 fn(t){return hn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(r.ok){const t=yield r.json();for(var o=0;o<t.length;o++){var i=t[o];e.push(i)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),R(r);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 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 pn(t){return yn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(r.ok){const t=yield r.json();for(var o=0;o<t.length;o++){var i=t[o];e.push(i)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),R(r);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 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){return vn(this,void 0,void 0,(function*(){for(var e=yield fn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Ee(o);t.type=i}return e}))}function Cn(t){return vn(this,void 0,void 0,(function*(){for(var e=yield pn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Ee(o);t.type=i}return e}))}var mn=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())}))},Tn=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 Nn(t,e=""){return Tn(this,void 0,void 0,(function*(){var n=yield Ee(t);yield f.removeNodeFromTree(t);var o=n.typeId,i=n.characterValue;yield C.removeTypeConcept(o,t),yield u.removeNodeByCharacter(i,t);let r=yield function(t,e=""){return mn(this,void 0,void 0,(function*(){let n=!1;try{let o=A("application/x-www-form-urlencoded");""!=e&&(o=x("application/x-www-form-urlencoded",e));const i=new FormData;i.append("id",t.toString()),i.append("apiKey","nodeserver");const r=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:i});if(!r.ok)throw R(r),new Error(`Error! status: ${r.status}`);n=(yield r.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 n}))}(t,e);return r}))}var wn=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 In(t,e){return wn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const o=new FormData;o.append("id",t.toString());const i=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:o,headers:n});if(!i.ok)throw R(i),new Error(`Delete composition Error! status: ${i.status}`)}catch(t){throw t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),t}}))}var kn=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 An(t,e,n,o,i=999){return kn(this,void 0,void 0,(function*(){var o,i=n,r=n,c=n,a=t.startsWith("the_"),s=p();return o=a?t:"the_"+t,s=yield un(o),yield Ze(e,n,4,n,s.id,s.userId,0,999,999,i,4,c,999,r)}))}class xn{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 Sn=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=[]){return Sn(this,void 0,void 0,(function*(){var e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield E.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=A();const t=yield fetch(I.GetConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});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),E.AddConnection(o)}yield H(e)}}else console.log("Get Connection Bulk error",t.status),R(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 _n=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 Ln(t=[]){return _n(this,void 0,void 0,(function*(){yield Q(t);var e=[];for(let o=0;o<t.length;o++){var n=yield ot(t[o]);e.push(n)}return e}))}function Gn(t=[]){return _n(this,void 0,void 0,(function*(){yield Q(t);var e=[];for(let o=0;o<t.length;o++){var n=yield it(t[o]);e.push(n)}return e}))}function Un(t=[],e=[]){return _n(this,void 0,void 0,(function*(){yield Rn(e);var n=yield W(t);!function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||E.RemoveConnection(e[n])}(e,n);var o=[];for(let e=0;e<t.length;e++){var i=yield it(t[e]);o.push(i)}return o}))}function Fn(t=[]){return _n(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 E.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 Rn(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 b(i),n}))}function Vn(t=[],e=[]){return _n(this,void 0,void 0,(function*(){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield E.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Rn(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 at(t[e],o,c);r[t[e]]=n}return console.timeEnd("start"),r}))}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 Pn(t=0,e=[],n=""){return Bn(this,void 0,void 0,(function*(){var o=[];try{var i=new xn;i.composition=t,i.listLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=A();const l=yield fetch(I.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(l.ok){const t=yield l.json();var a=t.compositionIds,s=t.internalConnections;t.externalConnections,o=yield Un(a,s)}else console.log("recursive search error ",l.status),R(l);return o}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search 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 En(t,e){return Dn(this,void 0,void 0,(function*(){try{var n={email:t,password:e},o=new Headers;o.append("Content-Type","application/json");var i=JSON.stringify(n);const r=yield fetch(I.LoginUrl(),{method:"POST",headers:o,body:i});if(r.ok){const t=yield r.json();return k.BearerAccessToken=t.data.token,t}console.log("Login tsccs error message: ",r.status),R(r)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}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 bn(t){return On(this,void 0,void 0,(function*(){return yield function(t="",e={}){return On(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}:R(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(I.SignupUrl(),t)}))}var Mn=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){return Mn(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const o=new Headers;o.append("Content-Type","application/json");const i=I.LoginUrl();try{const t=yield fetch(i,{method:"POST",headers:o,body:e,redirect:"follow"}),r=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==r?void 0:r.data}:R(t),n}catch(t){throw console.log("Sign in api error",t),t}}))}function jn(t,e){return-1===t.indexOf(e)&&t.push(e),t}function Wn(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 $n(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 Jn(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 Qn(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 zn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function Kn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class qn{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&&(Xn.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 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())}))};class Xn{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 qn(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return Yn(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return Yn(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}}Xn.root=null;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,e,n,o,i=[]){var r,c;return Zn(this,void 0,void 0,(function*(){let a={};const s=[];if(0==t)return"";let l=eo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Ee(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=eo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield Ee(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=eo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield Ee(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield T.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield Ee(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 to(d,e,n,o,i);a[u]=t}}else{const t=yield to(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function eo(t,e){let n=p();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class no{constructor(){this.id=0,this.mainConcept=p(),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 to(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(),I.MQTT_CONNECTION&&I.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 oo=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=null,n=null,o=null,i=null,r=null,c=null,a=null){return oo(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=p();null==a&&(a=new no);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield he(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 io(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 Wt(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield io(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 he(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield Wt(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var ro=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 co(t){return ro(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=p(),a=p();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield Ee(l,e);if(!(t.id>0))return null;l=t.id}i=yield X(l);const h=[],f=new no,y=[];f.id=l,f.isUpdating();let v=[];for(let t=0;t<i.length;t++)jn(y,i[t].ofTheConceptId),jn(h,i[t].ofTheConceptId),jn(h,i[t].toTheConceptId),v.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<h.length;t++){const e=yield Ee(h[t]);l==h[t]&&(c=e),d==h[t]&&(a=e),r.push(e)}const g=t.patchObject;for(const t in g){let i=p();const l=g[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield he(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=Wn(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=Jn(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield io(g[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield he(t,l,!1,e,o,n);const c=Wn(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=Jn(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield Wt(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++)Kn(f.connections,u[t]),Pe(u[t].id);for(let t=0;t<s.length;t++)zn(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),Xn.addCompositionToTree(f),yield jt.SyncDataOnline(),f.GetDataCache()}))}var ao=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,n,o,i=10,r=1){return ao(this,void 0,void 0,(function*(){var c=x("application/x-www-form-urlencoded",o),a=new URLSearchParams;a.append("type",t),a.append("search",e),a.append("composition",n),a.append("inpage",i.toString()),a.append("page",r.toString());const s=I.SearchCompositionsUrl()+"?"+a.toString();try{const t=yield fetch(s,{method:"GET",headers:c});return t.ok?yield t.json():(R(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var lo=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 uo(t,e=""){return lo(this,void 0,void 0,(function*(){var n=x("application/json",e);const o=I.SearchLinkMultipleAll(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(console.log("This is the searching error",t.status),R(t),[])}catch(t){throw console.log("This is the searching error",t),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())}))};function fo(t,e=[]){var n,o;return ho(this,void 0,void 0,(function*(){let i=[];const r=[];let c={},a={};const s=[];let l=yield T.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield q(t));let d=[];d=e.length>0?yo(t,e):yield X(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 lt(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 yo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function po(t,e=[]){var n,o;return ho(this,void 0,void 0,(function*(){let i={},r=[];const c=[];let a;const s={},l=[];let d=yield T.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield q(t));let u=[];u=e.length>0?yo(t,e):yield X(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 lt(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 vo(t,e){return ho(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Rn(e);for(let e=0;e<t.length;e++){const i=yield po(t[e],n);i&&o.push(i)}return o}))}var go=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 Co(t){return go(this,void 0,void 0,(function*(){try{var e=A();const n=JSON.stringify(t),o=yield fetch(I.CreateSessionId(),{method:"POST",headers:e,body:n});return o.ok?o.json():(console.log("Creating session failed",yield o.json()),R(o),null)}catch(t){throw console.log("Creating session failed",t),t}}))}var mo=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,e){return mo(this,void 0,void 0,(function*(){try{var n=A("application/x-www-form-urlencoded");const o=new URLSearchParams;o.append("sessionId",t.toString()),o.append("url",e);const i=yield fetch(I.CreateSessionVisitUrl(),{method:"POST",headers:n,body:o});return i.ok?i.json():(console.log("Creating session url failed",yield i.json()),R(i),null)}catch(t){throw console.log("Creating session url failed",t),t}}))}var No=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,o=10,i=1){return No(this,void 0,void 0,(function*(){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${t}`),c.append("toTheConceptId",`${e}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=A("application/x-www-form-urlencoded");const s=yield fetch(I.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:c});return s.ok?r=yield s.json():(console.log("Get connection of concept error",s.status),R(s)),r}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 Io=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 ko(t,e,n=10,o=1,i=!1){return Io(this,void 0,void 0,(function*(){let r=[],c=yield Ee(t),a=yield sn(e);if(a.id>0){let t=[],e=[];if(i){e=yield wo(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield Q(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield Ee(n),i=yield rt(o.id);r.push(i)}}else{e=yield Se(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield Q(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield Ee(n),i=yield rt(o.id);r.push(i)}}}return r}))}function Ao(t,e,n=10,o=1,i=!1){return Io(this,void 0,void 0,(function*(){let r=[],c=yield Ee(t),a=yield sn(e),s=[],l=[];if(a.id>0){if(i){s=yield wo(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield Se(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield b(l)}return r}))}class xo{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 So=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 Ro{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 So(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(s.isDataLoaded)return t("done");setTimeout(Ro.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=new pe(0,0,0,0,0,0);var r=new xo(o,t,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(t,e,n=999){let o=this.compositeKey(e,n,t.applicationId),i=xt();var r=new xo(o,i,t,null,null);this.addNodeToTree(r)}static getNodeFromTree(t,e,n=999){return So(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 So(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}}Ro.root=null;var _o=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 Lo(t,e,n=999,o=999){return _o(this,void 0,void 0,(function*(){let i=yield Ro.getNodeFromTree(t,n,o),r=xt();if(i)for(let t=0;t<i.value.length;t++){let n=i.value[t];n.ghostId==e&&(r=n)}return r}))}function Go(t,e,n=999,o=999){return _o(this,void 0,void 0,(function*(){let i=yield Ro.getNodeFromTree(t,n,o),r=new pe(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 Uo(t,e,n=999){return _o(this,void 0,void 0,(function*(){Ro.addConceptToTree(t,e,n)}))}function Fo(t,e,n=999){return _o(this,void 0,void 0,(function*(){Ro.addConnectionToTree(t,e,n)}))}var Vo=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=""){return Vo(this,void 0,void 0,(function*(){var n=x("application/json",e);const o=I.SearchLinkMultipleAllApiUrl(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(console.log("This is the searching multiple error",t.status),R(t),[])}catch(t){throw console.log("This is the searching multiple error",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 Do(t,e=""){return Po(this,void 0,void 0,(function*(){let n=[],o=yield Bo(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 Vn(c,a),yield Eo(s,n,i,l)}))}function Eo(t,e,n,o=[]){return Po(this,void 0,void 0,(function*(){let i={},r=yield Rn(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 Ee(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 Ee(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 Oo(t){var e,n;const o=xt();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 bo(t){const e=p();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 Mo(t){const e=new pe(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 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())}))};function jo(t){return Ho(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId;t.accessId;let o=[];const i=[];let r=xt(),c=xt();const a=[],s=t.compositionId,l=t.ofTheCompositionId;let d=[],u=yield X(s);for(let t=0;t<u.length;t++)o.push(Mo(u[t]));const h=[],f=[];let y=[];for(let t=0;t<o.length;t++)jn(f,o[t].ofTheConceptId),jn(h,o[t].ofTheConceptId),jn(h,o[t].toTheConceptId),y.push(o[t].ofTheConceptId);for(let t=0;t<h.length;t++){const e=yield Ee(h[t]);s==h[t]&&(r=Oo(e)),l==h[t]&&(c=Oo(e)),i.push(Oo(e))}const p=t.patchObject;for(const t in p){let s=xt();const l=p[t];let u=r;c.id>0&&(u=c),Array.isArray(l)||"object"==typeof l?(s=yield Ie(t,"",!0,r.userId,0,999),yield Ae(p[t],s.id,s.userId,r.id,r.userId,4,999)):s=yield Ie(t,l,!1,e,0,n);const h=$n(i,s);for(let t=0;t<h.length;t++)if(h[t].id>0){const e=Qn(o,h[t].id);d=d.concat(e),a.push(h[t])}yield ve(u.id,s.id,r.id,2),i.push(s)}for(let t=0;t<d.length;t++)Pe(d[t].id);jt.SyncDataOnline()}))}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())}))},$o=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 Jo(t){var e;return $o(this,void 0,void 0,(function*(){let n=yield function(t){return Wo(this,void 0,void 0,(function*(){let e=[];try{var n=A();const o=yield fetch(I.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(o.ok){let t=yield o.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;b(i),n[r]=e}return n}return console.log("View Internal Data error",o.status),R(o),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),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[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 lt(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield Ee(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}))}var Qo=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())}))},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 Ko(t,e=""){return zo(this,void 0,void 0,(function*(){var n=yield function(t,e=""){return Qo(this,void 0,void 0,(function*(){var n=x("application/json",e);let o=I.SearchInternalWithAuthenticatedCcsUrl();o=o+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(o,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),R(t),[])}catch(t){throw console.log("This is the searching internal error",t),t}}))}(t,e);return yield Jo(n)}))}var qo=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 qo(this,void 0,void 0,(function*(){let n=!0,o=yield fn(t),i=yield Kt(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 Pe(r[t]);n=n&&e}return n}))}function Xo(t,e){return qo(this,void 0,void 0,(function*(){let n=yield fn(t),o=yield Kt(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 Zo{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class ti{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 ei{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class ni{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var oi=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())}))},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())}))};class ci{}ci.isUpdated=!1,ci.isOnlineSync=!1;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())}))};var 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())}))};const li=1,di=2,ui=3,hi=4,fi=5,yi=6,pi=7;class vi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var gi=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){return gi(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield q(t[n].connectionTypeId);t[n].connectionType=o.characterValue,e[t[n].conceptId]=t[n]}return e}))}function mi(t){const e=t.split("_");if(3===e.length){let t=new vi;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 Ti(t){return t.startsWith("the_")?t.slice(4):t}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())}))},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())}))};function Ii(t,e,n){var o,i,r,c,a,s,l,d;return wi(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 Ee(t[u].ofTheConceptId),y=yield Ee(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 Ee(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 Ee(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 ki=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 Ai(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))}}function xi(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 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())}))};var 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 _i(t,e){return Ri(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=yi;let n,o=yield function(t,e=""){return si(this,void 0,void 0,(function*(){var n=x("application/json",e);const o=I.FreeschemaQueryUrl(),i=JSON.stringify(t);try{const t=yield fetch(o,{method:"POST",headers:n,body:i});return t.ok?yield t.json():(R(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 S(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new S(t.message,!1,500,t.stack);throw n.setUrl(e),n}}(t,o)}}))}(t,""),i=(o.conceptIds,o.internalConnections,o.linkers),r=o.reverse,c=o.mainCompositionIds,a=o.countinfo,s=t.order,l=function(t=[]){let e=[];if(t.length>0)for(let n=0;n<(null==t?void 0:t.length);n++){let o=mi(t[n]);e.push(o)}return e}(a);return n=e==di?yield function(t,e,n,o,i,r="DESC"){return Si(this,void 0,void 0,(function*(){let e=yield Fn(t);yield Ci(i),e=xi(e,r);let c=[];c=yield function(t,e,n=[]){var o,i,r,c,a,s,l,d;return Ni(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 Ee(t[u].ofTheConceptId),y=yield Ee(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ee(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 Ee(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 Ni(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 Ee(t[u].ofTheConceptId),y=yield Ee(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ee(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=Ti(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 Ee(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=Ti(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 Ni(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 Ee(t[n].ofTheConceptId),f=yield Ee(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 Ee(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 Ee(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}))}(i,0,c,r,l,s):e==ui?yield function(t,e,n,o,i,r="DESC"){return Si(this,void 0,void 0,(function*(){let e=yield Fn(t),c=yield Ci(i);e=xi(e,r);let a=[];a=yield Ii(e,a,o),a=yield function(t,e,n=[]){var o,i,r,c,a,s,l,d;return ki(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 Ee(t[u].ofTheConceptId),y=yield Ee(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ee(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=Ti(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 Ee(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=Ti(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 ki(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 Ee(t[n].ofTheConceptId),p=yield Ee(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 Ee(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 Ee(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),Ai(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,Ai(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}))}(i,0,c,r,l,s):yield function(t,e,n,o,i){return Si(this,void 0,void 0,(function*(){let e=yield Fn(t);e=xi(e);let i=[];i=yield Ii(e,i,o),i=yield function(t,e,n){var o,i,r,c,a,s,l,d;return wi(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 Ee(t[u].ofTheConceptId),y=yield Ee(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 Ee(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=Ti(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 Ee(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=Ti(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 wi(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 Ee(t[n].ofTheConceptId),h=yield Ee(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 Ee(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 Ee(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}))}(i,0,c,r),n}))}class Li{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=li,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var Gi=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,n=!1){return Gi(this,void 0,void 0,(function*(){let o=[];if(n){let n=yield pn(t),i=yield un(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield fn(t);for(let t=0;t<n.length;t++)E.AddConnection(n[t]);let i=yield un(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function Fi(t,e,n,o=!1){return Gi(this,void 0,void 0,(function*(){let i=[],r=[];if(i=o?yield Ui(e,n,o):yield Ui(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 Vi=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 Bi{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.transactionId=Math.random().toString().substring(5)}initialize(){return Vi(this,void 0,void 0,(function*(){yield jt.initializeTransaction(this.transactionId)}))}markAction(){return Vi(this,void 0,void 0,(function*(){yield jt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Vi(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},yield jt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Vi(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield jt.SyncDataOnline(this.transactionId),this.actions={concepts:[],connections:[]},this.success=!1}))}MakeTheInstanceConcept(t,e,n=!1,o,i,r=999,c=0){return Vi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const a=yield he(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 Vi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Le(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 Vi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield nn(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 Vi(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield _e(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 Pi(t=""){k.BearerAccessToken=t}function Di(t="",e="",o=""){I.BASE_URL=t,I.AI_URL=e,console.log("This ist he base url",I.BASE_URL),k.BearerAccessToken=o,function(){return ai(this,void 0,void 0,(function*(){return yield new n(!0),yield function(){return ri(this,void 0,void 0,(function*(){try{(new Date).getTime();var t=x("application/x-www-form-urlencoded");const n=yield fetch(I.GetAllAiData(),{method:"GET",headers:t});n.ok||(console.log("Ai Error Message: ","Cannot get response"),R(n));const o=yield n.json();for(var e=0;e<o.length;e++)T.AddConcept(o[e])}catch(t){throw t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),t}}))}(),!0}))}().then((()=>{const t=(new Date).getTime();(function(){return N(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield c();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];T.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{s.isDataLoaded=!0,s.isCharacterLoaded=!0,s.isTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare concept data is ",e)})),function(){return ii(this,void 0,void 0,(function*(){var t=yield a();if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];Rt.AddConceptToMemory(n)}}))}().then((()=>{s.isLocalDataLoaded=!0,s.isLocalTypeLoaded=!0,s.isLocalCharacterLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare local concept ",e)})),function(){return oi(this,void 0,void 0,(function*(){!function(){oi(this,void 0,void 0,(function*(){var t=yield a();if(Array.isArray(t))for(var e=0;e<t.length;e++)Lt.AddConnection(t[e])}))}()}))}().then((()=>{s.isLocalConnectionLoaded=!0})),function(){return oi(this,void 0,void 0,(function*(){!function(){oi(this,void 0,void 0,(function*(){var t=yield c();if(Array.isArray(t))for(var e=0;e<t.length;e++)E.AddConnectionToMemory(t[e])}))}()}))}().then((()=>{s.isConnectionLoaded=!0,s.isConnectionTypeLoaded=!0;let e=(new Date).getTime()-t;console.log("The time taken to prepare connections ",e)}))}))}var Ei=exports;for(var Oi in e)Ei[Oi]=e[Oi];e.__esModule&&Object.defineProperty(Ei,"__esModule",{value:!0})})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DeleteTheConnectionBulkApi(ids: number[]): Promise<boolean>;
|
|
@@ -46,5 +46,7 @@ export declare class BaseUrl {
|
|
|
46
46
|
static CreateTheConnectionNewUrl(): string;
|
|
47
47
|
static MakeTheTypeConceptUrl(): string;
|
|
48
48
|
static DeleteTheConnectionUrl(): string;
|
|
49
|
+
static DeleteTheConnectionBulkUrl(): string;
|
|
49
50
|
static FreeschemaQueryUrl(): string;
|
|
51
|
+
static GetConceptConnectionByType(): string;
|
|
50
52
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param id the id of the concept whose connection needs to be returned
|
|
4
|
+
* @param linkers the connection types whose connection id need to be found
|
|
5
|
+
*/
|
|
6
|
+
export declare function DeleteConnectionByTypeBulk(id: number, linkers: string[]): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param id the id of the concept whose connection needs to be returned
|
|
10
|
+
* @param linkers the connection types whose connection id need to be found
|
|
11
|
+
* @returns list of ids of the connection
|
|
12
|
+
*/
|
|
13
|
+
export declare function GetConnectionByTypeBulk(id: number, linkers: string[]): Promise<number[]>;
|
package/dist/types/app.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export { GetConceptByCharacterAndType } from './Api/GetConceptByCharacterAndType
|
|
|
58
58
|
export { GetConceptByCharacterAndCategoryDirectApi } from './Api/SearchConcept/GetConceptByCharacterAndCategoryDirect';
|
|
59
59
|
export { SearchLinkMultipleApi } from './Api/Search/SearchLinkMultipleApi';
|
|
60
60
|
export { GetCompositionWithIdFromMemoryFromConnections, GetCompositionWithIdFromMemory } from './Services/GetComposition';
|
|
61
|
+
export { GetConceptByTypeBulk } from './Api/GetConceptByCharacterAndType';
|
|
62
|
+
export { DeleteConnectionByTypeBulk, GetConnectionByTypeBulk } from './Services/Delete/DeleteConnectionByType';
|
|
61
63
|
export { SyncData } from './DataStructures/SyncData';
|
|
62
64
|
export { Concept } from './DataStructures/Concept';
|
|
63
65
|
export { LConcept } from './DataStructures/Local/LConcept';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PermissionSet } from './PermissionSet';
|
|
2
|
-
export declare class AccessControlCacheService {
|
|
3
|
-
private readonly userAccessCache;
|
|
4
|
-
private readonly publicAccessCache;
|
|
5
|
-
private readonly baseUrl;
|
|
6
|
-
constructor();
|
|
7
|
-
loadCacheFromApi(entityId?: number): Promise<void>;
|
|
8
|
-
loadCacheFromJson(jsonData: any): void;
|
|
9
|
-
hasAccess(entityId: number, conceptId: number, required: PermissionSet): Promise<boolean>;
|
|
10
|
-
getAccessibleConcepts(entityId: number, conceptIds: number[], required: PermissionSet): Promise<number[]>;
|
|
11
|
-
getAccessByUser(entityId: number): Promise<Map<number, PermissionSet>>;
|
|
12
|
-
getAccessByConcept(conceptId: number): Promise<Map<number, PermissionSet>>;
|
|
13
|
-
deleteRecordByUserId(entityId: number): void;
|
|
14
|
-
deletePublicAccessRecordById(conceptId: number): void;
|
|
15
|
-
clearCache(): void;
|
|
16
|
-
getConceptsByPublicAccess(): Promise<Record<number, string[]>>;
|
|
17
|
-
hasPublicAccess(conceptId: number, required: PermissionSet): Promise<boolean>;
|
|
18
|
-
getConceptsWithPublicAccess(conceptIds: number[], required: PermissionSet): Promise<number[]>;
|
|
19
|
-
}
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { PermissionSet } from "./PermissionSet";
|
|
2
|
-
export declare class AccessControlService {
|
|
3
|
-
private static accessCache;
|
|
4
|
-
private static baseUrl;
|
|
5
|
-
private static initialize;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if a user or entity has the specified access for a single concept.
|
|
8
|
-
* @param userId - The user's ID.
|
|
9
|
-
* @param access - The required PermissionSet.
|
|
10
|
-
* @param conceptId - The concept ID to check.
|
|
11
|
-
* @param entityId - Optional entity ID (defaults to userId).
|
|
12
|
-
* @returns Promise<boolean> - True if access is granted, false otherwise.
|
|
13
|
-
*/
|
|
14
|
-
static checkAccessOfConcept(userId: number, access: PermissionSet, conceptId: number, entityId?: number): Promise<boolean>;
|
|
15
|
-
/**
|
|
16
|
-
* Checks if a user or entity has the specified access for all concepts in a list.
|
|
17
|
-
* @param userId - The user's ID.
|
|
18
|
-
* @param access - The required PermissionSet.
|
|
19
|
-
* @param conceptIdList - Array of concept IDs to check.
|
|
20
|
-
* @param entityId - Optional entity ID (defaults to userId).
|
|
21
|
-
* @returns Promise<boolean> - True if access is granted for all, false otherwise.
|
|
22
|
-
*/
|
|
23
|
-
static checkAccessOfConceptList(userId: number, access: PermissionSet, conceptIdList: number[], entityId?: number): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Filters a list of concept IDs, returning only those for which the user or entity has the specified access.
|
|
26
|
-
* @param userId - The user's ID.
|
|
27
|
-
* @param access - The required PermissionSet.
|
|
28
|
-
* @param conceptIdList - Array of concept IDs to filter.
|
|
29
|
-
* @param entityId - Optional entity ID (defaults to userId).
|
|
30
|
-
* @returns Promise<number[]> - Array of concept IDs with access.
|
|
31
|
-
*/
|
|
32
|
-
static filterConceptListByAccess(userId: number, access: PermissionSet, conceptIdList: number[], entityId?: number): Promise<number[]>;
|
|
33
|
-
/**
|
|
34
|
-
* Gets the entity ID for a given user ID.
|
|
35
|
-
* @param userId - The user's ID.
|
|
36
|
-
* @returns number - The entity ID (default: userId).
|
|
37
|
-
*/
|
|
38
|
-
private static getEntityIdConceptByUserId;
|
|
39
|
-
/**
|
|
40
|
-
* Assigns access to a specific entity for a concept.
|
|
41
|
-
* @param request - Object containing conceptId, access, entityId, makePublic.
|
|
42
|
-
* @returns Promise<any> - API response.
|
|
43
|
-
*/
|
|
44
|
-
static assignAccessToEntity(request: {
|
|
45
|
-
conceptId: number;
|
|
46
|
-
access: string;
|
|
47
|
-
entityId: number;
|
|
48
|
-
makePublic: boolean;
|
|
49
|
-
}): Promise<any>;
|
|
50
|
-
/**
|
|
51
|
-
* Assigns public access to a concept or list of concepts.
|
|
52
|
-
* @param request - Object containing conceptId, accessList, connectionTypeList, nestedAccessLevel, conceptIdList.
|
|
53
|
-
* @returns Promise<any> - API response.
|
|
54
|
-
*/
|
|
55
|
-
static assignPublicAccess(request: {
|
|
56
|
-
conceptId: number;
|
|
57
|
-
accessList: string[];
|
|
58
|
-
connectionTypeList?: string[];
|
|
59
|
-
nestedAccessLevel?: number;
|
|
60
|
-
conceptIdList?: number[];
|
|
61
|
-
}): Promise<any>;
|
|
62
|
-
/**
|
|
63
|
-
* Assigns public access to multiple concepts in bulk.
|
|
64
|
-
* @param request - Object containing conceptIdList, accessList, connectionTypeList, nestedAccessLevel, conceptId.
|
|
65
|
-
* @returns Promise<any> - API response.
|
|
66
|
-
*/
|
|
67
|
-
static assignPublicAccessBlukConcept(request: {
|
|
68
|
-
conceptIdList: number[];
|
|
69
|
-
accessList: string[];
|
|
70
|
-
connectionTypeList?: string[];
|
|
71
|
-
nestedAccessLevel?: number;
|
|
72
|
-
conceptId?: number;
|
|
73
|
-
}): Promise<any>;
|
|
74
|
-
/**
|
|
75
|
-
* Assigns access to multiple entities and concepts in bulk.
|
|
76
|
-
* @param request - Object containing conceptId, conceptIdList, entityIdList, accessList, connectionTypeList, nestedAccessLevel.
|
|
77
|
-
* @returns Promise<any> - API response.
|
|
78
|
-
*/
|
|
79
|
-
static assignAccessToEntityBulk(request: {
|
|
80
|
-
conceptId: number;
|
|
81
|
-
conceptIdList?: number[];
|
|
82
|
-
entityIdList: number[];
|
|
83
|
-
accessList: string[];
|
|
84
|
-
connectionTypeList?: string[];
|
|
85
|
-
nestedAccessLevel?: number;
|
|
86
|
-
}): Promise<any>;
|
|
87
|
-
/**
|
|
88
|
-
* Assigns access to a user for a concept.
|
|
89
|
-
* @param request - Object containing conceptId, access, userId, makePublic.
|
|
90
|
-
* @returns Promise<any> - API response.
|
|
91
|
-
*/
|
|
92
|
-
static assignAccessByUser(request: {
|
|
93
|
-
conceptId: number;
|
|
94
|
-
access: string;
|
|
95
|
-
userId: number;
|
|
96
|
-
makePublic: boolean;
|
|
97
|
-
}): Promise<any>;
|
|
98
|
-
/**
|
|
99
|
-
* Revokes access for an entity from a concept.
|
|
100
|
-
* @param params - Object containing conceptId, access, entityId.
|
|
101
|
-
* @returns Promise<any> - API response.
|
|
102
|
-
*/
|
|
103
|
-
static revokeAccess(params: {
|
|
104
|
-
conceptId: number;
|
|
105
|
-
access: string;
|
|
106
|
-
entityId: number;
|
|
107
|
-
}): Promise<any>;
|
|
108
|
-
/**
|
|
109
|
-
* Revokes access for multiple entities in bulk.
|
|
110
|
-
* @param request - Object containing conceptId, entityIdList, accessList.
|
|
111
|
-
* @returns Promise<any> - API response.
|
|
112
|
-
*/
|
|
113
|
-
static revokeAccessBulk(request: {
|
|
114
|
-
conceptId: number;
|
|
115
|
-
entityIdList: number[];
|
|
116
|
-
accessList: string[];
|
|
117
|
-
}): Promise<any>;
|
|
118
|
-
/**
|
|
119
|
-
* Gets the access list for a concept and user.
|
|
120
|
-
* @param conceptId - The concept ID.
|
|
121
|
-
* @param userId - The user ID.
|
|
122
|
-
* @returns Promise<any> - API response.
|
|
123
|
-
*/
|
|
124
|
-
static getAccessList(conceptId: number, userId: number): Promise<any>;
|
|
125
|
-
/**
|
|
126
|
-
* Gets the public access list for a list of concept IDs.
|
|
127
|
-
* @param conceptIdList - Array of concept IDs.
|
|
128
|
-
* @returns Promise<any> - API response.
|
|
129
|
-
*/
|
|
130
|
-
static getPublicAccessList(conceptIdList: number[]): Promise<any>;
|
|
131
|
-
/**
|
|
132
|
-
* Revokes public access for a concept.
|
|
133
|
-
* @param request - Object containing conceptId, accessList.
|
|
134
|
-
* @returns Promise<any> - API response.
|
|
135
|
-
*/
|
|
136
|
-
static revokePublicAccess(request: {
|
|
137
|
-
conceptId: number;
|
|
138
|
-
accessList: string[];
|
|
139
|
-
}): Promise<any>;
|
|
140
|
-
/**
|
|
141
|
-
* Checks if an entity has a specific permission for a concept.
|
|
142
|
-
* @param params - Object containing conceptId, permission, entityId.
|
|
143
|
-
* @returns Promise<any> - API response.
|
|
144
|
-
*/
|
|
145
|
-
static checkAccess(params: {
|
|
146
|
-
conceptId: number;
|
|
147
|
-
permission: string;
|
|
148
|
-
entityId: number;
|
|
149
|
-
}): Promise<any>;
|
|
150
|
-
/**
|
|
151
|
-
* Checks if a user has a specific access for a concept.
|
|
152
|
-
* @param request - Object containing conceptId, access, userId.
|
|
153
|
-
* @returns Promise<any> - API response.
|
|
154
|
-
*/
|
|
155
|
-
static checkAccessByUser(request: {
|
|
156
|
-
conceptId: number;
|
|
157
|
-
access: string;
|
|
158
|
-
userId: number;
|
|
159
|
-
}): Promise<any>;
|
|
160
|
-
/**
|
|
161
|
-
* Filters concepts by access for a user.
|
|
162
|
-
* @param request - Object containing userId, access, conceptIdList, connectionIdList.
|
|
163
|
-
* @returns Promise<any> - API response.
|
|
164
|
-
*/
|
|
165
|
-
static filterConceptsByAccess(request: {
|
|
166
|
-
userId: number;
|
|
167
|
-
access: string;
|
|
168
|
-
conceptIdList?: number[];
|
|
169
|
-
connectionIdList?: number[];
|
|
170
|
-
}): Promise<any>;
|
|
171
|
-
/**
|
|
172
|
-
* Checks access for a user on multiple concepts in bulk.
|
|
173
|
-
* @param request - Object containing userId, access, conceptIdList.
|
|
174
|
-
* @returns Promise<any> - API response.
|
|
175
|
-
*/
|
|
176
|
-
static checkAccessOfConceptBulk(request: {
|
|
177
|
-
userId: number;
|
|
178
|
-
access: string;
|
|
179
|
-
conceptIdList: number[];
|
|
180
|
-
}): Promise<any>;
|
|
181
|
-
/**
|
|
182
|
-
* Gets entities with a specific access for a concept.
|
|
183
|
-
* @param conceptId - The concept ID.
|
|
184
|
-
* @param access - The access type.
|
|
185
|
-
* @returns Promise<any> - API response.
|
|
186
|
-
*/
|
|
187
|
-
static getEntitiesByAccess(conceptId: number, access: string): Promise<any>;
|
|
188
|
-
/**
|
|
189
|
-
* Gets all entities with any access for a concept.
|
|
190
|
-
* @param conceptId - The concept ID.
|
|
191
|
-
* @returns Promise<any> - API response.
|
|
192
|
-
*/
|
|
193
|
-
static getEntitiesWithAccess(conceptId: number): Promise<any>;
|
|
194
|
-
/**
|
|
195
|
-
* Gets access groups by entity.
|
|
196
|
-
* @param entityId - Optional entity ID.
|
|
197
|
-
* @returns Promise<any> - API response.
|
|
198
|
-
*/
|
|
199
|
-
static getAccessGroupByEntity(entityId?: number): Promise<any>;
|
|
200
|
-
/**
|
|
201
|
-
* Gets access groups by user.
|
|
202
|
-
* @param userId - Optional user ID.
|
|
203
|
-
* @returns Promise<any> - API response.
|
|
204
|
-
*/
|
|
205
|
-
static getAccessGroupByUser(userId?: number): Promise<any>;
|
|
206
|
-
/**
|
|
207
|
-
* Gets public access by access IDs.
|
|
208
|
-
* @param accessIdList - Array of access IDs.
|
|
209
|
-
* @returns Promise<any> - API response.
|
|
210
|
-
*/
|
|
211
|
-
static getPublicAccessByAccessIds(accessIdList: number[]): Promise<any>;
|
|
212
|
-
/**
|
|
213
|
-
* Gets the full access mapping for public users.
|
|
214
|
-
* @returns Promise<any> - API response.
|
|
215
|
-
*/
|
|
216
|
-
static getFullAccessMappingForPublic(): Promise<any>;
|
|
217
|
-
/**
|
|
218
|
-
* Assigns public access for all users.
|
|
219
|
-
* @returns Promise<any> - API response.
|
|
220
|
-
*/
|
|
221
|
-
static assignPublicAccessForAllUser(): Promise<any>;
|
|
222
|
-
/**
|
|
223
|
-
* Assigns access by connection type for users.
|
|
224
|
-
* @returns Promise<any> - API response.
|
|
225
|
-
*/
|
|
226
|
-
static assignAccessByConncetionTypeOfUser(): Promise<any>;
|
|
227
|
-
/**
|
|
228
|
-
* Sets access inheritance for a concept.
|
|
229
|
-
* @param request - Object containing mainConceptId, enable, connectionTypeId.
|
|
230
|
-
* @returns Promise<any> - API response.
|
|
231
|
-
*/
|
|
232
|
-
static setAccessInheritance(request: {
|
|
233
|
-
mainConceptId: number;
|
|
234
|
-
enable: boolean;
|
|
235
|
-
connectionTypeId?: number;
|
|
236
|
-
}): Promise<any>;
|
|
237
|
-
/**
|
|
238
|
-
* Gets the status of access inheritance for a concept.
|
|
239
|
-
* @param mainConceptId - The main concept ID.
|
|
240
|
-
* @param connectionTypeId - The connection type ID (default: 999).
|
|
241
|
-
* @returns Promise<any> - API response.
|
|
242
|
-
*/
|
|
243
|
-
static getAccessInheritanceStatus(mainConceptId: number, connectionTypeId?: number): Promise<any>;
|
|
244
|
-
/**
|
|
245
|
-
* Performs a GET request to the backend API.
|
|
246
|
-
* @param path - The API path.
|
|
247
|
-
* @param errorMsg - Error message to throw if request fails.
|
|
248
|
-
* @returns Promise<any> - API response.
|
|
249
|
-
*/
|
|
250
|
-
private static _get;
|
|
251
|
-
/**
|
|
252
|
-
* Performs a POST request to the backend API.
|
|
253
|
-
* @param path - The API path.
|
|
254
|
-
* @param body - Request body.
|
|
255
|
-
* @param errorMsg - Error message to throw if request fails.
|
|
256
|
-
* @returns Promise<any> - API response.
|
|
257
|
-
*/
|
|
258
|
-
private static _post;
|
|
259
|
-
/**
|
|
260
|
-
* Performs a DELETE request to the backend API.
|
|
261
|
-
* @param path - The API path.
|
|
262
|
-
* @param body - Optional request body.
|
|
263
|
-
* @param errorMsg - Error message to throw if request fails.
|
|
264
|
-
* @returns Promise<any> - API response.
|
|
265
|
-
*/
|
|
266
|
-
private static _delete;
|
|
267
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getServerJwtToken: () => string;
|