mftsccs-browser 100.0.85 → 100.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/types/Api/Create/CreateTheConceptApi.d.ts +2 -1
- package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +1 -1
- package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +1 -1
- package/dist/types/Api/GetCharacterDataByCharacter.d.ts +1 -1
- package/dist/types/Api/GetConcept.d.ts +1 -1
- package/dist/types/Api/GetConceptByCharacterAndType.d.ts +1 -1
- package/dist/types/Api/GetConnection.d.ts +1 -1
- package/dist/types/Api/GetConnectionOfTheConcept.d.ts +1 -1
- package/dist/types/Api/RecursiveSearch.d.ts +1 -1
- package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +1 -1
- package/dist/types/Api/Signin.d.ts +1 -1
- package/dist/types/Api/Signup.d.ts +1 -1
- package/dist/types/Services/Common/ErrorPosting.d.ts +1 -0
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AddGhostConcept:()=>Ho,BaseUrl:()=>o,BinaryTree:()=>v,Composition:()=>vo,CompositionBinaryTree:()=>uo,CompositionNode:()=>lo,Concept:()=>g,ConceptsData:()=>T,Connection:()=>P,ConnectionData:()=>j,CreateComposition:()=>Ce,CreateConnectionBetweenTwoConcepts:()=>Qe,CreateConnectionBetweenTwoConceptsGeneral:()=>Xe,CreateConnectionBetweenTwoConceptsLocal:()=>ui,CreateDefaultConcept:()=>m,CreateDefaultLConcept:()=>ft,CreateSession:()=>_o,CreateSessionVisit:()=>Po,CreateTheCompositionLocal:()=>Ue,CreateTheCompositionWithCache:()=>mo,CreateTheConnection:()=>ie,CreateTheConnectionGeneral:()=>Ve,CreateTheConnectionLocal:()=>xe,DelayFunctionExecution:()=>mi,DeleteConceptById:()=>Gn,DeleteConceptLocal:()=>yi,DeleteConnectionById:()=>Je,FilterSearch:()=>Ai,FormatFromConnections:()=>Zo,GetAllConnectionsOfComposition:()=>wt,GetAllConnectionsOfCompositionBulk:()=>q,GetComposition:()=>kt,GetCompositionBulk:()=>En,GetCompositionBulkWithDataId:()=>Vn,GetCompositionFromConnectionsWithDataId:()=>jn,GetCompositionFromConnectionsWithDataIdInObject:()=>Wn,GetCompositionFromConnectionsWithDataIdIndex:()=>Mn,GetCompositionFromConnectionsWithIndex:()=>Hn,GetCompositionList:()=>Vt,GetCompositionListAll:()=>jt,GetCompositionListAllWithId:()=>Mt,GetCompositionListLocal:()=>Xt,GetCompositionListLocalWithId:()=>Yt,GetCompositionListWithId:()=>Ht,GetCompositionLocal:()=>zt,GetCompositionLocalWithId:()=>Kt,GetCompositionWithAllIds:()=>At,GetCompositionWithCache:()=>So,GetCompositionWithDataIdBulk:()=>Lo,GetCompositionWithDataIdWithCache:()=>Ro,GetCompositionWithId:()=>Lt,GetConceptBulk:()=>H,GetConceptByCharacter:()=>Bt,GetConceptByCharacterAndCategoryLocal:()=>Ot,GetConnectionBetweenTwoConceptsLinker:()=>gi,GetConnectionBulk:()=>Dn,GetConnectionById:()=>We,GetConnectionOfTheConcept:()=>Oe,GetLink:()=>rn,GetLinkRaw:()=>cn,GetLinkerConnectionFromConcepts:()=>Sn,GetLinkerConnectionToConcepts:()=>xn,GetRelation:()=>Uo,GetRelationLocal:()=>oi,GetRelationRaw:()=>Do,GetTheConcept:()=>ze,GetTheConceptLocal:()=>Xo,GetUserGhostId:()=>Mo,LConcept:()=>Ci,LConnection:()=>Ni,LocalConceptsData:()=>gt,LocalSyncData:()=>ki,LoginToBackend:()=>qn,MakeTheInstanceConcept:()=>ge,MakeTheInstanceConceptLocal:()=>Pe,MakeTheTimestamp:()=>Pn,MakeTheTypeConcept:()=>gn,MakeTheTypeConceptApi:()=>Tn,MakeTheTypeConceptLocal:()=>_e,PatcherStructure:()=>wi,RecursiveSearchApi:()=>Jn,RecursiveSearchApiNewRawFullLinker:()=>Kn,RecursiveSearchApiRaw:()=>Zn,RecursiveSearchApiRawFullLinker:()=>zn,SearchAllConcepts:()=>To,SearchLinkInternal:()=>di,SearchLinkMultipleAll:()=>Jo,SearchQuery:()=>Bn,SearchStructure:()=>Si,SearchWithLinker:()=>ko,SessionData:()=>Ti,Signin:()=>eo,Signup:()=>Yn,SplitStrings:()=>A,SyncData:()=>oe,TrashTheConcept:()=>_n,UpdateComposition:()=>No,UpdateCompositionLocal:()=>ti,UserBinaryTree:()=>Vo,ViewInternalData:()=>ai,ViewInternalDataApi:()=>ri,convertFromConceptToLConcept:()=>zo,convertFromLConceptToConcept:()=>Ko,getFromDatabaseWithType:()=>en,getObjectsFromIndexDb:()=>nn,init:()=>Pi,recursiveFetch:()=>Gt,recursiveFetchNew:()=>yo,storeToDatabase:()=>tn,updateAccessToken:()=>Fi});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}class o{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 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 CreateGhostConceptApiUrl(){return o.NODE_URL+"/api/v1/local-concepts"}static CreateGhostConnectionApiUrl(){return o.NODE_URL+"/api/v1/local-connections"}static GetRealConceptById(){return o.NODE_URL+"/api/v1/local-concepts-translate"}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"}}o.BASE_URL="https://localhost:7053/",o.AI_URL="https://ai.freeschema.com",o.MQTT_URL="192.168.1.249",o.NODE_URL="http://localhost:5001",o.BASE_APPLICATION="",o.BASE_RANDOMIZER=999;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},r=9;class c{}function a(t){return new Promise((function(e,n){c.db&&e(c.db);let i=o.BASE_URL+"_FreeSchema"+o.BASE_APPLICATION;const s=indexedDB.open(i,r);s.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),a(t),n(e)},s.onsuccess=function(t){let n=t.target;c.db=n.result,e(c.db)},s.onupgradeneeded=t=>{let n=t.target.result,o="concept",i="connection",c="settings";console.log("this is the version update for index",r),n.objectStoreNames.contains(o)&&n.deleteObjectStore(o),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(o)||(n.createObjectStore(o,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{}),e(n)}}))}function s(t,e){return new Promise((function(n,o){a(t).then((i=>{if(0!=e.id){const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the database"+t,data:n,body:e})}}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to the database because you cannot open the database",data:t})}))}))}function l(t){return i(this,void 0,void 0,(function*(){return new Promise((function(e,n){a(t).then((n=>{let o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(let e=0;e<t.length;e++)o.push(t[e]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from the database because you cannot open the database",data:t})}))}))}))}function d(t,e){return new Promise((function(n,o){a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).delete(Number(e));r.onsuccess=function(t){n(e)},r.onerror=e=>{o({status:400,ok:!1,message:"Cannot remove from the database"+t,data:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove from the database because you cannot open the database",data:t,body:e})}))}))}class h{}h.isTypeLoaded=!1,h.isCharacterLoaded=!1,h.isDataLoaded=!1,h.isLocalDataLoaded=!1,h.isLocalCharacterLoaded=!1,h.isLocalTypeLoaded=!1,h.isConnectionLoaded=!1,h.isConnectionTypeLoaded=!1,h.isLocalConnectionLoaded=!1;class u{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getCharacterFromNodeUpdated(t,e){var n;return e?t==e.key||51==(null===(n=e.value)||void 0===n?void 0:n.typeId)?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var f=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class y{static waitForDataToLoad(){return f(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isCharacterLoaded)return t("done");setTimeout(y.checkFlag,1e3,t)}static addNodeToTree(t){return f(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=t,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(t,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(t,e){return f(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new u(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return f(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return f(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}y.characterRoot=null;var p=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class v{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return p(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isDataLoaded)return t("done");setTimeout(v.checkFlag,1e3,t)}static addConceptToTree(t){var e=new u(t.id,t,null,null),n=new u(t.characterValue,t,null,null);y.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return p(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return p(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}v.root=null;class g{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.typeCharacter="",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.x=0,this.y=0,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.referentId=r,this.characterValue=`${c}`,this.accessId=a,this.typeCharacter=h,this.type=null,this.isNew=s,this.entryTimeStamp=l,this.updatedTimeStamp=d}getType(){console.log(this.typeId)}}function m(){let t=new Date,e=new Date;return new g(0,0,0,0,0,"0",0,!1,t,e,"0")}var C=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class N{static addNodeToTree(t){return C(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=t,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(t,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new u(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,t,e))}static getNodeFromTree(t){return this.typeRoot?this.typeRoot.getFromNode(t,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return C(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isTypeLoaded)return t("done");setTimeout(N.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return C(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)if(o.variants[t].value.userId==e){var i=!1;for(let e=0;e<n.length;e++)n[e].id==o.variants[t].value.id&&(i=!0);i||n.push(o.variants[t].value)}}return n}))}static getTypeVariantsWithCharacterValue(t,e){return C(this,void 0,void 0,(function*(){let n=m();try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(e);if(o){o.value.characterValue==t&&(n=o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.characterValue==t&&(n=o.variants[e].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}N.typeRoot=null;var w=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class T{constructor(){this.name="conceptsArray"}static CheckContains(t){for(var e=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==t.id&&(e=!0);return e}static AddNpc(t){this.NPC.includes(t)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(t))}static GetNpc(t){return!!this.NPC.includes(t)}static AddConceptToStorage(t){t.id>0&&s("concept",t)}static AddConcept(t){var e,n;t.id>0&&(e="concept",n=t,new Promise((function(t,o){a(e).then((i=>{const r=i.transaction(e,"readwrite").objectStore(e).put(n);r.onsuccess=e=>{t(n)},r.onerror=t=>{o({status:400,ok:!1,message:"Cannot Update to the database"+e,data:t,body:n})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the database",data:t})}))})),v.addConceptToTree(t),N.addConceptToTree(t),y.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(v.addConceptToTree(t),N.addConceptToTree(t),y.addConceptToTree(t))}static AddConceptTemporary(t){var e=this.CheckContains(t);this.conceptDictionary[t.id]=t,e&&this.RemoveConcept(t),this.conceptsArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsArray.length;e++)this.conceptsArray[e].id==t.id&&this.conceptsArray.splice(e,1);d("concept",t.id)}static GetConcept(t){return w(this,void 0,void 0,(function*(){var e=m(),n=yield v.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return w(this,void 0,void 0,(function*(){var e=m(),n=y.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return w(this,void 0,void 0,(function*(){var e=m(),n=y.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return w(this,void 0,void 0,(function*(){return m(),yield N.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return w(this,void 0,void 0,(function*(){var n=m(),o=yield y.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return w(this,void 0,void 0,(function*(){let n=[];return n=yield N.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return y.characterRoot}getName(){return this.name}}T.conceptsArray=[],T.NPC=[],T.conceptDictionary=[];var I=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function k(){return I(this,void 0,void 0,(function*(){try{let e=yield l("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];T.AddConceptToMemory(n)}h.isDataLoaded=!0,h.isCharacterLoaded=!0,h.isTypeLoaded=!0}catch(t){throw yield mi(2e3,k()),{message:"Cannot create Binary Tree Concept",ok:!1,status:400,data:t}}}))}function A(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}class S{}function x(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+S.BearerAccessToken,Accept:e}}function R(t="application/json",e="",n="application/json"){return""==e&&(e=S.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}function L(){let t=S.BearerAccessToken;const e=new Headers;return e.append("Authorization","Bearer "+t),e}S.BearerAccessToken="";class G{constructor(t,e,n,i){this.url=o.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function b(t){if(401==t.status){let e=new G(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}var _=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function F(t,e){return _(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var i=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:n});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)T.AddConcept(t[r])}else console.log("GetAllConceptsByType error",c.status),b(c)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class P{constructor(t=0,e,n,i,r,c,a){this.isTemp=!1,this.toUpdate=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=m(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.userId=i,this.typeId=r,this.ghostId=t,this.orderId=c,this.accessId=a,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date,this.typeCharacter=""}}class B{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;t.value.id==e.value.id&&(n=!0);for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var U=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class D{static addNodeToTree(t){if(null==this.connectionroot)return this.connectionroot=t,this.connectionroot;this.connectionroot=this.connectionroot.addNode(t,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(t){var e=new B(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return U(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isConnectionLoaded)return t("done");setTimeout(D.checkFlag,1e3,t)}static removeNodeFromTree(t){return U(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return U(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}D.connectionroot=null;var O=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class E{static addNodeToTree(t){return O(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=t,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(t,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return O(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isConnectionTypeLoaded)return t("done");setTimeout(E.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new B(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,t,e))}static getNodeFromTree(t){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(t,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(t){return O(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad()}catch(t){return e}var n=this.getNodeFromTree(t);if(n){e.push(null==n?void 0:n.value);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value);return e}}))}static getTypeVariantsFromTreeWithUserId(t,e){return O(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}E.connectionTypeRoot=null;var V=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class j{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){s("connection",t)}static AddConnection(t){t.isTemp||(s("connection",t),D.addConnectionToTree(t),E.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(D.addConnectionToTree(t),E.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(d("connection",t.id),D.removeNodeFromTree(t.id),E.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return D.connectionroot}static GetConnectionTypeTree(){return E.connectionTypeRoot}static GetConnection(t){return V(this,void 0,void 0,(function*(){var e=new P(0,0,0,0,0,0,0),n=yield D.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return V(this,void 0,void 0,(function*(){var e=[],n=yield E.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;if(o){let t=o;e.push(t);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value)}}return e}))}getName(){return this.name}}j.connectionArray=[],j.connectionDictionary=[];var M=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function H(t){return M(this,void 0,void 0,(function*(){let e=[];try{var n=[];for(let e=0;e<t.length;e++)0==(yield T.GetConcept(t[e])).id&&n.push(t[e]);if(0==n.length)return e;{var i=x();const t=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(n)});if(t.ok){if(e=yield t.json(),e.length>0)for(let t=0;t<e.length;t++){let n=e[t];T.AddConcept(n)}}else console.log("Get Concept Bulk error",t.status),b(t);return e}}catch(t){throw t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),e}}))}var W=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $(){return W(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length>0){for(let n=0;n<t.length;n++)e.includes(t[n].ofTheConceptId)||e.push(t[n].ofTheConceptId),e.includes(t[n].toTheConceptId)||e.push(t[n].toTheConceptId);yield H(e)}}))}var J=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Z(){return J(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield j.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function z(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||j.RemoveConnection(e[n]))}function K(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||j.RemoveConnection(e[n])}var Q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function q(){return Q(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var n=yield Z(t),i=yield function(){return Q(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=x();const r=yield fetch(o.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)j.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),b(r);return e}catch(t){throw t instanceof Error?console.log("Get all connections of composition bulk error message: ",t.message):console.log("Get all connections of composition bulk unexpected error: ",t),t}}))}(t);return z(e=i,n),yield $(e),e}))}var X=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Y=9;class tt{}function et(t){return new Promise((function(e,n){tt.db&&e(tt.db);let i=o.BASE_URL+"_FreeSchemaLocal"+o.BASE_APPLICATION;const r=indexedDB.open(i,Y);r.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),et(t),n(e)},r.onsuccess=function(t){var n=t.target;tt.db=n.result,e(tt.db)},r.onupgradeneeded=t=>{var n=t.target.result,i="localconcept",r="localconnection",c="localid";console.log("this is the version upgrade",Y),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(r)&&n.deleteObjectStore(r),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(r)||(n.createObjectStore(r,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{ot(c,{id:0,value:-100}),ot(c,{id:1,value:-200}),ot(c,{id:3,value:o.BASE_RANDOMIZER})}),e(n)}}))}function nt(t){return X(this,void 0,void 0,(function*(){return new Promise((function(e,n){et(t).then((n=>{var o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(var n=0;n<t.length;n++)o.push(t[n]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from database because you cannot open the Local database",data:t})}))}))}))}function ot(t,e){return new Promise((function(n,o){et(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the Local database "+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to database because you cannot open the Local database",data:t})}))}))}function it(t,e){return new Promise((function(n,o){et(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the Local database",data:t})}))}))}function rt(t,e){return new Promise((function(n,o){et(t).then((i=>{let r=i.transaction(t,"readwrite").objectStore(t).delete(e);r.onsuccess=function(t){n(e)},r.onerror=function(n){o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove object from database because you cannot open the Local database",data:t})}))}))}class ct{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}updateNodeSyncStatus(t,e,n){if(n){if(t==n.key){let t=n.value;return t.isSynced=e,n.value=t,n}return t<n.key?this.updateNodeSyncStatus(t,e,n.leftNode):t>n.key?this.updateNodeSyncStatus(t,e,n.rightNode):n}return n}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var at=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class st{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ct(t.id,t,null,null);new ct(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return at(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalDataLoaded)return t("done");setTimeout(st.checkFlag,1e3,t)}static getNodeFromTree(t){return at(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static updateSyncStatus(t){return this.root?this.root.updateNodeSyncStatus(t,!0,this.root):this.root}static removeNodeFromTree(t){return at(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}st.root=null;var lt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class dt{static waitForDataToLoad(){return lt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalCharacterLoaded)return t("done");setTimeout(dt.checkFlag,1e3,t)}static addNodeToTree(t){return lt(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=t,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(t,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(t){if(""!=t.characterValue){var e=new ct(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(t,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(t,e){return lt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static getCharacterAndCategoryFromTree(t,e){return lt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndCategory(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}dt.LocalCharacterRoot=null;var ht=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ut{static addNodeToTree(t){return ht(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=t,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(t,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new ct(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeConceptType(t,e){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,t,e))}static getNodeFromTree(t){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(t,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return ht(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalTypeLoaded)return t("done");setTimeout(ut.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return ht(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){console.log("this is the node to type",o),o.value.userId!=e&&999!=o.value.userId||n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId!=e&&999!=o.value.userId||n.push(o.variants[t].value)}return n}))}}function ft(){let t=new Date,e=new Date;return new g(0,0,0,0,0,"0",0,!1,t,e,"0")}ut.LocalTypeRoot=null;var yt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class pt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ct(t.ghostId,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return yt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalDataLoaded)return t("done");setTimeout(pt.checkFlag,1e3,t)}static getNodeFromTree(t){return yt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return yt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}pt.root=null;var vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class gt{constructor(){this.name="conceptsArray"}static AddConcept(t){0!=t.id&&(ot("localconcept",t),st.addConceptToTree(t),dt.addConceptToTree(t),ut.addConceptToTree(t),this.localconceptsArray.push(t))}static AddPermanentConcept(t){0!=t.id&&(st.removeNodeFromTree(t.ghostId),dt.removeConceptType(t.characterValue,t.ghostId),ut.removeConceptType(t.typeId,t.ghostId),pt.addConceptToTree(t),rt("localconcept",t.ghostId),T.AddConcept(t))}static RemoveConcept(t){return vt(this,void 0,void 0,(function*(){try{0!=t.id&&(st.removeNodeFromTree(t.ghostId),dt.removeConceptType(t.characterValue,t.ghostId),ut.removeConceptType(t.typeId,t.ghostId),yield rt("localconcept",t.ghostId))}catch(t){throw t}}))}static AddConceptToMemory(t){0!=t.id&&(st.addConceptToTree(t),dt.addConceptToTree(t),ut.addConceptToTree(t))}static GetConcept(t){return vt(this,void 0,void 0,(function*(){var e=ft(),n=yield st.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static UpdateConceptSyncStatus(t){return vt(this,void 0,void 0,(function*(){st.updateSyncStatus(t)}))}static GetConceptByGhostId(t){return vt(this,void 0,void 0,(function*(){var e=ft(),n=yield pt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return vt(this,void 0,void 0,(function*(){var e=ft(),n=dt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return vt(this,void 0,void 0,(function*(){var n=ft(),o=yield dt.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptByCharacterAndCategoryLocal(t,e){return vt(this,void 0,void 0,(function*(){var n=ft(),o=yield dt.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return vt(this,void 0,void 0,(function*(){let n=[];return n=yield ut.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}gt.localconceptsArray=[];var mt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ct(t){return mt(this,void 0,void 0,(function*(){try{let i=m();var e=yield T.GetConcept(t);let r=T.GetNpc(t);if(0!=e.id||r)return e;{var n=x("application/x-www-form-urlencoded");console.log("this is the url",o.GetConceptUrl());const e=yield fetch(o.GetConceptUrl(),{method:"POST",headers:n,body:`id=${t}`});return e.ok?(i=yield e.json(),i.id>0?T.AddConcept(i):T.AddNpc(t)):(console.log("Get the concept error",e.status),b(e)),i}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message):console.log("Get the concept unexpected error: ",t),t}}))}var Nt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wt(t){return Nt(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield j.GetConnectionsOfCompositionLocal(t)).length)e=yield Tt(t);else{var n=yield Tt(t);z(n,e),e=n}return e}))}function Tt(t){return Nt(this,void 0,void 0,(function*(){var e=[];try{var n=x("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${t}`});if(console.log("this is getting connection from online",o.GetAllConnectionsOfCompositionUrl(),t),!r.ok)throw b(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)j.AddConnection(c[i]),e.push(c[i]);return e}catch(t){throw t instanceof Error?console.log("Get all connection of composition error : ",t.message):console.log("Get all connection of composition error : ",t),t}}))}var It=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function kt(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t),console.log("this is the connection list online",o);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Ct(t));var s=yield Gt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function At(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Ct(t));var s=yield bt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function St(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield j.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Ct(t));var s=yield Gt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function xt(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield j.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(console.log("this concept you cannot find ",t),a=yield Ct(t));var s=yield Gt(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function Rt(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield j.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Ct(t));var s=yield Gt(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l.created_at=a.entryTimeStamp,l}))}function Lt(t){return It(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield T.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Ct(t));var s=yield Gt(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l}))}function Gt(t,e,n){return It(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Ct(t)),0!=l.id&&null==l.type){var d=l.typeId,h=yield T.GetConcept(d);l.type=h,null==h&&null!=d&&null!=d&&(h=yield Ct(d),l.type=h)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t)if(t!=e[u].toTheConceptId){var f=e[u].toTheConceptId,y=yield T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Ct(f)),0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield T.GetConcept(d),y.type=h,null==h&&null!=d&&null!=d&&(h=yield Ct(d),y.type=h));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield Gt(f,e,n,o);a[p]=t}}else{const t=yield Gt(f,e,n,o);s[p]=t,a=s}}else console.log("this is the faulty connection ",e[u]);return a}))}function bt(t,e,n){return It(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield T.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Ct(t)),0!=l.id&&null==l.type){var d=l.typeId,h=yield T.GetConcept(d);l.type=h,null==h&&null!=d&&null!=d&&(h=yield Ct(d),l.type=h)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t){var f=e[u].toTheConceptId,y=yield T.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Ct(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield T.GetConcept(d),y.type=h,null==h&&null!=d&&null!=d&&(h=yield Ct(d),y.type=h));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield bt(f,e,n);a[p]=t}}else{const t=yield bt(f,e,n);s[p]=t,a=s}}return a}))}var _t=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ft(t){return _t(this,void 0,void 0,(function*(){let e=m();try{var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${t}`});return i.ok?(e=yield i.json(),e.id>0&&T.AddConcept(e)):(b(i),console.log("Error in Getting concept by character value Error",i.status)),e}catch(t){throw t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),t}}))}var Pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bt(t){return Pt(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Ft(t),e=yield T.GetConceptByCharacterAndTypeLocal(t,51)),e}))}var Ut=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dt(t){return Ut(this,void 0,void 0,(function*(){return yield gt.GetConceptByCharacterAndTypeLocal(t,51)}))}function Ot(t){return Ut(this,void 0,void 0,(function*(){let e=ft();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;var n=A(t);if(n.length>1){let o=1,i=yield Ot(n[0]);0!=i.id&&(o=i.id),e=yield function(t,e){return Ut(this,void 0,void 0,(function*(){return gt.GetConceptByCharacterAndCategoryLocal(t,e)}))}(t,o)}else n[0]==t&&(e=yield Dt(t));return e}))}var Et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Vt(t,e){return Et(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Bt(t),r=[];if(i){yield F(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield q(s),l=a;l<a+n;l++)if(c[l]){var d=yield St(c[l].id);r.push(d)}}return r}))}function jt(t,e){return Et(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=Xt(t,e),r=Vt(t,e),c=[];return Promise.race([i,r]).then((t=>{console.log("Promise result",t),c.push(...t)})).catch((t=>{console.log("error in handling",t)})),r.then((t=>{console.log("This is the second promise result",t),c.push(...t)})),c}))}function Mt(t,e){return Et(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Dt(t),r=yield Bt(t);let c=[],a=[],s=[],l=[];0!=i.id&&(a=yield gt.GetConceptsByTypeIdAndUser(i.id,e)),0!=r.id&&(yield F(t,e),l=yield T.GetConceptsByTypeIdAndUser(r.id,e),c=l);for(let t=0;t<a.length;t++){let e=!1;for(let n=0;n<l.length;n++)a[t].ghostId==l[n].ghostId&&(e=!0);e||s.push(a[t])}console.log("This is the all list",s);let d=[];return d=yield function(t,e){return Et(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[];var r=n*(o-1),c=[];let a=e.length;for(var s=r;s<r+n-a;s++)t[s]&&c.push(t[s].id);for(s=0;s<e.length;s++){var l=yield Kt(e[s].id);i.push(l)}for(yield q(c),s=r;s<r+n-a;s++)t[s]&&(l=yield xt(t[s].id),i.push(l));return i}))}(c,s,n,o),d}))}function Ht(t,e){return Et(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Bt(t),r=[];if(i){yield F(t,e);for(var c=yield T.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield q(s),l=a;l<a+n;l++)if(c[l]){var d=yield xt(c[l].id);r.push(d)}}return r}))}var Wt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class $t{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),0!=t.id&&ot("localconnection",t),this.connectionArray.push(t)}static AddConnectionToMemory(t){this.CheckContains(t)&&this.RemoveConnection(t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){console.log("this is removing",t);for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static AddPermanentConnection(t){t.id>0&&(rt("localconnection",t.ghostId),j.AddConnection(function(t){let e=new P(0,0,0,0,0,0,0);return e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.typeId=t.typeId,e.orderId=t.orderId,e.id=t.id,e}(t)))}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return Wt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalConnectionLoaded)return t("done");setTimeout($t.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return Wt(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad();for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}static GetConnectionOfCompositionAndTypeLocal(t,e){return Wt(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad(),console.log("this is the connections",this.connectionArray,t,e);for(var o=0;o<this.connectionArray.length;o++)this.connectionArray[o].typeId==t&&this.connectionArray[o].ofTheConceptId==e&&n.push(this.connectionArray[o]);return n}catch(t){return n}}))}getName(){return this.name}}$t.connectionArray=[],$t.connectionDictionary=[];var Jt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function zt(t){return Zt(this,void 0,void 0,(function*(){var e,n;try{var i,r={};i=yield $t.GetConnectionsOfCompositionLocal(t);for(var c=[],a=0;a<i.length;a++)c.includes(i[a].ofTheConceptId)||c.push(i[a].ofTheConceptId);var s=yield gt.GetConcept(t);if(0==s.id){let e=yield function(t){return Jt(this,void 0,void 0,(function*(){let e=m();try{var n=R("application/x-www-form-urlencoded");const i=yield fetch(o.GetRealConceptById(),{method:"POST",headers:n,body:`id=${t}`});return i.ok?(e=yield i.json(),e.id>0&&T.AddConcept(e),e):(console.log("Error in Getting Translating concept Error",i.status),b(i),e)}catch(t){throw t instanceof Error?console.log("Error in Getting Translating concept error message: ",t):console.log("Error in Getting Translating concept unexpected error: ",t),t}}))}(t);if(e.id>0)return yield kt(e.id)}var l=yield Qt(t,i,c);return r[null!==(n=null===(e=null==s?void 0:s.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=l,r}catch(t){throw t}}))}function Kt(t){return Zt(this,void 0,void 0,(function*(){var e,n;try{var o,i={},r={};o=yield $t.GetConnectionsOfCompositionLocal(t);for(var c=[],a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);var s=yield gt.GetConcept(t);if(0!=s.id){var l=yield Qt(t,o,c);i[null!==(n=null===(e=null==s?void 0:s.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=l}return r.data=i,r.id=t,r}catch(t){throw t}}))}function Qt(t,e,n){return Zt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[],l=yield gt.GetConcept(t);if(0!=l.id&&null==l.type){var d=l.typeId,h=yield gt.GetConcept(d);l.type=h}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t){var f=e[u].toTheConceptId,y=yield gt.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield gt.GetConcept(d),y.type=h);var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield Qt(f,e,n);a[p]=t}}else{const t=yield Qt(f,e,n);s[p]=t,a=s}}return a}))}var qt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xt(t,e){return qt(this,void 0,void 0,(function*(){try{var n=yield Dt(t),o=[];if(0!=n.id)for(var i=yield gt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield zt(i[r].id);o.push(c)}return o}catch(t){throw t}}))}function Yt(t,e){return qt(this,void 0,void 0,(function*(){try{var n=yield Dt(t),o=[];if(0!=n.id)for(var i=yield gt.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Kt(i[r].id);o.push(c)}return o}catch(t){throw t}}))}var te=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ee(t){return te(this,void 0,void 0,(function*(){let e=m();try{var n=x();const i=yield fetch(o.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!i.ok)throw b(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){return t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),t}}))}var ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class oe{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(){return ne(this,void 0,void 0,(function*(){for(let t=0;t<this.conceptsSyncArray.length;t++)T.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)j.AddConnection(this.connectionSyncArray[t]);if(this.conceptsSyncArray.length>0){let t=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],ee(t)}if(this.connectionSyncArray.length>0){let t=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(t){return e=this,n=void 0,r=function*(){let e=new P(0,0,0,0,0,0,0);try{var n=x(),i=JSON.stringify(t);const r=yield fetch(o.CreateTheConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?yield r.json():(console.log("Create the connection error message: ",r.status),b(r)),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,n||[])).next())}));var e,n,i,r}(t)}return"done"}))}static syncDataLocalDb(){return ne(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)s("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)s("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}function ie(t,e,n,o){var i=new P(0,t,n,e,o,1,4);return t==n?(i.ofTheConceptId=0,i.toTheConceptId=1,i):(i.isTemp=!0,i.id=Math.floor(1e8*Math.random()),oe.AddConnection(i),i)}oe.conceptsSyncArray=[],oe.connectionSyncArray=[];var re=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ce=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ae(t,e){return ce(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndTypeLocal(t,e);try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=x();const a=yield fetch(o.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});a.ok?(n=yield a.json(),T.AddConcept(n)):(b(a),console.log("This is the concept by type and character error",a.status))}return n}catch(t){throw t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),t}}))}var se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class le{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.userId=t,this.data=e,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var de=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class he{static getId(){return de(this,void 0,void 0,(function*(){this.ids.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{var t=x("application/x-www-form-urlencoded");const n=yield fetch(o.GetReservedIdUrl(),{method:"GET",headers:t});if(!n.ok)throw b(n),new Error(`Error! status: ${n.status}`);const i=yield n.json();for(var e=0;e<i.length;e++)he.AddId(i[e])}catch(t){throw t instanceof Error?console.log("get reserved ids error message: ",t.message):console.log("get reserved ids unexpected error: ",t),t}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}he.ids=[];class ue{static getId(){return de(this,void 0,void 0,(function*(){this.connectionIds.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{var t=x("application/x-www-form-urlencoded");const n=yield fetch(o.GetReservedConnectionIdUrl(),{method:"GET",headers:t});if(!n.ok)throw b(n),new Error(`Error! status: ${n.status}`);const i=yield n.json();for(var e=0;e<i.length;e++)ue.AddId(i[e])}catch(t){throw t instanceof Error?console.log("get reserved connection ids error message: ",t.message):console.log("get reserved connection ids unexpected error: ",t),t}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}ue.connectionIds=[];var fe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ye(t,e,n,o,i,r,c){return fe(this,void 0,void 0,(function*(){var a=yield he.getId();let s=new Date,l=new Date,d=new g(a,e,o,n,i,t,r,!0,s,l,c);return d.isTemp=!1,oe.AddConcept(d),d}))}function pe(t,e,n,o,i,r,c){return fe(this,void 0,void 0,(function*(){var a=yield he.getId();let s=new Date,l=new Date,d=new g(a,e,o,n,i,t,r,!1,s,l,c);return T.AddConcept(d),ee([d]),d}))}var ve=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ge(t,e){return ve(this,arguments,void 0,(function*(t,e,n=!1,i,r=4,c=999,a=0){let s,l=c,d=i,h=i,u=r,f=i,y="",p=e.length,v=m();if(y=t.startsWith("the_")?t:"the_"+t,n)v=yield Tn(t),s=yield ye(e,i,4,v.id,a,u,t);else if(p>255)v=yield Tn(y),s=yield ye(e,i,4,v.id,a,u,y),function(t){re(this,void 0,void 0,(function*(){try{var e=x();const n=yield fetch(o.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw b(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(t){throw t instanceof Error?console.log("Create the text error message: ",t.message):console.log("Create the text unexpected error: ",t),t}}))}(new le(i,e,999,d,u,f,l,h,Date.now().toString(),!0));else{v=yield Tn(y);let t=yield ae(e,v.id);s=t,0==t.id&&0==t.userId&&(s=yield pe(e,i,4,v.id,12,u,y),function(t,e,n,i){se(this,void 0,void 0,(function*(){try{var r={newConceptId:t,referent:e,typeId:n,typeUserId:i},c=x(),a=JSON.stringify(r);const s=yield fetch(o.MakeTheNameInBackendUrl(),{method:"POST",headers:c,body:a});s.ok||b(s)}catch(t){throw t instanceof Error?console.log("make the name in backend error message: ",t.message):console.log("make the name in backend unexpected error: ",t),t}}))}(s.id,`${e}`,v.id,i))}return s.type=v,s}))}var me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ce(t){return me(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,h=m();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var u=d;h=p=yield ge(o,"",!0,a,s,l),u=p.id,d=p.id,yield Ce(t[o],p.id,p.userId,u,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;u=d,h=p=yield ge(o,"",!0,a,s,l),yield ie(f,y,p.id,u),yield Ce(t[o],p.id,p.userId,u,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,u=d;var p=yield ge(o,t[o].toString(),!1,a,s,l);yield ie(f,y,p.id,u)}return h}))}var Ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function we(){return Ne(this,void 0,void 0,(function*(){console.log("this is trying to create local binary tree");try{let t=yield nt("localconcept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];gt.AddConceptToMemory(n)}h.isLocalDataLoaded=!0,h.isLocalTypeLoaded=!0,h.isLocalCharacterLoaded=!0}catch(t){throw yield mi(2e3,we()),{message:"Cannot create local binary tree from index db",data:t,ok:!1,status:400}}}))}function Te(){return Ne(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ne(this,void 0,void 0,(function*(){let t=yield nt("localid");if(Array.isArray(t)){if(t[0]){let e=t[0].value;if(e)Ae.AddConceptId(t[0]),yield it("localid",{id:0,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ae.AddConceptId(t),yield it("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}function Ie(){return Ne(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ne(this,void 0,void 0,(function*(){let t=yield nt("localid");if(Array.isArray(t)){if(t[1]){let e=t[1].value;if(e)Ae.AddConnectionId(t[1]),yield it("localid",{id:1,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ae.AddConnectionId(t),yield it("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}var ke=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ae{static AddConceptId(t){this.localId=t.value}static getConceptId(){return ke(this,void 0,void 0,(function*(){try{if(this.localId){if(this.ReservedLocalId.length<5){yield Te().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}})).catch((t=>(console.log(" getid: cannot get the id from indexdb"),-Math.floor(1e8*Math.random()))));let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}{let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}}return yield Te().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}})),this.getConceptId()}catch(t){return console.log(" getid: this is the eror in concept",t),-Math.floor(1e8*Math.random())}}))}static AddConnectionId(t){this.localConnectionId=t.value}static getConnectionId(){return ke(this,void 0,void 0,(function*(){try{if(this.localConnectionId){if(this.ReservedConnectionId.length<5){yield Ie().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})).catch((t=>(console.log("this is the new event",t),-Math.floor(1e8*Math.random()))));let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}{let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}}return yield Ie().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})),this.getConnectionId()}catch(t){return-Math.floor(1e8*Math.random())}}))}}Ae.ReservedLocalId=[],Ae.ReservedConnectionId=[];var Se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xe(t,e,n){return Se(this,arguments,void 0,(function*(t,e,n,o=1,i="",r=999){try{let c=yield Ae.getConnectionId(),a=0,s=0,l=0;a=t,s=e,l=n;let d=new P(0,0,0,0,0,0,0);return t!=e&&(d=new P(c,a,s,r,n,o,4),d.isTemp=!0,d.typeCharacter=i,yield ki.AddConnection(d),$t.AddConnection(d)),d}catch(t){throw t}}))}var Re=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Le(t,e,n,o,i,r){return Re(this,arguments,void 0,(function*(t,e,n,o,i,r,c=!1,a=0){try{var s=yield Ae.getConceptId();console.log("this is the getting id type connection",s);var l=!0;let h=new Date,u=new Date;if("the"==t)return new g(1,999,5,5,a,t,r,l,h,u,e);var d=new g(s,n,i,o,a,t,r,l,h,u,e);return d.isTemp=!0,d.isComposition=c,gt.AddConcept(d),d}catch(t){throw t}}))}var Ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _e(t,e,n,o){return be(this,void 0,void 0,(function*(){let i=yield Ot(t);if(i&&(0==i.id||0==i.userId)){let r=A(t);if(r[0]==t){let e=yield function(t,e,n,o){return Ge(this,void 0,void 0,(function*(){var e=yield gt.GetConceptByCharacterAndTypeLocal(t,51),i=e;return o=1,0==i.id&&(i=e=yield Le(t,"the",n,o,51,4)),i}))}(t,0,o,1);i=e}else{let c=yield _e(r[0],e,n,o),a=yield _e(r[1],e,n,o);i=yield Le(t,r[1],o,c.id,a.id,4)}}return i}))}var Fe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pe(t,e){return Fe(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{let i,r,a=999,s=4,l=o,d=4,h="",u=e.length;if(h=t.startsWith("the_")?t:"the_"+t,n)i=yield _e(t,a,o,o),r=yield Le(e,t,o,s,i.id,d,!0,c);else if(u>255)i=yield _e(h,a,l,o),r=yield Le(e,h,o,s,i.id,d);else{i=yield _e(h,a,l,o);let t=yield gt.GetConceptByCharacterAndTypeLocal(e,i.id);r=t,0==t.id&&0==t.userId&&(r=yield Le(e,h,o,s,i.id,d))}return r.type=i,ki.AddConcept(r),r}catch(t){throw t}}))}var Be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ue(t){return Be(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=!1){var s=null!=i?i:999,l=null!=r?r:999,d=null!=c?c:999,h=null!=o?o:0,u=ft();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var f=h;u=p=yield Pe(o,"",!0,s,l,d),f=p.id,h=p.id,yield Ue(t[o],p.id,p.userId,f,i,r,c)}else{var y=null!=e?e:999,p=(f=h,yield Pe(o,"",!0,s,l,d));yield xe(y,p.id,f),yield Ue(t[o],p.id,p.userId,f,i,r,c)}else y=null!=e?e:999,f=h,p=yield Pe(o,t[o].toString(),!1,s,l,d),yield xe(y,p.id,f);return u}))}var De=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oe(t,e,n){return De(this,arguments,void 0,(function*(t,e,n,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${n}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=x("application/x-www-form-urlencoded");const l=yield fetch(o.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(b(l),console.log("Get connection of concept error",l.status)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var Ee=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ve(t,e,n,o,i,r,c){return Ee(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4){var l=e,d=yield ue.getId(),h=new P(d,t,n,l,i,a,s);return t==n?(h.ofTheConceptId=0,h.toTheConceptId=1,h):(h.toUpdate=!0,h.isTemp=!1,oe.AddConnection(h),h)}))}var je=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},He=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function We(t){return He(this,void 0,void 0,(function*(){var e=yield j.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var n=yield function(t){return Me(this,void 0,void 0,(function*(){var e=yield j.GetConnection(t);try{if(0!=e.id)return e;{var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${t}`});return i.ok?(e=yield i.json(),j.AddConnection(e)):(b(i),console.log("Get Connection Error",i.status)),e}}catch(t){throw t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),e}}))}(t);e=n}return e}))}var $e=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Je(t){return $e(this,void 0,void 0,(function*(){var e=yield We(t);yield function(t){return je(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=L();const i=yield fetch(o.DeleteTheConnectionUrl(),{method:"POST",headers:n,body:e,redirect:"follow"});i.ok||(console.log("Delete connection error status: ",i.status),b(i))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}}))}(t),d("connection",t),D.removeNodeFromTree(t),E.removeTypeConcept(e.typeId,t)}))}var Ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ze(t){return Ze(this,arguments,void 0,(function*(t,e=999){try{var n=m();if(t<0)return Ko(yield Mo(e,t));if(null!=(n=yield T.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield Ct(t)),0!=n.id&&null==n.type&&null==(yield T.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield Ct(n.typeId);n.type=o}return n}catch(t){throw console.error("this is the error in the getting concept",t),t}}))}var Ke=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qe(t,e,n){return Ke(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield qe(o,e,a));var s=yield ge("connection",c,!1,999,999,999);let l=new P(0,e.id,t.id,a,s.id,1e3,4);oe.AddConnection(l)}let l=n+"_s",d=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+l;i&&(yield qe(l,t,a));var h=yield ge("connection",d,!1,999,999,999);let u=new P(0,t.id,e.id,a,h.id,1e3,4);return oe.AddConnection(u),u}))}function qe(t,e){return Ke(this,arguments,void 0,(function*(t,e,n=null){for(var o,i=e,r=null!=n?n:e.userId,c=t+"_count",a=(null===(o=e.type)||void 0===o?void 0:o.characterValue)+"_s_"+c,s=yield ge("connection",a,!1,r,4,999),l=yield Oe(s.id,e.id,r,10,1),d=[],h=m(),u=0;u<l.length;u++){let t=yield ze(l[u].toTheConceptId);d.push(t)}if(d.length<1)h=yield ge("count","1",!1,r,4,999);else{var f=d[0];let t=0;try{t=Number(f.characterValue)}catch(e){t=0}t+=1,h=yield ge("count",t.toString(),!1,r,4,999);for(let t=0;t<l.length;t++)Je(l[t].id)}let y=new P(0,i.id,h.id,i.userId,s.id,1e3,4);yield oe.AddConnection(y)}))}function Xe(t,e,n){return Ke(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield qe(o,e,a));var s=yield ge("connection",c,!1,999,999,999);let l=new P(0,e.id,t.id,a,s.id,1e3,4);oe.AddConnection(l)}let l=n+"_s",d=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+l;i&&(yield qe(l,t,a));var h=yield ge("connection",d,!1,999,999,999);return yield Ve(t.id,t.userId,e.id,e.userId,h.id,999,999,1e3,4)}))}var Ye=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tn(t,e){}function en(t,e,n){return Ye(this,void 0,void 0,(function*(){}))}function nn(t){return Ye(this,void 0,void 0,(function*(){}))}var on=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function rn(t,e){return on(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield ze(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield ae(a,16);if(s.id>0){for(var l=yield Oe(s.id,c.id,c.userId,n,o),d=[],h=0;h<l.length;h++)d.push(l[h].toTheConceptId);for(yield q(d),h=0;h<l.length;h++){let t=l[h].toTheConceptId,e=yield ze(t),n=yield Rt(e.id);r.push(n)}}return r}))}function cn(t,e){return on(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield ze(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield ae(a,16);if(s.id>0){for(var l=yield Oe(s.id,c.id,c.userId,n,o),d=[],h=0;h<l.length;h++)d.push(l[h].toTheConceptId);for(h=0;h<l.length;h++){let t=l[h].toTheConceptId,e=yield ze(t);r.push(e)}}return r}))}class an{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class sn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new an(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}sn.characterData=[];class ln{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var dn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function un(t,e,n,i,r){return hn(this,void 0,void 0,(function*(){return new an(e,t,n,e,i,e,r,e,"",!1),yield function(){return dn(this,void 0,void 0,(function*(){var t;try{if(0==(t=sn.GetCharacter(t.data)).id){var e=x();const i=yield fetch(o.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw b(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var n=new an(r.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=r.id,sn.AddCharacter(n),r}return new ln(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}()}))}var fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yn(t,e,n,o,i,r,c){return fn(this,void 0,void 0,(function*(){var a=yield ae(t,o),s=a;return 0==s.id&&(s=a=yield ye(t,e,n,o,i,r,c)),s}))}var pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gn(t,e,n,o){return vn(this,void 0,void 0,(function*(){var i=yield Bt(t);if(i&&(0==i.id||0==i.userId)){var r=A(t);if(r.length>0)if(r[0]==t){var c=yield function(t,e,n,o,i,r){return pn(this,void 0,void 0,(function*(){var n;if(1==t.length){var i=t.charCodeAt(0);yield un(t,e,999,o,r),n=yn(t,e,4,49,i,o,"the_character")}else{var c=yield un(t,e,999,o,r);c.isNew,n=yield yn(t,e,4,51,c.id,o,"the_characters")}return n}))}(t,o,0,999,0,e);i=c}else{var a=yield gn(r[0],e,n,o),s=yield gn(r[1],e,n,o);s&&(i=yield pe(t,o,a.id,s.id,999,999,r[1]))}}return i}))}var mn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nn(t){return Cn(this,void 0,void 0,(function*(){let e=m();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;var n=A(t);if(n.length>1){let i=1,r=yield Nn(n[0]);0!=r.id&&(i=r.id),e=yield function(t,e){return Cn(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield function(t,e){return mn(this,void 0,void 0,(function*(){let n=m();try{var i=x("application/x-www-form-urlencoded");const r=yield fetch(o.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});return r.ok?(n=yield r.json(),T.AddConcept(n)):(console.log("This is the concept by category and character error",r.status),b(r)),n}catch(t){throw t instanceof Error?console.log(" This is the concept by category and character error message: ",t.message):console.log(" This is the concept by category and character unexpected error: ",t),t}}))}(t,e)),n}))}(t,i)}else n[0]==t&&(e=yield function(t){return Cn(this,void 0,void 0,(function*(){var e=yield T.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Ft(t)),e}))}(t));return e}))}var wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Tn(t,e){return wn(this,void 0,void 0,(function*(){let e=m();try{if(e=yield Nn(t),0==e.id||4==e.typeId){var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!i.ok)throw b(i),new Error(`Error! status: ${i.status}`);e=yield i.json()}return e}catch(t){throw t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),t}}))}var In=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},kn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},An=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Sn(t){return An(this,void 0,void 0,(function*(){for(var e=yield function(t){return In(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),b(c);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),t}}))}(t),n=0;n<e.length;n++){let t=e[n];var i=t.typeId;let o=yield ze(i);t.type=o}return e}))}function xn(t){return An(this,void 0,void 0,(function*(){for(var e=yield function(t){return kn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),b(c);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),t}}))}(t),n=0;n<e.length;n++){let t=e[n];var i=t.typeId;let o=yield ze(i);t.type=o}return e}))}var Rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gn(t){return Ln(this,void 0,void 0,(function*(){var e=yield ze(t);yield v.removeNodeFromTree(t);var n=e.typeId,i=e.characterValue;yield N.removeTypeConcept(n,t),yield y.removeNodeByCharacter(i,t),d("concept",t),yield function(t){return Rn(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=L();const i=yield fetch(o.DeleteConceptUrl(),{method:"POST",headers:n,body:e});i.ok||(console.log("Delete concept error",i.status),b(i))}catch(t){throw t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),t}}))}(t)}))}var bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t,e){return bn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.DeleteConceptUrl(),{method:"POST",body:i,headers:n});if(!r.ok)throw b(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){throw t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),t}}))}var Fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pn(t,e,n,o){return Fn(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=t.startsWith("the_"),a=m();return r=c?t:"the_"+t,a=yield Tn(r),yield yn(e,n,4,a.id,0,4,r)}))}class Bn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var Un=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dn(){return Un(this,arguments,void 0,(function*(t=[]){try{let e=[],n=[];for(let o=0;o<t.length;o++){let i=yield j.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{let t=x();const i=yield fetch(o.GetConnectionBulkUrl(),{method:"POST",headers:t,body:JSON.stringify(n)});if(i.ok){const t=yield i.json();if(t.length>0){for(let n=0;n<t.length;n++){let o=t[n];e.push(o),j.AddConnection(o)}yield $(e)}}else b(i),console.log("Get Connection Bulk error",i.status);return e}}catch(t){throw t instanceof Error?console.log("Get Connection Bulk error message: ",t.message):console.log("Get Connection Bulk unexpected error: ",t),t}}))}var On=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function En(){return On(this,arguments,void 0,(function*(t=[]){yield q(t);let e=[];for(let n=0;n<t.length;n++){let o=yield St(t[n]);e.push(o)}return e}))}function Vn(){return On(this,arguments,void 0,(function*(t=[]){yield q(t);let e=[];for(let n=0;n<t.length;n++){let o=yield xt(t[n]);e.push(o)}return e}))}function jn(){return On(this,arguments,void 0,(function*(t=[],e=[]){yield Dn(e),K(e,yield Z(t));let n=[];for(let e=0;e<t.length;e++){let o=yield xt(t[e]);n.push(o)}return n}))}function Mn(){return On(this,arguments,void 0,(function*(t=[],e=[]){yield Dn(e),K(e,yield Z(t));let n={};for(let e=0;e<t.length;e++){let o=yield xt(t[e]);n[t[e]]=o}return n}))}function Hn(){return On(this,arguments,void 0,(function*(t=[],e=[]){yield Dn(e),K(e,yield Z(t));let n={};for(let e=0;e<t.length;e++){let o=yield St(t[e]);n[t[e]]=o}return n}))}function Wn(){return On(this,arguments,void 0,(function*(t=[],e=[]){let n=[];for(let t=0;t<e.length;t++)0==(yield j.GetConnection(e[t])).id&&n.push(e[t]);let o=[],i=yield Dn(n);for(let t=0;t<i.length;t++)o.push(i[t].ofTheConceptId),o.push(i[t].toTheConceptId);yield H(o);let r={};for(let e=0;e<t.length;e++){let n=yield xt(t[e]);r[t[e]]=n}return r}))}var $n=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jn(){return $n(this,arguments,void 0,(function*(t=0,e=[],n=""){var i=[];try{var r=new Bn;r.composition=t,r.listLinkers=e,r.textSearch=n;var c=JSON.stringify(r),a=x();const d=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const t=yield d.json();var s=t.compositionIds,l=t.internalConnections;t.externalConnections,i=yield jn(s,l)}else console.log("recursive search error ",d.status),b(d);return i}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}function Zn(){return $n(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.listLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),b(a),[]}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}function zn(){return $n(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.fullLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),b(a),[]}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}function Kn(){return $n(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.fullLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),b(a),[]}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}var Qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qn(t,e){return Qn(this,void 0,void 0,(function*(){try{var n={email:t,password:e},i=new Headers;i.append("Content-Type","application/json");var r=JSON.stringify(n);const c=yield fetch(o.LoginUrl(),{method:"POST",headers:i,body:r});if(c.ok){const t=yield c.json();return console.log(t.data),S.BearerAccessToken=t.data.token,console.log("this is the token",S.BearerAccessToken),t}console.log("Login tsccs error message: ",c.status),b(c)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}var Xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yn(t){return Xn(this,void 0,void 0,(function*(){const e=yield function(){return Xn(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(t,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:b(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(o.SignupUrl(),t);return e}))}var to=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function eo(t){return to(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=o.LoginUrl();try{const t=yield fetch(r,{method:"POST",headers:i,body:e,redirect:"follow"}),o=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==o?void 0:o.data}:b(t),n}catch(t){throw console.log("Sign in api error",t),t}}))}function no(t,e){return-1===t.indexOf(e)&&t.push(e),t}function oo(t=[],e){var n,o;let i=[],r=null===(n=e.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(t))for(let n=0;n<t.length;n++){let c=null===(o=t[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),e.typeId!=t[n].typeId&&r!=c||i.push(t[n])}return i}function io(t=[],e){let n=[],o=e.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(t))for(let i=0;i<t.length;i++){let r=t[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),e.typeId!=t[i].typeId&&o!=r||n.push(t[i])}return n}function ro(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function co(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function ao(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function so(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class lo{constructor(t,e,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}isValid(){const t=new Date(Date.now());return!(this.expiryTime<t&&(uo.removeNodeFromTree(this.key),1))}saveToCache(t){this.value.cached=t}addNode(t,e,n){if(null==e)return t;const o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return this.isValid(),t;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));const r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return this.isValid(),e}rightRotate(t){if(t){const e=t.leftNode;if(e){const n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){const e=t.rightNode;if(e){const n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key&&e.isValid()?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){const e=t.rightNode;return t=null,e}if(null==t.rightNode){const e=t.leftNode;return t=null,e}{const e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.rightNode=this.removeNode(t.rightNode,e.key),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class uo{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addCompositionToTree(t){const e=new lo(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return ho(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return ho(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}uo.root=null;var fo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yo(t,e,n,o){return fo(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=po(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield ze(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=po(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield ze(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=po(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield ze(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield T.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield ze(e),t.type=n)}const l="the_",h=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(h))){if(h){const t=yield yo(d,e,n,o,i);a[h]=t}}else{const t=yield yo(d,e,n,o,i);s[h]=t,a=s}}}return a}))}function po(t,e){let n=m();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class vo{constructor(){this.id=0,this.mainConcept=m(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield yo(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),o.MQTT_CONNECTION&&o.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var go=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mo(t){return go(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let h=null!=o?o:0,u=m();null==a&&(a=new vo);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield ge(o,"",!0,s,l,d);if(null==e&&null==n){let e=h;u=f,e=f.id,h=f.id,a.concepts.push(f),a.id=f.id,yield mo(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,d=h;u=f,a.concepts.push(f);const y=yield ie(s,l,f.id,d);a.connections.push(y),yield mo(t[o],f.id,f.userId,d,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=h,u=yield ge(o,t[o],!1,s,l,d);a.concepts.push(u);const f=yield ie(i,r,u.id,c);a.connections.push(f)}return u}))}var Co=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function No(t){return Co(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=m(),a=m();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let h=[];if(l<0){let t=yield ze(l,e);if(!(t.id>0))return null;l=t.id}i=yield wt(l);const u=[],f=new vo,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)no(y,i[t].ofTheConceptId),no(u,i[t].ofTheConceptId),no(u,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<u.length;t++){const e=yield ze(u[t]);l==u[t]&&(c=e),d==u[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=m();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield ge(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=oo(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=ro(f.connections,e[t].id);h=h.concat(n),s.push(e[t])}yield mo(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield ge(t,l,!1,e,o,n);const c=oo(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=ro(f.connections,c[t].id);h=h.concat(e),s.push(c[t])}}const u=ie(d.id,d.userId,i.id,c.id);r.push(i),f.connections.push(u)}for(let t=0;t<h.length;t++)so(f.connections,h[t]),Je(h[t].id);for(let t=0;t<s.length;t++)ao(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),uo.addCompositionToTree(f),oe.SyncDataOnline(),f.GetDataCache()}))}var wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function To(t,e,n,i){return wo(this,arguments,void 0,(function*(t,e,n,i,r=10,c=1){var a=R("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",n),s.append("inpage",r.toString()),s.append("page",c.toString());const l=o.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield fetch(l,{method:"GET",headers:a});return t.ok?yield t.json():(b(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var Io=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ko(t){return Io(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);const i=o.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(console.log("This is the searching error",t.status),b(t),[])}catch(t){throw console.log("This is the searching error",t),t}}))}var Ao=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function So(t){return Ao(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=yield uo.getNodeFromTree(t),l=[];let d=yield T.GetConcept(t);if(0==d.id&&null!=t&&null!=t&&(d=yield Ct(t)),null==s){let s=[];s=e.length>0?xo(t,e):yield wt(t),i=s;for(let t=0;t<i.length;t++)l.includes(i[t].ofTheConceptId)||(l.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);Go(d,i,r,l);let h=[];a=yield Gt(t,i,l,h),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 xo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function Ro(t){return Ao(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=yield uo.getNodeFromTree(t),d=[];let h=yield T.GetConcept(t);if(0==h.id&&null!=t&&null!=t&&(h=yield Ct(t)),null==l){let l=[];l=e.length>0?xo(t,e):yield wt(t),r=l;for(let t=0;t<r.length;t++)d.includes(r[t].ofTheConceptId)||(d.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);Go(h,r,c,d),a=yield Gt(t,r,d),s[null!==(o=null===(n=null==h?void 0:h.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=h.entryTimeStamp,i.data=s,i.id=t}else a=l.value.GetDataCache(),i=a;return 0==h.id?"":i}))}function Lo(t,e){return Ao(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Dn(e);for(let e=0;e<t.length;e++){const i=yield Ro(t[e],n);i&&o.push(i)}return o}))}function Go(t,e,n,i){return Ao(this,void 0,void 0,(function*(){const r=new vo,c=yield function(t){return Ao(this,void 0,void 0,(function*(){let e=[];const n=[];for(let o=0;o<(null==t?void 0:t.length);o++){const i=yield T.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}return 0==(null==n?void 0:n.length)||(e=yield function(t){return M(this,void 0,void 0,(function*(){const e=[];if(t.length>0){const n={"Content-Type":"application/json"};try{const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){const o=t[n];e.push(o),T.AddConcept(o)}}else console.log("bulk concept getter api error: ",i.status),b(i)}catch(t){throw t instanceof Error?console.log("bulk concept getter api error: ",t.message):console.log("bulk concept getter api error: ",t),t}}return e}))}(n)),e}))}(n);r.connections=e,r.concepts=c,r.id=t.id,r.subcompositions=i,r.mainConcept=t;const a=yield yo(t.id,e,c,i,[]);r.cached=a,uo.addCompositionToTree(r)}))}var bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _o(t){return bo(this,void 0,void 0,(function*(){try{var e=x();const n=JSON.stringify(t),i=yield fetch(o.CreateSessionId(),{method:"POST",headers:e,body:n});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),b(i),null)}catch(t){throw console.log("Creating session failed",t),t}}))}var Fo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Po(t,e){return Fo(this,void 0,void 0,(function*(){try{var n=x("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield fetch(o.CreateSessionVisitUrl(),{method:"POST",headers:n,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),b(r),null)}catch(t){throw console.log("Creating session url failed",t),t}}))}var Bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Uo(t,e){return Bo(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=[],r=yield ze(t),c=yield Nn(e);if(c.id>0){for(var a=yield Oe(c.id,r.id,r.userId,n,o),s=[],l=0;l<a.length;l++)s.push(a[l].toTheConceptId);for(yield q(s),l=0;l<a.length;l++){let t=a[l].toTheConceptId,e=yield ze(t),n=yield Rt(e.id);i.push(n)}}return i}))}function Do(t,e){return Bo(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=[],r=yield ze(t),c=yield Nn(e);if(c.id>0){for(var a=yield Oe(c.id,r.id,r.userId,n,o),s=[],l=0;l<a.length;l++)s.push(a[l].toTheConceptId);for(l=0;l<a.length;l++){let t=a[l].toTheConceptId,e=yield ze(t);i.push(e)}}return i}))}class Oo{constructor(t,e,n,o){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e.value.push(...t.value),e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.rightNode=this.removeNode(t.rightNode,n.key),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Eo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Vo{static compositeKey(t,e){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return Eo(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isDataLoaded)return t("done");setTimeout(Vo.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n);var i=new Oo(o,t,null,null);this.addNodeToTree(i)}static getNodeFromTree(t,e){return Eo(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}let n=this.compositeKey(t,e);return this.root?this.root.getFromNode(n,this.root):null}))}static removeNodeFromTree(t){return Eo(this,arguments,void 0,(function*(t,e=999){if(this.root){let n=this.compositeKey(t,e);this.root=this.root.removeNode(this.root,n)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Vo.root=null;var jo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mo(t,e){return jo(this,arguments,void 0,(function*(t,e,n=999){let o=yield Vo.getNodeFromTree(t,n);console.log("this is the ghost id",t,n);let i=ft();if(o)for(let t=0;t<o.value.length;t++){let n=o.value[t];n.ghostId==e&&(i=n)}return i}))}function Ho(t,e){return jo(this,arguments,void 0,(function*(t,e,n=999){Vo.addConceptToTree(t,e,n)}))}var Wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},$o=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jo(t){return $o(this,arguments,void 0,(function*(t,e=""){let n=[];try{let i=yield function(t){return Wo(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);const i=o.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(b(t),console.log("This is the searching multiple error",t.status),[])}catch(t){throw console.log("This is the searching multiple error",t),t}}))}(t,e),r=t[0].composition;const c=i;let a=c.compositionIds,s=c.internalConnections,l=c.linkers,d=c.reverse;return yield function(t){return On(this,void 0,void 0,(function*(){let e=[],n=[];for(let o=0;o<t.length;o++){let i=yield j.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}let o=[],i=yield Dn(e);n=[...n,...i];for(let t=0;t<n.length;t++)o.push(n[t].ofTheConceptId),o.push(n[t].toTheConceptId);return yield H(o),n}))}(l),n=yield Wn(a,s),yield Zo(l,n,r,d)}catch(t){throw console.log("this is the error in the search link multiple",t),t}}))}function Zo(t,e,n){return $o(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Dn(t),c=[];for(let t=0;t<r.length;t++)c.push(r[t].toTheConceptId),c.push(r[t].ofTheConceptId),c.push(r[t].typeId);yield H(c),r.sort((function(t,e){return e.id-t.id}));for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield ze(r[t].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(e[r[t].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield ze(r[t].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(e[r[t].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function zo(t){var e,n;const o=ft();return o.id=t.id,o.ghostId=t.ghostId,o.userId=t.userId,o.accessId=t.accessId,o.categoryId=t.categoryId,o.characterValue=t.characterValue,o.entryTimeStamp=t.entryTimeStamp,o.typeId=t.typeId,o.type=t.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(e=null==t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"",o}function Ko(t){const e=m();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e}function Qo(t){const e=new P(0,0,0,0,0,0,0);return e.id=t.id,e.ghostId=t.ghostId,e.accessId=t.accessId,e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.isTemp=!1,e}var qo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xo(t){return qo(this,void 0,void 0,(function*(){try{let e=ft();if(t<0){if(e=yield gt.GetConcept(t),0==e.id){let n=yield pt.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}}}else e=zo(yield ze(t));return e}catch(t){throw t}}))}var Yo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ti(t){return Yo(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=ft(),a=ft();const s=[],l=t.compositionId,d=t.ofTheCompositionId;let h=[],u=yield wt(l);for(let t=0;t<u.length;t++)i.push(Qo(u[t]));const f=[],y=[];let p=[];for(let t=0;t<i.length;t++)no(y,i[t].ofTheConceptId),no(f,i[t].ofTheConceptId),no(f,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);for(let t=0;t<f.length;t++){const e=yield ze(f[t]);l==f[t]&&(c=zo(e)),d==f[t]&&(a=zo(e)),r.push(zo(e))}const v=t.patchObject;for(const t in v){let l=ft();const d=v[t];let u=c;a.id>0&&(u=a),Array.isArray(d)||"object"==typeof d?(l=yield Pe(t,"",!0,c.userId,4,999),yield Ue(v[t],l.id,l.userId,c.id,c.userId,4,999)):l=yield Pe(t,d,!1,e,o,n);const f=io(r,l);for(let t=0;t<f.length;t++)if(f[t].id>0){const e=co(i,f[t].id);h=h.concat(e),s.push(f[t])}yield xe(u.id,l.id,c.id,2),r.push(l)}for(let t=0;t<h.length;t++)Je(h[t].id);ki.SyncDataOnline()}))}var ei=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ni=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function oi(t,e,n){return ni(this,void 0,void 0,(function*(){try{let n=yield Ot(e),o=[];0!=n.id&&(o=yield function(t,e){return ei(this,void 0,void 0,(function*(){try{return yield $t.GetConnectionOfCompositionAndTypeLocal(e,t)}catch(t){throw t}}))}(t,n.id));let i=[];for(let t=0;t<o.length;t++){let e=yield zt(o[t].toTheConceptId);i.push(e)}return i}catch(t){throw t}}))}var ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ri(t){return ii(this,void 0,void 0,(function*(){let e=[];try{var n=x();const i=yield fetch(o.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;H(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),b(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}var ci=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ai(t){return ci(this,void 0,void 0,(function*(){var e;try{let n=yield ri(t),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield Gt(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield ze(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}catch(t){throw t}}))}var si=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},li=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function di(t){return li(this,arguments,void 0,(function*(t,e=""){try{var n=yield function(t){return si(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);let i=o.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(i,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),b(t),[])}catch(t){throw console.log("This is the searching internal error",t),t}}))}(t,e);return yield ai(n)}catch(t){throw t}}))}var hi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ui(t,e,n){return hi(this,arguments,void 0,(function*(t,e,n,o=!1){var i,r;try{if(t.userId,o){let o=(null===(i=e.type)||void 0===i?void 0:i.characterValue)+"_s_"+n+"_by";var c=yield Pe("connection",o,!1,999,999,999);yield xe(e.id,t.id,c.id,1e3)}let s=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+n+"_s";var a=yield Pe("connection",s,!1,999,999,999);return yield xe(t.id,e.id,a.id,1e3)}catch(t){throw t}}))}var fi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yi(t){return fi(this,void 0,void 0,(function*(){let e=yield Xo(t);gt.RemoveConcept(e)}))}var pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},vi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gi(t,e,n,i){return vi(this,arguments,void 0,(function*(t,e,n,i,r=!0){var c,a;let s=m();if(""!=n){let o="";o=r?(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+n+"_s":(null===(a=e.type)||void 0===a?void 0:a.characterValue)+"_s_"+n+"_by",s=yield ge("connection",o,!1,999)}""!=i&&(s=yield Tn(i));let l=yield function(t,e,n){return pi(this,void 0,void 0,(function*(){var i=[];try{var r=new FormData;r.append("ofConceptId",t.toString()),r.append("mainKey",n.toString()),r.append("toConceptId",e.toString());const a=yield fetch(o.GetCompositionConnectionBetweenTwoConceptsUrl(),{method:"POST",body:r,redirect:"follow"});if(a.ok){const t=yield a.json();for(var c=0;c<t.length;c++)j.AddConnection(t[c]),i.push(t[c])}else console.log("Get composition connection between two concepts",a.status),b(a);return i}catch(t){throw t instanceof Error?console.log("Get composition connection between two concepts error message: ",t.message):console.log("Get composition connection between two concepts unexpected error: ",t),t}}))}(t.id,e.id,s.id);return l}))}function mi(t,e){return new Promise(((n,o)=>{setTimeout((()=>{n(e)}),t)}))}class Ci{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.structureType="lconcept",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.characterValue=c,this.accessId=r,this.type=null,this.isNew=s,this.typeCharacter=a,this.entryTimeStamp=l,this.updatedTimeStamp=d,this.isSynced=!1,this.referentId=h}getType(){console.log(this.typeId)}}class Ni{constructor(t,e,n,i,r,c){this.isTemp=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=m(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=i,this.ghostId=t,this.orderId=r,this.typeCharacter="",this.accessId=c,this.typeCharacter="",this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date}}class wi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Ti{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}var Ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ki{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){try{let e=!1;0!=ki.CheckIfTheConceptIdExists(t.id,this.conceptsSyncArray).id&&(e=!0),e||this.conceptsSyncArray.push(t)}catch(t){throw t}}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static SyncDataOnline(){return Ii(this,void 0,void 0,(function*(){try{let t=this.conceptsSyncArray.slice(),e=this.connectionSyncArray.slice();this.connectionSyncArray=[],this.conceptsSyncArray=[];let n=[];for(let e=0;e<t.length;e++)n.push(t[e]),yield gt.UpdateConceptSyncStatus(t[e].id);yield this.UpdateConceptListToIncludeRelatedConcepts(e,n);let i=yield function(t,e){return n=this,i=void 0,c=function*(){let n={concepts:[],connections:[]};try{const i=new Headers;let r={concepts:t,connections:e};i.set("Content-Type","application/json"),i.set("Authorization","Bearer "+S.BearerAccessToken),i.set("Accept","application/json"),i.set("Randomizer",o.BASE_RANDOMIZER.toString());const c=yield fetch(o.CreateGhostConceptApiUrl(),{method:"POST",headers:i,body:JSON.stringify(r)});if(!c.ok)throw b(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();return n.concepts=a.concepts,n.connections=a.connections,n}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),t}},new((r=void 0)||(r=Promise))((function(t,e){function o(t){try{s(c.next(t))}catch(t){e(t)}}function a(t){try{s(c.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(o,a)}s((c=c.apply(n,i||[])).next())}));var n,i,r,c}(n,e),r=i.concepts,c=i.connections;for(let t=0;t<r.length;t++)gt.AddPermanentConcept(r[t]);for(let t=0;t<c.length;t++)$t.AddPermanentConnection(c[t]);return t}catch(t){throw t}}))}static ConvertGhostIdsInConnections(t){var e,n,o;for(let i=0;i<t.length;i++){let r=t[i].ofTheConceptId,c=t[i].toTheConceptId,a=t[i].typeId,s=null!==(e=ki.ghostIdMap.get(r))&&void 0!==e?e:r,l=null!==(n=ki.ghostIdMap.get(c))&&void 0!==n?n:c,d=null!==(o=ki.ghostIdMap.get(a))&&void 0!==o?o:a;t[i].ofTheConceptId=s,t[i].toTheConceptId=l,t[i].typeId=d}}static UpdateConceptListToIncludeRelatedConcepts(t,e){return Ii(this,void 0,void 0,(function*(){for(let n=0;n<t.length;n++){let o=t[n].ofTheConceptId,i=t[n].toTheConceptId,r=t[n].typeId;if(o<0){let i=this.CheckIfTheConceptIdExists(o,e);0==i.id&&(i=yield gt.GetConceptByGhostId(o),0!=i.id?i.id!=i.ghostId&&(t[n].ofTheConceptId=i.id):(i=yield gt.GetConcept(o),this.AddConceptIfDoesNotExist(i,e)))}if(i<0){let o=this.CheckIfTheConceptIdExists(i,e);0==o.id&&(o=yield gt.GetConceptByGhostId(i),0!=o.id?o.id!=o.ghostId&&(t[n].toTheConceptId=o.id):(o=yield gt.GetConcept(i),this.AddConceptIfDoesNotExist(o,e)))}if(r<0){let o=this.CheckIfTheConceptIdExists(r,e);0==o.id&&(o=yield gt.GetConceptByGhostId(r),0!=o.id?o.id!=o.ghostId&&(t[n].typeId=o.id):(o=yield gt.GetConcept(r),this.AddConceptIfDoesNotExist(o,e)))}}}))}static AddConceptIfDoesNotExist(t,e=[]){let n=!1;for(let o=0;o<e.length;o++)t.ghostId==e[o].ghostId&&(n=!0);n||e.push(t)}static CheckIfTheConceptIdExists(t,e=[]){let n=ft();for(let o=0;o<e.length;o++)t!=e[o].ghostId&&t!=e[o].id||(n=e[o]);return n}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static syncDataLocalDb(){return Ii(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)ot("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)ot("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}ki.conceptsSyncArray=[],ki.connectionSyncArray=[],ki.ghostIdMap=new Map;class Ai{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0}}class Si{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var xi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Li{}Li.isUpdated=!1,Li.isOnlineSync=!1;var Gi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bi(){return Gi(this,arguments,void 0,(function*(t=!0){try{if(yield a("concepts"),yield et("concepts"),t){var e=yield new Promise((function(t,e){let o="settings";a(o).then((i=>{let r=i.transaction(o,"readwrite").objectStore(o).getAll();r.onsuccess=()=>{let e=new n(!1),o=r.result;for(let t=0;t<o.length;t++)e=o[t];t(e)},r.onerror=t=>{e(t)}})).catch((t=>{e({status:400,ok:!1,message:"Cannot get last object from database because you cannot open the database",data:t})}))}));if(e.isOnlineSync)return!0;yield function(){return Ri(this,void 0,void 0,(function*(){try{const i=(new Date).getTime();var t=R("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllAiData(),{method:"GET",headers:t});r.ok||(console.log("Ai Error Message: ","Cannot get response"),b(r));const c=yield r.json();for(var e=0;e<c.length;e++)T.AddConcept(c[e]);!function(){Gi(this,void 0,void 0,(function*(){Li.isOnlineSync=!0;var t,e=new n(Li.isOnlineSync);t=e,new Promise((function(e,n){let o="settings";a(o).then((i=>{const r=i.transaction(o,"readwrite").objectStore(o).put(t);r.onsuccess=n=>{e(t)},r.onerror=e=>{n({status:400,ok:!1,message:"Cannot update AI flag",data:e,body:t})}})).catch((t=>{n({status:400,ok:!1,message:"Cannot update AI flag because you cannot open the database",data:t})}))}))}))}();let s=(new Date).getTime()-i;console.log("The time taken is ",s)}catch(t){throw t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),t}}))}()}return!0}catch(t){let e={message:"cannot initlize the AI system",ok:!1,status:400,data:t};return console.log(e),!0}}))}var _i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fi(t=""){S.BearerAccessToken=t}function Pi(){return _i(this,arguments,void 0,(function*(t="",e="",n="",i="",r=!0,c="",a=!1){try{o.BASE_URL=t,o.AI_URL=e,o.NODE_URL=i,o.BASE_APPLICATION=c,S.BearerAccessToken=n;let s=Math.floor(1e8*Math.random());if(o.BASE_RANDOMIZER=s,a)return h.isDataLoaded=!0,h.isCharacterLoaded=!0,h.isTypeLoaded=!0,h.isLocalDataLoaded=!0,h.isLocalTypeLoaded=!0,h.isLocalCharacterLoaded=!0,h.isConnectionLoaded=!0,h.isConnectionTypeLoaded=!0,h.isLocalConnectionLoaded=!0,!0;console.log("This ist he base url",o.BASE_URL,s),yield bi(r);const d=(new Date).getTime();return yield k().then((()=>{let t=(new Date).getTime()-d;console.log("The time taken to prepare concept data is ",t)})).catch((t=>{throw t})),yield we().then((()=>{let t=(new Date).getTime()-d;console.log("The time taken to prepare local concept ",t)})).catch((t=>{throw t})),yield function(){return xi(this,void 0,void 0,(function*(){try{var t=yield nt("localconnection");if(Array.isArray(t))for(var e=0;e<t.length;e++)$t.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Local Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{h.isLocalConnectionLoaded=!0})).catch((t=>{throw t})),yield function(){return xi(this,void 0,void 0,(function*(){try{let t=yield l("connection");if(Array.isArray(t))for(let e=0;e<t.length;e++)j.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{h.isConnectionLoaded=!0,h.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-d;console.log("The time taken to prepare connections ",t)})).catch((t=>{throw t})),!0}catch(t){console.log("cannot initialize the system",t)}}))}var Bi=exports;for(var Ui in e)Bi[Ui]=e[Ui];e.__esModule&&Object.defineProperty(Bi,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AddGhostConcept:()=>Wo,BaseUrl:()=>o,BinaryTree:()=>v,Composition:()=>go,CompositionBinaryTree:()=>fo,CompositionNode:()=>ho,Concept:()=>g,ConceptsData:()=>w,Connection:()=>P,ConnectionData:()=>M,CreateComposition:()=>Ne,CreateConnectionBetweenTwoConcepts:()=>qe,CreateConnectionBetweenTwoConceptsGeneral:()=>Ye,CreateConnectionBetweenTwoConceptsLocal:()=>fi,CreateDefaultConcept:()=>C,CreateDefaultLConcept:()=>yt,CreateSession:()=>_o,CreateSessionVisit:()=>Po,CreateTheCompositionLocal:()=>De,CreateTheCompositionWithCache:()=>mo,CreateTheConnection:()=>re,CreateTheConnectionGeneral:()=>je,CreateTheConnectionLocal:()=>Re,DelayFunctionExecution:()=>mi,DeleteConceptById:()=>Un,DeleteConceptLocal:()=>pi,DeleteConnectionById:()=>Ze,FilterSearch:()=>Si,FormatFromConnections:()=>zo,GetAllConnectionsOfComposition:()=>wt,GetAllConnectionsOfCompositionBulk:()=>X,GetComposition:()=>At,GetCompositionBulk:()=>Vn,GetCompositionBulkWithDataId:()=>jn,GetCompositionFromConnectionsWithDataId:()=>Mn,GetCompositionFromConnectionsWithDataIdInObject:()=>$n,GetCompositionFromConnectionsWithDataIdIndex:()=>Hn,GetCompositionFromConnectionsWithIndex:()=>Wn,GetCompositionList:()=>jt,GetCompositionListAll:()=>Mt,GetCompositionListAllWithId:()=>Ht,GetCompositionListLocal:()=>Yt,GetCompositionListLocalWithId:()=>te,GetCompositionListWithId:()=>Wt,GetCompositionLocal:()=>Kt,GetCompositionLocalWithId:()=>Qt,GetCompositionWithAllIds:()=>St,GetCompositionWithCache:()=>xo,GetCompositionWithDataIdBulk:()=>Go,GetCompositionWithDataIdWithCache:()=>Lo,GetCompositionWithId:()=>Gt,GetConceptBulk:()=>W,GetConceptByCharacter:()=>Bt,GetConceptByCharacterAndCategoryLocal:()=>Et,GetConnectionBetweenTwoConceptsLinker:()=>Ci,GetConnectionBulk:()=>On,GetConnectionById:()=>$e,GetConnectionOfTheConcept:()=>Ee,GetLink:()=>cn,GetLinkRaw:()=>an,GetLinkerConnectionFromConcepts:()=>xn,GetLinkerConnectionToConcepts:()=>Rn,GetRelation:()=>Do,GetRelationLocal:()=>ii,GetRelationRaw:()=>Oo,GetTheConcept:()=>Ke,GetTheConceptLocal:()=>Yo,GetUserGhostId:()=>Ho,LConcept:()=>Ni,LConnection:()=>Ti,LocalConceptsData:()=>Ct,LocalSyncData:()=>Ai,LoginToBackend:()=>Xn,MakeTheInstanceConcept:()=>Ce,MakeTheInstanceConceptLocal:()=>Pe,MakeTheTimestamp:()=>Pn,MakeTheTypeConcept:()=>Cn,MakeTheTypeConceptApi:()=>In,MakeTheTypeConceptLocal:()=>_e,PatcherStructure:()=>wi,RecursiveSearchApi:()=>Zn,RecursiveSearchApiNewRawFullLinker:()=>Qn,RecursiveSearchApiRaw:()=>zn,RecursiveSearchApiRawFullLinker:()=>Kn,SearchAllConcepts:()=>Io,SearchLinkInternal:()=>hi,SearchLinkMultipleAll:()=>Zo,SearchQuery:()=>Bn,SearchStructure:()=>xi,SearchWithLinker:()=>Ao,SessionData:()=>Ii,Signin:()=>no,Signup:()=>to,SplitStrings:()=>A,SyncData:()=>ie,TrashTheConcept:()=>_n,UpdateComposition:()=>To,UpdateCompositionLocal:()=>ei,UserBinaryTree:()=>jo,ViewInternalData:()=>si,ViewInternalDataApi:()=>ci,convertFromConceptToLConcept:()=>Ko,convertFromLConceptToConcept:()=>Qo,getFromDatabaseWithType:()=>nn,getObjectsFromIndexDb:()=>on,init:()=>Pi,recursiveFetch:()=>Ut,recursiveFetchNew:()=>po,storeToDatabase:()=>en,updateAccessToken:()=>Fi});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}class o{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 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 CreateGhostConceptApiUrl(){return o.NODE_URL+"/api/v1/local-concepts"}static CreateGhostConnectionApiUrl(){return o.NODE_URL+"/api/v1/local-connections"}static GetRealConceptById(){return o.NODE_URL+"/api/v1/local-concepts-translate"}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"}}o.BASE_URL="https://localhost:7053/",o.AI_URL="https://ai.freeschema.com",o.MQTT_URL="192.168.1.249",o.NODE_URL="http://localhost:5001",o.BASE_APPLICATION="",o.BASE_RANDOMIZER=999;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},r=9;class c{}function a(t){return new Promise((function(e,n){c.db&&e(c.db);let i=o.BASE_URL+"_FreeSchema"+o.BASE_APPLICATION;const s=indexedDB.open(i,r);s.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),a(t),n(e)},s.onsuccess=function(t){let n=t.target;c.db=n.result,e(c.db)},s.onupgradeneeded=t=>{let n=t.target.result,o="concept",i="connection",c="settings";console.log("this is the version update for index",r),n.objectStoreNames.contains(o)&&n.deleteObjectStore(o),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(o)||(n.createObjectStore(o,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{}),e(n)}}))}function s(t,e){return new Promise((function(n,o){a(t).then((i=>{if(0!=e.id){const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the database"+t,data:n,body:e})}}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to the database because you cannot open the database",data:t})}))}))}function l(t){return i(this,void 0,void 0,(function*(){return new Promise((function(e,n){a(t).then((n=>{let o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(let e=0;e<t.length;e++)o.push(t[e]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from the database because you cannot open the database",data:t})}))}))}))}function d(t,e){return new Promise((function(n,o){a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).delete(Number(e));r.onsuccess=function(t){n(e)},r.onerror=e=>{o({status:400,ok:!1,message:"Cannot remove from the database"+t,data:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove from the database because you cannot open the database",data:t,body:e})}))}))}class h{}h.isTypeLoaded=!1,h.isCharacterLoaded=!1,h.isDataLoaded=!1,h.isLocalDataLoaded=!1,h.isLocalCharacterLoaded=!1,h.isLocalTypeLoaded=!1,h.isConnectionLoaded=!1,h.isConnectionTypeLoaded=!1,h.isLocalConnectionLoaded=!1;class u{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getCharacterFromNodeUpdated(t,e){var n;return e?t==e.key||51==(null===(n=e.value)||void 0===n?void 0:n.typeId)?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var f=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class y{static waitForDataToLoad(){return f(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isCharacterLoaded)return t("done");setTimeout(y.checkFlag,1e3,t)}static addNodeToTree(t){return f(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=t,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(t,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(t,e){return f(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new u(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return f(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return f(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}y.characterRoot=null;var p=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class v{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return p(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isDataLoaded)return t("done");setTimeout(v.checkFlag,1e3,t)}static addConceptToTree(t){var e=new u(t.id,t,null,null),n=new u(t.characterValue,t,null,null);y.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return p(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return p(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}v.root=null;class g{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.typeCharacter="",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.x=0,this.y=0,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.referentId=r,this.characterValue=`${c}`,this.accessId=a,this.typeCharacter=h,this.type=null,this.isNew=s,this.entryTimeStamp=l,this.updatedTimeStamp=d}getType(){console.log(this.typeId)}}function C(){let t=new Date,e=new Date;return new g(0,0,0,0,0,"0",0,!1,t,e,"0")}var m=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class N{static addNodeToTree(t){return m(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=t,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(t,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new u(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,t,e))}static getNodeFromTree(t){return this.typeRoot?this.typeRoot.getFromNode(t,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return m(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isTypeLoaded)return t("done");setTimeout(N.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return m(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)if(o.variants[t].value.userId==e){var i=!1;for(let e=0;e<n.length;e++)n[e].id==o.variants[t].value.id&&(i=!0);i||n.push(o.variants[t].value)}}return n}))}static getTypeVariantsWithCharacterValue(t,e){return m(this,void 0,void 0,(function*(){let n=C();try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(e);if(o){o.value.characterValue==t&&(n=o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.characterValue==t&&(n=o.variants[e].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}N.typeRoot=null;var T=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class w{constructor(){this.name="conceptsArray"}static CheckContains(t){for(var e=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==t.id&&(e=!0);return e}static AddNpc(t){this.NPC.includes(t)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(t))}static GetNpc(t){return!!this.NPC.includes(t)}static AddConceptToStorage(t){t.id>0&&s("concept",t)}static AddConcept(t){var e,n;t.id>0&&(e="concept",n=t,new Promise((function(t,o){a(e).then((i=>{const r=i.transaction(e,"readwrite").objectStore(e).put(n);r.onsuccess=e=>{t(n)},r.onerror=t=>{o({status:400,ok:!1,message:"Cannot Update to the database"+e,data:t,body:n})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the database",data:t})}))})),v.addConceptToTree(t),N.addConceptToTree(t),y.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(v.addConceptToTree(t),N.addConceptToTree(t),y.addConceptToTree(t))}static AddConceptTemporary(t){var e=this.CheckContains(t);this.conceptDictionary[t.id]=t,e&&this.RemoveConcept(t),this.conceptsArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsArray.length;e++)this.conceptsArray[e].id==t.id&&this.conceptsArray.splice(e,1);d("concept",t.id)}static GetConcept(t){return T(this,void 0,void 0,(function*(){var e=C(),n=yield v.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return T(this,void 0,void 0,(function*(){var e=C(),n=y.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return T(this,void 0,void 0,(function*(){var e=C(),n=y.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return T(this,void 0,void 0,(function*(){return C(),yield N.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return T(this,void 0,void 0,(function*(){var n=C(),o=yield y.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return T(this,void 0,void 0,(function*(){let n=[];return n=yield N.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return y.characterRoot}getName(){return this.name}}w.conceptsArray=[],w.NPC=[],w.conceptDictionary=[];var I=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function k(){return I(this,void 0,void 0,(function*(){try{let e=yield l("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];w.AddConceptToMemory(n)}h.isDataLoaded=!0,h.isCharacterLoaded=!0,h.isTypeLoaded=!0}catch(t){throw yield mi(2e3,k()),{message:"Cannot create Binary Tree Concept",ok:!1,status:400,data:t}}}))}function A(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}class S{}function x(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+S.BearerAccessToken,Accept:e}}function R(t="application/json",e="",n="application/json"){return""==e&&(e=S.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}function L(){let t=S.BearerAccessToken;const e=new Headers;return e.append("Authorization","Bearer "+t),e}S.BearerAccessToken="";class G{constructor(t,e,n,i){this.url=o.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function U(t){if(401==t.status){let e=new G(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}if(500==t.status){let e=new G(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}function b(t,e=""){let n=new G(t.message,!1,500,t.stack);throw n.setUrl(e),n}var _=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function F(t,e){return _(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var i=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:n});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)w.AddConcept(t[r])}else console.log("GetAllConceptsByType error",c.status),U(c)}catch(t){t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),b(t,o.GetAllConceptsByTypeUrl())}}))}class P{constructor(t=0,e,n,i,r,c,a){this.isTemp=!1,this.toUpdate=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.userId=i,this.typeId=r,this.ghostId=t,this.orderId=c,this.accessId=a,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date,this.typeCharacter=""}}class B{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;t.value.id==e.value.id&&(n=!0);for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var D=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class O{static addNodeToTree(t){if(null==this.connectionroot)return this.connectionroot=t,this.connectionroot;this.connectionroot=this.connectionroot.addNode(t,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(t){var e=new B(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return D(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isConnectionLoaded)return t("done");setTimeout(O.checkFlag,1e3,t)}static removeNodeFromTree(t){return D(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return D(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}O.connectionroot=null;var E=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class V{static addNodeToTree(t){return E(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=t,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(t,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return E(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isConnectionTypeLoaded)return t("done");setTimeout(V.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new B(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,t,e))}static getNodeFromTree(t){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(t,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(t){return E(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad()}catch(t){return e}var n=this.getNodeFromTree(t);if(n){e.push(null==n?void 0:n.value);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value);return e}}))}static getTypeVariantsFromTreeWithUserId(t,e){return E(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}V.connectionTypeRoot=null;var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class M{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){s("connection",t)}static AddConnection(t){t.isTemp||(s("connection",t),O.addConnectionToTree(t),V.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(O.addConnectionToTree(t),V.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(d("connection",t.id),O.removeNodeFromTree(t.id),V.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return O.connectionroot}static GetConnectionTypeTree(){return V.connectionTypeRoot}static GetConnection(t){return j(this,void 0,void 0,(function*(){var e=new P(0,0,0,0,0,0,0),n=yield O.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return j(this,void 0,void 0,(function*(){var e=[],n=yield V.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;if(o){let t=o;e.push(t);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value)}}return e}))}getName(){return this.name}}M.connectionArray=[],M.connectionDictionary=[];var H=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function W(t){return H(this,void 0,void 0,(function*(){let e=[];try{var n=[];for(let e=0;e<t.length;e++)0==(yield w.GetConcept(t[e])).id&&n.push(t[e]);if(0==n.length)return e;{var i=x();const t=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(n)});if(t.ok){if(e=yield t.json(),e.length>0)for(let t=0;t<e.length;t++){let n=e[t];w.AddConcept(n)}}else console.log("Get Concept Bulk error",t.status),U(t)}}catch(t){t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),b(t,o.GetConceptBulkUrl())}return e}))}var $=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function J(){return $(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length>0){for(let n=0;n<t.length;n++)e.includes(t[n].ofTheConceptId)||e.push(t[n].ofTheConceptId),e.includes(t[n].toTheConceptId)||e.push(t[n].toTheConceptId);yield W(e)}}))}var Z=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function z(){return Z(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield M.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function K(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||M.RemoveConnection(e[n]))}function Q(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||M.RemoveConnection(e[n])}var q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function X(){return q(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var n=yield z(t),i=yield function(){return q(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=x();const r=yield fetch(o.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)M.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),U(r);return e}catch(t){t instanceof Error?console.log("Get all connections of composition bulk error message: ",t.message):console.log("Get all connections of composition bulk unexpected error: ",t),b(t,o.GetAllConnectionsOfCompositionBulkUrl())}}))}(t);return K(e=i,n),yield J(e),e}))}var Y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},tt=9;class et{}function nt(t){return new Promise((function(e,n){et.db&&e(et.db);let i=o.BASE_URL+"_FreeSchemaLocal"+o.BASE_APPLICATION;const r=indexedDB.open(i,tt);r.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),nt(t),n(e)},r.onsuccess=function(t){var n=t.target;et.db=n.result,e(et.db)},r.onupgradeneeded=t=>{var n=t.target.result,i="localconcept",r="localconnection",c="localid";console.log("this is the version upgrade",tt),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(r)&&n.deleteObjectStore(r),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(r)||(n.createObjectStore(r,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{it(c,{id:0,value:-100}),it(c,{id:1,value:-200}),it(c,{id:3,value:o.BASE_RANDOMIZER})}),e(n)}}))}function ot(t){return Y(this,void 0,void 0,(function*(){return new Promise((function(e,n){nt(t).then((n=>{var o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(var n=0;n<t.length;n++)o.push(t[n]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from database because you cannot open the Local database",data:t})}))}))}))}function it(t,e){return new Promise((function(n,o){nt(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the Local database "+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to database because you cannot open the Local database",data:t})}))}))}function rt(t,e){return new Promise((function(n,o){nt(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the Local database",data:t})}))}))}function ct(t,e){return new Promise((function(n,o){nt(t).then((i=>{let r=i.transaction(t,"readwrite").objectStore(t).delete(e);r.onsuccess=function(t){n(e)},r.onerror=function(n){o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove object from database because you cannot open the Local database",data:t})}))}))}class at{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}updateNodeSyncStatus(t,e,n){if(n){if(t==n.key){let t=n.value;return t.isSynced=e,n.value=t,n}return t<n.key?this.updateNodeSyncStatus(t,e,n.leftNode):t>n.key?this.updateNodeSyncStatus(t,e,n.rightNode):n}return n}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var st=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class lt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new at(t.id,t,null,null);new at(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return st(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalDataLoaded)return t("done");setTimeout(lt.checkFlag,1e3,t)}static getNodeFromTree(t){return st(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static updateSyncStatus(t){return this.root?this.root.updateNodeSyncStatus(t,!0,this.root):this.root}static removeNodeFromTree(t){return st(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}lt.root=null;var dt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ht{static waitForDataToLoad(){return dt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalCharacterLoaded)return t("done");setTimeout(ht.checkFlag,1e3,t)}static addNodeToTree(t){return dt(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=t,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(t,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(t){if(""!=t.characterValue){var e=new at(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(t,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(t,e){return dt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static getCharacterAndCategoryFromTree(t,e){return dt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndCategory(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}ht.LocalCharacterRoot=null;var ut=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ft{static addNodeToTree(t){return ut(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=t,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(t,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new at(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeConceptType(t,e){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,t,e))}static getNodeFromTree(t){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(t,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return ut(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalTypeLoaded)return t("done");setTimeout(ft.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return ut(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){console.log("this is the node to type",o),o.value.userId!=e&&999!=o.value.userId||n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId!=e&&999!=o.value.userId||n.push(o.variants[t].value)}return n}))}}function yt(){let t=new Date,e=new Date;return new g(0,0,0,0,0,"0",0,!1,t,e,"0")}ft.LocalTypeRoot=null;var pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class vt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new at(t.ghostId,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return pt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalDataLoaded)return t("done");setTimeout(vt.checkFlag,1e3,t)}static getNodeFromTree(t){return pt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return pt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}vt.root=null;var gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ct{constructor(){this.name="conceptsArray"}static AddConcept(t){0!=t.id&&(it("localconcept",t),lt.addConceptToTree(t),ht.addConceptToTree(t),ft.addConceptToTree(t),this.localconceptsArray.push(t))}static AddPermanentConcept(t){0!=t.id&&(lt.removeNodeFromTree(t.ghostId),ht.removeConceptType(t.characterValue,t.ghostId),ft.removeConceptType(t.typeId,t.ghostId),vt.addConceptToTree(t),ct("localconcept",t.ghostId),w.AddConcept(t))}static RemoveConcept(t){return gt(this,void 0,void 0,(function*(){try{0!=t.id&&(lt.removeNodeFromTree(t.ghostId),ht.removeConceptType(t.characterValue,t.ghostId),ft.removeConceptType(t.typeId,t.ghostId),yield ct("localconcept",t.ghostId))}catch(t){throw t}}))}static AddConceptToMemory(t){0!=t.id&&(lt.addConceptToTree(t),ht.addConceptToTree(t),ft.addConceptToTree(t))}static GetConcept(t){return gt(this,void 0,void 0,(function*(){var e=yt(),n=yield lt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static UpdateConceptSyncStatus(t){return gt(this,void 0,void 0,(function*(){lt.updateSyncStatus(t)}))}static GetConceptByGhostId(t){return gt(this,void 0,void 0,(function*(){var e=yt(),n=yield vt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return gt(this,void 0,void 0,(function*(){var e=yt(),n=ht.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return gt(this,void 0,void 0,(function*(){var n=yt(),o=yield ht.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptByCharacterAndCategoryLocal(t,e){return gt(this,void 0,void 0,(function*(){var n=yt(),o=yield ht.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return gt(this,void 0,void 0,(function*(){let n=[];return n=yield ft.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}Ct.localconceptsArray=[];var mt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nt(t){return mt(this,void 0,void 0,(function*(){try{let i=C();var e=yield w.GetConcept(t);let r=w.GetNpc(t);if(0!=e.id||r)return e;{var n=x("application/x-www-form-urlencoded");console.log("this is the url",o.GetConceptUrl());const e=yield fetch(o.GetConceptUrl(),{method:"POST",headers:n,body:`id=${t}`});return e.ok?(i=yield e.json(),i.id>0?w.AddConcept(i):w.AddNpc(t)):(console.log("Get the concept error",e.status),U(e)),i}}catch(t){t instanceof Error?console.log("Get the concept error message: ",t.message):console.log("Get the concept unexpected error: ",t),b(t,o.GetConceptUrl())}}))}var Tt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wt(t){return Tt(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield M.GetConnectionsOfCompositionLocal(t)).length)e=yield It(t);else{var n=yield It(t);K(n,e),e=n}return e}))}function It(t){return Tt(this,void 0,void 0,(function*(){var e=[];try{var n=x("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${t}`});if(console.log("this is getting connection from online",o.GetAllConnectionsOfCompositionUrl(),t),!r.ok)throw U(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)M.AddConnection(c[i]),e.push(c[i]);return e}catch(t){t instanceof Error?console.log("Get all connection of composition error : ",t.message):console.log("Get all connection of composition error : ",t),b(t,o.GetAllConnectionsOfCompositionUrl())}}))}var kt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function At(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t),console.log("this is the connection list online",o);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Nt(t));var s=yield Ut(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function St(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Nt(t));var s=yield bt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function xt(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield M.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Nt(t));var s=yield Ut(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function Rt(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield M.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(console.log("this concept you cannot find ",t),a=yield Nt(t));var s=yield Ut(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function Lt(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield M.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Nt(t));var s=yield Ut(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l.created_at=a.entryTimeStamp,l}))}function Gt(t){return kt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield w.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Nt(t));var s=yield Ut(t,o,r);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s;var l={};return l.data=i,l.id=t,l}))}function Ut(t,e,n){return kt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield w.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Nt(t)),0!=l.id&&null==l.type){var d=l.typeId,h=yield w.GetConcept(d);l.type=h,null==h&&null!=d&&null!=d&&(h=yield Nt(d),l.type=h)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t)if(t!=e[u].toTheConceptId){var f=e[u].toTheConceptId,y=yield w.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Nt(f)),0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield w.GetConcept(d),y.type=h,null==h&&null!=d&&null!=d&&(h=yield Nt(d),y.type=h));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield Ut(f,e,n,o);a[p]=t}}else{const t=yield Ut(f,e,n,o);s[p]=t,a=s}}else console.log("this is the faulty connection ",e[u]);return a}))}function bt(t,e,n){return kt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield w.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Nt(t)),0!=l.id&&null==l.type){var d=l.typeId,h=yield w.GetConcept(d);l.type=h,null==h&&null!=d&&null!=d&&(h=yield Nt(d),l.type=h)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t){var f=e[u].toTheConceptId,y=yield w.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Nt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield w.GetConcept(d),y.type=h,null==h&&null!=d&&null!=d&&(h=yield Nt(d),y.type=h));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield bt(f,e,n);a[p]=t}}else{const t=yield bt(f,e,n);s[p]=t,a=s}}return a}))}var _t=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ft(t){return _t(this,void 0,void 0,(function*(){let e=C();try{var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${t}`});i.ok?(e=yield i.json(),e.id>0&&w.AddConcept(e)):(U(i),console.log("Error in Getting concept by character value Error",i.status))}catch(t){t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),b(t,o.GetConceptByCharacterValueUrl())}return e}))}var Pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bt(t){return Pt(this,void 0,void 0,(function*(){var e=yield w.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Ft(t),e=yield w.GetConceptByCharacterAndTypeLocal(t,51)),e}))}var Dt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ot(t){return Dt(this,void 0,void 0,(function*(){return yield Ct.GetConceptByCharacterAndTypeLocal(t,51)}))}function Et(t){return Dt(this,void 0,void 0,(function*(){let e=yt();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;var n=A(t);if(n.length>1){let o=1,i=yield Et(n[0]);0!=i.id&&(o=i.id),e=yield function(t,e){return Dt(this,void 0,void 0,(function*(){return Ct.GetConceptByCharacterAndCategoryLocal(t,e)}))}(t,o)}else n[0]==t&&(e=yield Ot(t));return e}))}var Vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function jt(t,e){return Vt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Bt(t),r=[];if(i){yield F(t,e);for(var c=yield w.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield X(s),l=a;l<a+n;l++)if(c[l]){var d=yield xt(c[l].id);r.push(d)}}return r}))}function Mt(t,e){return Vt(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=Yt(t,e),r=jt(t,e),c=[];return Promise.race([i,r]).then((t=>{console.log("Promise result",t),c.push(...t)})).catch((t=>{console.log("error in handling",t)})),r.then((t=>{console.log("This is the second promise result",t),c.push(...t)})),c}))}function Ht(t,e){return Vt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Ot(t),r=yield Bt(t);let c=[],a=[],s=[],l=[];0!=i.id&&(a=yield Ct.GetConceptsByTypeIdAndUser(i.id,e)),0!=r.id&&(yield F(t,e),l=yield w.GetConceptsByTypeIdAndUser(r.id,e),c=l);for(let t=0;t<a.length;t++){let e=!1;for(let n=0;n<l.length;n++)a[t].ghostId==l[n].ghostId&&(e=!0);e||s.push(a[t])}console.log("This is the all list",s);let d=[];return d=yield function(t,e){return Vt(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[];var r=n*(o-1),c=[];let a=e.length;for(var s=r;s<r+n-a;s++)t[s]&&c.push(t[s].id);for(s=0;s<e.length;s++){var l=yield Qt(e[s].id);i.push(l)}for(yield X(c),s=r;s<r+n-a;s++)t[s]&&(l=yield Rt(t[s].id),i.push(l));return i}))}(c,s,n,o),d}))}function Wt(t,e){return Vt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Bt(t),r=[];if(i){yield F(t,e);for(var c=yield w.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield X(s),l=a;l<a+n;l++)if(c[l]){var d=yield Rt(c[l].id);r.push(d)}}return r}))}var $t=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Jt{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),0!=t.id&&it("localconnection",t),this.connectionArray.push(t)}static AddConnectionToMemory(t){this.CheckContains(t)&&this.RemoveConnection(t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){console.log("this is removing",t);for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static AddPermanentConnection(t){t.id>0&&(ct("localconnection",t.ghostId),M.AddConnection(function(t){let e=new P(0,0,0,0,0,0,0);return e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.typeId=t.typeId,e.orderId=t.orderId,e.id=t.id,e}(t)))}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return $t(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isLocalConnectionLoaded)return t("done");setTimeout(Jt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return $t(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad();for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}static GetConnectionOfCompositionAndTypeLocal(t,e){return $t(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad(),console.log("this is the connections",this.connectionArray,t,e);for(var o=0;o<this.connectionArray.length;o++)this.connectionArray[o].typeId==t&&this.connectionArray[o].ofTheConceptId==e&&n.push(this.connectionArray[o]);return n}catch(t){return n}}))}getName(){return this.name}}Jt.connectionArray=[],Jt.connectionDictionary=[];var Zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kt(t){return zt(this,void 0,void 0,(function*(){var e,n;try{var i,r={};i=yield Jt.GetConnectionsOfCompositionLocal(t);for(var c=[],a=0;a<i.length;a++)c.includes(i[a].ofTheConceptId)||c.push(i[a].ofTheConceptId);var s=yield Ct.GetConcept(t);if(0==s.id){let e=yield function(t){return Zt(this,void 0,void 0,(function*(){let e=C();try{var n=R("application/x-www-form-urlencoded");const i=yield fetch(o.GetRealConceptById(),{method:"POST",headers:n,body:`id=${t}`});if(i.ok)return e=yield i.json(),e.id>0&&w.AddConcept(e),e;console.log("Error in Getting Translating concept Error",i.status),U(i)}catch(t){t instanceof Error?console.log("Error in Getting Translating concept error message: ",t):console.log("Error in Getting Translating concept unexpected error: ",t),b(t,o.GetRealConceptById())}return e}))}(t);if(e.id>0)return yield At(e.id)}var l=yield qt(t,i,c);return r[null!==(n=null===(e=null==s?void 0:s.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=l,r}catch(t){throw t}}))}function Qt(t){return zt(this,void 0,void 0,(function*(){var e,n;try{var o,i={},r={};o=yield Jt.GetConnectionsOfCompositionLocal(t);for(var c=[],a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);var s=yield Ct.GetConcept(t);if(0!=s.id){var l=yield qt(t,o,c);i[null!==(n=null===(e=null==s?void 0:s.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=l}return r.data=i,r.id=t,r}catch(t){throw t}}))}function qt(t,e,n){return zt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[],l=yield Ct.GetConcept(t);if(0!=l.id&&null==l.type){var d=l.typeId,h=yield Ct.GetConcept(d);l.type=h}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var u=0;u<e.length;u++)if(e[u].ofTheConceptId==t){var f=e[u].toTheConceptId,y=yield Ct.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,h=yield Ct.GetConcept(d),y.type=h);var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield qt(f,e,n);a[p]=t}}else{const t=yield qt(f,e,n);s[p]=t,a=s}}return a}))}var Xt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yt(t,e){return Xt(this,void 0,void 0,(function*(){try{var n=yield Ot(t),o=[];if(0!=n.id)for(var i=yield Ct.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Kt(i[r].id);o.push(c)}return o}catch(t){throw t}}))}function te(t,e){return Xt(this,void 0,void 0,(function*(){try{var n=yield Ot(t),o=[];if(0!=n.id)for(var i=yield Ct.GetConceptsByTypeIdAndUser(n.id,e),r=0;r<i.length;r++){var c=yield Qt(i[r].id);o.push(c)}return o}catch(t){throw t}}))}var ee=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ne(t){return ee(this,void 0,void 0,(function*(){let e=C();try{var n=x();const i=yield fetch(o.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!i.ok)throw U(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),b(t,o.CreateTheConceptUrl())}}))}var oe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ie{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(){return oe(this,void 0,void 0,(function*(){for(let t=0;t<this.conceptsSyncArray.length;t++)w.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)M.AddConnection(this.connectionSyncArray[t]);if(this.conceptsSyncArray.length>0){let t=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],ne(t)}if(this.connectionSyncArray.length>0){let t=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(t){return e=this,n=void 0,r=function*(){let e=new P(0,0,0,0,0,0,0);try{var n=x(),i=JSON.stringify(t);const r=yield fetch(o.CreateTheConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?yield r.json():(console.log("Create the connection error message: ",r.status),U(r)),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,n||[])).next())}));var e,n,i,r}(t)}return"done"}))}static syncDataLocalDb(){return oe(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)s("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)s("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}function re(t,e,n,o){var i=new P(0,t,n,e,o,1,4);return t==n?(i.ofTheConceptId=0,i.toTheConceptId=1,i):(i.isTemp=!0,i.id=Math.floor(1e8*Math.random()),ie.AddConnection(i),i)}ie.conceptsSyncArray=[],ie.connectionSyncArray=[];var ce=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function se(t,e){return ae(this,void 0,void 0,(function*(){let n=yield w.GetConceptByCharacterAndTypeLocal(t,e);try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=x();const a=yield fetch(o.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});a.ok?(n=yield a.json(),w.AddConcept(n)):(U(a),console.log("This is the concept by type and character error",a.status))}return n}catch(t){t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),b(t,o.GetConceptByCharacterAndTypeUrl())}}))}var le=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class de{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.userId=t,this.data=e,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var he=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ue{static getId(){return he(this,void 0,void 0,(function*(){this.ids.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{var t=x("application/x-www-form-urlencoded");const n=yield fetch(o.GetReservedIdUrl(),{method:"GET",headers:t});if(!n.ok)throw U(n),new Error(`Error! status: ${n.status}`);const i=yield n.json();for(var e=0;e<i.length;e++)ue.AddId(i[e])}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message):console.log("get reserved ids unexpected error: ",t),b(t,o.GetReservedIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}ue.ids=[];class fe{static getId(){return he(this,void 0,void 0,(function*(){this.connectionIds.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{var t=x("application/x-www-form-urlencoded");const n=yield fetch(o.GetReservedConnectionIdUrl(),{method:"GET",headers:t});if(!n.ok)throw U(n),new Error(`Error! status: ${n.status}`);const i=yield n.json();for(var e=0;e<i.length;e++)fe.AddId(i[e])}catch(t){t instanceof Error?console.log("get reserved connection ids error message: ",t.message):console.log("get reserved connection ids unexpected error: ",t),b(t,o.GetReservedConnectionIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}fe.connectionIds=[];var ye=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function pe(t,e,n,o,i,r,c){return ye(this,void 0,void 0,(function*(){var a=yield ue.getId();let s=new Date,l=new Date,d=new g(a,e,o,n,i,t,r,!0,s,l,c);return d.isTemp=!1,ie.AddConcept(d),d}))}function ve(t,e,n,o,i,r,c){return ye(this,void 0,void 0,(function*(){var a=yield ue.getId();let s=new Date,l=new Date,d=new g(a,e,o,n,i,t,r,!1,s,l,c);return w.AddConcept(d),ne([d]),d}))}var ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ce(t,e){return ge(this,arguments,void 0,(function*(t,e,n=!1,i,r=4,c=999,a=0){let s,l=c,d=i,h=i,u=r,f=i,y="",p=e.length,v=C();if(y=t.startsWith("the_")?t:"the_"+t,n)v=yield In(t),s=yield pe(e,i,4,v.id,a,u,t);else if(p>255)v=yield In(y),s=yield pe(e,i,4,v.id,a,u,y),function(t){ce(this,void 0,void 0,(function*(){try{var e=x();const n=yield fetch(o.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw U(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(t){throw t instanceof Error?console.log("Create the text error message: ",t.message):console.log("Create the text unexpected error: ",t),t}}))}(new de(i,e,999,d,u,f,l,h,Date.now().toString(),!0));else{v=yield In(y);let t=yield se(e,v.id);s=t,0==t.id&&0==t.userId&&(s=yield ve(e,i,4,v.id,12,u,y),function(t,e,n,i){le(this,void 0,void 0,(function*(){try{var r={newConceptId:t,referent:e,typeId:n,typeUserId:i},c=x(),a=JSON.stringify(r);const s=yield fetch(o.MakeTheNameInBackendUrl(),{method:"POST",headers:c,body:a});s.ok||U(s)}catch(t){t instanceof Error?console.log("make the name in backend error message: ",t.message):console.log("make the name in backend unexpected error: ",t),b(t,o.MakeTheNameInBackendUrl())}}))}(s.id,`${e}`,v.id,i))}return s.type=v,s}))}var me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ne(t){return me(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,h=C();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var u=d;h=p=yield Ce(o,"",!0,a,s,l),u=p.id,d=p.id,yield Ne(t[o],p.id,p.userId,u,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;u=d,h=p=yield Ce(o,"",!0,a,s,l),yield re(f,y,p.id,u),yield Ne(t[o],p.id,p.userId,u,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,u=d;var p=yield Ce(o,t[o].toString(),!1,a,s,l);yield re(f,y,p.id,u)}return h}))}var Te=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function we(){return Te(this,void 0,void 0,(function*(){console.log("this is trying to create local binary tree");try{let t=yield ot("localconcept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];Ct.AddConceptToMemory(n)}h.isLocalDataLoaded=!0,h.isLocalTypeLoaded=!0,h.isLocalCharacterLoaded=!0}catch(t){throw yield mi(2e3,we()),{message:"Cannot create local binary tree from index db",data:t,ok:!1,status:400}}}))}function Ie(){return Te(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Te(this,void 0,void 0,(function*(){let t=yield ot("localid");if(Array.isArray(t)){if(t[0]){let e=t[0].value;if(e)Se.AddConceptId(t[0]),yield rt("localid",{id:0,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Se.AddConceptId(t),yield rt("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}function ke(){return Te(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Te(this,void 0,void 0,(function*(){let t=yield ot("localid");if(Array.isArray(t)){if(t[1]){let e=t[1].value;if(e)Se.AddConnectionId(t[1]),yield rt("localid",{id:1,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Se.AddConnectionId(t),yield rt("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Se{static AddConceptId(t){this.localId=t.value}static getConceptId(){return Ae(this,void 0,void 0,(function*(){try{if(this.localId){if(this.ReservedLocalId.length<5){yield Ie().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}})).catch((t=>(console.log(" getid: cannot get the id from indexdb"),-Math.floor(1e8*Math.random()))));let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}{let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}}return yield Ie().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}})),this.getConceptId()}catch(t){return console.log(" getid: this is the eror in concept",t),-Math.floor(1e8*Math.random())}}))}static AddConnectionId(t){this.localConnectionId=t.value}static getConnectionId(){return Ae(this,void 0,void 0,(function*(){try{if(this.localConnectionId){if(this.ReservedConnectionId.length<5){yield ke().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})).catch((t=>(console.log("this is the new event",t),-Math.floor(1e8*Math.random()))));let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}{let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}}return yield ke().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})),this.getConnectionId()}catch(t){return-Math.floor(1e8*Math.random())}}))}}Se.ReservedLocalId=[],Se.ReservedConnectionId=[];var xe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Re(t,e,n){return xe(this,arguments,void 0,(function*(t,e,n,o=1,i="",r=999){try{let c=yield Se.getConnectionId(),a=0,s=0,l=0;a=t,s=e,l=n;let d=new P(0,0,0,0,0,0,0);return t!=e&&(d=new P(c,a,s,r,n,o,4),d.isTemp=!0,d.typeCharacter=i,yield Ai.AddConnection(d),Jt.AddConnection(d)),d}catch(t){throw t}}))}var Le=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ge(t,e,n,o,i,r){return Le(this,arguments,void 0,(function*(t,e,n,o,i,r,c=!1,a=0){try{var s=yield Se.getConceptId();console.log("this is the getting id type connection",s);var l=!0;let h=new Date,u=new Date;if("the"==t)return new g(1,999,5,5,a,t,r,l,h,u,e);var d=new g(s,n,i,o,a,t,r,l,h,u,e);return d.isTemp=!0,d.isComposition=c,Ct.AddConcept(d),d}catch(t){throw t}}))}var Ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _e(t,e,n,o){return be(this,void 0,void 0,(function*(){let i=yield Et(t);if(i&&(0==i.id||0==i.userId)){let r=A(t);if(r[0]==t){let e=yield function(t,e,n,o){return Ue(this,void 0,void 0,(function*(){var e=yield Ct.GetConceptByCharacterAndTypeLocal(t,51),i=e;return o=1,0==i.id&&(i=e=yield Ge(t,"the",n,o,51,4)),i}))}(t,0,o,1);i=e}else{let c=yield _e(r[0],e,n,o),a=yield _e(r[1],e,n,o);i=yield Ge(t,r[1],o,c.id,a.id,4)}}return i}))}var Fe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pe(t,e){return Fe(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{let i,r,a=999,s=4,l=o,d=4,h="",u=e.length;if(h=t.startsWith("the_")?t:"the_"+t,n)i=yield _e(t,a,o,o),r=yield Ge(e,t,o,s,i.id,d,!0,c);else if(u>255)i=yield _e(h,a,l,o),r=yield Ge(e,h,o,s,i.id,d);else{i=yield _e(h,a,l,o);let t=yield Ct.GetConceptByCharacterAndTypeLocal(e,i.id);r=t,0==t.id&&0==t.userId&&(r=yield Ge(e,h,o,s,i.id,d))}return r.type=i,Ai.AddConcept(r),r}catch(t){throw t}}))}var Be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function De(t){return Be(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=!1){var s=null!=i?i:999,l=null!=r?r:999,d=null!=c?c:999,h=null!=o?o:0,u=yt();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var f=h;u=p=yield Pe(o,"",!0,s,l,d),f=p.id,h=p.id,yield De(t[o],p.id,p.userId,f,i,r,c)}else{var y=null!=e?e:999,p=(f=h,yield Pe(o,"",!0,s,l,d));yield Re(y,p.id,f),yield De(t[o],p.id,p.userId,f,i,r,c)}else y=null!=e?e:999,f=h,p=yield Pe(o,t[o].toString(),!1,s,l,d),yield Re(y,p.id,f);return u}))}var Oe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ee(t,e,n){return Oe(this,arguments,void 0,(function*(t,e,n,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${n}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=x("application/x-www-form-urlencoded");const l=yield fetch(o.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(U(l),console.log("Get connection of concept error",l.status)),c}catch(t){t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),b(t,o.GetAllConnectionsOfConceptUrl())}}))}var Ve=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function je(t,e,n,o,i,r,c){return Ve(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4){var l=e,d=yield fe.getId(),h=new P(d,t,n,l,i,a,s);return t==n?(h.ofTheConceptId=0,h.toTheConceptId=1,h):(h.toUpdate=!0,h.isTemp=!1,ie.AddConnection(h),h)}))}var Me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},He=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},We=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $e(t){return We(this,void 0,void 0,(function*(){var e=yield M.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var n=yield function(t){return He(this,void 0,void 0,(function*(){var e=yield M.GetConnection(t);try{if(0!=e.id)return e;{var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${t}`});return i.ok?(e=yield i.json(),M.AddConnection(e)):(U(i),console.log("Get Connection Error",i.status)),e}}catch(t){t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),b(t,o.GetConnectionUrl())}}))}(t);e=n}return e}))}var Je=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ze(t){return Je(this,void 0,void 0,(function*(){var e=yield $e(t);yield function(t){return Me(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=L();const i=yield fetch(o.DeleteTheConnectionUrl(),{method:"POST",headers:n,body:e,redirect:"follow"});i.ok||(console.log("Delete connection error status: ",i.status),U(i))}catch(t){t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),b(t,o.DeleteTheConnectionUrl())}}))}(t),d("connection",t),O.removeNodeFromTree(t),V.removeTypeConcept(e.typeId,t)}))}var ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ke(t){return ze(this,arguments,void 0,(function*(t,e=999){try{var n=C();if(t<0)return Qo(yield Ho(e,t));if(null!=(n=yield w.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield Nt(t)),0!=n.id&&null==n.type&&null==(yield w.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield Nt(n.typeId);n.type=o}return n}catch(t){throw console.error("this is the error in the getting concept",t),t}}))}var Qe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qe(t,e,n){return Qe(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Xe(o,e,a));var s=yield Ce("connection",c,!1,999,999,999);let l=new P(0,e.id,t.id,a,s.id,1e3,4);ie.AddConnection(l)}let l=n+"_s",d=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+l;i&&(yield Xe(l,t,a));var h=yield Ce("connection",d,!1,999,999,999);let u=new P(0,t.id,e.id,a,h.id,1e3,4);return ie.AddConnection(u),u}))}function Xe(t,e){return Qe(this,arguments,void 0,(function*(t,e,n=null){for(var o,i=e,r=null!=n?n:e.userId,c=t+"_count",a=(null===(o=e.type)||void 0===o?void 0:o.characterValue)+"_s_"+c,s=yield Ce("connection",a,!1,r,4,999),l=yield Ee(s.id,e.id,r,10,1),d=[],h=C(),u=0;u<l.length;u++){let t=yield Ke(l[u].toTheConceptId);d.push(t)}if(d.length<1)h=yield Ce("count","1",!1,r,4,999);else{var f=d[0];let t=0;try{t=Number(f.characterValue)}catch(e){t=0}t+=1,h=yield Ce("count",t.toString(),!1,r,4,999);for(let t=0;t<l.length;t++)Ze(l[t].id)}let y=new P(0,i.id,h.id,i.userId,s.id,1e3,4);yield ie.AddConnection(y)}))}function Ye(t,e,n){return Qe(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c,a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield Xe(o,e,a));var s=yield Ce("connection",c,!1,999,999,999);let l=new P(0,e.id,t.id,a,s.id,1e3,4);ie.AddConnection(l)}let l=n+"_s",d=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+l;i&&(yield Xe(l,t,a));var h=yield Ce("connection",d,!1,999,999,999);return yield je(t.id,t.userId,e.id,e.userId,h.id,999,999,1e3,4)}))}var tn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function en(t,e){}function nn(t,e,n){return tn(this,void 0,void 0,(function*(){}))}function on(t){return tn(this,void 0,void 0,(function*(){}))}var rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function cn(t,e){return rn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield Ke(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield se(a,16);if(s.id>0){for(var l=yield Ee(s.id,c.id,c.userId,n,o),d=[],h=0;h<l.length;h++)d.push(l[h].toTheConceptId);for(yield X(d),h=0;h<l.length;h++){let t=l[h].toTheConceptId,e=yield Ke(t),n=yield Lt(e.id);r.push(n)}}return r}))}function an(t,e){return rn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield Ke(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield se(a,16);if(s.id>0){for(var l=yield Ee(s.id,c.id,c.userId,n,o),d=[],h=0;h<l.length;h++)d.push(l[h].toTheConceptId);for(h=0;h<l.length;h++){let t=l[h].toTheConceptId,e=yield Ke(t);r.push(e)}}return r}))}class sn{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class ln{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new sn(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}ln.characterData=[];class dn{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},un=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fn(t,e,n,i,r){return un(this,void 0,void 0,(function*(){return new sn(e,t,n,e,i,e,r,e,"",!1),yield function(){return hn(this,void 0,void 0,(function*(){var t;try{if(0==(t=ln.GetCharacter(t.data)).id){var e=x();const i=yield fetch(o.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw U(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var n=new sn(r.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=r.id,ln.AddCharacter(n),r}return new dn(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}()}))}var yn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function pn(t,e,n,o,i,r,c){return yn(this,void 0,void 0,(function*(){var a=yield se(t,o),s=a;return 0==s.id&&(s=a=yield pe(t,e,n,o,i,r,c)),s}))}var vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},gn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Cn(t,e,n,o){return gn(this,void 0,void 0,(function*(){var i=yield Bt(t);if(i&&(0==i.id||0==i.userId)){var r=A(t);if(r.length>0)if(r[0]==t){var c=yield function(t,e,n,o,i,r){return vn(this,void 0,void 0,(function*(){var n;if(1==t.length){var i=t.charCodeAt(0);yield fn(t,e,999,o,r),n=pn(t,e,4,49,i,o,"the_character")}else{var c=yield fn(t,e,999,o,r);c.isNew,n=yield pn(t,e,4,51,c.id,o,"the_characters")}return n}))}(t,o,0,999,0,e);i=c}else{var a=yield Cn(r[0],e,n,o),s=yield Cn(r[1],e,n,o);s&&(i=yield ve(t,o,a.id,s.id,999,999,r[1]))}}return i}))}var mn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Nn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Tn(t){return Nn(this,void 0,void 0,(function*(){let e=C();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;var n=A(t);if(n.length>1){let i=1,r=yield Tn(n[0]);0!=r.id&&(i=r.id),e=yield function(t,e){return Nn(this,void 0,void 0,(function*(){let n=yield w.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield function(t,e){return mn(this,void 0,void 0,(function*(){let n=C();try{var i=x("application/x-www-form-urlencoded");const r=yield fetch(o.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});r.ok?(n=yield r.json(),w.AddConcept(n)):(console.log("This is the concept by category and character error",r.status),U(r))}catch(t){t instanceof Error?console.log(" This is the concept by category and character error message: ",t.message):console.log(" This is the concept by category and character unexpected error: ",t),b(t,o.GetConceptByCharacterAndCategoryDirectUrl())}return n}))}(t,e)),n}))}(t,i)}else n[0]==t&&(e=yield function(t){return Nn(this,void 0,void 0,(function*(){var e=yield w.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Ft(t)),e}))}(t));return e}))}var wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function In(t,e){return wn(this,void 0,void 0,(function*(){let e=C();try{if(e=yield Tn(t),0==e.id||4==e.typeId){var n=x("application/x-www-form-urlencoded");const i=yield fetch(o.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!i.ok)throw U(i),new Error(`Error! status: ${i.status}`);e=yield i.json()}}catch(t){t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),b(t,o.MakeTheTypeConceptUrl())}return e}))}var kn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},An=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Sn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xn(t){return Sn(this,void 0,void 0,(function*(){for(var e=yield function(t){return kn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),U(c)}catch(t){t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),b(t,o.GetAllLinkerConnectionOfConceptUrl())}return e}))}(t),n=0;n<e.length;n++){let t=e[n];var i=t.typeId;let o=yield Ke(i);t.type=o}return e}))}function Rn(t){return Sn(this,void 0,void 0,(function*(){for(var e=yield function(t){return An(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=x("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),U(c)}catch(t){t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),b(t,o.GetAllLinkerConnectionToConceptUrl())}return e}))}(t),n=0;n<e.length;n++){let t=e[n];var i=t.typeId;let o=yield Ke(i);t.type=o}return e}))}var Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Gn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Un(t){return Gn(this,void 0,void 0,(function*(){var e=yield Ke(t);yield v.removeNodeFromTree(t);var n=e.typeId,i=e.characterValue;yield N.removeTypeConcept(n,t),yield y.removeNodeByCharacter(i,t),d("concept",t),yield function(t){return Ln(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=L();const i=yield fetch(o.DeleteConceptUrl(),{method:"POST",headers:n,body:e});i.ok||(console.log("Delete concept error",i.status),U(i))}catch(t){t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),b(t,o.DeleteConceptUrl())}}))}(t)}))}var bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t,e){return bn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.DeleteConceptUrl(),{method:"POST",body:i,headers:n});if(!r.ok)throw U(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),b(t,o.DeleteConceptUrl())}}))}var Fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pn(t,e,n,o){return Fn(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=t.startsWith("the_"),a=C();return r=c?t:"the_"+t,a=yield In(r),yield pn(e,n,4,a.id,0,4,r)}))}class Bn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var Dn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function On(){return Dn(this,arguments,void 0,(function*(t=[]){let e=[];try{let n=[];for(let o=0;o<t.length;o++){let i=yield M.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{let t=x();const i=yield fetch(o.GetConnectionBulkUrl(),{method:"POST",headers:t,body:JSON.stringify(n)});if(i.ok){const t=yield i.json();if(t.length>0){for(let n=0;n<t.length;n++){let o=t[n];e.push(o),M.AddConnection(o)}yield J(e)}}else U(i),console.log("Get Connection Bulk error",i.status)}}catch(t){t instanceof Error?console.log("Get Connection Bulk error message: ",t.message):console.log("Get Connection Bulk unexpected error: ",t),b(t,o.GetConnectionBulkUrl())}return e}))}var En=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Vn(){return En(this,arguments,void 0,(function*(t=[]){yield X(t);let e=[];for(let n=0;n<t.length;n++){let o=yield xt(t[n]);e.push(o)}return e}))}function jn(){return En(this,arguments,void 0,(function*(t=[]){yield X(t);let e=[];for(let n=0;n<t.length;n++){let o=yield Rt(t[n]);e.push(o)}return e}))}function Mn(){return En(this,arguments,void 0,(function*(t=[],e=[]){yield On(e),Q(e,yield z(t));let n=[];for(let e=0;e<t.length;e++){let o=yield Rt(t[e]);n.push(o)}return n}))}function Hn(){return En(this,arguments,void 0,(function*(t=[],e=[]){yield On(e),Q(e,yield z(t));let n={};for(let e=0;e<t.length;e++){let o=yield Rt(t[e]);n[t[e]]=o}return n}))}function Wn(){return En(this,arguments,void 0,(function*(t=[],e=[]){yield On(e),Q(e,yield z(t));let n={};for(let e=0;e<t.length;e++){let o=yield xt(t[e]);n[t[e]]=o}return n}))}function $n(){return En(this,arguments,void 0,(function*(t=[],e=[]){let n=[];for(let t=0;t<e.length;t++)0==(yield M.GetConnection(e[t])).id&&n.push(e[t]);let o=[],i=yield On(n);for(let t=0;t<i.length;t++)o.push(i[t].ofTheConceptId),o.push(i[t].toTheConceptId);yield W(o);let r={};for(let e=0;e<t.length;e++){let n=yield Rt(t[e]);r[t[e]]=n}return r}))}var Jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zn(){return Jn(this,arguments,void 0,(function*(t=0,e=[],n=""){var i=[];try{var r=new Bn;r.composition=t,r.listLinkers=e,r.textSearch=n;var c=JSON.stringify(r),a=x();const d=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const t=yield d.json();var s=t.compositionIds,l=t.internalConnections;t.externalConnections,i=yield Mn(s,l)}else console.log("recursive search error ",d.status),U(d);return i}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),b(t,o.RecursiveSearchUrl())}}))}function zn(){return Jn(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.listLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),U(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),b(t,o.RecursiveSearchUrl())}}))}function Kn(){return Jn(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.fullLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),U(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),b(t,o.RecursiveSearchUrl())}}))}function Qn(){return Jn(this,arguments,void 0,(function*(t=0,e=[],n=""){try{var i=new Bn;i.composition=t,i.fullLinkers=e,i.textSearch=n;var r=JSON.stringify(i),c=x();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),U(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),b(t,o.RecursiveSearchUrl())}}))}var qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xn(t,e){return qn(this,void 0,void 0,(function*(){try{var n={email:t,password:e},i=new Headers;i.append("Content-Type","application/json");var r=JSON.stringify(n);const c=yield fetch(o.LoginUrl(),{method:"POST",headers:i,body:r});if(c.ok){const t=yield c.json();return console.log(t.data),S.BearerAccessToken=t.data.token,console.log("this is the token",S.BearerAccessToken),t}console.log("Login tsccs error message: ",c.status),U(c)}catch(t){t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),b(t,o.LoginUrl())}}))}var Yn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function to(t){return Yn(this,void 0,void 0,(function*(){const e=yield function(){return Yn(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(t,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:U(o),n}catch(e){console.log("Signup Error: ",e),b(e,t)}}))}(o.SignupUrl(),t);return e}))}var eo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function no(t){return eo(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=o.LoginUrl();try{const t=yield fetch(r,{method:"POST",headers:i,body:e,redirect:"follow"}),o=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==o?void 0:o.data}:U(t),n}catch(t){console.log("Sign in api error",t),b(t,r)}}))}function oo(t,e){return-1===t.indexOf(e)&&t.push(e),t}function io(t=[],e){var n,o;let i=[],r=null===(n=e.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(t))for(let n=0;n<t.length;n++){let c=null===(o=t[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),e.typeId!=t[n].typeId&&r!=c||i.push(t[n])}return i}function ro(t=[],e){let n=[],o=e.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(t))for(let i=0;i<t.length;i++){let r=t[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),e.typeId!=t[i].typeId&&o!=r||n.push(t[i])}return n}function co(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function ao(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function so(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function lo(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class ho{constructor(t,e,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}isValid(){const t=new Date(Date.now());return!(this.expiryTime<t&&(fo.removeNodeFromTree(this.key),1))}saveToCache(t){this.value.cached=t}addNode(t,e,n){if(null==e)return t;const o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return this.isValid(),t;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));const r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return this.isValid(),e}rightRotate(t){if(t){const e=t.leftNode;if(e){const n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){const e=t.rightNode;if(e){const n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key&&e.isValid()?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){const e=t.rightNode;return t=null,e}if(null==t.rightNode){const e=t.leftNode;return t=null,e}{const e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.rightNode=this.removeNode(t.rightNode,e.key),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var uo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class fo{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addCompositionToTree(t){const e=new ho(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return uo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return uo(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}fo.root=null;var yo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function po(t,e,n,o){return yo(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=vo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Ke(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=vo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield Ke(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=vo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield Ke(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield w.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield Ke(e),t.type=n)}const l="the_",h=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(h))){if(h){const t=yield po(d,e,n,o,i);a[h]=t}}else{const t=yield po(d,e,n,o,i);s[h]=t,a=s}}}return a}))}function vo(t,e){let n=C();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class go{constructor(){this.id=0,this.mainConcept=C(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield po(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),o.MQTT_CONNECTION&&o.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Co=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mo(t){return Co(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let h=null!=o?o:0,u=C();null==a&&(a=new go);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield Ce(o,"",!0,s,l,d);if(null==e&&null==n){let e=h;u=f,e=f.id,h=f.id,a.concepts.push(f),a.id=f.id,yield mo(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,d=h;u=f,a.concepts.push(f);const y=yield re(s,l,f.id,d);a.connections.push(y),yield mo(t[o],f.id,f.userId,d,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=h,u=yield Ce(o,t[o],!1,s,l,d);a.concepts.push(u);const f=yield re(i,r,u.id,c);a.connections.push(f)}return u}))}var No=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function To(t){return No(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=C(),a=C();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let h=[];if(l<0){let t=yield Ke(l,e);if(!(t.id>0))return null;l=t.id}i=yield wt(l);const u=[],f=new go,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)oo(y,i[t].ofTheConceptId),oo(u,i[t].ofTheConceptId),oo(u,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<u.length;t++){const e=yield Ke(u[t]);l==u[t]&&(c=e),d==u[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=C();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield Ce(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=io(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=co(f.connections,e[t].id);h=h.concat(n),s.push(e[t])}yield mo(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield Ce(t,l,!1,e,o,n);const c=io(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=co(f.connections,c[t].id);h=h.concat(e),s.push(c[t])}}const u=re(d.id,d.userId,i.id,c.id);r.push(i),f.connections.push(u)}for(let t=0;t<h.length;t++)lo(f.connections,h[t]),Ze(h[t].id);for(let t=0;t<s.length;t++)so(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),fo.addCompositionToTree(f),ie.SyncDataOnline(),f.GetDataCache()}))}var wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Io(t,e,n,i){return wo(this,arguments,void 0,(function*(t,e,n,i,r=10,c=1){var a=R("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",n),s.append("inpage",r.toString()),s.append("page",c.toString());const l=o.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield fetch(l,{method:"GET",headers:a});return t.ok?yield t.json():(U(t),[])}catch(t){console.log("This is the searching error",t),b(t,l)}}))}var ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ao(t){return ko(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);const i=o.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(console.log("This is the searching error",t.status),U(t),[])}catch(t){console.log("This is the searching error",t),b(t,i)}}))}var So=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xo(t){return So(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=yield fo.getNodeFromTree(t),l=[];let d=yield w.GetConcept(t);if(0==d.id&&null!=t&&null!=t&&(d=yield Nt(t)),null==s){let s=[];s=e.length>0?Ro(t,e):yield wt(t),i=s;for(let t=0;t<i.length;t++)l.includes(i[t].ofTheConceptId)||(l.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);Uo(d,i,r,l);let h=[];a=yield Ut(t,i,l,h),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 Ro(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function Lo(t){return So(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=yield fo.getNodeFromTree(t),d=[];let h=yield w.GetConcept(t);if(0==h.id&&null!=t&&null!=t&&(h=yield Nt(t)),null==l){let l=[];l=e.length>0?Ro(t,e):yield wt(t),r=l;for(let t=0;t<r.length;t++)d.includes(r[t].ofTheConceptId)||(d.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);Uo(h,r,c,d),a=yield Ut(t,r,d),s[null!==(o=null===(n=null==h?void 0:h.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=h.entryTimeStamp,i.data=s,i.id=t}else a=l.value.GetDataCache(),i=a;return 0==h.id?"":i}))}function Go(t,e){return So(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield On(e);for(let e=0;e<t.length;e++){const i=yield Lo(t[e],n);i&&o.push(i)}return o}))}function Uo(t,e,n,i){return So(this,void 0,void 0,(function*(){const r=new go,c=yield function(t){return So(this,void 0,void 0,(function*(){let e=[];const n=[];for(let o=0;o<(null==t?void 0:t.length);o++){const i=yield w.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}return 0==(null==n?void 0:n.length)||(e=yield function(t){return H(this,void 0,void 0,(function*(){const e=[];if(t.length>0){const n={"Content-Type":"application/json"};try{const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){const o=t[n];e.push(o),w.AddConcept(o)}}else console.log("bulk concept getter api error: ",i.status),U(i)}catch(t){t instanceof Error?console.log("bulk concept getter api error: ",t.message):console.log("bulk concept getter api error: ",t),b(t,o.GetConceptBulkUrl())}}return e}))}(n)),e}))}(n);r.connections=e,r.concepts=c,r.id=t.id,r.subcompositions=i,r.mainConcept=t;const a=yield po(t.id,e,c,i,[]);r.cached=a,fo.addCompositionToTree(r)}))}var bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _o(t){return bo(this,void 0,void 0,(function*(){try{var e=x();const n=JSON.stringify(t),i=yield fetch(o.CreateSessionId(),{method:"POST",headers:e,body:n});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),U(i),null)}catch(t){console.log("Creating session failed",t),b(t,o.CreateSessionId())}}))}var Fo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Po(t,e){return Fo(this,void 0,void 0,(function*(){try{var n=x("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield fetch(o.CreateSessionVisitUrl(),{method:"POST",headers:n,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),U(r),null)}catch(t){console.log("Creating session url failed",t),b(t,o.CreateSessionVisitUrl())}}))}var Bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Do(t,e){return Bo(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=[],r=yield Ke(t),c=yield Tn(e);if(c.id>0){for(var a=yield Ee(c.id,r.id,r.userId,n,o),s=[],l=0;l<a.length;l++)s.push(a[l].toTheConceptId);for(yield X(s),l=0;l<a.length;l++){let t=a[l].toTheConceptId,e=yield Ke(t),n=yield Lt(e.id);i.push(n)}}return i}))}function Oo(t,e){return Bo(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=[],r=yield Ke(t),c=yield Tn(e);if(c.id>0){for(var a=yield Ee(c.id,r.id,r.userId,n,o),s=[],l=0;l<a.length;l++)s.push(a[l].toTheConceptId);for(l=0;l<a.length;l++){let t=a[l].toTheConceptId,e=yield Ke(t);i.push(e)}}return i}))}class Eo{constructor(t,e,n,o){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e.value.push(...t.value),e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.rightNode=this.removeNode(t.rightNode,n.key),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Vo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class jo{static compositeKey(t,e){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return Vo(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(h.isDataLoaded)return t("done");setTimeout(jo.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n);var i=new Eo(o,t,null,null);this.addNodeToTree(i)}static getNodeFromTree(t,e){return Vo(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}let n=this.compositeKey(t,e);return this.root?this.root.getFromNode(n,this.root):null}))}static removeNodeFromTree(t){return Vo(this,arguments,void 0,(function*(t,e=999){if(this.root){let n=this.compositeKey(t,e);this.root=this.root.removeNode(this.root,n)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}jo.root=null;var Mo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ho(t,e){return Mo(this,arguments,void 0,(function*(t,e,n=999){let o=yield jo.getNodeFromTree(t,n);console.log("this is the ghost id",t,n);let i=yt();if(o)for(let t=0;t<o.value.length;t++){let n=o.value[t];n.ghostId==e&&(i=n)}return i}))}function Wo(t,e){return Mo(this,arguments,void 0,(function*(t,e,n=999){jo.addConceptToTree(t,e,n)}))}var $o=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Jo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zo(t){return Jo(this,arguments,void 0,(function*(t,e=""){let n=[];try{let i=yield function(t){return $o(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);const i=o.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(U(t),console.log("This is the searching multiple error",t.status),[])}catch(t){console.log("This is the searching multiple error",t),b(t,i)}}))}(t,e),r=t[0].composition;const c=i;let a=c.compositionIds,s=c.internalConnections,l=c.linkers,d=c.reverse;return yield function(t){return En(this,void 0,void 0,(function*(){let e=[],n=[];for(let o=0;o<t.length;o++){let i=yield M.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}let o=[],i=yield On(e);n=[...n,...i];for(let t=0;t<n.length;t++)o.push(n[t].ofTheConceptId),o.push(n[t].toTheConceptId);return yield W(o),n}))}(l),n=yield $n(a,s),yield zo(l,n,r,d)}catch(t){throw console.log("this is the error in the search link multiple",t),t}}))}function zo(t,e,n){return Jo(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield On(t),c=[];for(let t=0;t<r.length;t++)c.push(r[t].toTheConceptId),c.push(r[t].ofTheConceptId),c.push(r[t].typeId);yield W(c),r.sort((function(t,e){return e.id-t.id}));for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield Ke(r[t].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(e[r[t].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield Ke(r[t].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(e[r[t].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function Ko(t){var e,n;const o=yt();return o.id=t.id,o.ghostId=t.ghostId,o.userId=t.userId,o.accessId=t.accessId,o.categoryId=t.categoryId,o.characterValue=t.characterValue,o.entryTimeStamp=t.entryTimeStamp,o.typeId=t.typeId,o.type=t.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(e=null==t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"",o}function Qo(t){const e=C();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e}function qo(t){const e=new P(0,0,0,0,0,0,0);return e.id=t.id,e.ghostId=t.ghostId,e.accessId=t.accessId,e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.isTemp=!1,e}var Xo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yo(t){return Xo(this,void 0,void 0,(function*(){try{let e=yt();if(t<0){if(e=yield Ct.GetConcept(t),0==e.id){let n=yield vt.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}}}else e=Ko(yield Ke(t));return e}catch(t){throw t}}))}var ti=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ei(t){return ti(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=yt(),a=yt();const s=[],l=t.compositionId,d=t.ofTheCompositionId;let h=[],u=yield wt(l);for(let t=0;t<u.length;t++)i.push(qo(u[t]));const f=[],y=[];let p=[];for(let t=0;t<i.length;t++)oo(y,i[t].ofTheConceptId),oo(f,i[t].ofTheConceptId),oo(f,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);for(let t=0;t<f.length;t++){const e=yield Ke(f[t]);l==f[t]&&(c=Ko(e)),d==f[t]&&(a=Ko(e)),r.push(Ko(e))}const v=t.patchObject;for(const t in v){let l=yt();const d=v[t];let u=c;a.id>0&&(u=a),Array.isArray(d)||"object"==typeof d?(l=yield Pe(t,"",!0,c.userId,4,999),yield De(v[t],l.id,l.userId,c.id,c.userId,4,999)):l=yield Pe(t,d,!1,e,o,n);const f=ro(r,l);for(let t=0;t<f.length;t++)if(f[t].id>0){const e=ao(i,f[t].id);h=h.concat(e),s.push(f[t])}yield Re(u.id,l.id,c.id,2),r.push(l)}for(let t=0;t<h.length;t++)Ze(h[t].id);Ai.SyncDataOnline()}))}var ni=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},oi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ii(t,e,n){return oi(this,void 0,void 0,(function*(){try{let n=yield Et(e),o=[];0!=n.id&&(o=yield function(t,e){return ni(this,void 0,void 0,(function*(){try{return yield Jt.GetConnectionOfCompositionAndTypeLocal(e,t)}catch(t){throw t}}))}(t,n.id));let i=[];for(let t=0;t<o.length;t++){let e=yield Kt(o[t].toTheConceptId);i.push(e)}return i}catch(t){throw t}}))}var ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ci(t){return ri(this,void 0,void 0,(function*(){let e=[];try{var n=x();const i=yield fetch(o.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;W(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),U(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}var ai=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function si(t){return ai(this,void 0,void 0,(function*(){var e;try{let n=yield ci(t),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield Ut(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield Ke(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}catch(t){throw t}}))}var li=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},di=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function hi(t){return di(this,arguments,void 0,(function*(t,e=""){try{var n=yield function(t){return li(this,arguments,void 0,(function*(t,e=""){var n=R("application/json",e);let i=o.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(i,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),U(t),[])}catch(t){console.log("This is the searching internal error",t),b(t,i)}}))}(t,e);return yield si(n)}catch(t){throw t}}))}var ui=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fi(t,e,n){return ui(this,arguments,void 0,(function*(t,e,n,o=!1){var i,r;try{if(t.userId,o){let o=(null===(i=e.type)||void 0===i?void 0:i.characterValue)+"_s_"+n+"_by";var c=yield Pe("connection",o,!1,999,999,999);yield Re(e.id,t.id,c.id,1e3)}let s=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+n+"_s";var a=yield Pe("connection",s,!1,999,999,999);return yield Re(t.id,e.id,a.id,1e3)}catch(t){throw t}}))}var yi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function pi(t){return yi(this,void 0,void 0,(function*(){let e=yield Yo(t);Ct.RemoveConcept(e)}))}var vi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},gi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ci(t,e,n,i){return gi(this,arguments,void 0,(function*(t,e,n,i,r=!0){var c,a;let s=C();if(""!=n){let o="";o=r?(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+n+"_s":(null===(a=e.type)||void 0===a?void 0:a.characterValue)+"_s_"+n+"_by",s=yield Ce("connection",o,!1,999)}""!=i&&(s=yield In(i));let l=yield function(t,e,n){return vi(this,void 0,void 0,(function*(){var i=[];try{var r=new FormData;r.append("ofConceptId",t.toString()),r.append("mainKey",n.toString()),r.append("toConceptId",e.toString());const a=yield fetch(o.GetCompositionConnectionBetweenTwoConceptsUrl(),{method:"POST",body:r,redirect:"follow"});if(a.ok){const t=yield a.json();for(var c=0;c<t.length;c++)M.AddConnection(t[c]),i.push(t[c])}else console.log("Get composition connection between two concepts",a.status),U(a)}catch(t){t instanceof Error?console.log("Get composition connection between two concepts error message: ",t.message):console.log("Get composition connection between two concepts unexpected error: ",t),b(t,o.GetCompositionConnectionBetweenTwoConceptsUrl())}return i}))}(t.id,e.id,s.id);return l}))}function mi(t,e){return new Promise(((n,o)=>{setTimeout((()=>{n(e)}),t)}))}class Ni{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.structureType="lconcept",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.characterValue=c,this.accessId=r,this.type=null,this.isNew=s,this.typeCharacter=a,this.entryTimeStamp=l,this.updatedTimeStamp=d,this.isSynced=!1,this.referentId=h}getType(){console.log(this.typeId)}}class Ti{constructor(t,e,n,i,r,c){this.isTemp=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=i,this.ghostId=t,this.orderId=r,this.typeCharacter="",this.accessId=c,this.typeCharacter="",this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date}}class wi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Ii{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=""}}var ki=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ai{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){try{let e=!1;0!=Ai.CheckIfTheConceptIdExists(t.id,this.conceptsSyncArray).id&&(e=!0),e||this.conceptsSyncArray.push(t)}catch(t){throw t}}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static SyncDataOnline(){return ki(this,void 0,void 0,(function*(){try{let t=this.conceptsSyncArray.slice(),e=this.connectionSyncArray.slice();this.connectionSyncArray=[],this.conceptsSyncArray=[];let n=[];for(let e=0;e<t.length;e++)n.push(t[e]),yield Ct.UpdateConceptSyncStatus(t[e].id);yield this.UpdateConceptListToIncludeRelatedConcepts(e,n);let i=yield function(t,e){return n=this,i=void 0,c=function*(){let n={concepts:[],connections:[]};try{const i=new Headers;let r={concepts:t,connections:e};i.set("Content-Type","application/json"),i.set("Authorization","Bearer "+S.BearerAccessToken),i.set("Accept","application/json"),i.set("Randomizer",o.BASE_RANDOMIZER.toString());const c=yield fetch(o.CreateGhostConceptApiUrl(),{method:"POST",headers:i,body:JSON.stringify(r)});if(!c.ok)throw U(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();return n.concepts=a.concepts,n.connections=a.connections,n}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),t}},new((r=void 0)||(r=Promise))((function(t,e){function o(t){try{s(c.next(t))}catch(t){e(t)}}function a(t){try{s(c.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(o,a)}s((c=c.apply(n,i||[])).next())}));var n,i,r,c}(n,e),r=i.concepts,c=i.connections;for(let t=0;t<r.length;t++)Ct.AddPermanentConcept(r[t]);for(let t=0;t<c.length;t++)Jt.AddPermanentConnection(c[t]);return t}catch(t){throw t}}))}static ConvertGhostIdsInConnections(t){var e,n,o;for(let i=0;i<t.length;i++){let r=t[i].ofTheConceptId,c=t[i].toTheConceptId,a=t[i].typeId,s=null!==(e=Ai.ghostIdMap.get(r))&&void 0!==e?e:r,l=null!==(n=Ai.ghostIdMap.get(c))&&void 0!==n?n:c,d=null!==(o=Ai.ghostIdMap.get(a))&&void 0!==o?o:a;t[i].ofTheConceptId=s,t[i].toTheConceptId=l,t[i].typeId=d}}static UpdateConceptListToIncludeRelatedConcepts(t,e){return ki(this,void 0,void 0,(function*(){for(let n=0;n<t.length;n++){let o=t[n].ofTheConceptId,i=t[n].toTheConceptId,r=t[n].typeId;if(o<0){let i=this.CheckIfTheConceptIdExists(o,e);0==i.id&&(i=yield Ct.GetConceptByGhostId(o),0!=i.id?i.id!=i.ghostId&&(t[n].ofTheConceptId=i.id):(i=yield Ct.GetConcept(o),this.AddConceptIfDoesNotExist(i,e)))}if(i<0){let o=this.CheckIfTheConceptIdExists(i,e);0==o.id&&(o=yield Ct.GetConceptByGhostId(i),0!=o.id?o.id!=o.ghostId&&(t[n].toTheConceptId=o.id):(o=yield Ct.GetConcept(i),this.AddConceptIfDoesNotExist(o,e)))}if(r<0){let o=this.CheckIfTheConceptIdExists(r,e);0==o.id&&(o=yield Ct.GetConceptByGhostId(r),0!=o.id?o.id!=o.ghostId&&(t[n].typeId=o.id):(o=yield Ct.GetConcept(r),this.AddConceptIfDoesNotExist(o,e)))}}}))}static AddConceptIfDoesNotExist(t,e=[]){let n=!1;for(let o=0;o<e.length;o++)t.ghostId==e[o].ghostId&&(n=!0);n||e.push(t)}static CheckIfTheConceptIdExists(t,e=[]){let n=yt();for(let o=0;o<e.length;o++)t!=e[o].ghostId&&t!=e[o].id||(n=e[o]);return n}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static syncDataLocalDb(){return ki(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)it("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)it("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}Ai.conceptsSyncArray=[],Ai.connectionSyncArray=[],Ai.ghostIdMap=new Map;class Si{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0}}class xi{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var Ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Li=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Gi{}Gi.isUpdated=!1,Gi.isOnlineSync=!1;var Ui=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bi(){return Ui(this,arguments,void 0,(function*(t=!0){try{if(yield a("concepts"),yield nt("concepts"),t){var e=yield new Promise((function(t,e){let o="settings";a(o).then((i=>{let r=i.transaction(o,"readwrite").objectStore(o).getAll();r.onsuccess=()=>{let e=new n(!1),o=r.result;for(let t=0;t<o.length;t++)e=o[t];t(e)},r.onerror=t=>{e(t)}})).catch((t=>{e({status:400,ok:!1,message:"Cannot get last object from database because you cannot open the database",data:t})}))}));if(e.isOnlineSync)return!0;yield function(){return Li(this,void 0,void 0,(function*(){try{const i=(new Date).getTime();var t=R("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllAiData(),{method:"GET",headers:t});r.ok||(console.log("Ai Error Message: ","Cannot get response"),U(r));const c=yield r.json();for(var e=0;e<c.length;e++)w.AddConcept(c[e]);!function(){Ui(this,void 0,void 0,(function*(){Gi.isOnlineSync=!0;var t,e=new n(Gi.isOnlineSync);t=e,new Promise((function(e,n){let o="settings";a(o).then((i=>{const r=i.transaction(o,"readwrite").objectStore(o).put(t);r.onsuccess=n=>{e(t)},r.onerror=e=>{n({status:400,ok:!1,message:"Cannot update AI flag",data:e,body:t})}})).catch((t=>{n({status:400,ok:!1,message:"Cannot update AI flag because you cannot open the database",data:t})}))}))}))}();let s=(new Date).getTime()-i;console.log("The time taken is ",s)}catch(t){t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),b(t,o.GetAllAiData())}}))}()}return!0}catch(t){let e={message:"cannot initlize the AI system",ok:!1,status:400,data:t};return console.log(e),!0}}))}var _i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fi(t=""){S.BearerAccessToken=t}function Pi(){return _i(this,arguments,void 0,(function*(t="",e="",n="",i="",r=!0,c="",a=!1){try{o.BASE_URL=t,o.AI_URL=e,o.NODE_URL=i,o.BASE_APPLICATION=c,S.BearerAccessToken=n;let s=Math.floor(1e8*Math.random());if(o.BASE_RANDOMIZER=s,a)return h.isDataLoaded=!0,h.isCharacterLoaded=!0,h.isTypeLoaded=!0,h.isLocalDataLoaded=!0,h.isLocalTypeLoaded=!0,h.isLocalCharacterLoaded=!0,h.isConnectionLoaded=!0,h.isConnectionTypeLoaded=!0,h.isLocalConnectionLoaded=!0,!0;console.log("This ist he base url",o.BASE_URL,s),yield bi(r);const d=(new Date).getTime();return yield k().then((()=>{let t=(new Date).getTime()-d;console.log("The time taken to prepare concept data is ",t)})).catch((t=>{throw t})),yield we().then((()=>{let t=(new Date).getTime()-d;console.log("The time taken to prepare local concept ",t)})).catch((t=>{throw t})),yield function(){return Ri(this,void 0,void 0,(function*(){try{var t=yield ot("localconnection");if(Array.isArray(t))for(var e=0;e<t.length;e++)Jt.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Local Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{h.isLocalConnectionLoaded=!0})).catch((t=>{throw t})),yield function(){return Ri(this,void 0,void 0,(function*(){try{let t=yield l("connection");if(Array.isArray(t))for(let e=0;e<t.length;e++)M.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{h.isConnectionLoaded=!0,h.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-d;console.log("The time taken to prepare connections ",t)})).catch((t=>{throw t})),!0}catch(t){console.log("cannot initialize the system",t)}}))}var Bi=exports;for(var Di in e)Bi[Di]=e[Di];e.__esModule&&Object.defineProperty(Bi,"__esModule",{value:!0})})();
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Concept } from "../../DataStructures/Concept";
|
|
2
|
+
export declare function CreateTheConceptApi(conceptData: any): Promise<Concept | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Connection } from '../DataStructures/Connection';
|
|
2
2
|
export declare function GetAllConnectionsOfComposition(composition_id: number): Promise<Connection[]>;
|
|
3
|
-
export declare function GetAllConnectionsOfCompositionOnline(composition_id: number): Promise<Connection[]>;
|
|
3
|
+
export declare function GetAllConnectionsOfCompositionOnline(composition_id: number): Promise<Connection[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Connection } from '../DataStructures/Connection';
|
|
2
2
|
export declare function GetAllConnectionsOfCompositionBulk(composition_ids?: number[]): Promise<Connection[]>;
|
|
3
|
-
export declare function GetAllConnectionsOfCompositionOnline(composition_ids?: number[]): Promise<Connection[]>;
|
|
3
|
+
export declare function GetAllConnectionsOfCompositionOnline(composition_ids?: number[]): Promise<Connection[] | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TheCharacter } from "../DataStructures/TheCharacter";
|
|
2
|
-
export declare function GetCharacterByCharacter(characterValue: string): Promise<TheCharacter>;
|
|
2
|
+
export declare function GetCharacterByCharacter(characterValue: string): Promise<TheCharacter | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Concept } from "./../DataStructures/Concept";
|
|
2
|
-
export declare function GetConcept(id: number): Promise<Concept>;
|
|
2
|
+
export declare function GetConcept(id: number): Promise<Concept | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Concept } from "./../DataStructures/Concept";
|
|
2
|
-
export declare function GetConceptByCharacterAndType(characterValue: string, typeId: number): Promise<Concept>;
|
|
2
|
+
export declare function GetConceptByCharacterAndType(characterValue: string, typeId: number): Promise<Concept | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Connection } from "../DataStructures/Connection";
|
|
2
|
-
export declare function GetConnection(id: number): Promise<Connection>;
|
|
2
|
+
export declare function GetConnection(id: number): Promise<Connection | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Connection } from "../DataStructures/Connection";
|
|
2
|
-
export declare function GetConnectionOfTheConcept(typeId: number, ofTheConceptId: number, userId: number, inpage?: number, page?: number): Promise<Connection[]>;
|
|
2
|
+
export declare function GetConnectionOfTheConcept(typeId: number, ofTheConceptId: number, userId: number, inpage?: number, page?: number): Promise<Connection[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function RecursiveSearchApi(composition?: number, listLinkers?: string[], textSearch?: string): Promise<any[]>;
|
|
1
|
+
export declare function RecursiveSearchApi(composition?: number, listLinkers?: string[], textSearch?: string): Promise<any[] | undefined>;
|
|
2
2
|
export declare function RecursiveSearchApiRaw(composition?: number, listLinkers?: string[], textSearch?: string): Promise<any>;
|
|
3
3
|
export declare function RecursiveSearchApiRawFullLinker(composition?: number, fullLinkers?: string[], textSearch?: string): Promise<any>;
|
|
4
4
|
export declare function RecursiveSearchApiNewRawFullLinker(composition?: number, fullLinkers?: string[], textSearch?: string): Promise<any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Concept } from "../../DataStructures/Concept";
|
|
2
|
-
export declare function GetConceptByCharacterAndCategoryApi(characterValue: string): Promise<Concept>;
|
|
2
|
+
export declare function GetConceptByCharacterAndCategoryApi(characterValue: string): Promise<Concept | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FreeschemaResponse } from "../DataStructures/Responses/StandardResponses";
|
|
2
2
|
import { SigninModel } from "../DataStructures/SigninModel";
|
|
3
|
-
export default function Signin(signinInfo: SigninModel): Promise<FreeschemaResponse>;
|
|
3
|
+
export default function Signin(signinInfo: SigninModel): Promise<FreeschemaResponse | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FreeschemaResponse } from "../DataStructures/Responses/StandardResponses";
|
|
2
2
|
import { SignupModel } from "../DataStructures/SignupModel";
|
|
3
|
-
export default function Signup(signupModel: SignupModel): Promise<FreeschemaResponse>;
|
|
3
|
+
export default function Signup(signupModel: SignupModel): Promise<FreeschemaResponse | undefined>;
|