mftsccs-node 0.0.43 → 0.0.44
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/DataStructures/Concept.d.ts +3 -3
- package/dist/types/DataStructures/Connection.d.ts +1 -1
- package/dist/types/DataStructures/Local/LConcept.d.ts +3 -3
- package/dist/types/DataStructures/Local/LConnection.d.ts +1 -1
- package/dist/types/Services/CreateDefaultConcept.d.ts +1 -0
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALLID:()=>ri,AddGhostConcept:()=>Ro,AddGhostConnection:()=>So,BaseUrl:()=>w,BinaryTree:()=>f,Composition:()=>zn,CompositionBinaryTree:()=>Jn,CompositionNode:()=>Wn,Concept:()=>y,ConceptsData:()=>m,Connection:()=>L,ConnectionData:()=>D,CreateComposition:()=>lt,CreateConnection:()=>kt,CreateConnectionBetweenTwoConcepts:()=>Vt,CreateConnectionBetweenTwoConceptsGeneral:()=>Bt,CreateDefaultConcept:()=>p,CreateDefaultLConcept:()=>Ie,CreateSession:()=>fo,CreateSessionVisit:()=>po,CreateTheCompositionLocal:()=>mt,CreateTheCompositionWithCache:()=>Yn,CreateTheConnection:()=>Oe,CreateTheConnectionGeneral:()=>It,CreateTheConnectionLocal:()=>dt,DATAID:()=>ti,DATAIDDATE:()=>oi,DeleteConceptById:()=>pn,DeleteConnectionById:()=>Lt,FilterSearch:()=>Jo,FormatFromConnections:()=>Uo,FreeSchemaResponse:()=>x,FreeschemaQuery:()=>Ti,GetAllConnectionsOfComposition:()=>X,GetAllConnectionsOfCompositionBulk:()=>J,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Ii,GetComposition:()=>ee,GetCompositionBulk:()=>kn,GetCompositionBulkWithDataId:()=>An,GetCompositionFromConnectionsWithDataId:()=>xn,GetCompositionFromConnectionsWithDataIdInObject:()=>Sn,GetCompositionList:()=>fe,GetCompositionListLocal:()=>Pe,GetCompositionListLocalWithId:()=>Be,GetCompositionListWithId:()=>ye,GetCompositionLocal:()=>_e,GetCompositionLocalWithId:()=>Le,GetCompositionWithAllIds:()=>te,GetCompositionWithCache:()=>co,GetCompositionWithDataIdBulk:()=>so,GetCompositionWithDataIdWithCache:()=>lo,GetCompositionWithId:()=>re,GetConceptBulk:()=>O,GetConceptByCharacter:()=>ue,GetConceptByCharacterAndCategoryDirectApi:()=>Zt,GetConceptByCharacterAndType:()=>je,GetConnectionBulk:()=>wn,GetConnectionById:()=>St,GetConnectionOfTheConcept:()=>Tt,GetLink:()=>Et,GetLinkRaw:()=>Ot,GetLinkerConnectionFromConcepts:()=>un,GetLinkerConnectionToConcepts:()=>hn,GetRelation:()=>mo,GetRelationRaw:()=>No,GetTheConcept:()=>Ut,GetUserGhostConnectionId:()=>xo,GetUserGhostId:()=>Ao,GiveConnection:()=>ki,HandleHttpError:()=>R,JUSTDATA:()=>ni,LConcept:()=>we,LConnection:()=>st,LISTNORMAL:()=>ci,LoginToBackend:()=>Un,MakeTheInstanceConcept:()=>ct,MakeTheInstanceConceptLocal:()=>gt,MakeTheTimestamp:()=>mn,MakeTheTypeConcept:()=>zt,MakeTheTypeConceptApi:()=>rn,NORMAL:()=>ei,PatcherStructure:()=>Wo,RAW:()=>ii,RecursiveSearchApi:()=>Ln,SchemaQueryListener:()=>Ni,SearchAllConcepts:()=>no,SearchLinkInternal:()=>jo,SearchLinkMultipleAll:()=>Go,SearchQuery:()=>Nn,SearchStructure:()=>Qo,SearchWithLinker:()=>io,SessionData:()=>$o,Signin:()=>Bn,Signup:()=>Vn,SplitStrings:()=>T,SyncData:()=>Ee,TrashTheConcept:()=>gn,UpdateComposition:()=>eo,UpdateCompositionLocal:()=>Do,UserBinaryTree:()=>Io,ViewInternalData:()=>bo,convertFromLConceptToConcept:()=>Vo,getFromDatabaseWithType:()=>r,getFromDatabaseWithTypeOld:()=>c,init:()=>xi,recursiveFetch:()=>ce,recursiveFetchNew:()=>Kn,storeToDatabase:()=>i,updateAccessToken:()=>Ai});class n{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function i(e,t){}function r(e,t,n){return o(this,void 0,void 0,(function*(){}))}function c(e){return o(this,void 0,void 0,(function*(){}))}function a(e){return o(this,void 0,void 0,(function*(){}))}class l{}l.isTypeLoaded=!1,l.isCharacterLoaded=!1,l.isDataLoaded=!1,l.isLocalDataLoaded=!1,l.isLocalCharacterLoaded=!1,l.isLocalTypeLoaded=!1,l.isConnectionLoaded=!1,l.isConnectionTypeLoaded=!1,l.isLocalConnectionLoaded=!1;class s{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var d=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class u{static waitForDataToLoad(){return d(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isCharacterLoaded)return e("done");setTimeout(u.checkFlag,1e3,e)}static addNodeToTree(e){return d(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return d(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new s(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}u.characterRoot=null;var h=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class f{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return h(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isDataLoaded)return e("done");setTimeout(f.checkFlag,1e3,e)}static addConceptToTree(e){var t=new s(e.id,e,null,null),n=new s(e.characterValue,e,null,null);u.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return h(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return h(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}f.root=null;class y{constructor(e,t,n,o,i,r,c,a,l,s,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=o,this.ghostId=e,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=a,this.characterValue=`${l}`,this.securityId=s,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 e=new Date,t=new Date;return new y(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}var v=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class g{static addNodeToTree(e){return v(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new s(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return v(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isTypeLoaded)return e("done");setTimeout(g.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return v(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)if(o.variants[e].value.userId==t){var i=!1;for(let t=0;t<n.length;t++)n[t].id==o.variants[e].value.id&&(i=!0);i||n.push(o.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return v(this,void 0,void 0,(function*(){let n=p();var o=this.getNodeFromTree(t);if(o){o.value.characterValue==e&&(n=o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.characterValue==e&&(n=o.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}g.typeRoot=null;var C=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class m{constructor(){this.name="conceptsArray"}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){this.NPC.includes(e)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(e))}static GetNpc(e){return!!this.NPC.includes(e)}static AddConceptToStorage(e){e.id}static AddConcept(e){e.id>0&&(f.addConceptToTree(e),g.addConceptToTree(e),u.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(f.addConceptToTree(e),g.addConceptToTree(e),u.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);f.removeNodeFromTree(e.id),e.id}static GetConcept(e){return C(this,void 0,void 0,(function*(){var t=p(),n=yield f.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return C(this,void 0,void 0,(function*(){var t=p(),n=u.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return C(this,void 0,void 0,(function*(){var t=p(),n=u.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return C(this,void 0,void 0,(function*(){return p(),yield g.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return C(this,void 0,void 0,(function*(){var n=p(),o=yield u.getCharacterAndCategoryFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return C(this,void 0,void 0,(function*(){let n=[];return n=yield g.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return u.characterRoot}getName(){return this.name}}m.conceptsArray=[],m.NPC=[],m.conceptDictionary=[];var N=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function T(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}class w{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"}}w.BASE_URL="https://localhost:7053/",w.AI_URL="https://ai.freeschema.com",w.MQTT_URL="192.168.1.249",w.NODE_URL="http://localhost:5001/";class I{}function k(e="application/json",t="application/json"){return{"Content-Type":e,Authorization:"Bearer "+I.BearerAccessToken,Accept:t}}function A(e="application/json",t="",n="application/json"){return""==t&&(t=I.BearerAccessToken),{"Content-Type":e,Authorization:"Bearer "+t,Accept:n}}I.BearerAccessToken="";class x{constructor(e,t,n,o){this.url=w.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=o}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function R(e){if(401==e.status){let t=new x(e.statusText,!1,e.status,"");throw t.setUrl(e.url),t}}var S=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function _(e,t){return S(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.toString());var o=k("application/x-www-form-urlencoded");const r=yield fetch(w.GetAllConceptsByTypeUrl(),{method:"POST",headers:o,body:n});if(r.ok){const e=yield r.json();for(var i=0;i<e.length;i++)m.AddConcept(e[i])}console.log("GetAllConceptsByType error",r.status),R(r)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class L{constructor(e=0,t,n,o,i,r,c,a,l,s,d,u,h,f,y,v){this.isTemp=!1,this.toUpdate=!1,this.type=p(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=e,this.typeUserId=a,this.orderId=l,this.orderUserId=s,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=v,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date}}class G{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var U=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class F{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new G(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isConnectionLoaded)return e("done");setTimeout(F.checkFlag,1e3,e)}static removeNodeFromTree(e){return U(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return U(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}F.connectionroot=null;var V=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class P{static addNodeToTree(e){return V(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return V(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isConnectionTypeLoaded)return e("done");setTimeout(P.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new G(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return V(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return V(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}P.connectionTypeRoot=null;var B=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class D{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){}static AddConnection(e){e.isTemp||(F.addConnectionToTree(e),P.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(F.addConnectionToTree(e),P.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(e.id,F.removeNodeFromTree(e.id),P.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return F.connectionroot}static GetConnectionTypeTree(){return P.connectionTypeRoot}static GetConnection(e){return B(this,void 0,void 0,(function*(){var t=new L(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield F.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return B(this,void 0,void 0,(function*(){var t=[],n=yield P.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;if(o){let e=o;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}D.connectionArray=[],D.connectionDictionary=[];var E=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function O(e){return E(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield m.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=k();const e=yield fetch(w.GetConceptBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){let n=yield e.json();if(n.length>0)for(let e=0;e<n.length;e++){let o=n[e];t.push(o),m.AddConcept(o)}}else console.log("Get Concept Bulk error",e.status),R(e);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var b=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function H(){return b(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield O(t)}}))}var M=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function j(){return M(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield D.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function W(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||D.RemoveConnection(t[n]))}var $=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function J(){return $(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield j(e),o=yield function(){return $(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=k();const i=yield fetch(w.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++)D.AddConnection(e[o]),t.push(e[o])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),R(i);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return W(t=o,n),yield H(t),t}))}var Q=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};const K=new Map;function q(e){return Q(this,void 0,void 0,(function*(){let t=p();if(K.has(e))return K.get(e)||t;const n=(()=>Q(this,void 0,void 0,(function*(){try{var n=yield m.GetConcept(e);let i=m.GetNpc(e);if(0!=n.id||i)return n;{var o=k("application/x-www-form-urlencoded");const n=yield fetch(w.GetConceptUrl(),{method:"POST",headers:o,body:`id=${e}`});return n.ok?(t=yield n.json(),t.id>0?m.AddConcept(t):m.AddNpc(e)):(console.log("Get the concept error",n.status),R(n)),t}}catch(e){throw e instanceof Error?console.log("Get the concept error message: ",e.message):console.log("Get the concept unexpected error: ",e),e}finally{K.delete(e)}})))();return K.set(e,n),n}))}var z=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function X(e){return z(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield D.GetConnectionsOfCompositionLocal(e)).length)t=yield Y(e);else{var n=yield Y(e);W(n,t),t=n}return t}))}function Y(e){return z(this,void 0,void 0,(function*(){var t=[];try{var n=k("application/x-www-form-urlencoded");const i=yield fetch(w.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});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++)D.AddConnection(r[o]),t.push(r[o]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var Z=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function ee(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ce(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l,i}))}function te(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ae(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l,i}))}function ne(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield D.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ce(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l,i}))}function oe(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield D.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ce(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l;var s={};return s.created_at=a.entryTimeStamp,s.data=i,s.id=e,s}))}function ie(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield D.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ce(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l;var s={};return s.data=i,s.id=e,s.created_at=a.entryTimeStamp,s}))}function re(e){return Z(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield m.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield q(e));var l=yield ce(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=l;var s={};return s.data=i,s.id=e,s}))}function ce(e,t,n){return Z(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},l=[];if(0==e)return null;var s=yield m.GetConcept(e);if(null!=s&&0!=s.id||null==e||null==e||(s=yield q(e)),0!=s.id&&null==s.type){var d=s.typeId,u=yield m.GetConcept(d);s.type=u,null==u&&null!=d&&null!=d&&(u=yield q(d),s.type=u)}if(null===(i=null==s?void 0:s.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==s?void 0:s.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield m.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield q(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield m.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield 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 e=yield ce(f,t,n,o);a[p]=e}}else{const e=yield ce(f,t,n,o);l[p]=e,a=l}}return a}))}function ae(e,t,n){return Z(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},l=[];if(0==e)return null;var s=yield m.GetConcept(e);if(null!=s&&0!=s.id||null==e||null==e||(s=yield q(e)),0!=s.id&&null==s.type){var d=s.typeId,u=yield m.GetConcept(d);s.type=u,null==u&&null!=d&&null!=d&&(u=yield q(d),s.type=u)}if(null===(i=null==s?void 0:s.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==s?void 0:s.characterValue;if(o.includes(e))return"";o.push(e),a.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield m.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 m.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 e=yield ae(f,t,n);a[p]=e}}else{const e=yield ae(f,t,n);l[p]=e,a=l}}return a}))}var le=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function se(e){return le(this,void 0,void 0,(function*(){let t=p();try{var n=k("application/x-www-form-urlencoded");const o=yield fetch(w.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return o.ok?(t=yield o.json(),t.id>0&&(console.log("This is adding the new concept",t),m.AddConcept(t))):(console.log("Error in Getting concept by character value Error",o.status),R(o)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var de=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function ue(e){return de(this,void 0,void 0,(function*(){var t=yield m.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield se(e),t=yield m.GetConceptByCharacter(e)),t}))}var he=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function fe(e,t){return he(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield ue(e),r=[];if(i){yield _(e,t);for(var c=yield m.GetConceptsByTypeIdAndUser(i.id,t),a=n*(o-1),l=[],s=a;s<a+n;s++)c[s]&&l.push(c[s].id);for(yield J(l),s=a;s<a+n;s++)if(c[s]){var d=yield ne(c[s].id);r.push(d)}}return r}))}function ye(e,t){return he(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield ue(e),r=[];if(i){yield _(e,t);for(var c=yield m.GetConceptsByTypeIdAndUser(i.id,t),a=n*(o-1),l=[],s=a;s<a+n;s++)c[s]&&l.push(c[s].id);for(yield J(l),s=a;s<a+n;s++)if(c[s]){var d=yield oe(c[s].id);r.push(d)}}return r}))}class pe{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ve=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class ge{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new pe(e.id,e,null,null);new pe(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return ve(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isLocalDataLoaded)return e("done");setTimeout(ge.checkFlag,1e3,e)}static getNodeFromTree(e){return ve(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return ve(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}ge.root=null;var Ce=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class me{static waitForDataToLoad(){return Ce(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isLocalCharacterLoaded)return e("done");setTimeout(me.checkFlag,1e3,e)}static addNodeToTree(e){return Ce(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new pe(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return Ce(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}me.LocalCharacterRoot=null;var Ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Te{static addNodeToTree(e){return Ne(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new pe(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return Ne(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isLocalTypeLoaded)return e("done");setTimeout(Te.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Ne(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}Te.LocalTypeRoot=null;class we{constructor(e,t,n,o,i,r,c,a=!1,l,s,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=a,this.typeCharacter=c,this.entryTimeStamp=l,this.updatedTimeStamp=s,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function Ie(){let e=new Date,t=new Date;return new we(0,0,0,0,0,"0","0",!1,e,t,0)}var ke=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Ae{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(ge.addConceptToTree(e),me.addConceptToTree(e),Te.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(ge.addConceptToTree(e),me.addConceptToTree(e),Te.addConceptToTree(e))}static GetConcept(e){return ke(this,void 0,void 0,(function*(){var t=Ie(),n=yield ge.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return ke(this,void 0,void 0,(function*(){var t=Ie(),n=me.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return ke(this,void 0,void 0,(function*(){var n=Ie(),o=yield me.getCharacterAndTypeFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return ke(this,void 0,void 0,(function*(){let n=[];return n=yield Te.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Ae.localconceptsArray=[];var xe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Re{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),0!=e.id||e.isTemp,this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return xe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isLocalConnectionLoaded)return e("done");setTimeout(Re.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return xe(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}Re.connectionArray=[],Re.connectionDictionary=[];var Se=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function _e(e){return Se(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Re.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Ae.GetConcept(e),l=yield Ge(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=l,i}))}function Le(e){return Se(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Re.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield Ae.GetConcept(e);if(0!=a.id){var l=yield Ge(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=l;var s={}}return s.data=i,s.id=e,s}))}function Ge(e,t,n){return Se(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},l=[],s=yield Ae.GetConcept(e);if(0!=s.id&&null==s.type){var d=s.typeId,u=yield Ae.GetConcept(d);s.type=u}if(null===(i=null==s?void 0:s.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==s?void 0:s.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield Ae.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield Ae.GetConcept(d),y.type=u);var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ge(f,t,n);a[p]=e}}else{const e=yield Ge(f,t,n);l[p]=e,a=l}}return a}))}var Ue=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Fe(e){return Ue(this,void 0,void 0,(function*(){return yield Ae.GetConceptByCharacter(e)}))}var Ve=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Pe(e,t){return Ve(this,void 0,void 0,(function*(){var n=yield Fe(e),o=[];if(n)for(var i=yield Ae.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield _e(i[r].id);o.push(c)}return o}))}function Be(e,t){return Ve(this,void 0,void 0,(function*(){var n=yield Fe(e),o=[];if(n)for(var i=yield Ae.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Le(i[r].id);o.push(c)}return o}))}var De=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Ee{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(){return De(this,void 0,void 0,(function*(){try{for(let e=0;e<this.conceptsSyncArray.length;e++)m.AddConcept(this.conceptsSyncArray[e]);for(let e=0;e<this.connectionSyncArray.length;e++)D.AddConnection(this.connectionSyncArray[e]);if(this.conceptsSyncArray.length>0){let e=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],function(e){var t,n,o,i;t=this,n=void 0,i=function*(){let t=p();try{var n=k();const o=yield fetch(w.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,a)}l((i=i.apply(t,n||[])).next())}))}(e)}if(this.connectionSyncArray.length>0){let e=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(e){return t=this,n=void 0,i=function*(){let t=new L(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=k(),o=JSON.stringify(e);const i=yield fetch(w.CreateTheConnectionUrl(),{method:"POST",headers:n,body:o});return i.ok?yield i.json():(console.log("Create the connection error message: ",i),R(i)),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,a)}l((i=i.apply(t,n||[])).next())}));var t,n,o,i}(e)}return"done"}catch(e){throw e}}))}static syncDataLocalDb(){return De(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e];this.connectionSyncArray=[]}return"done"}))}}function Oe(e,t,n,o,i,r,c){var a=new L(0,e,n,t,o,t,i,t,1,t,0,t,4,t,r,c);return e==n?(a.ofTheConceptId=0,a.toTheConceptId=1,a):(a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Ee.AddConnection(a),a)}Ee.conceptsSyncArray=[],Ee.connectionSyncArray=[];var be=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},He=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};const Me=new Map;function je(e,t){return He(this,void 0,void 0,(function*(){let n=yield m.GetConceptByCharacterAndTypeLocal(e,t),o=e+t;if(Me.has(o))return Me.get(o)||n;const i=(()=>He(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var i={character_value:`${e}`,type_id:t},r=JSON.stringify(i),c=k();const o=yield fetch(w.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});if(o.ok){let e=yield o.json();n=e,m.AddConcept(n)}else console.log("This is the concept by type and character error",o.status),R(o)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{Me.delete(o)}})))();return Me.set(o,i),i}))}class We{constructor(e,t,n,o,i,r,c,a,l,s){this.id=0,this.userId=e,this.data=t,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=l,this.isNew=s}}var $e=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};let Je=!1,Qe=[];const Ke=()=>{Qe.length>0&&!Je&&Qe.shift()()};var qe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};let ze=!1,Xe=[];const Ye=()=>{Xe.length>0&&!ze&&Xe.shift()()};var Ze=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class et{static getId(){return Ze(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return qe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{console.log("trying to fetch more concepts"),Xe.push((()=>qe(this,void 0,void 0,(function*(){try{if(ze)return;if(ze=!0,et.ids.length>10)return console.log("Enough IDs available, skipping fetch."),ze=!1,Ye(),e();var n=k("application/x-www-form-urlencoded");const t=yield fetch(w.GetReservedIdUrl(),{method:"GET",headers:n});if(!t.ok)throw R(t),new Error(`Error! status: ${t.status}`);const i=yield t.json();for(var o=0;o<i.length;o++)et.AddId(i[o]);console.log("Ids Fetch Success"),e()}catch(e){e instanceof Error?console.log("get reserved ids error message: ",e.message,w.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",e),t(e)}finally{ze=!1,Ye()}})))),Ye()}))}))}());var e=this.ids[0];return this.ids.shift(),e}))}static AddId(e){this.ids.includes(e)||this.ids.push(e)}}et.ids=[];class tt{static getId(){return Ze(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return $e(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{Qe.push((()=>$e(this,void 0,void 0,(function*(){try{if(Je)return;if(Je=!0,tt.connectionIds.length>10)return Je=!1,Ke(),e();var n=k("application/x-www-form-urlencoded");const t=yield fetch(w.GetReservedConnectionIdUrl(),{method:"GET",headers:n});if(!t.ok)throw R(t),new Error(`Error! status: ${t.status}`);const i=yield t.json();for(var o=0;o<i.length;o++)tt.AddId(i[o]);e()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),t(e)}finally{Je=!1,Ke()}})))),Ke()}))}))}());var e=this.connectionIds[0];return this.connectionIds.shift(),e}))}static AddId(e){this.connectionIds.includes(e)||this.connectionIds.push(e)}}tt.connectionIds=[];var nt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function ot(e,t,n,o,i,r,c,a,l,s,d,u,h,f){return nt(this,void 0,void 0,(function*(){var p=yield et.getId();let v=new Date,g=new Date;var C=new y(p,t,i,r,n,o,c,a,e,l,s,d,u,h,f,!0,v,g);return C.isTemp=!1,Ee.AddConcept(C),C}))}function it(e,t,n,o,i,r,c,a,l,s,d,u,h,f){return nt(this,void 0,void 0,(function*(){var p=yield et.getId();let v=new Date,g=new Date;var C=new y(p,t,i,r,n,o,c,a,e,l,s,d,u,h,f,!1,v,g);return m.AddConcept(C),C.updateRecursion=!0,Ee.AddConcept(C),C}))}var rt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function ct(e,t){return rt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){let a,l=r,s=999,d=o,u=o,h=i,f=o,y="",v=t.length,g=p();y=e.startsWith("the_")?e:"the_"+e;(new Date).getTime();if(n)g=yield rn(e),a=yield ot(t,o,4,o,g.id,g.userId,c,999,s,d,h,f,l,u),(new Date).getTime();else if(v>255)g=yield rn(y),a=yield ot(t,o,4,o,g.id,g.userId,c,999,s,d,h,f,l,u),function(e){be(this,void 0,void 0,(function*(){try{var t=k();const n=yield fetch(w.CreateTheTextDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw R(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("Create the text error message: ",e.message):console.log("Create the text unexpected error: ",e),e}}))}(new We(o,t,s,d,h,f,l,u,Date.now().toString(),!0)),(new Date).getTime();else{g=yield rn(y);let e=yield je(t,g.id);a=e,0==e.id&&0==e.userId&&(a=yield it(t,o,4,o,g.id,g.userId,12,12,s,d,h,f,l,u)),(new Date).getTime()}return a.type=g,a}))}var at=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function lt(e){return at(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,l=null!=r?r:4,s=null!=c?c:999,d=null!=o?o:0,u=p();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=v=yield ct(o,"",!0,a,l,s),h=v.id,d=v.id,yield lt(e[o],v.id,v.userId,h,i,r,c)}else{var f=null!=t?t:999,y=null!=n?n:999;h=d,u=v=yield ct(o,"",!0,a,l,s),yield Oe(f,y,v.id,v.userId,h,s,v.userId),yield lt(e[o],v.id,v.userId,h,i,r,c)}else{f=null!=t?t:999,y=null!=n?n:10267,h=d;var v=yield ct(o,e[o].toString(),!1,a,l,s);yield Oe(f,y,v.id,v.userId,h,s,v.userId)}return u}))}class st{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=Ie(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=o,this.ghostId=e,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function dt(e,t,n,o=1){Math.floor(1e8*Math.random());let i=0,r=0,c=0;i=e,r=t,c=n;let a=new st(0,0,0,0,0,0);return e!=t&&(a=new st(0,e,t,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Re.AddConnection(a)),a}var ut=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function ht(e,t,n,o,i,r){return ut(this,arguments,void 0,(function*(e,t,n,o,i,r,c=0){var a=Math.floor(1e8*Math.random());let l=new Date,s=new Date;var d=new we(a,n,i,o,r,e,t,!0,l,s,c);return d.isTemp=!0,Ae.AddConcept(d),d}))}var ft=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},yt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function pt(e,t,n,o){return yt(this,void 0,void 0,(function*(){var i=yield Fe(e);if(i&&(0==i.id||0==i.userId)){var r=T(e);if(r[0]==e){var c=yield function(e,t,n){return ft(this,void 0,void 0,(function*(){var t=yield Ae.GetConceptByCharacterAndTypeLocal(e,51),o=t;return 0==o.id&&(o=t=yield ht(e,"the",n,4,51,4)),o}))}(e,0,o);i=c}else{var a=yield pt(r[0],t,n,o),l=yield pt(r[1],t,n,o);l&&(i=c=yield ht(e,r[1],o,a.id,l.id,4))}}return i}))}var vt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function gt(e,t){return vt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){var a,l,s,d=o,u=t.length;if(s=e.startsWith("the_")?e:"the_"+e,n)a=yield pt(e,999,o,o),l=yield ht(t,e,o,4,a.id,4,c);else if(u>255)a=yield pt(s,999,d,o),l=yield ht(t,s,o,4,a.id,4);else{a=yield pt(s,999,d,o);var h=yield Ae.GetConceptByCharacterAndTypeLocal(t,a.id);l=h,0==h.id&&0==h.userId&&(l=yield ht(t,s,o,4,a.id,4))}return l.type=a,l}))}var Ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function mt(e){return Ct(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,l=null!=r?r:999,s=null!=c?c:4,d=null!=o?o:0,u=Ie();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=y=yield gt(o,"",!0,a,l,s),h=y.id,d=y.id,yield mt(e[o],y.id,y.userId,h,i,r,c)}else{var f=null!=t?t:999,y=(h=d,yield gt(o,"",!0,a,l,s));yield dt(f,y.id,h),yield mt(e[o],y.id,y.userId,h,i,r,c)}else f=null!=t?t:999,h=d,y=yield gt(o,e[o].toString(),!1,a,l,s),yield dt(f,y.id,h);return u}))}var Nt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Tt(e,t,n){return Nt(this,arguments,void 0,(function*(e,t,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("ofTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=k("application/x-www-form-urlencoded");const l=yield fetch(w.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?r=yield l.json():(console.log("Get connection of concept error",l.status),R(l)),r}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var wt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function It(e,t,n,o,i,r,c){return wt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a=1,l=4,s=999){let d=t,u=t,h=t;999!=s&&(h=s);let f=t,y=t,p=yield tt.getId(),v=new L(p,e,n,t,o,h,i,u,a,d,0,f,l,y,r,c);return e==n?(v.ofTheConceptId=0,v.toTheConceptId=1,v):(v.toUpdate=!0,v.isTemp=!1,Ee.AddConnection(v),v)}))}function kt(e,t,n){return wt(this,void 0,void 0,(function*(){let o=yield rn(n),i=e.userId;return yield It(e.id,e.userId,t.id,t.userId,o.id,999,999,1e3,4,i)}))}var At=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},xt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},Rt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function St(e){return Rt(this,void 0,void 0,(function*(){var t=yield D.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return xt(this,void 0,void 0,(function*(){var t=yield D.GetConnection(e);try{if(0!=t.id)return t;{var n=k("application/x-www-form-urlencoded");const o=yield fetch(w.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return o.ok?(t=yield o.json(),D.AddConnection(t)):(console.log("Get Connection Error",o.status),R(o)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var _t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Lt(e){return _t(this,arguments,void 0,(function*(e,t=""){let n=!1;var o=yield St(e);return n=yield function(e){return At(this,arguments,void 0,(function*(e,t=""){let n=!1;try{const o=new FormData;let i=k("application/x-www-form-urlencoded");""!=t&&(i=A("application/x-www-form-urlencoded",t)),o.append("id",e.toString()),o.append("apiKey","nodeserver");const r=yield fetch(w.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(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),F.removeNodeFromTree(e),P.removeTypeConcept(o.typeId,e),n}))}var Gt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Ut(e){return Gt(this,arguments,void 0,(function*(e,t=999){var n=p();if(e<0)return Vo(yield Ao(t,e));if(null!=(n=yield m.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield q(e)),0!=n.id&&null==n.type&&null==(yield m.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield q(n.typeId);n.type=o}return n}))}var Ft=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Vt(e,t,n){return Ft(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,l=a,s=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Pt(o,t,a));var d=yield ct("connection",c,!1,999,999,999);let u=new L(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,l,4,s,999,999);Ee.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield Pt(u,e,a));var f=yield ct("connection",h,!1,999,999,999);let y=new L(0,e.id,t.id,e.userId,t.userId,e.userId,f.id,f.userId,1e3,a,999,l,4,s,999,999);return Ee.AddConnection(y),y}))}function Pt(e,t){return Ft(this,arguments,void 0,(function*(e,t,n=null){for(var o,i=t,r=null!=n?n:t.userId,c=r,a=r,l=999,s=e+"_count",d=(null===(o=t.type)||void 0===o?void 0:o.characterValue)+"_s_"+s,u=yield ct("connection",d,!1,r,4,l),h=yield Tt(u.id,t.id,r,10,1),f=[],y=p(),v=0;v<h.length;v++){let e=yield Ut(h[v].toTheConceptId);f.push(e)}if(f.length<1)y=yield ct("count","1",!1,r,4,l);else{var g=f[0];let e=0;try{e=Number(g.characterValue)}catch(t){e=0}e+=1,y=yield ct("count",e.toString(),!1,r,4,l);for(let e=0;e<h.length;e++)Lt(h[e].id)}let C=new L(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,a,l,999);yield Ee.AddConnection(C)}))}function Bt(e,t,n){return Ft(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,l=a,s=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Pt(o,t,a));var d=yield ct("connection",c,!1,999,999,999);let u=new L(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,l,4,s,999,999);Ee.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield Pt(u,e,a));var f=yield ct("connection",h,!1,999,999,999);return yield It(e.id,e.userId,t.id,t.userId,f.id,999,999,1e3,4)}))}var Dt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Et(e,t){return Dt(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ut(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,l=yield je(a,16);if(l.id>0){for(var s=yield Tt(l.id,c.id,c.userId,n,o),d=[],u=0;u<s.length;u++)d.push(s[u].toTheConceptId);for(yield J(d),u=0;u<s.length;u++){let e=s[u].toTheConceptId,t=yield Ut(e),n=yield ie(t.id);r.push(n)}}return r}))}function Ot(e,t){return Dt(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ut(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,l=yield je(a,16);if(l.id>0){for(var s=yield Tt(l.id,c.id,c.userId,n,o),d=[],u=0;u<s.length;u++)d.push(s[u].toTheConceptId);for(u=0;u<s.length;u++){let e=s[u].toTheConceptId,t=yield Ut(e);r.push(t)}}return r}))}class bt{constructor(e,t,n,o,i,r,c,a,l,s){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=s}}class Ht{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new bt(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}Ht.characterData=[];class Mt{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var jt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},Wt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function $t(e,t,n,o,i){return Wt(this,void 0,void 0,(function*(){return new bt(t,e,n,t,o,t,i,t,"",!1),yield function(){return jt(this,void 0,void 0,(function*(){var e;try{if(0==(e=Ht.GetCharacter(e.data)).id){var t=k();const o=yield fetch(w.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();var n=new bt(i.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=i.id,Ht.AddCharacter(n),i}return new Mt(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var Jt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Qt(e,t,n,o,i,r,c,a,l,s,d,u,h,f){return Jt(this,void 0,void 0,(function*(){var y=yield je(e,i),p=y;return 0==p.id&&(p=y=yield ot(e,t,n,o,i,r,c,a,l,s,d,u,h,f)),p}))}var Kt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},qt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function zt(e,t,n,o){return qt(this,void 0,void 0,(function*(){var i=yield ue(e);if(i&&(0==i.id||0==i.userId)){var r=T(e);if(r.length>0)if(console.log(r),r[0]==e){var c=yield function(e,t,n,o,i,r){return Kt(this,void 0,void 0,(function*(){var i,c=t,a=t;i=t;var l,s=t,d=t,u=t;if(1==e.length){var h=e.charCodeAt(0);yield $t(e,t,n,o,r),l=Qt(e,t,4,c,h,u,49,s,n,a,o,i,r,d)}else{var f=yield $t(e,t,n,o,r);f.isNew,l=yield Qt(e,t,4,c,51,s,f.id,f.userId,n,a,o,i,r,d)}return l}))}(e,o,999,999,0,t);i=c}else{var a=yield zt(r[0],t,n,o),l=yield zt(r[1],t,n,o);l&&(i=yield it(e,o,a.id,o,l.id,o,999,o,999,o,999,o,t,o))}}return i}))}var Xt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};const Yt=new Map;function Zt(e,t){return Xt(this,void 0,void 0,(function*(){let n=p();if(Yt.has(e+t))return Yt.get(e+t)||n;const o=(()=>Xt(this,void 0,void 0,(function*(){try{var o=k("application/x-www-form-urlencoded");const i=yield fetch(w.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:o,body:`character_value=${e}&category_id=${t}`});if(i.ok){let e=yield i.json();n=e,m.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,e,t,w.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,w.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{Yt.delete(e+t)}})))();return Yt.set(e+t,o),o}))}var en=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function tn(e){return en(this,void 0,void 0,(function*(){let t=p();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=T(e);if(o.length>1){let n=1,i=yield tn(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return en(this,void 0,void 0,(function*(){let n=yield m.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield Zt(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return en(this,void 0,void 0,(function*(){console.log("inside the character length function",e);var t=yield m.GetConceptByCharacterAndTypeLocal(e,49);return console.log("inside the character length function after",t),0==t.id&&(t=yield se(e)),t}))}(e):o[0]==e&&(t=yield function(e){return en(this,void 0,void 0,(function*(){var t=yield m.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield se(e)),t}))}(e));return t}))}var nn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};const on=new Map;function rn(e,t){return nn(this,void 0,void 0,(function*(){let t=p();if(on.has(e))return on.get(e)||t;const n=(()=>nn(this,void 0,void 0,(function*(){try{if(t=yield tn(e),0==t.id||4==t.typeId){var n=k("application/x-www-form-urlencoded");const o=yield fetch(w.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!o.ok)throw R(o),new Error(`Error! status: ${o.status}`);let i=yield o.json();t=i,t.id>0&&m.AddConcept(t)}return t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{on.delete(e)}})))();return on.set(e,n),n}))}var cn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function an(e){return cn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=k("application/x-www-form-urlencoded");const r=yield fetch(w.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(r.ok){const e=yield r.json();for(var o=0;o<e.length;o++){var i=e[o];t.push(i)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),R(r);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var ln=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function sn(e){return ln(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=k("application/x-www-form-urlencoded");const r=yield fetch(w.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(r.ok){const e=yield r.json();for(var o=0;o<e.length;o++){var i=e[o];t.push(i)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),R(r);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var dn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function un(e){return dn(this,void 0,void 0,(function*(){for(var t=yield an(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ut(o);e.type=i}return t}))}function hn(e){return dn(this,void 0,void 0,(function*(){for(var t=yield sn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ut(o);e.type=i}return t}))}var fn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},yn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function pn(e){return yn(this,arguments,void 0,(function*(e,t=""){var n=yield Ut(e);yield f.removeNodeFromTree(e);var o=n.typeId,i=n.characterValue;yield g.removeTypeConcept(o,e),yield u.removeNodeByCharacter(i,e),function(e){fn(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let o=k("application/x-www-form-urlencoded");""!=t&&(o=A("application/x-www-form-urlencoded",t));const i=new FormData;i.append("id",e.toString());const r=yield fetch(w.DeleteConceptUrl(),{method:"POST",body:i});if(!r.ok)throw R(r),new Error(`Error! status: ${r.status}`);n=(yield r.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t)}))}var vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function gn(e,t){return vn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const o=new FormData;o.append("id",e.toString());const i=yield fetch(w.DeleteConceptUrl(),{method:"POST",body:o,headers:n});if(!i.ok)throw R(i),new Error(`Delete composition Error! status: ${i.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var Cn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function mn(e,t,n,o){return Cn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,a=n,l=n,s=e.startsWith("the_"),d=p();return r=s?e:"the_"+e,d=yield rn(r),yield Qt(t,n,4,n,d.id,d.userId,0,999,999,c,4,l,999,a)}))}class Nn{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 Tn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function wn(){return Tn(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield D.GetConnection(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=k();const e=yield fetch(w.GetConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let o=n[e];t.push(o),D.AddConnection(o)}yield H(t)}}else console.log("Get Connection Bulk error",e.status),R(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var In=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function kn(){return In(this,arguments,void 0,(function*(e=[]){yield J(e);var t=[];for(let o=0;o<e.length;o++){var n=yield ne(e[o]);t.push(n)}return t}))}function An(){return In(this,arguments,void 0,(function*(e=[]){yield J(e);var t=[];for(let o=0;o<e.length;o++){var n=yield oe(e[o]);t.push(n)}return t}))}function xn(){return In(this,arguments,void 0,(function*(e=[],t=[]){yield wn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||D.RemoveConnection(t[n])}(t,yield j(e));var n=[];for(let t=0;t<e.length;t++){var o=yield oe(e[t]);n.push(o)}return n}))}function Rn(){return In(this,arguments,void 0,(function*(e=[]){let t=[],n=[],o={};for(let o=0;o<(null==e?void 0:e.length);o++){let i=yield D.GetConnection(e[o]);0==i.id?t.push(e[o]):n.push(i)}for(let n=0;n<t.length;n++)o[e[n]]=!1;let i=[],r=yield wn(t);n=[...n,...r];for(let e=0;e<n.length;e++)i.push(n[e].ofTheConceptId),i.push(n[e].toTheConceptId),i.push(n[e].typeId);return yield O(i),n}))}function Sn(){return In(this,arguments,void 0,(function*(e=[],t=[]){let n=[];for(let e=0;e<t.length;e++)0==(yield D.GetConnection(t[e])).id&&n.push(t[e]);yield wn(n);var o={};for(let t=0;t<e.length;t++){var i=yield oe(e[t]);o[e[t]]=i}return o}))}var _n=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Ln(){return _n(this,arguments,void 0,(function*(e=0,t=[],n=""){var o=[];try{var i=new Nn;i.composition=e,i.listLinkers=t,i.textSearch=n;var r=JSON.stringify(i),c=k();const s=yield fetch(w.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(s.ok){const e=yield s.json();var a=e.compositionIds,l=e.internalConnections;e.externalConnections,o=yield xn(a,l)}else console.log("recursive search error ",s.status),R(s);return o}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var Gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Un(e,t){return Gn(this,void 0,void 0,(function*(){try{var n={email:e,password:t},o=new Headers;o.append("Content-Type","application/json");var i=JSON.stringify(n);const r=yield fetch(w.LoginUrl(),{method:"POST",headers:o,body:i});if(r.ok){const e=yield r.json();return I.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",r.status),R(r)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var Fn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Vn(e){return Fn(this,void 0,void 0,(function*(){const t=yield function(){return Fn(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:R(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(w.SignupUrl(),e);return t}))}var Pn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Bn(e){return Pn(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const o=new Headers;o.append("Content-Type","application/json");const i=w.LoginUrl();try{const e=yield fetch(i,{method:"POST",headers:o,body:t,redirect:"follow"}),r=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==r?void 0:r.data}:R(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function Dn(e,t){return-1===e.indexOf(t)&&e.push(t),e}function En(e=[],t){var n,o;let i=[],r=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(o=e[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&r!=c||i.push(e[n])}return i}function On(e=[],t){let n=[],o=t.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(e))for(let i=0;i<e.length;i++){let r=e[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),t.typeId!=e[i].typeId&&o!=r||n.push(e[i])}return n}function bn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function Hn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function Mn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function jn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class Wn{constructor(e,t,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(Jn.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var $n=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Jn{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new Wn(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return $n(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return $n(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Jn.root=null;var Qn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Kn(e,t,n,o){return Qn(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let a={};const l=[];if(0==e)return"";let s=qn(n,e);if(null!=s&&0!=s.id||null==e||null==e||(s=yield Ut(e)),0!=s.id&&null==s.type){const e=s.typeId;let t=qn(n,e);s.type=t,null==t&&null!=e&&null!=e&&(t=yield Ut(e),s.type=t)}if(!o.includes(e))return null==s?void 0:s.characterValue;if(i.includes(e))return"";i.push(e);for(let s=0;s<t.length;s++)if(t[s].ofTheConceptId==e){const d=t[s].toTheConceptId;if(o.includes(e)){let e=qn(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield Ut(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield m.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Ut(t),e.type=n)}const s="the_",u=(null!==(c=null===(r=null==e?void 0:e.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(s,"");if(isNaN(Number(u))){if(u){const e=yield Kn(d,t,n,o,i);a[u]=e}}else{const e=yield Kn(d,t,n,o,i);l[u]=e,a=l}}}return a}))}function qn(e,t){let n=p();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class zn{constructor(){this.id=0,this.mainConcept=p(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,o=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield Kn(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}));var e,t,n,o}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),w.MQTT_CONNECTION&&w.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const o={};o[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Xn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Yn(e){return Xn(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null,a=null){const l=null!=i?i:999,s=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=p();null==a&&(a=new zn);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield ct(o,"",!0,l,s,d);if(null==t&&null==n){let t=u;h=f,t=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield Yn(e[o],f.id,f.userId,t,i,r,c,a)}else{const l=null!=t?t:999,s=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield Oe(l,s,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield Yn(e[o],f.id,f.userId,y,i,r,c,a)}null!=e[o]&&null!=e[o]&&a.subcompositions.push(f.id)}else{const i=null!=t?t:999,r=null!=n?n:999,c=u,h=yield ct(o,e[o],!1,l,s,d);a.concepts.push(h);const f=yield Oe(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var Zn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function eo(e){return Zn(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=p(),a=p();const l=[];let s=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(s<0){let e=yield Ut(s,t);if(!(e.id>0))return null;s=e.id}i=yield X(s);const h=[],f=new zn,y=[];f.id=s,f.isUpdating();let v=[];for(let e=0;e<i.length;e++)Dn(y,i[e].ofTheConceptId),Dn(h,i[e].ofTheConceptId),Dn(h,i[e].toTheConceptId),v.push(i[e].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let e=0;e<h.length;e++){const t=yield Ut(h[e]);s==h[e]&&(c=t),d==h[e]&&(a=t),r.push(t)}const g=e.patchObject;for(const e in g){let i=p();const s=g[e];let d=c;if(a.id>0&&(d=a),Array.isArray(s)||"object"==typeof s){i=yield ct(e,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const t=En(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=bn(f.connections,t[e].id);u=u.concat(n),l.push(t[e])}yield Yn(g[e],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield ct(e,s,!1,t,o,n);const c=En(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=bn(f.connections,c[e].id);u=u.concat(t),l.push(c[e])}}const h=Oe(d.id,d.userId,i.id,i.userId,c.id,n,t);r.push(i),f.connections.push(h)}for(let e=0;e<u.length;e++)jn(f.connections,u[e]),Lt(u[e].id);for(let e=0;e<l.length;e++)Mn(r,l[e]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),Jn.addCompositionToTree(f),Ee.SyncDataOnline(),f.GetDataCache()}))}var to=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function no(e,t,n,o){return to(this,arguments,void 0,(function*(e,t,n,o,i=10,r=1){var c=A("application/x-www-form-urlencoded",o),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",n),a.append("inpage",i.toString()),a.append("page",r.toString());const l=w.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield fetch(l,{method:"GET",headers:c});return e.ok?yield e.json():(R(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var oo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function io(e){return oo(this,arguments,void 0,(function*(e,t=""){var n=A("application/json",t);const o=w.SearchLinkMultipleAll(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(console.log("This is the searching error",e.status),R(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var ro=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function co(e){return ro(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},a={};const l=yield Jn.getNodeFromTree(e),s=[];let d=yield m.GetConcept(e);if(0==d.id&&null!=e&&null!=e&&(d=yield q(e)),null==l){let l=[];l=t.length>0?ao(e,t):yield X(e),i=l;for(let e=0;e<i.length;e++)s.includes(i[e].ofTheConceptId)||(s.push(i[e].ofTheConceptId),r.push(i[e].ofTheConceptId)),r.includes(i[e].toTheConceptId)||r.push(i[e].toTheConceptId);uo(d,i,r,s);let u=[];a=yield ce(e,i,s,u),c[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a}else a=l.value.GetDataCache(),c=a;return 0==d.id?"":c}))}function ao(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function lo(e){return ro(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let a;const l={},s=yield Jn.getNodeFromTree(e),d=[];let u=yield m.GetConcept(e);if(0==u.id&&null!=e&&null!=e&&(u=yield q(e)),null==s){let s=[];s=t.length>0?ao(e,t):yield X(e),r=s;for(let e=0;e<r.length;e++)d.includes(r[e].ofTheConceptId)||(d.push(r[e].ofTheConceptId),c.push(r[e].ofTheConceptId)),c.includes(r[e].toTheConceptId)||c.push(r[e].toTheConceptId);uo(u,r,c,d),a=yield ce(e,r,d),l[null!==(o=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=u.entryTimeStamp,i.data=l,i.id=e}else a=s.value.GetDataCache(),i=a;return 0==u.id?"":i}))}function so(e,t){return ro(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield wn(t);for(let t=0;t<e.length;t++){const i=yield lo(e[t],n);i&&o.push(i)}return o}))}function uo(e,t,n,o){return ro(this,void 0,void 0,(function*(){const i=new zn,r=yield function(e){return ro(this,void 0,void 0,(function*(){let t=[];const n=[];for(let o=0;o<(null==e?void 0:e.length);o++){const i=yield m.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}return 0==(null==n?void 0:n.length)||(t=yield function(e){return E(this,void 0,void 0,(function*(){const t=[];if(e.length>0){const n={"Content-Type":"application/json"};try{const o=yield fetch(w.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){const e=yield o.json();if(e.length>0)for(let n=0;n<e.length;n++){const o=e[n];t.push(o),m.AddConcept(o)}}else R(o)}catch(e){throw e instanceof Error?console.log("bulk concept getter api error: ",e.message):console.log("bulk concept getter api error: ",e),e}}return t}))}(n)),t}))}(n);i.connections=t,i.concepts=r,i.id=e.id,i.subcompositions=o,i.mainConcept=e;const c=yield Kn(e.id,t,r,o,[]);i.cached=c,Jn.addCompositionToTree(i)}))}var ho=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function fo(e){return ho(this,void 0,void 0,(function*(){try{var t=k();const n=JSON.stringify(e),o=yield fetch(w.CreateSessionId(),{method:"POST",headers:t,body:n});return o.ok?o.json():(console.log("Creating session failed",yield o.json()),R(o),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function po(e,t){return yo(this,void 0,void 0,(function*(){try{var n=k("application/x-www-form-urlencoded");const o=new URLSearchParams;o.append("sessionId",e.toString()),o.append("url",t);const i=yield fetch(w.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(e){throw console.log("Creating session url failed",e),e}}))}var vo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function go(e,t,n){return vo(this,arguments,void 0,(function*(e,t,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("toTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${i}`);var a=k("application/x-www-form-urlencoded");const l=yield fetch(w.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?r=yield l.json():(console.log("Get connection of concept error",l.status),R(l)),r}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Co=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function mo(e,t){return Co(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ut(e),a=yield tn(t);if(a.id>0){let e=[],t=[];if(i){t=yield go(a.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield J(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield Ut(n),i=yield ie(o.id);r.push(i)}}else{t=yield Tt(a.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield J(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield Ut(n),i=yield ie(o.id);r.push(i)}}}return r}))}function No(e,t){return Co(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ut(e),a=yield tn(t),l=[],s=[];if(a.id>0){if(i){l=yield go(a.id,c.id,c.userId,n,o);for(let e=0;e<l.length;e++)s.push(l[e].ofTheConceptId)}else{l=yield Tt(a.id,c.id,c.userId,n,o);for(let e=0;e<l.length;e++)s.push(l[e].toTheConceptId)}r=yield O(s)}return r}))}class To{constructor(e,t,n,o,i){this.connectionValue=[],this.value=[],this.height=1,this.key=e,t.id>0&&this.value.push(t),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=i}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t.value.push(...e.value),t.connectionValue.push(...e.connectionValue),t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.rightNode=this.removeNode(e.rightNode,n.key),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var wo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Io{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return wo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(l.isDataLoaded)return e("done");setTimeout(Io.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=new st(0,0,0,0,0,0);var r=new To(o,e,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=Ie();var r=new To(o,i,e,null,null);this.addNodeToTree(r)}static getNodeFromTree(e,t){return wo(this,arguments,void 0,(function*(e,t,n=999){let o=this.compositeKey(e,t,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(e){return wo(this,arguments,void 0,(function*(e,t=999,n=999){if(this.root){let o=this.compositeKey(e,t,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Io.root=null;var ko=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Ao(e,t){return ko(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield Io.getNodeFromTree(e,n,o),r=Ie();if(i)for(let e=0;e<i.value.length;e++){let n=i.value[e];n.ghostId==t&&(r=n)}return r}))}function xo(e,t){return ko(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield Io.getNodeFromTree(e,n,o),r=new st(0,0,0,0,0,0);if(i)for(let e=0;e<i.connectionValue.length;e++){let n=i.connectionValue[e];n.ghostId==t&&(r=n)}return r}))}function Ro(e,t){return ko(this,arguments,void 0,(function*(e,t,n=999){Io.addConceptToTree(e,t,n)}))}function So(e,t){return ko(this,arguments,void 0,(function*(e,t,n=999){Io.addConnectionToTree(e,t,n)}))}var _o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},Lo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Go(e){return Lo(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield function(e){return _o(this,arguments,void 0,(function*(e,t=""){var n=A("application/json",t);const o=w.SearchLinkMultipleAllApiUrl(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(console.log("This is the searching multiple error",e.status),R(e),[])}catch(e){throw console.log("This is the searching multiple error",e),e}}))}(e,t),i=e[0].composition;const r=o;let c=r.compositionIds,a=r.internalConnections,l=r.linkers,s=r.reverse;return n=yield Sn(c,a),yield Uo(l,n,i,s)}))}function Uo(e,t,n){return Lo(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield wn(e);for(let e=0;e<r.length;e++){let n=!1;if(o.includes(r[e].id)&&(n=!0),1==n){if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].toTheConceptId],o=yield Ut(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(t[r[e].ofTheConceptId])}catch(e){console.log("this is error",e)}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield Ut(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(t[r[e].toTheConceptId])}catch(e){console.log("this is error",e)}}}return i=t[n],i}))}function Fo(e){var t,n;const o=Ie();return o.id=e.id,o.ghostId=e.ghostId,o.userId=e.userId,o.accessId=e.accessId,o.categoryId=e.categoryId,o.characterValue=e.characterValue,o.entryTimeStamp=e.entryTimeStamp,o.typeId=e.typeId,o.type=e.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"",o}function Vo(e){const t=p();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}function Po(e){const t=new st(0,0,0,0,0,0);return t.id=e.id,t.ghostId=e.ghostId,t.accessId=e.accessId,t.ofTheConceptId=e.ofTheConceptId,t.toTheConceptId=e.toTheConceptId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.isTemp=!1,t}var Bo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Do(e){return Bo(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=Ie(),a=Ie();const l=[],s=e.compositionId,d=e.ofTheCompositionId;let u=[],h=yield X(s);for(let e=0;e<h.length;e++)i.push(Po(h[e]));const f=[],y=[];let p=[];for(let e=0;e<i.length;e++)Dn(y,i[e].ofTheConceptId),Dn(f,i[e].ofTheConceptId),Dn(f,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);for(let e=0;e<f.length;e++){const t=yield Ut(f[e]);s==f[e]&&(c=Fo(t)),d==f[e]&&(a=Fo(t)),r.push(Fo(t))}const v=e.patchObject;for(const e in v){let s=Ie();const d=v[e];let h=c;a.id>0&&(h=a),Array.isArray(d)||"object"==typeof d?(s=yield gt(e,"",!0,c.userId,4,999),yield mt(v[e],s.id,s.userId,c.id,c.userId,4,999)):s=yield gt(e,d,!1,t,o,n);const f=On(r,s);for(let e=0;e<f.length;e++)if(f[e].id>0){const t=Hn(i,f[e].id);u=u.concat(t),l.push(f[e])}yield dt(h.id,s.id,c.id,2),r.push(s)}for(let e=0;e<u.length;e++)Lt(u[e].id);Ee.SyncDataOnline()}))}var Eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},Oo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function bo(e){return Oo(this,void 0,void 0,(function*(){var t;let n=yield function(e){return Eo(this,void 0,void 0,(function*(){let t=[];try{var n=k();const o=yield fetch(w.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){let e=yield o.json(),n={};for(let o=0;o<e.length;o++){let i=e[o].concepts;t=e[o].connections;let r=e[o].id;O(i),n[r]=t}return n}return console.log("View Internal Data error",o.status),R(o),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),o=[];for(let i=0;i<e.length;i++){let r=e[i],c=n[r];if(r&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield ce(r,c,e);t.data=n,t.id=r,o.push(t)}else{let e={};e.id=r;let n=yield Ut(r),i={};n.type&&(i[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=i,o.push(e))}}return o}))}var Ho=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},Mo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function jo(e){return Mo(this,arguments,void 0,(function*(e,t=""){var n=yield function(e){return Ho(this,arguments,void 0,(function*(e,t=""){var n=A("application/json",t);let o=w.SearchInternalWithAuthenticatedCcsUrl();o=o+"?composition="+e.composition+"&search="+e.search+"&internalComposition="+e.internalComposition+"&type="+e.type+"&inpage="+e.inpage+"&page="+e.page;try{const e=yield fetch(o,{method:"GET",headers:n});return e.ok?yield e.json():(console.log("This is the searching internal error",e.status),R(e),[])}catch(e){throw console.log("This is the searching internal error",e),e}}))}(e,t);return yield bo(n)}))}class Wo{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class $o{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 Jo{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Qo{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var Ko=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};var qo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};class Xo{}Xo.isUpdated=!1,Xo.isOnlineSync=!1;var Yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};var Zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};const ei=1,ti=2,ni=3,oi=4,ii=5,ri=6,ci=7;class ai{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var li=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function si(e){return li(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield q(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]=e[n]}return t}))}function di(e){const t=e.split("_");if(3===t.length){let e=new ai;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function ui(e){return e.startsWith("the_")?e.slice(4):e}var hi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))},fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function yi(e,t,n){return fi(this,void 0,void 0,(function*(){var o,i,r,c,a,l,s,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ut(e[u].ofTheConceptId),y=yield Ut(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[a]={},t[e[u].toTheConceptId]=n);let l=yield Ut(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;l.characterValue,l.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ut(e[u].typeId);try{let e=null!==(d=null===(s=null==y?void 0:y.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}var pi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function vi(e,t,n){if(e in t){let o=t[e];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}function gi(e,t="DESC"){return console.log("this is the order",t),"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var Ci=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};var mi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Ni(e,t){return mi(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=ri;let n,o=yield function(e){return Zo(this,arguments,void 0,(function*(e,t=""){var n=A("application/json",t);const o=w.FreeschemaQueryUrl(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(R(e),console.log("This is the freeschema query error",e.status),[])}catch(e){console.log("This is the freeschema query error others",e),function(e,t=""){if(e.status){let n=new x(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new x(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,o)}}))}(e,""),i=o.conceptIds,r=(o.internalConnections,o.linkers),c=o.reverse,a=o.mainCompositionIds,l=o.countinfo,s=e.order,d=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let o=di(e[n]);t.push(o)}return t}(l);return n=t==ti?yield function(e,t,n,o,i){return Ci(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Rn(e),a=yield si(i);c=gi(c,r);let l=[];l=yield function(e,t){return hi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,l,s,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ut(e[u].ofTheConceptId),y=yield Ut(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ut(e[u].typeId),l=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[l]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ut(e[u].typeId),i=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(s=null==y?void 0:y.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}(c,l,o),l=yield function(e,t){return hi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,l,s,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ut(e[u].ofTheConceptId),y=yield Ut(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ut(e[u].typeId),l=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],l in n||(n[l]={})):(n={},n[l]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=ui(o));let i={id:f.id,data:{[e]:t}},s=o+"_reverse";s.includes("_s_")||("string"==typeof n[l]&&(n[l]={}),n[l][s]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ut(e[u].typeId),i=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(s=null==y?void 0:y.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=e,r=ui(r),c=!0);let a={id:y.id,data:{[e]:t}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(e){console.log("this is error",e)}}}return t}))}(c,l,o);let s=yield function(e,t,n,o){return hi(this,arguments,void 0,(function*(e,t,n,o,i=[],r){var c,a,l,s,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let o=!1,r=yield Ut(e[n].ofTheConceptId),f=yield Ut(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=r.id&&0!=f.id&&f.id in t){let o,i=yield Ut(e[n].typeId),l=null!==(a=null===(c=f.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[l]&&(o[l]={})):(o={},o[l]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let c={id:r.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},a=i.characterValue+"_reverse";Array.isArray(o[l][a])?o[l][a].push(c):a.includes("_s_")?(o[l][a]=[],o[l][a].push(c)):o[l][a]=c}}catch(e){console.log("this is error",e)}}}else if(0!=r.id&&0!=f.id&&r.id in t){let o,i=yield Ut(e[n].typeId),c=null!==(s=null===(l=r.type)||void 0===l?void 0:l.characterValue)&&void 0!==s?s:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o);let y=!0,p=i.characterValue;""==p&&(p=f.characterValue,y=!0),""==p&&(p=null!==(u=null===(d=null==f?void 0:f.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let r=t[e[n].toTheConceptId];if(r){let a={id:f.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(r):Array.isArray(o[c][p])?o[c][i.characterValue].push(a):p.includes("_s_")?(o[c][p]=[],o[c][p].push(a)):o[c][p]=a}}catch(e){console.log("this is error",e)}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e],n.data=t[o[e]],f.push(n)}return f}))}(c,l,[],n,o,a);return s}))}(r,i,a,c,d,s):t==ni?yield function(e,t,n,o,i){return Ci(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Rn(e),a=yield si(i);c=gi(c,r);let l=[];l=yield yi(c,l,o),l=yield function(e,t){return pi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,l,s,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ut(e[u].ofTheConceptId),y=yield Ut(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ut(e[u].typeId),l=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],l in n||(n[l]={})):(n={},n[l]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=ui(o));let i={id:f.id,[e]:t},s=o+"_reverse";s.includes("_s_")||("string"==typeof n[l]&&(n[l]={}),n[l][s]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ut(e[u].typeId),i=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let t=null!==(d=null===(s=null==y?void 0:y.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,a=!1;""==c&&(c=t,c=ui(c),a=!0);let l={};l[t]={id:y.id,data:r,created_on:e[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=a?l[t]:l):(Array.isArray(n[i])||(n[i]=[]),n[i].push(l[t]))}catch(e){console.log("this is error",e)}}}return t}))}(c,l,o);let s=yield function(e,t,n){return pi(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,a,l,s,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,y=yield Ut(e[n].ofTheConceptId),p=yield Ut(e[n].toTheConceptId);if(o.includes(e[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in t){let o,i=yield Ut(e[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let r=t[e[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(e){console.log("this is error",e)}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield Ut(e[n].typeId),c=null!==(l=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),vi(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(s=null==p?void 0:p.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",a=t[e[n].toTheConceptId];if(a){let t={};t[r]={data:a[r],id:p.id,created_on:e[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(t):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(t[r]):o[c][g].push(t)):o[c][g]=v?t[r]:t,vi(p.id,i,t)}}catch(e){console.log("this is error",e)}}}console.log("this is the main compositions",n);for(let e=0;e<n.length;e++){let o={};console.log("this is the main compositions DATA",t[n[e]]),o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,l,n,o,a);return s}))}(r,i,a,c,d,s):yield function(e,t,n,o){return Ci(this,void 0,void 0,(function*(){let t=yield Rn(e);t=gi(t);let i=[];i=yield yi(t,i,o),i=yield function(e,t,n){return fi(this,void 0,void 0,(function*(){var o,i,r,c,a,l,s,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ut(e[u].ofTheConceptId),y=yield Ut(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);let l=yield Ut(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=l.characterValue;""==o&&(o=e,o=ui(o));let i={[e]:t},s=o+"_reverse";l.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][s]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ut(e[u].typeId);try{let e=null!==(d=null===(s=null==y?void 0:y.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=e,r=ui(r),c=!0);let a={[e]:t};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?t:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){console.log("this is error",e)}}}return t}))}(t,i,o);let r=yield function(){return fi(this,arguments,void 0,(function*(e=[],t=[],n=[],o,i=[]){var r,c,a,l,s,d;let u=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let o=!1;i.includes(e[n].id)&&(o=!0);let u=yield Ut(e[n].ofTheConceptId),h=yield Ut(e[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in t){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?o=t[e[n].toTheConceptId]:(o={},o[i]={},t[e[n].toTheConceptId]=o);let a=yield Ut(e[n].typeId);try{let r=a.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(e){console.log("this is error",e)}}}else if(0!=u.id&&0!=h.id&&u.id in t){let o,i=null!==(l=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self";e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},t[e[n].ofTheConceptId]=o);let r=!1,c=(yield Ut(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(s=null==h?void 0:h.type)||void 0===s?void 0:s.characterValue)&&void 0!==d?d:"");try{let a=t[e[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(e){console.log("this is error",e)}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],u.push(o))}return u}))}(t,i,n,[],o);return r}))}(r,0,a,c),n}))}class Ti{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=ei,this.name="",this.reverse=!1,this.limit=!1,this.includeInFilter=!1,this.isOldConnectionType=!1}}var wi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}l((o=o.apply(e,t||[])).next())}))};function Ii(e,t){return wi(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield sn(e),i=yield rn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield an(e);for(let e=0;e<n.length;e++)D.AddConnection(n[e]);let i=yield rn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function ki(e,t,n){return wi(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield Ii(t,n,o):yield Ii(e,n,o),o)for(let t=0;t<i.length;t++)i[t].ofTheConceptId==e&&r.push(i[t]);else for(let e=0;e<i.length;e++)i[e].toTheConceptId==t&&r.push(i[e]);return r}))}function Ai(e=""){I.BearerAccessToken=e}function xi(e="",t="",o=""){w.BASE_URL=e,w.AI_URL=t,console.log("This ist he base url",w.BASE_URL),I.BearerAccessToken=o,function(){return Yo(this,void 0,void 0,(function*(){return yield new n(!0),yield function(){return zo(this,void 0,void 0,(function*(){try{(new Date).getTime();var e=A("application/x-www-form-urlencoded");const n=yield fetch(w.GetAllAiData(),{method:"GET",headers:e});n.ok||(console.log("Ai Error Message: ","Cannot get response"),R(n));const o=yield n.json();for(var t=0;t<o.length;t++)m.AddConcept(o[t])}catch(e){throw e instanceof Error?console.log("Ai Error Message: ",e.message):console.log("Ai Error Message: ",e),e}}))}(),!0}))}().then((()=>{const e=(new Date).getTime();(function(){return N(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];m.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{l.isDataLoaded=!0,l.isCharacterLoaded=!0,l.isTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare concept data is ",t)})),function(){return qo(this,void 0,void 0,(function*(){var e=yield a();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Ae.AddConceptToMemory(n)}}))}().then((()=>{l.isLocalDataLoaded=!0,l.isLocalTypeLoaded=!0,l.isLocalCharacterLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare local concept ",t)})),function(){return Ko(this,void 0,void 0,(function*(){!function(){Ko(this,void 0,void 0,(function*(){var e=yield a();if(Array.isArray(e))for(var t=0;t<e.length;t++)Re.AddConnection(e[t])}))}()}))}().then((()=>{l.isLocalConnectionLoaded=!0})),function(){return Ko(this,void 0,void 0,(function*(){!function(){Ko(this,void 0,void 0,(function*(){var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++)D.AddConnectionToMemory(e[t])}))}()}))}().then((()=>{l.isConnectionLoaded=!0,l.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare connections ",t)}))}))}var Ri=exports;for(var Si in t)Ri[Si]=t[Si];t.__esModule&&Object.defineProperty(Ri,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALLID:()=>ci,AddGhostConcept:()=>So,AddGhostConnection:()=>_o,BaseUrl:()=>I,BinaryTree:()=>f,Composition:()=>Yn,CompositionBinaryTree:()=>Qn,CompositionNode:()=>$n,Concept:()=>y,ConceptsData:()=>N,Connection:()=>G,ConnectionData:()=>E,CreateComposition:()=>lt,CreateConnection:()=>At,CreateConnectionBetweenTwoConcepts:()=>Pt,CreateConnectionBetweenTwoConceptsGeneral:()=>Dt,CreateDefaultConcept:()=>p,CreateDefaultLConcept:()=>ke,CreateSession:()=>yo,CreateSessionVisit:()=>vo,CreateTheCompositionLocal:()=>Nt,CreateTheCompositionWithCache:()=>Zn,CreateTheConnection:()=>be,CreateTheConnectionGeneral:()=>kt,CreateTheConnectionLocal:()=>ut,DATAID:()=>ni,DATAIDDATE:()=>ii,DeleteConceptById:()=>vn,DeleteConnectionById:()=>Gt,FilterSearch:()=>Qo,FormatFromConnections:()=>Fo,FreeSchemaResponse:()=>R,FreeschemaQuery:()=>wi,GetAllConnectionsOfComposition:()=>X,GetAllConnectionsOfCompositionBulk:()=>Q,GetAllTheConnectionsByTypeAndOfTheConcept:()=>ki,GetComposition:()=>te,GetCompositionBulk:()=>An,GetCompositionBulkWithDataId:()=>xn,GetCompositionFromConnectionsWithDataId:()=>Rn,GetCompositionFromConnectionsWithDataIdInObject:()=>_n,GetCompositionList:()=>ye,GetCompositionListLocal:()=>Be,GetCompositionListLocalWithId:()=>De,GetCompositionListWithId:()=>pe,GetCompositionLocal:()=>Le,GetCompositionLocalWithId:()=>Ge,GetCompositionWithAllIds:()=>ne,GetCompositionWithCache:()=>ao,GetCompositionWithDataIdBulk:()=>uo,GetCompositionWithDataIdWithCache:()=>lo,GetCompositionWithId:()=>ce,GetConceptBulk:()=>b,GetConceptByCharacter:()=>he,GetConceptByCharacterAndCategoryDirectApi:()=>en,GetConceptByCharacterAndType:()=>We,GetConnectionBulk:()=>In,GetConnectionById:()=>_t,GetConnectionOfTheConcept:()=>wt,GetLink:()=>Ot,GetLinkRaw:()=>bt,GetLinkerConnectionFromConcepts:()=>hn,GetLinkerConnectionToConcepts:()=>fn,GetRelation:()=>No,GetRelationRaw:()=>To,GetTheConcept:()=>Ft,GetUserGhostConnectionId:()=>Ro,GetUserGhostId:()=>xo,GiveConnection:()=>Ai,HandleHttpError:()=>S,JUSTDATA:()=>oi,LConcept:()=>Ie,LConnection:()=>dt,LISTNORMAL:()=>ai,LoginToBackend:()=>Fn,MakeTheInstanceConcept:()=>at,MakeTheInstanceConceptLocal:()=>Ct,MakeTheTimestamp:()=>Nn,MakeTheTypeConcept:()=>Yt,MakeTheTypeConceptApi:()=>cn,NORMAL:()=>ti,PatcherStructure:()=>$o,RAW:()=>ri,RecursiveSearchApi:()=>Gn,SchemaQueryListener:()=>Ti,SearchAllConcepts:()=>oo,SearchLinkInternal:()=>Wo,SearchLinkMultipleAll:()=>Uo,SearchQuery:()=>Tn,SearchStructure:()=>Ko,SearchWithLinker:()=>ro,SessionData:()=>Jo,Signin:()=>Dn,Signup:()=>Pn,SplitStrings:()=>w,SyncData:()=>Oe,TrashTheConcept:()=>Cn,UpdateComposition:()=>to,UpdateCompositionLocal:()=>Eo,UserBinaryTree:()=>ko,ViewInternalData:()=>Ho,convertFromLConceptToConcept:()=>Po,getFromDatabaseWithType:()=>r,getFromDatabaseWithTypeOld:()=>c,init:()=>Ri,recursiveFetch:()=>ae,recursiveFetchNew:()=>qn,storeToDatabase:()=>i,updateAccessToken:()=>xi});class n{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function i(e,t){}function r(e,t,n){return o(this,void 0,void 0,(function*(){}))}function c(e){return o(this,void 0,void 0,(function*(){}))}function a(e){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(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var d=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class u{static waitForDataToLoad(){return d(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isCharacterLoaded)return e("done");setTimeout(u.checkFlag,1e3,e)}static addNodeToTree(e){return d(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return d(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new l(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return d(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}u.characterRoot=null;var h=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class f{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return h(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isDataLoaded)return e("done");setTimeout(f.checkFlag,1e3,e)}static addConceptToTree(e){var t=new l(e.id,e,null,null),n=new l(e.characterValue,e,null,null);u.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return h(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return h(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}f.root=null;class y{constructor(e,t,n,o,i,r,c,a,s,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=o,this.ghostId=e,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=a,this.characterValue=`${s}`,this.securityId=l,this.securityUserId=d,this.accessId=u,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=y,this.x=0,this.y=0,this.type=null,this.isNew=p,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function p(){let e=v(new Date),t=v(new Date);return new y(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function v(e){const t=e.getMonth()+1,n=e.getDate(),o=e.getFullYear();let i=e.getHours();const r=e.getMinutes(),c=e.getSeconds(),a=i>=12?"PM":"AM";i%=12,i=i||12;const s=e=>e.toString().padStart(2,"0");return`${t}/${n}/${o} ${i}:${s(r)}:${s(c)} ${a}`}var g=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class C{static addNodeToTree(e){return g(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new l(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return g(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isTypeLoaded)return e("done");setTimeout(C.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return g(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)if(o.variants[e].value.userId==t){var i=!1;for(let t=0;t<n.length;t++)n[t].id==o.variants[e].value.id&&(i=!0);i||n.push(o.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return g(this,void 0,void 0,(function*(){let n=p();var o=this.getNodeFromTree(t);if(o){o.value.characterValue==e&&(n=o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.characterValue==e&&(n=o.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}C.typeRoot=null;var m=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class N{constructor(){this.name="conceptsArray"}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){this.NPC.includes(e)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(e))}static GetNpc(e){return!!this.NPC.includes(e)}static AddConceptToStorage(e){e.id}static AddConcept(e){e.id>0&&(f.addConceptToTree(e),C.addConceptToTree(e),u.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(f.addConceptToTree(e),C.addConceptToTree(e),u.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);f.removeNodeFromTree(e.id),e.id}static GetConcept(e){return m(this,void 0,void 0,(function*(){var t=p(),n=yield f.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return m(this,void 0,void 0,(function*(){var t=p(),n=u.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return m(this,void 0,void 0,(function*(){var t=p(),n=u.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return m(this,void 0,void 0,(function*(){return p(),yield C.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return m(this,void 0,void 0,(function*(){var n=p(),o=yield u.getCharacterAndCategoryFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return m(this,void 0,void 0,(function*(){let n=[];return n=yield C.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return u.characterRoot}getName(){return this.name}}N.conceptsArray=[],N.NPC=[],N.conceptDictionary=[];var T=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function w(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],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(e="application/json",t="application/json"){return{"Content-Type":e,Authorization:"Bearer "+k.BearerAccessToken,Accept:t}}function x(e="application/json",t="",n="application/json"){return""==t&&(t=k.BearerAccessToken),{"Content-Type":e,Authorization:"Bearer "+t,Accept:n}}k.BearerAccessToken="";class R{constructor(e,t,n,o){this.url=I.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=o}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function S(e){if(401==e.status){let t=new R(e.statusText,!1,e.status,"");throw t.setUrl(e.url),t}}var _=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function L(e,t){return _(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.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 e=yield r.json();for(var i=0;i<e.length;i++)N.AddConcept(e[i])}console.log("GetAllConceptsByType error",r.status),S(r)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class G{constructor(e=0,t,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=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=e,this.typeUserId=a,this.orderId=s,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=g,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class U{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var F=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class V{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new U(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isConnectionLoaded)return e("done");setTimeout(V.checkFlag,1e3,e)}static removeNodeFromTree(e){return F(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return F(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}V.connectionroot=null;var P=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class B{static addNodeToTree(e){return P(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return P(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isConnectionTypeLoaded)return e("done");setTimeout(B.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new U(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return P(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return P(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}B.connectionTypeRoot=null;var D=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class E{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){}static AddConnection(e){e.isTemp||(V.addConnectionToTree(e),B.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(V.addConnectionToTree(e),B.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(e.id,V.removeNodeFromTree(e.id),B.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return V.connectionroot}static GetConnectionTypeTree(){return B.connectionTypeRoot}static GetConnection(e){return D(this,void 0,void 0,(function*(){var t=new G(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield V.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return D(this,void 0,void 0,(function*(){var t=[],n=yield B.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;if(o){let e=o;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}E.connectionArray=[],E.connectionDictionary=[];var O=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function b(e){return O(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield N.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=A();const e=yield fetch(I.GetConceptBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){let n=yield e.json();if(n.length>0)for(let e=0;e<n.length;e++){let o=n[e];t.push(o),N.AddConcept(o)}}else console.log("Get Concept Bulk error",e.status),S(e);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var H=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function M(){return H(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield b(t)}}))}var j=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function W(){return j(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield E.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function $(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||E.RemoveConnection(t[n]))}var J=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Q(){return J(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield W(e),o=yield function(){return J(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=A();const i=yield fetch(I.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++)E.AddConnection(e[o]),t.push(e[o])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),S(i);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return $(t=o,n),yield M(t),t}))}var K=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const q=new Map;function z(e){return K(this,void 0,void 0,(function*(){let t=p();if(q.has(e))return q.get(e)||t;const n=(()=>K(this,void 0,void 0,(function*(){try{var n=yield N.GetConcept(e);let i=N.GetNpc(e);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=${e}`});return n.ok?(t=yield n.json(),t.id>0?N.AddConcept(t):N.AddNpc(e)):(console.log("Get the concept error",n.status),S(n)),t}}catch(e){throw e instanceof Error?console.log("Get the concept error message: ",e.message):console.log("Get the concept unexpected error: ",e),e}finally{q.delete(e)}})))();return q.set(e,n),n}))}var Y=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function X(e){return Y(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield E.GetConnectionsOfCompositionLocal(e)).length)t=yield Z(e);else{var n=yield Z(e);$(n,t),t=n}return t}))}function Z(e){return Y(this,void 0,void 0,(function*(){var t=[];try{var n=A("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});if(!i.ok)throw S(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();for(var o=0;o<r.length;o++)E.AddConnection(r[o]),t.push(r[o]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var ee=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function te(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield ae(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function ne(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield se(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function oe(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield ae(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s,i}))}function ie(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield ae(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=e,l}))}function re(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield E.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield ae(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=e,l.created_at=a.entryTimeStamp,l}))}function ce(e){return ee(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield X(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield N.GetConcept(e);0==a.id&&null!=e&&null!=e&&(a=yield z(e));var s=yield ae(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=e,l}))}function ae(e,t,n){return ee(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[];if(0==e)return null;var l=yield N.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield z(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield N.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield z(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield N.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield z(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield N.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield z(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield ae(f,t,n,o);a[p]=e}}else{const e=yield ae(f,t,n,o);s[p]=e,a=s}}return a}))}function se(e,t,n){return ee(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[];if(0==e)return null;var l=yield N.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield z(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield N.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield z(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e),a.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield N.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield z(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield N.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield z(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield se(f,t,n);a[p]=e}}else{const e=yield se(f,t,n);s[p]=e,a=s}}return a}))}var le=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function de(e){return le(this,void 0,void 0,(function*(){let t=p();try{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return o.ok?(t=yield o.json(),t.id>0&&(console.log("This is adding the new concept",t),N.AddConcept(t))):(console.log("Error in Getting concept by character value Error",o.status),S(o)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var ue=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function he(e){return ue(this,void 0,void 0,(function*(){var t=yield N.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield de(e),t=yield N.GetConceptByCharacter(e)),t}))}var fe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ye(e,t){return fe(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield he(e),r=[];if(i){yield L(e,t);for(var c=yield N.GetConceptsByTypeIdAndUser(i.id,t),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 oe(c[l].id);r.push(d)}}return r}))}function pe(e,t){return fe(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield he(e),r=[];if(i){yield L(e,t);for(var c=yield N.GetConceptsByTypeIdAndUser(i.id,t),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 ie(c[l].id);r.push(d)}}return r}))}class ve{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ge=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Ce{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new ve(e.id,e,null,null);new ve(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return ge(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isLocalDataLoaded)return e("done");setTimeout(Ce.checkFlag,1e3,e)}static getNodeFromTree(e){return ge(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return ge(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Ce.root=null;var me=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Ne{static waitForDataToLoad(){return me(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isLocalCharacterLoaded)return e("done");setTimeout(Ne.checkFlag,1e3,e)}static addNodeToTree(e){return me(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new ve(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return me(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}Ne.LocalCharacterRoot=null;var Te=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class we{static addNodeToTree(e){return Te(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new ve(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return Te(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isLocalTypeLoaded)return e("done");setTimeout(we.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Te(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}we.LocalTypeRoot=null;class Ie{constructor(e,t,n,o,i,r,c,a=!1,s,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=a,this.typeCharacter=c,this.entryTimeStamp=s,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function ke(){let e=new Date,t=new Date;return new Ie(0,0,0,0,0,"0","0",!1,e,t,0)}var Ae=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class xe{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(Ce.addConceptToTree(e),Ne.addConceptToTree(e),we.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Ce.addConceptToTree(e),Ne.addConceptToTree(e),we.addConceptToTree(e))}static GetConcept(e){return Ae(this,void 0,void 0,(function*(){var t=ke(),n=yield Ce.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return Ae(this,void 0,void 0,(function*(){var t=ke(),n=Ne.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Ae(this,void 0,void 0,(function*(){var n=ke(),o=yield Ne.getCharacterAndTypeFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return Ae(this,void 0,void 0,(function*(){let n=[];return n=yield we.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}xe.localconceptsArray=[];var Re=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Se{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),0!=e.id||e.isTemp,this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return Re(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isLocalConnectionLoaded)return e("done");setTimeout(Se.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return Re(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}Se.connectionArray=[],Se.connectionDictionary=[];var _e=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Le(e){return _e(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield xe.GetConcept(e),s=yield Ue(e,o,r);return i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=s,i}))}function Ge(e){return _e(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield xe.GetConcept(e);if(0!=a.id){var s=yield Ue(e,o,r);i[null!==(n=null===(t=null==a?void 0:a.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=s;var l={}}return l.data=i,l.id=e,l}))}function Ue(e,t,n){return _e(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,a={},s=[],l=yield xe.GetConcept(e);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield xe.GetConcept(d);l.type=u}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield xe.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield xe.GetConcept(d),y.type=u);var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ue(f,t,n);a[p]=e}}else{const e=yield Ue(f,t,n);s[p]=e,a=s}}return a}))}var Fe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ve(e){return Fe(this,void 0,void 0,(function*(){return yield xe.GetConceptByCharacter(e)}))}var Pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Be(e,t){return Pe(this,void 0,void 0,(function*(){var n=yield Ve(e),o=[];if(n)for(var i=yield xe.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Le(i[r].id);o.push(c)}return o}))}function De(e,t){return Pe(this,void 0,void 0,(function*(){var n=yield Ve(e),o=[];if(n)for(var i=yield xe.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Ge(i[r].id);o.push(c)}return o}))}var Ee=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Oe{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(){return Ee(this,void 0,void 0,(function*(){try{for(let e=0;e<this.conceptsSyncArray.length;e++)N.AddConcept(this.conceptsSyncArray[e]);for(let e=0;e<this.connectionSyncArray.length;e++)E.AddConnection(this.connectionSyncArray[e]);if(this.conceptsSyncArray.length>0){let e=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],function(e){var t,n,o,i;t=this,n=void 0,i=function*(){let t=p();try{var n=A();const o=yield fetch(I.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(!o.ok)throw S(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{s(i.next(e))}catch(e){r(e)}}function a(e){try{s(i.throw(e))}catch(e){r(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,a)}s((i=i.apply(t,n||[])).next())}))}(e)}if(this.connectionSyncArray.length>0){let e=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(e){return t=this,n=void 0,i=function*(){let t=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(e);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),S(i)),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{s(i.next(e))}catch(e){r(e)}}function a(e){try{s(i.throw(e))}catch(e){r(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,a)}s((i=i.apply(t,n||[])).next())}));var t,n,o,i}(e)}return"done"}catch(e){throw e}}))}static syncDataLocalDb(){return Ee(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e];this.connectionSyncArray=[]}return"done"}))}}function be(e,t,n,o,i,r,c){var a=new G(0,e,n,t,o,t,i,t,1,t,0,t,4,t,r,c);return e==n?(a.ofTheConceptId=0,a.toTheConceptId=1,a):(a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Oe.AddConnection(a),a)}Oe.conceptsSyncArray=[],Oe.connectionSyncArray=[];var He=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Me=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const je=new Map;function We(e,t){return Me(this,void 0,void 0,(function*(){let n=yield N.GetConceptByCharacterAndTypeLocal(e,t),o=e+t;if(je.has(o))return je.get(o)||n;const i=(()=>Me(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var i={character_value:`${e}`,type_id:t},r=JSON.stringify(i),c=A();const o=yield fetch(I.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});if(o.ok){let e=yield o.json();n=e,N.AddConcept(n)}else console.log("This is the concept by type and character error",o.status),S(o)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{je.delete(o)}})))();return je.set(o,i),i}))}class $e{constructor(e,t,n,o,i,r,c,a,s,l){this.id=0,this.userId=e,this.data=t,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var Je=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};let Qe=!1,Ke=[];const qe=()=>{Ke.length>0&&!Qe&&Ke.shift()()};var ze=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};let Ye=!1,Xe=[];const Ze=()=>{Xe.length>0&&!Ye&&Xe.shift()()};var et=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class tt{static getId(){return et(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return ze(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{console.log("trying to fetch more concepts"),Xe.push((()=>ze(this,void 0,void 0,(function*(){try{if(Ye)return;if(Ye=!0,tt.ids.length>10)return console.log("Enough IDs available, skipping fetch."),Ye=!1,Ze(),e();var n=A("application/x-www-form-urlencoded");const t=yield fetch(I.GetReservedIdUrl(),{method:"GET",headers:n});if(!t.ok)throw S(t),new Error(`Error! status: ${t.status}`);const i=yield t.json();for(var o=0;o<i.length;o++)tt.AddId(i[o]);console.log("Ids Fetch Success"),e()}catch(e){e instanceof Error?console.log("get reserved ids error message: ",e.message,I.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",e),t(e)}finally{Ye=!1,Ze()}})))),Ze()}))}))}());var e=this.ids[0];return this.ids.shift(),e}))}static AddId(e){this.ids.includes(e)||this.ids.push(e)}}tt.ids=[];class nt{static getId(){return et(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return Je(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{Ke.push((()=>Je(this,void 0,void 0,(function*(){try{if(Qe)return;if(Qe=!0,nt.connectionIds.length>10)return Qe=!1,qe(),e();var n=A("application/x-www-form-urlencoded");const t=yield fetch(I.GetReservedConnectionIdUrl(),{method:"GET",headers:n});if(!t.ok)throw S(t),new Error(`Error! status: ${t.status}`);const i=yield t.json();for(var o=0;o<i.length;o++)nt.AddId(i[o]);e()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),t(e)}finally{Qe=!1,qe()}})))),qe()}))}))}());var e=this.connectionIds[0];return this.connectionIds.shift(),e}))}static AddId(e){this.connectionIds.includes(e)||this.connectionIds.push(e)}}nt.connectionIds=[];var ot=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function it(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return ot(this,void 0,void 0,(function*(){var p=yield tt.getId();let v=new Date,g=new Date;var C=new y(p,t,i,r,n,o,c,a,e,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,Oe.AddConcept(C),C}))}function rt(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return ot(this,void 0,void 0,(function*(){var p=yield tt.getId();let v=new Date,g=new Date;var C=new y(p,t,i,r,n,o,c,a,e,s,l,d,u,h,f,!1,v,g);return N.AddConcept(C),C.updateRecursion=!0,Oe.AddConcept(C),C}))}var ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function at(e,t){return ct(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){let a,s=r,l=999,d=o,u=o,h=i,f=o,y="",v=t.length,g=p();y=e.startsWith("the_")?e:"the_"+e;(new Date).getTime();if(n)g=yield cn(e),a=yield it(t,o,4,o,g.id,g.userId,c,999,l,d,h,f,s,u),(new Date).getTime();else if(v>255)g=yield cn(y),a=yield it(t,o,4,o,g.id,g.userId,c,999,l,d,h,f,s,u),function(e){He(this,void 0,void 0,(function*(){try{var t=A();const n=yield fetch(I.CreateTheTextDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw S(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("Create the text error message: ",e.message):console.log("Create the text unexpected error: ",e),e}}))}(new $e(o,t,l,d,h,f,s,u,Date.now().toString(),!0)),(new Date).getTime();else{g=yield cn(y);let e=yield We(t,g.id);a=e,0==e.id&&0==e.userId&&(a=yield rt(t,o,4,o,g.id,g.userId,12,12,l,d,h,f,s,u)),(new Date).getTime()}return a.type=g,a}))}var st=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function lt(e){return st(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=p();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=v=yield at(o,"",!0,a,s,l),h=v.id,d=v.id,yield lt(e[o],v.id,v.userId,h,i,r,c)}else{var f=null!=t?t:999,y=null!=n?n:999;h=d,u=v=yield at(o,"",!0,a,s,l),yield be(f,y,v.id,v.userId,h,l,v.userId),yield lt(e[o],v.id,v.userId,h,i,r,c)}else{f=null!=t?t:999,y=null!=n?n:10267,h=d;var v=yield at(o,e[o].toString(),!1,a,s,l);yield be(f,y,v.id,v.userId,h,l,v.userId)}return u}))}class dt{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=ke(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=o,this.ghostId=e,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function ut(e,t,n,o=1){Math.floor(1e8*Math.random());let i=0,r=0,c=0;i=e,r=t,c=n;let a=new dt(0,0,0,0,0,0);return e!=t&&(a=new dt(0,e,t,n,o,4),a.isTemp=!0,a.id=Math.floor(1e8*Math.random()),Se.AddConnection(a)),a}var ht=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ft(e,t,n,o,i,r){return ht(this,arguments,void 0,(function*(e,t,n,o,i,r,c=0){var a=Math.floor(1e8*Math.random());let s=new Date,l=new Date;var d=new Ie(a,n,i,o,r,e,t,!0,s,l,c);return d.isTemp=!0,xe.AddConcept(d),d}))}var yt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},pt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function vt(e,t,n,o){return pt(this,void 0,void 0,(function*(){var i=yield Ve(e);if(i&&(0==i.id||0==i.userId)){var r=w(e);if(r[0]==e){var c=yield function(e,t,n){return yt(this,void 0,void 0,(function*(){var t=yield xe.GetConceptByCharacterAndTypeLocal(e,51),o=t;return 0==o.id&&(o=t=yield ft(e,"the",n,4,51,4)),o}))}(e,0,o);i=c}else{var a=yield vt(r[0],t,n,o),s=yield vt(r[1],t,n,o);s&&(i=c=yield ft(e,r[1],o,a.id,s.id,4))}}return i}))}var gt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ct(e,t){return gt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){var a,s,l,d=o,u=t.length;if(l=e.startsWith("the_")?e:"the_"+e,n)a=yield vt(e,999,o,o),s=yield ft(t,e,o,4,a.id,4,c);else if(u>255)a=yield vt(l,999,d,o),s=yield ft(t,l,o,4,a.id,4);else{a=yield vt(l,999,d,o);var h=yield xe.GetConceptByCharacterAndTypeLocal(t,a.id);s=h,0==h.id&&0==h.userId&&(s=yield ft(t,l,o,4,a.id,4))}return s.type=a,s}))}var mt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Nt(e){return mt(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:999,l=null!=c?c:4,d=null!=o?o:0,u=ke();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=y=yield Ct(o,"",!0,a,s,l),h=y.id,d=y.id,yield Nt(e[o],y.id,y.userId,h,i,r,c)}else{var f=null!=t?t:999,y=(h=d,yield Ct(o,"",!0,a,s,l));yield ut(f,y.id,h),yield Nt(e[o],y.id,y.userId,h,i,r,c)}else f=null!=t?t:999,h=d,y=yield Ct(o,e[o].toString(),!1,a,s,l),yield ut(f,y.id,h);return u}))}var Tt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function wt(e,t,n){return Tt(this,arguments,void 0,(function*(e,t,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("ofTheConceptId",`${t}`),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),S(s)),r}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var It=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function kt(e,t,n,o,i,r,c){return It(this,arguments,void 0,(function*(e,t,n,o,i,r,c,a=1,s=4,l=999){let d=t,u=t,h=t;999!=l&&(h=l);let f=t,y=t,p=yield nt.getId(),v=new G(p,e,n,t,o,h,i,u,a,d,0,f,s,y,r,c);return e==n?(v.ofTheConceptId=0,v.toTheConceptId=1,v):(v.toUpdate=!0,v.isTemp=!1,Oe.AddConnection(v),v)}))}function At(e,t,n){return It(this,void 0,void 0,(function*(){let o=yield cn(n),i=e.userId;return yield kt(e.id,e.userId,t.id,t.userId,o.id,999,999,1e3,4,i)}))}var xt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Rt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},St=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function _t(e){return St(this,void 0,void 0,(function*(){var t=yield E.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return Rt(this,void 0,void 0,(function*(){var t=yield E.GetConnection(e);try{if(0!=t.id)return t;{var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return o.ok?(t=yield o.json(),E.AddConnection(t)):(console.log("Get Connection Error",o.status),S(o)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var Lt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Gt(e){return Lt(this,arguments,void 0,(function*(e,t=""){let n=!1;var o=yield _t(e);return n=yield function(e){return xt(this,arguments,void 0,(function*(e,t=""){let n=!1;try{const o=new FormData;let i=A("application/x-www-form-urlencoded");""!=t&&(i=x("application/x-www-form-urlencoded",t)),o.append("id",e.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),S(r))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),V.removeNodeFromTree(e),B.removeTypeConcept(o.typeId,e),n}))}var Ut=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ft(e){return Ut(this,arguments,void 0,(function*(e,t=999){var n=p();if(e<0)return Po(yield xo(t,e));if(null!=(n=yield N.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield z(e)),0!=n.id&&null==n.type&&null==(yield N.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield z(n.typeId);n.type=o}return n}))}var Vt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Pt(e,t,n){return Vt(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Bt(o,t,a));var d=yield at("connection",c,!1,999,999,999);let u=new G(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);Oe.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield Bt(u,e,a));var f=yield at("connection",h,!1,999,999,999);let y=new G(0,e.id,t.id,e.userId,t.userId,e.userId,f.id,f.userId,1e3,a,999,s,4,l,999,999);return Oe.AddConnection(y),y}))}function Bt(e,t){return Vt(this,arguments,void 0,(function*(e,t,n=null){for(var o,i=t,r=null!=n?n:t.userId,c=r,a=r,s=999,l=e+"_count",d=(null===(o=t.type)||void 0===o?void 0:o.characterValue)+"_s_"+l,u=yield at("connection",d,!1,r,4,s),h=yield wt(u.id,t.id,r,10,1),f=[],y=p(),v=0;v<h.length;v++){let e=yield Ft(h[v].toTheConceptId);f.push(e)}if(f.length<1)y=yield at("count","1",!1,r,4,s);else{var g=f[0];let e=0;try{e=Number(g.characterValue)}catch(t){e=0}e+=1,y=yield at("count",e.toString(),!1,r,4,s);for(let e=0;e<h.length;e++)Gt(h[e].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 Oe.AddConnection(C)}))}function Dt(e,t,n){return Vt(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,a=e.userId,s=a,l=a;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Bt(o,t,a));var d=yield at("connection",c,!1,999,999,999);let u=new G(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,a,999,s,4,l,999,999);Oe.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield Bt(u,e,a));var f=yield at("connection",h,!1,999,999,999);return yield kt(e.id,e.userId,t.id,t.userId,f.id,999,999,1e3,4)}))}var Et=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ot(e,t){return Et(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ft(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,s=yield We(a,16);if(s.id>0){for(var l=yield wt(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 e=l[u].toTheConceptId,t=yield Ft(e),n=yield re(t.id);r.push(n)}}return r}))}function bt(e,t){return Et(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Ft(e),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,s=yield We(a,16);if(s.id>0){for(var l=yield wt(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield Ft(e);r.push(t)}}return r}))}class Ht{constructor(e,t,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class Mt{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new Ht(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}Mt.characterData=[];class jt{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var Wt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},$t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Jt(e,t,n,o,i){return $t(this,void 0,void 0,(function*(){return new Ht(t,e,n,t,o,t,i,t,"",!1),yield function(){return Wt(this,void 0,void 0,(function*(){var e;try{if(0==(e=Mt.GetCharacter(e.data)).id){var t=A();const o=yield fetch(I.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw S(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();var n=new Ht(i.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=i.id,Mt.AddCharacter(n),i}return new jt(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var Qt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Kt(e,t,n,o,i,r,c,a,s,l,d,u,h,f){return Qt(this,void 0,void 0,(function*(){var y=yield We(e,i),p=y;return 0==p.id&&(p=y=yield it(e,t,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var qt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},zt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Yt(e,t,n,o){return zt(this,void 0,void 0,(function*(){var i=yield he(e);if(i&&(0==i.id||0==i.userId)){var r=w(e);if(r.length>0)if(console.log(r),r[0]==e){var c=yield function(e,t,n,o,i,r){return qt(this,void 0,void 0,(function*(){var i,c=t,a=t;i=t;var s,l=t,d=t,u=t;if(1==e.length){var h=e.charCodeAt(0);yield Jt(e,t,n,o,r),s=Kt(e,t,4,c,h,u,49,l,n,a,o,i,r,d)}else{var f=yield Jt(e,t,n,o,r);f.isNew,s=yield Kt(e,t,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(e,o,999,999,0,t);i=c}else{var a=yield Yt(r[0],t,n,o),s=yield Yt(r[1],t,n,o);s&&(i=yield rt(e,o,a.id,o,s.id,o,999,o,999,o,999,o,t,o))}}return i}))}var Xt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const Zt=new Map;function en(e,t){return Xt(this,void 0,void 0,(function*(){let n=p();if(Zt.has(e+t))return Zt.get(e+t)||n;const o=(()=>Xt(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=${e}&category_id=${t}`});if(i.ok){let e=yield i.json();n=e,N.AddConcept(n)}else console.log("This is the concept by category and character direct api error",i.status),S(i);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,e,t,I.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,I.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{Zt.delete(e+t)}})))();return Zt.set(e+t,o),o}))}var tn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function nn(e){return tn(this,void 0,void 0,(function*(){let t=p();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=w(e);if(o.length>1){let n=1,i=yield nn(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return tn(this,void 0,void 0,(function*(){let n=yield N.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield en(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return tn(this,void 0,void 0,(function*(){console.log("inside the character length function",e);var t=yield N.GetConceptByCharacterAndTypeLocal(e,49);return console.log("inside the character length function after",t),0==t.id&&(t=yield de(e)),t}))}(e):o[0]==e&&(t=yield function(e){return tn(this,void 0,void 0,(function*(){var t=yield N.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield de(e)),t}))}(e));return t}))}var on=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const rn=new Map;function cn(e,t){return on(this,void 0,void 0,(function*(){let t=p();if(rn.has(e))return rn.get(e)||t;const n=(()=>on(this,void 0,void 0,(function*(){try{if(t=yield nn(e),0==t.id||4==t.typeId){var n=A("application/x-www-form-urlencoded");const o=yield fetch(I.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!o.ok)throw S(o),new Error(`Error! status: ${o.status}`);let i=yield o.json();t=i,t.id>0&&N.AddConcept(t)}return t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{rn.delete(e)}})))();return rn.set(e,n),n}))}var an=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function sn(e){return an(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(r.ok){const e=yield r.json();for(var o=0;o<e.length;o++){var i=e[o];t.push(i)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),S(r);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var ln=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function dn(e){return ln(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=A("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(r.ok){const e=yield r.json();for(var o=0;o<e.length;o++){var i=e[o];t.push(i)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),S(r);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var un=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function hn(e){return un(this,void 0,void 0,(function*(){for(var t=yield sn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ft(o);e.type=i}return t}))}function fn(e){return un(this,void 0,void 0,(function*(){for(var t=yield dn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Ft(o);e.type=i}return t}))}var yn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},pn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function vn(e){return pn(this,arguments,void 0,(function*(e,t=""){var n=yield Ft(e);yield f.removeNodeFromTree(e);var o=n.typeId,i=n.characterValue;yield C.removeTypeConcept(o,e),yield u.removeNodeByCharacter(i,e),function(e){yn(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let o=A("application/x-www-form-urlencoded");""!=t&&(o=x("application/x-www-form-urlencoded",t));const i=new FormData;i.append("id",e.toString());const r=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:i});if(!r.ok)throw S(r),new Error(`Error! status: ${r.status}`);n=(yield r.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t)}))}var gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Cn(e,t){return gn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const o=new FormData;o.append("id",e.toString());const i=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:o,headers:n});if(!i.ok)throw S(i),new Error(`Delete composition Error! status: ${i.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Nn(e,t,n,o){return mn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,a=n,s=n,l=e.startsWith("the_"),d=p();return r=l?e:"the_"+e,d=yield cn(r),yield Kt(t,n,4,n,d.id,d.userId,0,999,999,c,4,s,999,a)}))}class Tn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var wn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function In(){return wn(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield E.GetConnection(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=A();const e=yield fetch(I.GetConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let o=n[e];t.push(o),E.AddConnection(o)}yield M(t)}}else console.log("Get Connection Bulk error",e.status),S(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var kn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function An(){return kn(this,arguments,void 0,(function*(e=[]){yield Q(e);var t=[];for(let o=0;o<e.length;o++){var n=yield oe(e[o]);t.push(n)}return t}))}function xn(){return kn(this,arguments,void 0,(function*(e=[]){yield Q(e);var t=[];for(let o=0;o<e.length;o++){var n=yield ie(e[o]);t.push(n)}return t}))}function Rn(){return kn(this,arguments,void 0,(function*(e=[],t=[]){yield In(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||E.RemoveConnection(t[n])}(t,yield W(e));var n=[];for(let t=0;t<e.length;t++){var o=yield ie(e[t]);n.push(o)}return n}))}function Sn(){return kn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],o={};for(let o=0;o<(null==e?void 0:e.length);o++){let i=yield E.GetConnection(e[o]);0==i.id?t.push(e[o]):n.push(i)}for(let n=0;n<t.length;n++)o[e[n]]=!1;let i=[],r=yield In(t);n=[...n,...r];for(let e=0;e<n.length;e++)i.push(n[e].ofTheConceptId),i.push(n[e].toTheConceptId),i.push(n[e].typeId);return yield b(i),n}))}function _n(){return kn(this,arguments,void 0,(function*(e=[],t=[]){let n=[];for(let e=0;e<t.length;e++)0==(yield E.GetConnection(t[e])).id&&n.push(t[e]);yield In(n);var o={};for(let t=0;t<e.length;t++){var i=yield ie(e[t]);o[e[t]]=i}return o}))}var Ln=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Gn(){return Ln(this,arguments,void 0,(function*(e=0,t=[],n=""){var o=[];try{var i=new Tn;i.composition=e,i.listLinkers=t,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 e=yield l.json();var a=e.compositionIds,s=e.internalConnections;e.externalConnections,o=yield Rn(a,s)}else console.log("recursive search error ",l.status),S(l);return o}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var Un=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Fn(e,t){return Un(this,void 0,void 0,(function*(){try{var n={email:e,password:t},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 e=yield r.json();return k.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",r.status),S(r)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var Vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Pn(e){return Vn(this,void 0,void 0,(function*(){const t=yield function(){return Vn(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:S(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(I.SignupUrl(),e);return t}))}var Bn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Dn(e){return Bn(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const o=new Headers;o.append("Content-Type","application/json");const i=I.LoginUrl();try{const e=yield fetch(i,{method:"POST",headers:o,body:t,redirect:"follow"}),r=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==r?void 0:r.data}:S(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function En(e,t){return-1===e.indexOf(t)&&e.push(t),e}function On(e=[],t){var n,o;let i=[],r=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(o=e[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&r!=c||i.push(e[n])}return i}function bn(e=[],t){let n=[],o=t.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(e))for(let i=0;i<e.length;i++){let r=e[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),t.typeId!=e[i].typeId&&o!=r||n.push(e[i])}return n}function Hn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function Mn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function jn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function Wn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class $n{constructor(e,t,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(Qn.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Jn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Qn{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new $n(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return Jn(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return Jn(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Qn.root=null;var Kn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function qn(e,t,n,o){return Kn(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let a={};const s=[];if(0==e)return"";let l=zn(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Ft(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=zn(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Ft(e),l.type=t)}if(!o.includes(e))return null==l?void 0:l.characterValue;if(i.includes(e))return"";i.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const d=t[l].toTheConceptId;if(o.includes(e)){let e=zn(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield Ft(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield N.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Ft(t),e.type=n)}const l="the_",u=(null!==(c=null===(r=null==e?void 0:e.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const e=yield qn(d,t,n,o,i);a[u]=e}}else{const e=yield qn(d,t,n,o,i);s[u]=e,a=s}}}return a}))}function zn(e,t){let n=p();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class Yn{constructor(){this.id=0,this.mainConcept=p(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,o=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield qn(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}));var e,t,n,o}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),I.MQTT_CONNECTION&&I.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const o={};o[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Xn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Zn(e){return Xn(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=p();null==a&&(a=new Yn);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield at(o,"",!0,s,l,d);if(null==t&&null==n){let t=u;h=f,t=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield Zn(e[o],f.id,f.userId,t,i,r,c,a)}else{const s=null!=t?t:999,l=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield be(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield Zn(e[o],f.id,f.userId,y,i,r,c,a)}null!=e[o]&&null!=e[o]&&a.subcompositions.push(f.id)}else{const i=null!=t?t:999,r=null!=n?n:999,c=u,h=yield at(o,e[o],!1,s,l,d);a.concepts.push(h);const f=yield be(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function to(e){return eo(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=p(),a=p();const s=[];let l=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(l<0){let e=yield Ft(l,t);if(!(e.id>0))return null;l=e.id}i=yield X(l);const h=[],f=new Yn,y=[];f.id=l,f.isUpdating();let v=[];for(let e=0;e<i.length;e++)En(y,i[e].ofTheConceptId),En(h,i[e].ofTheConceptId),En(h,i[e].toTheConceptId),v.push(i[e].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let e=0;e<h.length;e++){const t=yield Ft(h[e]);l==h[e]&&(c=t),d==h[e]&&(a=t),r.push(t)}const g=e.patchObject;for(const e in g){let i=p();const l=g[e];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield at(e,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const t=On(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=Hn(f.connections,t[e].id);u=u.concat(n),s.push(t[e])}yield Zn(g[e],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield at(e,l,!1,t,o,n);const c=On(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=Hn(f.connections,c[e].id);u=u.concat(t),s.push(c[e])}}const h=be(d.id,d.userId,i.id,i.userId,c.id,n,t);r.push(i),f.connections.push(h)}for(let e=0;e<u.length;e++)Wn(f.connections,u[e]),Gt(u[e].id);for(let e=0;e<s.length;e++)jn(r,s[e]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),Qn.addCompositionToTree(f),Oe.SyncDataOnline(),f.GetDataCache()}))}var no=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function oo(e,t,n,o){return no(this,arguments,void 0,(function*(e,t,n,o,i=10,r=1){var c=x("application/x-www-form-urlencoded",o),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",n),a.append("inpage",i.toString()),a.append("page",r.toString());const s=I.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield fetch(s,{method:"GET",headers:c});return e.ok?yield e.json():(S(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var io=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ro(e){return io(this,arguments,void 0,(function*(e,t=""){var n=x("application/json",t);const o=I.SearchLinkMultipleAll(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(console.log("This is the searching error",e.status),S(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var co=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ao(e){return co(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},a={};const s=yield Qn.getNodeFromTree(e),l=[];let d=yield N.GetConcept(e);if(0==d.id&&null!=e&&null!=e&&(d=yield z(e)),null==s){let s=[];s=t.length>0?so(e,t):yield X(e),i=s;for(let e=0;e<i.length;e++)l.includes(i[e].ofTheConceptId)||(l.push(i[e].ofTheConceptId),r.push(i[e].ofTheConceptId)),r.includes(i[e].toTheConceptId)||r.push(i[e].toTheConceptId);ho(d,i,r,l);let u=[];a=yield ae(e,i,l,u),c[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a}else a=s.value.GetDataCache(),c=a;return 0==d.id?"":c}))}function so(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function lo(e){return co(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=yield Qn.getNodeFromTree(e),d=[];let u=yield N.GetConcept(e);if(0==u.id&&null!=e&&null!=e&&(u=yield z(e)),null==l){let l=[];l=t.length>0?so(e,t):yield X(e),r=l;for(let e=0;e<r.length;e++)d.includes(r[e].ofTheConceptId)||(d.push(r[e].ofTheConceptId),c.push(r[e].ofTheConceptId)),c.includes(r[e].toTheConceptId)||c.push(r[e].toTheConceptId);ho(u,r,c,d),a=yield ae(e,r,d),s[null!==(o=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=u.entryTimeStamp,i.data=s,i.id=e}else a=l.value.GetDataCache(),i=a;return 0==u.id?"":i}))}function uo(e,t){return co(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield In(t);for(let t=0;t<e.length;t++){const i=yield lo(e[t],n);i&&o.push(i)}return o}))}function ho(e,t,n,o){return co(this,void 0,void 0,(function*(){const i=new Yn,r=yield function(e){return co(this,void 0,void 0,(function*(){let t=[];const n=[];for(let o=0;o<(null==e?void 0:e.length);o++){const i=yield N.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}return 0==(null==n?void 0:n.length)||(t=yield function(e){return O(this,void 0,void 0,(function*(){const t=[];if(e.length>0){const n={"Content-Type":"application/json"};try{const o=yield fetch(I.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){const e=yield o.json();if(e.length>0)for(let n=0;n<e.length;n++){const o=e[n];t.push(o),N.AddConcept(o)}}else S(o)}catch(e){throw e instanceof Error?console.log("bulk concept getter api error: ",e.message):console.log("bulk concept getter api error: ",e),e}}return t}))}(n)),t}))}(n);i.connections=t,i.concepts=r,i.id=e.id,i.subcompositions=o,i.mainConcept=e;const c=yield qn(e.id,t,r,o,[]);i.cached=c,Qn.addCompositionToTree(i)}))}var fo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function yo(e){return fo(this,void 0,void 0,(function*(){try{var t=A();const n=JSON.stringify(e),o=yield fetch(I.CreateSessionId(),{method:"POST",headers:t,body:n});return o.ok?o.json():(console.log("Creating session failed",yield o.json()),S(o),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function vo(e,t){return po(this,void 0,void 0,(function*(){try{var n=A("application/x-www-form-urlencoded");const o=new URLSearchParams;o.append("sessionId",e.toString()),o.append("url",t);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()),S(i),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Co(e,t,n){return go(this,arguments,void 0,(function*(e,t,n,o=10,i=1){let r=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("toTheConceptId",`${t}`),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),S(s)),r}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var mo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function No(e,t){return mo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ft(e),a=yield nn(t);if(a.id>0){let e=[],t=[];if(i){t=yield Co(a.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield Q(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield Ft(n),i=yield re(o.id);r.push(i)}}else{t=yield wt(a.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield Q(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield Ft(n),i=yield re(o.id);r.push(i)}}}return r}))}function To(e,t){return mo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Ft(e),a=yield nn(t),s=[],l=[];if(a.id>0){if(i){s=yield Co(a.id,c.id,c.userId,n,o);for(let e=0;e<s.length;e++)l.push(s[e].ofTheConceptId)}else{s=yield wt(a.id,c.id,c.userId,n,o);for(let e=0;e<s.length;e++)l.push(s[e].toTheConceptId)}r=yield b(l)}return r}))}class wo{constructor(e,t,n,o,i){this.connectionValue=[],this.value=[],this.height=1,this.key=e,t.id>0&&this.value.push(t),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=i}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t.value.push(...e.value),t.connectionValue.push(...e.connectionValue),t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.rightNode=this.removeNode(e.rightNode,n.key),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Io=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class ko{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return Io(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(s.isDataLoaded)return e("done");setTimeout(ko.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=new dt(0,0,0,0,0,0);var r=new wo(o,e,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=ke();var r=new wo(o,i,e,null,null);this.addNodeToTree(r)}static getNodeFromTree(e,t){return Io(this,arguments,void 0,(function*(e,t,n=999){let o=this.compositeKey(e,t,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(e){return Io(this,arguments,void 0,(function*(e,t=999,n=999){if(this.root){let o=this.compositeKey(e,t,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}ko.root=null;var Ao=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function xo(e,t){return Ao(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield ko.getNodeFromTree(e,n,o),r=ke();if(i)for(let e=0;e<i.value.length;e++){let n=i.value[e];n.ghostId==t&&(r=n)}return r}))}function Ro(e,t){return Ao(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield ko.getNodeFromTree(e,n,o),r=new dt(0,0,0,0,0,0);if(i)for(let e=0;e<i.connectionValue.length;e++){let n=i.connectionValue[e];n.ghostId==t&&(r=n)}return r}))}function So(e,t){return Ao(this,arguments,void 0,(function*(e,t,n=999){ko.addConceptToTree(e,t,n)}))}function _o(e,t){return Ao(this,arguments,void 0,(function*(e,t,n=999){ko.addConnectionToTree(e,t,n)}))}var Lo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Uo(e){return Go(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield function(e){return Lo(this,arguments,void 0,(function*(e,t=""){var n=x("application/json",t);const o=I.SearchLinkMultipleAllApiUrl(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(console.log("This is the searching multiple error",e.status),S(e),[])}catch(e){throw console.log("This is the searching multiple error",e),e}}))}(e,t),i=e[0].composition;const r=o;let c=r.compositionIds,a=r.internalConnections,s=r.linkers,l=r.reverse;return n=yield _n(c,a),yield Fo(s,n,i,l)}))}function Fo(e,t,n){return Go(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield In(e);for(let e=0;e<r.length;e++){let n=!1;if(o.includes(r[e].id)&&(n=!0),1==n){if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].toTheConceptId],o=yield Ft(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(t[r[e].ofTheConceptId])}catch(e){console.log("this is error",e)}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield Ft(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(t[r[e].toTheConceptId])}catch(e){console.log("this is error",e)}}}return i=t[n],i}))}function Vo(e){var t,n;const o=ke();return o.id=e.id,o.ghostId=e.ghostId,o.userId=e.userId,o.accessId=e.accessId,o.categoryId=e.categoryId,o.characterValue=e.characterValue,o.entryTimeStamp=e.entryTimeStamp,o.typeId=e.typeId,o.type=e.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"",o}function Po(e){const t=p();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}function Bo(e){const t=new dt(0,0,0,0,0,0);return t.id=e.id,t.ghostId=e.ghostId,t.accessId=e.accessId,t.ofTheConceptId=e.ofTheConceptId,t.toTheConceptId=e.toTheConceptId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.isTemp=!1,t}var Do=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Eo(e){return Do(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=ke(),a=ke();const s=[],l=e.compositionId,d=e.ofTheCompositionId;let u=[],h=yield X(l);for(let e=0;e<h.length;e++)i.push(Bo(h[e]));const f=[],y=[];let p=[];for(let e=0;e<i.length;e++)En(y,i[e].ofTheConceptId),En(f,i[e].ofTheConceptId),En(f,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);for(let e=0;e<f.length;e++){const t=yield Ft(f[e]);l==f[e]&&(c=Vo(t)),d==f[e]&&(a=Vo(t)),r.push(Vo(t))}const v=e.patchObject;for(const e in v){let l=ke();const d=v[e];let h=c;a.id>0&&(h=a),Array.isArray(d)||"object"==typeof d?(l=yield Ct(e,"",!0,c.userId,4,999),yield Nt(v[e],l.id,l.userId,c.id,c.userId,4,999)):l=yield Ct(e,d,!1,t,o,n);const f=bn(r,l);for(let e=0;e<f.length;e++)if(f[e].id>0){const t=Mn(i,f[e].id);u=u.concat(t),s.push(f[e])}yield ut(h.id,l.id,c.id,2),r.push(l)}for(let e=0;e<u.length;e++)Gt(u[e].id);Oe.SyncDataOnline()}))}var Oo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},bo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ho(e){return bo(this,void 0,void 0,(function*(){var t;let n=yield function(e){return Oo(this,void 0,void 0,(function*(){let t=[];try{var n=A();const o=yield fetch(I.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){let e=yield o.json(),n={};for(let o=0;o<e.length;o++){let i=e[o].concepts;t=e[o].connections;let r=e[o].id;b(i),n[r]=t}return n}return console.log("View Internal Data error",o.status),S(o),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),o=[];for(let i=0;i<e.length;i++){let r=e[i],c=n[r];if(r&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield ae(r,c,e);t.data=n,t.id=r,o.push(t)}else{let e={};e.id=r;let n=yield Ft(r),i={};n.type&&(i[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=i,o.push(e))}}return o}))}var Mo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},jo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Wo(e){return jo(this,arguments,void 0,(function*(e,t=""){var n=yield function(e){return Mo(this,arguments,void 0,(function*(e,t=""){var n=x("application/json",t);let o=I.SearchInternalWithAuthenticatedCcsUrl();o=o+"?composition="+e.composition+"&search="+e.search+"&internalComposition="+e.internalComposition+"&type="+e.type+"&inpage="+e.inpage+"&page="+e.page;try{const e=yield fetch(o,{method:"GET",headers:n});return e.ok?yield e.json():(console.log("This is the searching internal error",e.status),S(e),[])}catch(e){throw console.log("This is the searching internal error",e),e}}))}(e,t);return yield Ho(n)}))}class $o{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Jo{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 Qo{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Ko{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var qo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},Yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};class Xo{}Xo.isUpdated=!1,Xo.isOnlineSync=!1;var Zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var ei=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};const ti=1,ni=2,oi=3,ii=4,ri=5,ci=6,ai=7;class si{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var li=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function di(e){return li(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield z(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]=e[n]}return t}))}function ui(e){const t=e.split("_");if(3===t.length){let e=new si;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function hi(e){return e.startsWith("the_")?e.slice(4):e}var fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},yi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function pi(e,t,n){return yi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ft(e[u].ofTheConceptId),y=yield Ft(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[a]={},t[e[u].toTheConceptId]=n);let s=yield Ft(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;s.characterValue,s.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ft(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}var vi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function gi(e,t,n){if(e in t){let o=t[e];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}function Ci(e,t="DESC"){return console.log("this is the order",t),"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var mi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};var Ni=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function Ti(e,t){return Ni(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=ci;let n,o=yield function(e){return ei(this,arguments,void 0,(function*(e,t=""){var n=x("application/json",t);const o=I.FreeschemaQueryUrl(),i=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:i});return e.ok?yield e.json():(S(e),console.log("This is the freeschema query error",e.status),[])}catch(e){console.log("This is the freeschema query error others",e),function(e,t=""){if(e.status){let n=new R(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new R(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,o)}}))}(e,""),i=o.conceptIds,r=(o.internalConnections,o.linkers),c=o.reverse,a=o.mainCompositionIds,s=o.countinfo,l=e.order,d=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let o=ui(e[n]);t.push(o)}return t}(s);return n=t==ni?yield function(e,t,n,o,i){return mi(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Sn(e),a=yield di(i);c=Ci(c,r);let s=[];s=yield function(e,t){return fi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ft(e[u].ofTheConceptId),y=yield Ft(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ft(e[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[s]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ft(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}(c,s,o),s=yield function(e,t){return fi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ft(e[u].ofTheConceptId),y=yield Ft(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ft(e[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=hi(o));let i={id:f.id,data:{[e]:t}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ft(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=e,r=hi(r),c=!0);let a={id:y.id,data:{[e]:t}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(e){console.log("this is error",e)}}}return t}))}(c,s,o);let l=yield function(e,t,n,o){return fi(this,arguments,void 0,(function*(e,t,n,o,i=[],r){var c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let o=!1,r=yield Ft(e[n].ofTheConceptId),f=yield Ft(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=r.id&&0!=f.id&&f.id in t){let o,i=yield Ft(e[n].typeId),s=null!==(a=null===(c=f.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let c={id:r.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},a=i.characterValue+"_reverse";Array.isArray(o[s][a])?o[s][a].push(c):a.includes("_s_")?(o[s][a]=[],o[s][a].push(c)):o[s][a]=c}}catch(e){console.log("this is error",e)}}}else if(0!=r.id&&0!=f.id&&r.id in t){let o,i=yield Ft(e[n].typeId),c=null!==(l=null===(s=r.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o);let y=!0,p=i.characterValue;""==p&&(p=f.characterValue,y=!0),""==p&&(p=null!==(u=null===(d=null==f?void 0:f.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let r=t[e[n].toTheConceptId];if(r){let a={id:f.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(r):Array.isArray(o[c][p])?o[c][i.characterValue].push(a):p.includes("_s_")?(o[c][p]=[],o[c][p].push(a)):o[c][p]=a}}catch(e){console.log("this is error",e)}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e],n.data=t[o[e]],f.push(n)}return f}))}(c,s,[],n,o,a);return l}))}(r,i,a,c,d,l):t==oi?yield function(e,t,n,o,i){return mi(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Sn(e),a=yield di(i);c=Ci(c,r);let s=[];s=yield pi(c,s,o),s=yield function(e,t){return vi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield Ft(e[u].ofTheConceptId),y=yield Ft(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Ft(e[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=hi(o));let i={id:f.id,[e]:t},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Ft(e[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,a=!1;""==c&&(c=t,c=hi(c),a=!0);let s={};s[t]={id:y.id,data:r,created_on:e[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=a?s[t]:s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s[t]))}catch(e){console.log("this is error",e)}}}return t}))}(c,s,o);let l=yield function(e,t,n){return vi(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,y=yield Ft(e[n].ofTheConceptId),p=yield Ft(e[n].toTheConceptId);if(o.includes(e[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in t){let o,i=yield Ft(e[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let r=t[e[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(e){console.log("this is error",e)}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield Ft(e[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),gi(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",a=t[e[n].toTheConceptId];if(a){let t={};t[r]={data:a[r],id:p.id,created_on:e[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(t):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(t[r]):o[c][g].push(t)):o[c][g]=v?t[r]:t,gi(p.id,i,t)}}catch(e){console.log("this is error",e)}}}console.log("this is the main compositions",n);for(let e=0;e<n.length;e++){let o={};console.log("this is the main compositions DATA",t[n[e]]),o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,s,n,o,a);return l}))}(r,i,a,c,d,l):yield function(e,t,n,o){return mi(this,void 0,void 0,(function*(){let t=yield Sn(e);t=Ci(t);let i=[];i=yield pi(t,i,o),i=yield function(e,t,n){return yi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield Ft(e[u].ofTheConceptId),y=yield Ft(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);let s=yield Ft(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=hi(o));let i={[e]:t},l=o+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield Ft(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=e,r=hi(r),c=!0);let a={[e]:t};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?t:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){console.log("this is error",e)}}}return t}))}(t,i,o);let r=yield function(){return yi(this,arguments,void 0,(function*(e=[],t=[],n=[],o,i=[]){var r,c,a,s,l,d;let u=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let o=!1;i.includes(e[n].id)&&(o=!0);let u=yield Ft(e[n].ofTheConceptId),h=yield Ft(e[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in t){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?o=t[e[n].toTheConceptId]:(o={},o[i]={},t[e[n].toTheConceptId]=o);let a=yield Ft(e[n].typeId);try{let r=a.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(e){console.log("this is error",e)}}}else if(0!=u.id&&0!=h.id&&u.id in t){let o,i=null!==(s=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},t[e[n].ofTheConceptId]=o);let r=!1,c=(yield Ft(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let a=t[e[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(e){console.log("this is error",e)}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],u.push(o))}return u}))}(t,i,n,[],o);return r}))}(r,0,a,c),n}))}class wi{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=ti,this.name="",this.reverse=!1,this.limit=!1,this.includeInFilter=!1,this.isOldConnectionType=!1}}var Ii=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};function ki(e,t){return Ii(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield dn(e),i=yield cn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield sn(e);for(let e=0;e<n.length;e++)E.AddConnection(n[e]);let i=yield cn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function Ai(e,t,n){return Ii(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield ki(t,n,o):yield ki(e,n,o),o)for(let t=0;t<i.length;t++)i[t].ofTheConceptId==e&&r.push(i[t]);else for(let e=0;e<i.length;e++)i[e].toTheConceptId==t&&r.push(i[e]);return r}))}function xi(e=""){k.BearerAccessToken=e}function Ri(e="",t="",o=""){I.BASE_URL=e,I.AI_URL=t,console.log("This ist he base url",I.BASE_URL),k.BearerAccessToken=o,function(){return Zo(this,void 0,void 0,(function*(){return yield new n(!0),yield function(){return Yo(this,void 0,void 0,(function*(){try{(new Date).getTime();var e=x("application/x-www-form-urlencoded");const n=yield fetch(I.GetAllAiData(),{method:"GET",headers:e});n.ok||(console.log("Ai Error Message: ","Cannot get response"),S(n));const o=yield n.json();for(var t=0;t<o.length;t++)N.AddConcept(o[t])}catch(e){throw e instanceof Error?console.log("Ai Error Message: ",e.message):console.log("Ai Error Message: ",e),e}}))}(),!0}))}().then((()=>{const e=(new Date).getTime();(function(){return T(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];N.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{s.isDataLoaded=!0,s.isCharacterLoaded=!0,s.isTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare concept data is ",t)})),function(){return zo(this,void 0,void 0,(function*(){var e=yield a();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];xe.AddConceptToMemory(n)}}))}().then((()=>{s.isLocalDataLoaded=!0,s.isLocalTypeLoaded=!0,s.isLocalCharacterLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare local concept ",t)})),function(){return qo(this,void 0,void 0,(function*(){!function(){qo(this,void 0,void 0,(function*(){var e=yield a();if(Array.isArray(e))for(var t=0;t<e.length;t++)Se.AddConnection(e[t])}))}()}))}().then((()=>{s.isLocalConnectionLoaded=!0})),function(){return qo(this,void 0,void 0,(function*(){!function(){qo(this,void 0,void 0,(function*(){var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++)E.AddConnectionToMemory(e[t])}))}()}))}().then((()=>{s.isConnectionLoaded=!0,s.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare connections ",t)}))}))}var Si=exports;for(var _i in t)Si[_i]=t[_i];t.__esModule&&Object.defineProperty(Si,"__esModule",{value:!0})})();
|
|
@@ -17,13 +17,13 @@ export declare class Concept {
|
|
|
17
17
|
accessUserId: number;
|
|
18
18
|
sessionInformationId: number;
|
|
19
19
|
sessionInformationUserId: number;
|
|
20
|
-
entryTimeStamp: Date;
|
|
21
|
-
updatedTimeStamp: Date;
|
|
20
|
+
entryTimeStamp: Date | string;
|
|
21
|
+
updatedTimeStamp: Date | string;
|
|
22
22
|
referent: Concept | null | void;
|
|
23
23
|
type: Concept | null | void;
|
|
24
24
|
isNew: boolean;
|
|
25
25
|
updateRecursion: boolean;
|
|
26
26
|
isTemp: boolean;
|
|
27
|
-
constructor(id: number, userId: number, typeId: number, typeUserId: number, categoryId: number, categoryUserId: number, referentId: number, referentUserId: number, characterValue: string, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionId: number, sessionUserId: number, isNew: boolean | undefined, entryTimeStamp: Date, updatedTimeStamp: Date);
|
|
27
|
+
constructor(id: number, userId: number, typeId: number, typeUserId: number, categoryId: number, categoryUserId: number, referentId: number, referentUserId: number, characterValue: string, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionId: number, sessionUserId: number, isNew: boolean | undefined, entryTimeStamp: Date | string, updatedTimeStamp: Date | string);
|
|
28
28
|
getType(): void;
|
|
29
29
|
}
|
|
@@ -8,14 +8,14 @@ export declare class LConcept {
|
|
|
8
8
|
accessId: number;
|
|
9
9
|
characterValue: string;
|
|
10
10
|
typeCharacter: string;
|
|
11
|
-
entryTimeStamp: Date;
|
|
11
|
+
entryTimeStamp: Date | string;
|
|
12
12
|
referentId: number;
|
|
13
|
-
updatedTimeStamp: Date;
|
|
13
|
+
updatedTimeStamp: Date | string;
|
|
14
14
|
type: LConcept | null | void | Concept;
|
|
15
15
|
isNew: boolean;
|
|
16
16
|
isComposition: boolean;
|
|
17
17
|
isTemp: boolean;
|
|
18
18
|
applicationId: number;
|
|
19
|
-
constructor(id: number, userId: number, typeId: number, categoryId: number, accessId: number, characterValue: string, typeCharacter: string, isNew: boolean | undefined, entryTimeStamp: Date, updatedTimeStamp: Date, referentId: number, applicationId?: number);
|
|
19
|
+
constructor(id: number, userId: number, typeId: number, categoryId: number, accessId: number, characterValue: string, typeCharacter: string, isNew: boolean | undefined, entryTimeStamp: Date | string, updatedTimeStamp: Date | string, referentId: number, applicationId?: number);
|
|
20
20
|
getType(): void;
|
|
21
21
|
}
|