mftsccs-node 0.0.74 → 0.0.76
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.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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)},e={};t.d(e,{BG:()=>xi,TR:()=>Fo,Tc:()=>Po,U3:()=>n,Wg:()=>U,g2:()=>ti,BO:()=>no,WW:()=>qn,BS:()=>zn,ji:()=>F,Ij:()=>O,Ng:()=>K,du:()=>it,RC:()=>ke,d4:()=>fe,Cd:()=>Xe,IM:()=>ze,oI:()=>P,u9:()=>en,B7:()=>Co,mF:()=>mo,Q9:()=>io,wT:()=>he,y0:()=>wi,iw:()=>ki,pU:()=>Ri,qN:()=>In,mZ:()=>Fe,Ec:()=>Pe,L0:()=>Xo,Te:()=>qo,vw:()=>Oo,z8:()=>J,k9:()=>$i,sP:()=>Ct,Y3:()=>ft,WC:()=>Ji,Nj:()=>Nt,dF:()=>Un,cw:()=>Fn,p8:()=>Pn,rv:()=>Bn,pX:()=>Bt,iD:()=>Vt,Mb:()=>wt,bq:()=>fo,ke:()=>vo,w1:()=>po,yz:()=>Rt,RW:()=>kt,WL:()=>xt,rh:()=>ct,nW:()=>Pt,RH:()=>bt,Aj:()=>ve,cV:()=>ge,jM:()=>Ln,nS:()=>Ee,Yu:()=>Yo,xf:()=>xe,KS:()=>Yi,L6:()=>qe,Z9:()=>Ze,Ny:()=>Tn,qY:()=>mn,jQ:()=>ko,NT:()=>Ao,Xr:()=>$,ab:()=>W,SV:()=>Be,EA:()=>Uo,M2:()=>Eo,OY:()=>Qi,ry:()=>Q,cS:()=>l,ZJ:()=>Ii,RA:()=>tn,BH:()=>So,SL:()=>Si,Ne:()=>bn,fg:()=>we,M4:()=>Sn,UG:()=>fn,CT:()=>Jt,yv:()=>Ni,vI:()=>zo,XZ:()=>Ai,ZE:()=>Dn,pi:()=>re,B8:()=>ie,yx:()=>Hi,br:()=>so,eU:()=>Jo,cf:()=>Do,jy:()=>Bo,cm:()=>Rn,qn:()=>Zo,ss:()=>uo,pf:()=>Ko,pZ:()=>$n,l4:()=>jn,f8:()=>j,Y6:()=>le,FS:()=>s,bM:()=>o,ZX:()=>qi,CE:()=>An,Sf:()=>co,tp:()=>_o,Ry:()=>jo,jh:()=>zi,dp:()=>Ho,a2:()=>v,J5:()=>h,sc:()=>I,x9:()=>k,Py:()=>r,Xc:()=>y,Ts:()=>er,P$:()=>g,xX:()=>f,ae:()=>p,zN:()=>_t,dU:()=>to,mA:()=>c,En:()=>u,eD:()=>w,$Q:()=>tr});class n{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}n.BASE_URL="https://localhost:7053/",n.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="http://localhost:5001/";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(t,e){this.BearerAccessToken=t,this.TOKEN_EXPIRY=e&&e>0?Date.now()+1e3*e:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const t=Date.now(),e=this.TOKEN_EXPIRY-t;return e>0?Math.floor(e/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(t,e,n){this.CLIENT_ID=t,this.CLIENT_SECRET=e,this.APPLICATION_NAME=n}}o.BearerAccessToken="",o.CLIENT_ID="",o.CLIENT_SECRET="",o.APPLICATION_NAME="",o.TOKEN_EXPIRY=0,o.EXPIRY_BUFFER_MS=3e5;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function r(t,e,r){return i(this,arguments,void 0,(function*(t,e,i,r=!0){try{const c=n.OAuthTokenUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("application_name",i);const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(r&&o.setToken(t,n),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}function c(t,e,r){return i(this,arguments,void 0,(function*(t,e,i,r=!0){try{const c=n.OAuthRefreshUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("refresh_token",i),a.append("grant_type","refresh_token");const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(r&&o.setToken(t,n),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}var a=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class s extends Error{constructor(t){super(t),this.name="TokenRefreshError"}}class l{constructor(t,e,n){this.status=t,this.body=e,this.headers=n}json(){return a(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return a(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return a(this,void 0,void 0,(function*(){if(!o.hasOAuthCredentials())return!1;try{return(yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0)).success}catch(t){return console.error("Token refresh failed:",t),!1}}))}function u(t,e,n,i){return a(this,arguments,void 0,(function*(t,e,n,i,r=1){var c,a;const u=Object.assign(Object.assign({},n),o.getAuthHeader()),h=["GET","HEAD","OPTIONS"].includes(t.toUpperCase());for(let n=0;n<=r;n++)try{const h={method:t,headers:u};void 0!==i&&("object"==typeof i?(u["Content-Type"]||u["content-type"]||(u["Content-Type"]="application/json"),(null===(c=u["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(a=u["content-type"])||void 0===a?void 0:a.includes("application/json"))?h.body=JSON.stringify(i):h.body=i):h.body=i),h.headers=u;const f=yield fetch(e,h),y=yield f.text(),p={};if(f.headers.forEach(((t,e)=>{p[e]=t})),401!==f.status)return new l(f.status,y,p);if(n<r){if(yield d()){Object.assign(u,o.getAuthHeader());continue}throw new s("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(t){if(t instanceof s)throw t;if(n>=r||!h)throw t;console.error(`Request failed (attempt ${n+1}/${r+1}):`,t)}throw new Error("Request failed after all retry attempts")}))}function h(t){return a(this,arguments,void 0,(function*(t,e={},n=1){return u(e.method||"GET",t,function(t){if(t){if(t instanceof Headers){const e={};return t.forEach(((t,n)=>{e[n]=t})),e}return Array.isArray(t)?t.reduce(((t,[e,n])=>(t[e]=n,t)),{}):t}}(e.headers),e.body,n)}))}function f(t,e,n){return a(this,void 0,void 0,(function*(){return u("POST",t,e,n)}))}function y(t,e,n){return a(this,void 0,void 0,(function*(){let o=t;if(n){const e=[];for(const t in n)n.hasOwnProperty(t)&&e.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(n[t]))}`);e.length>0&&(o=`${t}?${e.join("&")}`)}return u("GET",o,e)}))}function p(t,e,n){return a(this,void 0,void 0,(function*(){return u("PUT",t,e,n)}))}function v(t,e){return a(this,void 0,void 0,(function*(){return u("DELETE",t,e)}))}function g(t,e,n){return a(this,void 0,void 0,(function*(){return u("PATCH",t,e,n)}))}class C{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}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())}))};const m={};function N(t){return m[t]||(m[t]=[]),m[t]}function w(t,e){const n=N(t);if(e&&"number"==typeof e.id){const t=n.findIndex((t=>t&&t.id===e.id));if(t>=0)return void(n[t]=e)}n.push(e)}function I(t,e,n){return T(this,void 0,void 0,(function*(){return N(t).filter((t=>t&&t[e]===n))}))}function k(t){return T(this,void 0,void 0,(function*(){return N(t).slice()}))}function A(t,e){const n=N(t),o=n.findIndex((t=>t&&t.id===e));o>=0&&n.splice(o,1)}function x(t){return T(this,void 0,void 0,(function*(){return N(t).slice()}))}class S{}S.isTypeLoaded=!1,S.isCharacterLoaded=!1,S.isDataLoaded=!1,S.isLocalDataLoaded=!1,S.isLocalCharacterLoaded=!1,S.isLocalTypeLoaded=!1,S.isConnectionLoaded=!1,S.isConnectionTypeLoaded=!1,S.isLocalConnectionLoaded=!1;class R{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(e.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 _=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.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 L{static waitForDataToLoad(){return _(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isCharacterLoaded)return t("done");setTimeout(L.checkFlag,1e3,t)}static addNodeToTree(t){return _(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 _(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 R(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 _(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return _(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}L.characterRoot=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 U{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 E(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isDataLoaded)return t("done");setTimeout(U.checkFlag,1e3,t)}static addConceptToTree(t){var e=new R(t.id,t,null,null),n=new R(t.characterValue,t,null,null);L.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return E(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return E(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}}U.root=null;class F{constructor(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=t,this.userId=e,this.typeId=n,this.typeUserId=o,this.ghostId=t,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=a,this.characterValue=`${s}`,this.securityId=l,this.securityUserId=d,this.accessId=u,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=y,this.x=0,this.y=0,this.type=null,this.isNew=p,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function P(){let t=G(new Date),e=G(new Date);return new F(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function G(t){const e=t.getMonth()+1,n=t.getDate(),o=t.getFullYear();let i=t.getHours();const r=t.getMinutes(),c=t.getSeconds(),a=i>=12?"PM":"AM";i%=12,i=i||12;const s=t=>t.toString().padStart(2,"0");return`${e}/${n}/${o} ${i}:${s(r)}:${s(c)} ${a}`}var B=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class V{static addNodeToTree(t){return B(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 R(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 B(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isTypeLoaded)return t("done");setTimeout(V.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return B(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)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 B(this,void 0,void 0,(function*(){let n=P();var o=this.getNodeFromTree(e);if(o){o.value.characterValue==t&&(n=o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.characterValue==t&&(n=o.variants[e].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}V.typeRoot=null;var D=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class O{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(t=Date.now()){this.NPC=this.NPC.filter((e=>{const n=this.NPCMeta.get(e);return n&&n.expiresAt>t}))}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){var e;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(t)||this.NPC.push(t);const o=this.NPCMeta.get(t),i=(null!==(e=null==o?void 0:o.attempts)&&void 0!==e?e:0)+1;this.NPCMeta.set(t,{attempts:i,expiresAt:n+i*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(t){const e=Date.now();this.RemoveExpiredNpc(e);const n=this.NPCMeta.get(t);return!!(n&&n.expiresAt>e)}static AddConceptToStorage(t){t.id>0&&w("concept",t)}static AddConcept(t){t.id>0&&(w("concept",t),U.addConceptToTree(t),V.addConceptToTree(t),L.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(U.addConceptToTree(t),V.addConceptToTree(t),L.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);U.removeNodeFromTree(t.id),A("concept",t.id)}static GetConcept(t){return D(this,void 0,void 0,(function*(){var e=P(),n=yield U.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return D(this,void 0,void 0,(function*(){var e=P(),n=L.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return D(this,void 0,void 0,(function*(){var e=P(),n=L.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return D(this,void 0,void 0,(function*(){return P(),yield V.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return D(this,void 0,void 0,(function*(){var n=P(),o=yield L.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 D(this,void 0,void 0,(function*(){let n=[];return n=yield V.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return L.characterRoot}getName(){return this.name}}O.conceptsArray=[],O.NPC=[],O.NPCMeta=new Map,O.NPC_BACKOFF_SECONDS=30,O.conceptDictionary=[];var b=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function M(){return b(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield k("concept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];O.AddConceptToMemory(n)}(new Date).getTime()}))}function j(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}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 $(){return H(this,arguments,void 0,(function*(t="application/json",e="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const t=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);t.success||console.error("Failed to refresh token:",t.error)}return{"Content-Type":t,Authorization:"Bearer "+o.BearerAccessToken,Accept:e}}))}function W(){return H(this,arguments,void 0,(function*(t="application/json",e="",n="application/json"){if(""!==e)return{"Content-Type":t,Authorization:"Bearer "+e,Accept:n};if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const t=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);t.success||console.error("Failed to refresh token:",t.error)}return{"Content-Type":t,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class J{constructor(t,e,o,i){this.url=n.BASE_URL,this.message=t,this.ok=e,this.status=o,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function Q(t){if(!t.ok){const e=t instanceof l,n=e?t.body||`HTTP error ${t.status}`:t.statusText||`HTTP error ${t.status}`;let o=new J(n,!1,t.status,"");throw o.setUrl(e?t.headers.url||"":t.url),o}}function X(t){if(!t.ok){const e=t.body||`HTTP error ${t.status}`;let n=new J(e,!1,t.status,t.body);throw n.setUrl(t.headers.url||""),n}}var Y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function z(t,e){return Y(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",t),o.append("user_id",e.toString());var i=yield $("application/x-www-form-urlencoded");const c=yield h(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)O.AddConcept(t[r])}console.log("GetAllConceptsByType error",c.status),Q(c)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class K{constructor(t=0,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=P(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=t,this.typeUserId=a,this.orderId=s,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class q{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(e.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 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())}))};class tt{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 q(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return Z(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isConnectionLoaded)return t("done");setTimeout(tt.checkFlag,1e3,t)}static removeNodeFromTree(t){return Z(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return Z(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}tt.connectionroot=null;var et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class nt{static addNodeToTree(t){return et(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 et(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isConnectionTypeLoaded)return t("done");setTimeout(nt.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new q(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 et(this,void 0,void 0,(function*(){var e=[],n=this.getNodeFromTree(t);if(n){e.push(null==n?void 0:n.value);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value);return e}}))}static getTypeVariantsFromTreeWithUserId(t,e){return et(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}nt.connectionTypeRoot=null;var ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class it{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){w("connection",t)}static AddConnection(t){t.isTemp||(w("connection",t),tt.addConnectionToTree(t),nt.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(tt.addConnectionToTree(t),nt.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(A("connection",t.id),tt.removeNodeFromTree(t.id),nt.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return tt.connectionroot}static GetConnectionTypeTree(){return nt.connectionTypeRoot}static GetConnection(t){return ot(this,void 0,void 0,(function*(){var e=new K(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield tt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return ot(this,void 0,void 0,(function*(){var e=[],n=yield nt.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}}it.connectionArray=[],it.connectionDictionary=[];var rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(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 rt(this,void 0,void 0,(function*(){let e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield O.GetConcept(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=yield $();const t=yield h(n.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){let n=yield t.json();if(n.length>0)for(let t=0;t<n.length;t++){let o=n[t];e.push(o),O.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),Q(t);return e}}catch(t){throw t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),t}}))}var at=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function st(){return at(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 ct(e)}}))}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())}))};function dt(){return lt(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield it.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function ut(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||it.RemoveConnection(e[n]))}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())}))};function ft(){return ht(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var o=yield dt(t),i=yield function(){return ht(this,arguments,void 0,(function*(t=[]){var e=[];try{var o=yield $();const r=yield h(n.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)it.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),Q(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 ut(e=i,o),yield st(e),e}))}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())}))};const pt=new Map;function vt(t){return yt(this,void 0,void 0,(function*(){let e=P();if(pt.has(t))return pt.get(t)||e;const o=(()=>yt(this,void 0,void 0,(function*(){try{var o=yield O.GetConcept(t);let r=O.GetNpc(t);if(0!=o.id||r)return o;{var i=yield $("application/x-www-form-urlencoded");const o=yield h(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${t}`});return o.ok?(e=yield o.json(),e.id>0?O.AddConcept(e):O.AddNpc(t)):(console.log("Get the concept error",o.status,t),Q(o)),e}}catch(e){throw e instanceof Error?console.log("Get the concept error message: ",e.message,t):console.log("Get the concept unexpected error: ",e,t),e}finally{pt.delete(t)}})))();return pt.set(t,o),o}))}var gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ct(t){return gt(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield it.GetConnectionsOfCompositionLocal(t)).length)e=yield Tt(t);else{var n=yield Tt(t);ut(n,e),e=n}return e}))}function Tt(t){return gt(this,void 0,void 0,(function*(){var e=[];try{var o=yield $("application/x-www-form-urlencoded");const r=yield h(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${t}`});if(!r.ok)throw Q(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)it.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 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*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 wt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield Lt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function It(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 kt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 At(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 xt(t,e){return mt(this,void 0,void 0,(function*(){for(var n,o,i={},r=[],c=0;c<e.length;c++)r.includes(e[c].ofTheConceptId)||r.push(e[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(t,e,r);i[null!==(o=null===(n=null==a?void 0:a.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function St(t,e){return mt(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r={},c=yield O.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield vt(t));var a=yield _t(t,e,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a;var s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=t,s}))}function Rt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 _t(t,e,n){return mt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield O.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield vt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield O.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield O.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield vt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield O.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield _t(f,e,n,o);a[p]=t}}else{const t=yield _t(f,e,n,o);s[p]=t,a=s}}return a}))}function Lt(t,e,n){return mt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield O.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield vt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield O.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield O.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield vt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield O.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield Lt(f,e,n);a[p]=t}}else{const t=yield Lt(f,e,n);s[p]=t,a=s}}return a}))}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 Ut(t){return Et(this,void 0,void 0,(function*(){let e=P();try{var o=yield $("application/x-www-form-urlencoded");const i=yield h(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${t}`});return i.ok?(e=yield i.json(),e.id>0&&O.AddConcept(e)):(console.log("Error in Getting concept by character value Error",i.status),Q(i)),e}catch(t){throw t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),t}}))}var Ft=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pt(t){return Ft(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Ut(t),e=yield O.GetConceptByCharacter(t)),e}))}var Gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bt(t,e){return Gt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Pt(t),r=[];if(i){yield z(t,e);for(var c=yield O.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield ft(s),l=a;l<a+n;l++)if(c[l]){var d=yield It(c[l].id);r.push(d)}}return r}))}function Vt(t,e){return Gt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Pt(t),r=[];if(i){yield z(t,e);for(var c=yield O.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield ft(s),l=a;l<a+n;l++)if(c[l]){var d=yield kt(c[l].id);r.push(d)}}return r}))}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())}))};const Ot=new Map;function bt(t,e){return Dt(this,void 0,void 0,(function*(){let o=P();if(Ot.has(t+e))return Ot.get(t+e)||o;const i=(()=>Dt(this,void 0,void 0,(function*(){try{var i=yield $("application/x-www-form-urlencoded");const r=yield h(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});if(r.ok){let t=yield r.json();o=t,O.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),Q(r);return o}catch(o){throw o instanceof Error?console.log(" This is the concept by category and character direct api error message: ",o.message,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",o,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()),o}finally{Ot.delete(t+e)}})))();return Ot.set(t+e,i),i}))}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 jt(t){return Mt(this,void 0,void 0,(function*(){let e=P();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=t.length;var o=j(t);if(o.length>1){let n=1,i=yield jt(o[0]);0!=i.id&&(n=i.id),e=yield function(t,e){return Mt(this,void 0,void 0,(function*(){let n=yield O.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield bt(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return Mt(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacterAndTypeLocal(t,49);return 0==e.id&&(e=yield Ut(t)),e}))}(t):o[0]==t&&(e=yield function(t){return Mt(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Ut(t)),e}))}(t));return e}))}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())}))};const $t=new Map,Wt=new Map;function Jt(t,e){return Ht(this,void 0,void 0,(function*(){let e=P();if(Wt.has(t))return Wt.get(t);if($t.has(t))return $t.get(t)||e;const o=(()=>Ht(this,void 0,void 0,(function*(){try{if(e=yield jt(t),0==e.id||4==e.typeId){var o=yield $("application/x-www-form-urlencoded");const i=yield h(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${t}`});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();e=r,e.id>0&&O.AddConcept(e)}return e.id>0&&Wt.set(t,e),e}catch(t){throw t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),t}finally{$t.delete(t)}})))();return $t.set(t,o),o}))}var Qt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let Xt=!1,Yt=[];const zt=()=>{Yt.length>0&&!Xt&&Yt.shift()()};function Kt(t){return Qt(this,void 0,void 0,(function*(){return new Promise(((e,o)=>{Yt.push((()=>Qt(this,void 0,void 0,(function*(){try{if(Xt)return;if(Xt=!0,!t&&re.connectionIds.length>10)return Xt=!1,zt(),e();const o=t?`${n.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(t)}).toString()}`:n.GetReservedConnectionIdUrl();var i=yield $("application/x-www-form-urlencoded");const c=yield h(o,{method:"GET",headers:i});if(!c.ok)throw Q(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();for(var r=0;r<a.length;r++)re.AddId(a[r]);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),o(t)}finally{Xt=!1,zt()}})))),zt()}))}))}var qt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let Zt=!1,te=[];const ee=()=>{te.length>0&&!Zt&&te.shift()()};function ne(){return qt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{te.push((()=>qt(this,void 0,void 0,(function*(){try{if(Zt)return;if(Zt=!0,ie.ids.length>10)return Zt=!1,ee(),t();var o=yield $("application/x-www-form-urlencoded");const e=yield h(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!e.ok)throw Q(e),new Error(`Error! status: ${e.status}`);const r=yield e.json();for(var i=0;i<r.length;i++)ie.AddId(r[i]);t()}catch(t){e(t)}finally{Zt=!1,ee()}})))),ee()}))}))}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 getId(){return oe(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield ne()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((t=>console.error("Reserved ID refill failed:",t))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield ne()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(t){Number.isFinite(t)&&t>0&&!this.ids.includes(t)&&this.ids.push(t)}}ie.ids=[],ie.pendingFetch=null;class re{static getId(){return oe(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield Kt()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield Kt()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(t){Number.isFinite(t)&&t>0&&!this.connectionIds.includes(t)&&this.connectionIds.push(t)}static warmUp(t){return oe(this,void 0,void 0,(function*(){const e=t-this.connectionIds.length;e<=0||(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield Kt(e)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}re.connectionIds=[],re.pendingFetch=null;function ce(t){return e=this,o=void 0,r=function*(){let e=P();try{var o=yield $();const i=yield f(n.CreateTheConceptUrl(),o,t);if(!i.ok)throw X(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t):console.log("Create the concept api unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}function ae(t){return e=this,o=void 0,r=function*(){let e=new K(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield $();const i=yield f(n.CreateTheConnectionUrl(),o,t);if(!i.ok)throw console.log("Create the connection error message: ",i),X(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}var 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{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(t){return se(this,void 0,void 0,(function*(){try{let e=[],n=[];if(t&&this.transactionCollections.some((e=>e.id==t))){const o=this.transactionCollections.find((e=>e.id==t));if(this.transactionCollections=this.transactionCollections.filter((e=>e.id==t||new Date(e.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;e=o.data.concepts.slice(),n=o.data.connections.slice(),e.length>0&&(yield ce(e)),n.length>0&&(yield ae(n)),this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t))}else{for(let t=0;t<this.conceptsSyncArray.length;t++)O.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)it.AddConnection(this.connectionSyncArray[t]);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),yield ce(e),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.some((e=>e.id===t.id))))),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),yield ae(n),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!n.some((e=>e.id===t.id)))))}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return se(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections.push({id:t,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(t){console.log("error in initializeTransaction",t)}}))}static markTransactionActions(t,e){return se(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==t?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(e))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.concepts.some((e=>e.id==t.id||e.ghostId==t.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!e.connections.some((e=>e.id==t.id||e.ghostId==t.id))))}catch(t){console.log("error in markTransactionActions",t)}}))}static rollbackTransaction(t,e){return se(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t))}catch(t){console.log("LocalSyncData, roll",t)}}))}static syncDataLocalDb(){return se(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)w("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)w("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}function de(t,e){const n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${e} must be a positive finite number. Received ${JSON.stringify(t)}.`);return n}le.conceptsSyncArray=[],le.connectionSyncArray=[],le.transactionCollections=[];var ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function he(t,e,n,o,i,r,c){return ue(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){const u=function(t,e){const n=de(t,"ofTheConceptId"),o=de(e,"toTheConceptId");if(n===o)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:o}}(t,n);t=u.ofTheConceptId,n=u.toTheConceptId;let h=e,f=e,y=e;999!=l&&(y=l);let p=e,v=e,g=yield re.getId(),C=new K(g,t,n,e,o,y,i,f,a,h,0,p,s,v,r,c);return C.toUpdate=!0,C.isTemp=!1,le.AddConnection(C),d.connections.push(C),C}))}function fe(t,e,n){return ue(this,arguments,void 0,(function*(t,e,n,o={concepts:[],connections:[]}){let i=yield Jt(n),r=t.userId;return yield he(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}var ye=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const pe=new Map;function ve(t,e){return ye(this,void 0,void 0,(function*(){let o=yield O.GetConceptByCharacterAndTypeLocal(t,e),i=t+e;if(pe.has(i))return pe.get(i)||o;const r=(()=>ye(this,void 0,void 0,(function*(){try{if(null==o||0==o.id){var r={character_value:`${t}`,type_id:e},c=JSON.stringify(r),a=yield $();const i=yield h(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:a,body:c});if(i.ok){let t=yield i.json();o=t,O.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),Q(i)}return o}catch(t){throw t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),t}finally{pe.delete(i)}})))();return pe.set(i,r),r}))}function ge(t){return ye(this,void 0,void 0,(function*(){let e=[],o=JSON.stringify(t);var i=yield $();const r=yield h(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let t=yield r.json();e=yield ct(t)}else console.log("This is the concept by type and character error",r.status),Q(r);return e}))}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())}))};function Te(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return Ce(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield ie.getId();let v=new Date,g=new Date;var C=new F(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,le.AddConcept(C),y.concepts.push(C),C}))}function me(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return Ce(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield ie.getId();let v=new Date,g=new Date;var C=new F(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,v,g);return O.AddConcept(C),C.updateRecursion=!0,le.AddConcept(C),y.concepts.push(C),C}))}var Ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function we(t,e){return Ne(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0,a={concepts:[],connections:[]}){let s,l=r,d=o,u=o,h=i,f=o,y=t.startsWith("the_")?t:"the_"+t,p=P();return n?(p=yield Jt(t),s=yield Te(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a)):(p=yield Jt(y),s=yield ve(e,p.id),0==s.id&&0==s.userId&&(s=yield me(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a))),s.type=p,s}))}var Ie=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ke(t){return Ie(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=P();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=p=yield we(o,"",!0,a,s,l),h=p.id,d=p.id,yield ke(t[o],p.id,p.userId,h,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;h=d,u=p=yield we(o,"",!0,a,s,l),yield he(f,y,p.id,p.userId,h,l,p.userId),yield ke(t[o],p.id,p.userId,h,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,h=d;var p=yield we(o,t[o].toString(),!1,a,s,l);yield he(f,y,p.id,p.userId,h,l,p.userId)}return u}))}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function xe(t,e,o){return Ae(this,arguments,void 0,(function*(t,e,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield $("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var 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())}))},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())}))},_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())}))},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 Ee(t){return Le(this,void 0,void 0,(function*(){var e=yield it.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var o=yield function(t){return _e(this,void 0,void 0,(function*(){var e=yield it.GetConnection(t);try{if(0!=e.id)return e;{var o=yield $("application/x-www-form-urlencoded");const i=yield h(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${t}`});return i.ok?(e=yield i.json(),it.AddConnection(e)):(console.log("Get Connection Error",i.status),Q(i)),e}}catch(t){throw t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),t}}))}(t);e=o}return e}))}var Ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fe(t){return Ue(this,arguments,void 0,(function*(t,e=""){let o=!1;var i=yield Ee(t);return o=yield function(t){return Re(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield $("application/x-www-form-urlencoded");""!=e&&(i=yield W("application/x-www-form-urlencoded",e));const r=new URLSearchParams;r.append("id",t.toString()),r.append("apiKey","nodeserver");const c=yield h(n.DeleteTheConnectionUrl(),{method:"POST",headers:i,body:r,redirect:"follow"});c.ok?o=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),Q(c))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}return o}))}(t,e),A("connection",t),tt.removeNodeFromTree(t),nt.removeTypeConcept(i.typeId,t),o}))}function Pe(t){return Ue(this,void 0,void 0,(function*(){let e=yield function(t){return Se(this,void 0,void 0,(function*(){let e=!1;try{let o=yield W();const i=yield h(n.DeleteTheConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});i.ok?e=(yield i.json()).success:(console.log("Delete connection Bulk Api error status: ",i.status),Q(i))}catch(t){t instanceof Error?console.log("Delete connection Bulk Api error message: ",t.message):console.log("Delete connection Bulk Api unexpected error: ",t)}return e}))}(t);if(e)for(let e=0;e<t.length;e++){let n=t[e];n>0&&tt.removeNodeFromTree(n)}return e}))}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 Be(t){return Ge(this,arguments,void 0,(function*(t,e=999){var n=P();if(t<0)return Ho(yield Eo(e,t));if(null!=(n=yield O.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield vt(t)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var o=yield O.GetConcept(n.typeId);if(0!=o.id)n.type=o;else{var i=yield vt(n.typeId);0!=i.id&&(n.type=i)}}return n}))}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())}))};const De=999,Oe=4,be=999,Me=999,je=1e3;function He(t){const e=`${null!=t?t:""}`.trim();if(0===e.length)throw new Error("Cannot create a typed connection without a linker name.");return e}function $e(t,e){return Ve(this,void 0,void 0,(function*(){var n,o,i;if(null==t||null==t.id||0===t.id)throw new Error(`Cannot create a typed connection: ${e} must be a persisted concept.`);const r=t.type;if(null===(n=null==r?void 0:r.characterValue)||void 0===n?void 0:n.trim())return r.characterValue.trim();const c=(yield Be(t.id,t.userId)).type;if(null===(o=null==c?void 0:c.characterValue)||void 0===o?void 0:o.trim())return t.type=c,c.characterValue.trim();if(null!=t.typeId&&0!==t.typeId){const e=yield Be(t.typeId,t.typeUserId);if(0!==e.id&&(null===(i=e.characterValue)||void 0===i?void 0:i.trim()))return t.type=e,e.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${e} concept ${t.id} has no resolvable type.`)}))}function We(t){return Ve(this,void 0,void 0,(function*(){return yield we("connection",t,!1,De,De,be)}))}function Je(t,e,n){return Ve(this,void 0,void 0,(function*(){return yield he(t.id,t.userId,e.id,e.userId,n.id,be,Me,je,Oe)}))}function Qe(t,e,n){return Ve(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){const r=He(n),c=t.userId;if(o){const n=yield function(t,e){return Ve(this,void 0,void 0,(function*(){return`${yield $e(t,"toTheConcept")}_s_${e}_by`}))}(e,r);i&&(yield Ye(`${r}_by`,e,c));const o=yield We(n);yield Je(e,t,o)}const a=yield function(t,e){return Ve(this,void 0,void 0,(function*(){return`${yield $e(t,"ofTheConcept")}_s_${e}_s`}))}(t,r);i&&(yield Ye(`${r}_s`,t,c));const s=yield We(a);return yield Je(t,e,s)}))}function Xe(t,e,n){return Ve(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield Qe(t,e,n,o,i)}))}function Ye(t,e){return Ve(this,arguments,void 0,(function*(t,e,n=null){for(var o=e,i=null!=n?n:e.userId,r=999,c=He(t)+"_count",a=(yield $e(e,"concept"))+"_s_"+c,s=yield we("connection",a,!1,i,4,r),l=yield xe(s.id,e.id,i,10,1),d=[],u=P(),h=0;h<l.length;h++){let t=yield Be(l[h].toTheConceptId);d.push(t)}if(d.length<1)u=yield we("count","1",!1,i,4,r);else{var f=d[0];let t=Number(f.characterValue),e=Number.isFinite(t)?t+1:1;u=yield we("count",e.toString(),!1,i,4,r);for(let t=0;t<l.length;t++)yield Fe(l[t].id)}yield he(o.id,o.userId,u.id,u.userId,s.id,r,Me,je,4,i)}))}function ze(t,e,n){return Ve(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield Qe(t,e,n,o,i)}))}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){return Ke(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield Be(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield ve(a,16);if(s.id>0){for(var l=yield xe(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield ft(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield Be(t),n=yield At(e.id);r.push(n)}}return r}))}function Ze(t,e){return Ke(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield Be(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield ve(a,16);if(s.id>0){for(var l=yield xe(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield Be(t);r.push(e)}}return r}))}class tn{constructor(t,e,n,o,i,r,c,a=!1,s,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=a,this.typeCharacter=c,this.entryTimeStamp=s,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function en(){let t=new Date,e=new Date;return new tn(0,0,0,0,0,"0","0",!1,t,e,0)}class nn{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 on{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new nn(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}}on.characterData=[];class rn{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},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,e,o,i,r){return an(this,void 0,void 0,(function*(){return new nn(e,t,o,e,i,e,r,e,"",!1),yield function(){return cn(this,void 0,void 0,(function*(){var t;try{if(0==(t=on.GetCharacter(t.data)).id){var e=yield $();const i=yield h(n.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new nn(r.userId,t.data,0,0,4,4,999,999,"",!1);return o.id=r.id,on.AddCharacter(o),r}return new rn(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 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 dn(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return ln(this,void 0,void 0,(function*(){var y=yield ve(t,i),p=y;return 0==p.id&&(p=y=yield Te(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}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())}))},hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fn(t,e,n,o){return hn(this,arguments,void 0,(function*(t,e,n,o,i={concepts:[],connections:[]}){var r=yield Pt(t);if(r&&(0==r.id||0==r.userId)){var c=j(t);if(c.length>0)if(c[0]==t){var a=yield function(t,e,n,o,i,r){return un(this,void 0,void 0,(function*(){var i,c=e,a=e;i=e;var s,l=e,d=e,u=e;if(1==t.length){var h=t.charCodeAt(0);yield sn(t,e,n,o,r),s=yield dn(t,e,4,c,49,l,h,u,n,a,o,i,r,d)}else{var f=yield sn(t,e,n,o,r);f.isNew,s=yield dn(t,e,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(t,o,999,999,0,e);r=a}else{var s=yield fn(c[0],e,n,o,i),l=yield fn(c[1],e,n,o,i);l&&(r=yield me(t,o,s.id,o,l.id,o,999,o,999,o,999,o,e,o,i))}}return r}))}var yn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function pn(t){return yn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield $("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(t)}),a=yield h(`${n.GetAllLinkerConnectionOfConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(a.ok){const t=yield a.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"),Q(a);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),t}}))}var vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gn(t){return vn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield $("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(t)}),a=yield h(`${n.GetAllLinkerConnectionToConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(a.ok){const t=yield a.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"),Q(a);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),t}}))}var 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 Tn(t){return Cn(this,void 0,void 0,(function*(){for(var e=yield pn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Be(o);t.type=i}return e}))}function mn(t){return Cn(this,void 0,void 0,(function*(){for(var e=yield gn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield Be(o);t.type=i}return e}))}var Nn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},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){return wn(this,arguments,void 0,(function*(t,e=""){var o=yield Be(t);yield U.removeNodeFromTree(t);var i=o.typeId,r=o.characterValue;yield V.removeTypeConcept(i,t),yield L.removeNodeByCharacter(r,t),A("concept",t);let c=yield function(t){return Nn(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield $("application/x-www-form-urlencoded");""!=e&&(i=yield W("application/x-www-form-urlencoded",e));const r=new FormData;r.append("id",t.toString()),r.append("apiKey","nodeserver");const c=yield h(n.DeleteConceptUrl(),{method:"POST",body:r});if(!c.ok)throw Q(c),new Error(`Error! status: ${c.status}`);o=(yield c.json()).success}catch(t){throw t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),t}return o}))}(t,e);return c}))}var kn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function An(t,e){return kn(this,void 0,void 0,(function*(){try{const o=new Headers;o.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield h(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw Q(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 xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Sn(t,e,n,o){return xn(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=n,a=n,s=n,l=t.startsWith("the_"),d=P();return r=l?t:"the_"+t,d=yield Jt(r),yield dn(e,n,4,n,d.id,d.userId,0,999,999,c,o,s,i,a)}))}class Rn{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 _n=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ln(){return _n(this,arguments,void 0,(function*(t=[]){var e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield it.GetConnection(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=yield $();const t=yield h(n.GetConnectionBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){const n=yield t.json();if(n.length>0){for(let t=0;t<n.length;t++){let o=n[t];e.push(o),it.AddConnection(o)}yield st(e)}}else console.log("Get Connection Bulk error",t.status),Q(t);return e}}catch(t){throw t instanceof Error?console.log("Get Connection Bulk error message: ",t.message):console.log("Get Connection Bulk unexpected error: ",t),t}}))}var 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 Un(){return En(this,arguments,void 0,(function*(t=[]){yield ft(t);var e=[];for(let o=0;o<t.length;o++){var n=yield It(t[o]);e.push(n)}return e}))}function Fn(){return En(this,arguments,void 0,(function*(t=[]){yield ft(t);var e=[];for(let o=0;o<t.length;o++){var n=yield kt(t[o]);e.push(n)}return e}))}function Pn(){return En(this,arguments,void 0,(function*(t=[],e=[]){yield Ln(e),function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||it.RemoveConnection(e[n])}(e,yield dt(t));var n=[];for(let e=0;e<t.length;e++){var o=yield kt(t[e]);n.push(o)}return n}))}function Gn(){return En(this,arguments,void 0,(function*(t=[]){let e=[],n=[],o={};for(let o=0;o<(null==t?void 0:t.length);o++){let i=yield it.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}for(let n=0;n<e.length;n++)o[t[n]]=!1;let i=[],r=yield Ln(e);n=[...n,...r];for(let t=0;t<n.length;t++)i.push(n[t].ofTheConceptId),i.push(n[t].toTheConceptId),i.push(n[t].typeId);return yield ct(i),n}))}function Bn(){return En(this,arguments,void 0,(function*(t=[],e=[]){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield it.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Ln(n);for(let t=0;t<i.length;t++)o.push(i[t]);let r={},c=[];for(var a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);console.time("start");for(let e=0;e<t.length;e++){let n=yield St(t[e],o,c);r[t[e]]=n}return console.timeEnd("start"),r}))}var Vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dn(){return Vn(this,arguments,void 0,(function*(t=0,e=[],o="",i=[]){var r=[];try{var c=new Rn;c.composition=t,c.listLinkers=e,c.textSearch=o,c.fullLinkers=i;var a=JSON.stringify(c),s=yield $();const u=yield h(n.RecursiveSearchUrl(),{method:"POST",headers:s,body:a});if(u.ok){const t=yield u.json();var l=t.compositionIds,d=t.internalConnections;t.externalConnections,r=yield Pn(l,d)}else console.log("recursive search error ",u.status),Q(u);return r}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}var On=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bn(t,e){return On(this,void 0,void 0,(function*(){try{var i={email:t,password:e},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(i);const a=yield h(n.LoginUrl(),{method:"POST",headers:r,body:c});if(a.ok){const t=yield a.json();return o.BearerAccessToken=t.data.token,t}console.log("Login tsccs error message: ",a.status),Q(a)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}var Mn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function jn(t){return Mn(this,void 0,void 0,(function*(){const e=yield function(){return Mn(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield h(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}:Q(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(n.SignupUrl(),t);return e}))}var Hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $n(t){return Hn(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let o={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=n.LoginUrl();try{const t=yield h(r,{method:"POST",headers:i,body:e,redirect:"follow"}),n=yield t.json();return t.ok?o={message:"success",status:!0,statusCode:200,data:null==n?void 0:n.data}:Q(t),o}catch(t){throw console.log("Sign in api error",t),t}}))}function Wn(t,e){return-1===t.indexOf(e)&&t.push(e),t}function Jn(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 Qn(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function Xn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function Yn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class zn{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&&(qn.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(e.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 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())}))};class qn{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 zn(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return Kn(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return Kn(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}}qn.root=null;var Zn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function to(t,e,n,o){return Zn(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=eo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Be(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=eo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield Be(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=eo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield Be(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield O.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield Be(e),t.type=n)}const l="the_",u=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const t=yield to(d,e,n,o,i);a[u]=t}}else{const t=yield to(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function eo(t,e){let n=P();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class no{constructor(){this.id=0,this.mainConcept=P(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield to(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),n.MQTT_CONNECTION&&n.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var oo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function io(t){return oo(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=P();null==a&&(a=new no);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield we(o,"",!0,s,l,d);if(null==e&&null==n){let e=u;h=f,e=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield io(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield he(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield io(t[o],f.id,f.userId,y,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=u,h=yield we(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield he(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var ro=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function co(t){return ro(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=P(),a=P();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield Be(l,e);if(!(t.id>0))return null;l=t.id}i=yield Ct(l);const h=[],f=new no,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)Wn(y,i[t].ofTheConceptId),Wn(h,i[t].ofTheConceptId),Wn(h,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<h.length;t++){const e=yield Be(h[t]);l==h[t]&&(c=e),d==h[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=P();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield we(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=Jn(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=Qn(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield io(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield we(t,l,!1,e,o,n);const c=Jn(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=Qn(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield he(d.id,d.userId,i.id,i.userId,c.id,n,e);r.push(i),f.connections.push(h)}for(let t=0;t<u.length;t++)Yn(f.connections,u[t]),Fe(u[t].id);for(let t=0;t<s.length;t++)Xn(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),qn.addCompositionToTree(f),yield le.SyncDataOnline(),f.GetDataCache()}))}var ao=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function so(t,e,o,i){return ao(this,arguments,void 0,(function*(t,e,o,i,r=10,c=1){var a=yield W("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",o),s.append("inpage",r.toString()),s.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield h(l,{method:"GET",headers:a});if(t.ok)return yield t.json();Q(t)}catch(t){throw t}}))}var lo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function uo(t){return lo(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){throw t}}))}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fo(t){return ho(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=[];let l=yield O.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield vt(t));let d=[];d=e.length>0?yo(t,e):yield Ct(t),i=d;for(let t=0;t<i.length;t++)s.includes(i[t].ofTheConceptId)||(s.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);return a=yield _t(t,i,s,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,0==l.id?"":c}))}function yo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function po(t){return ho(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=[];let d=yield O.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield vt(t));let u=[];u=e.length>0?yo(t,e):yield Ct(t),r=u;for(let t=0;t<r.length;t++)l.includes(r[t].ofTheConceptId)||(l.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);return a=yield _t(t,r,l),s[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=d.entryTimeStamp,i.data=s,i.id=t,0==d.id?"":i}))}function vo(t,e){return ho(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Ln(e);for(let e=0;e<t.length;e++){const i=yield po(t[e],n);i&&o.push(i)}return o}))}var go=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Co(t){return go(this,void 0,void 0,(function*(){try{var e=yield $();const o=JSON.stringify(t),i=yield h(n.CreateSessionId(),{method:"POST",headers:e,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),Q(i),null)}catch(t){throw console.log("Creating session failed",t),t}}))}var To=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mo(t,e){return To(this,void 0,void 0,(function*(){try{var o=yield $("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield h(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),Q(r),null)}catch(t){throw console.log("Creating session url failed",t),t}}))}var No=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wo(t,e,o){return No(this,arguments,void 0,(function*(t,e,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("toTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield $("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var Io=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ko(t,e){return Io(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield Be(t),a=yield jt(e);if(a.id>0){let t=[],e=[];if(i){e=yield wo(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield ft(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield Be(n),i=yield At(o.id);r.push(i)}}else{e=yield xe(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield ft(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield Be(n),i=yield At(o.id);r.push(i)}}}return r}))}function Ao(t,e){return Io(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield Be(t),a=yield jt(e),s=[],l=[];if(a.id>0){if(i){s=yield wo(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield xe(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield ct(l)}return r}))}class xo{constructor(t,e,n){this.value=new Map,this.connectionValue=new Map,this.key=t,e.id>0&&this.value.set(e.ghostId,e),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class So{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=en(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=o,this.ghostId=t,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var Ro=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class _o{static compositeKey(t,e,n=999){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return Ro(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isDataLoaded)return t("done");setTimeout(_o.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){const o=this.compositeKey(e,n,t.applicationId),i=this.nodeMap.get(o);i?t.id>0&&i.value.set(t.ghostId,t):this.nodeMap.set(o,new xo(o,t,new So(0,0,0,0,0,0)))}static addConnectionToTree(t,e,n=999){const o=this.compositeKey(e,n,t.applicationId),i=this.nodeMap.get(o);i?t.id>0&&i.connectionValue.set(t.ghostId,t):this.nodeMap.set(o,new xo(o,en(),t))}static getNodeFromTree(t,e){return Ro(this,arguments,void 0,(function*(t,e,n=999){var o;const i=this.compositeKey(t,e,n);return null!==(o=this.nodeMap.get(i))&&void 0!==o?o:null}))}static removeNodeFromTree(t){return Ro(this,arguments,void 0,(function*(t,e=999,n=999){const o=this.compositeKey(t,e,n);this.nodeMap.delete(o)}))}static countNumberOfNodes(){return this.nodeMap.size}}_o.nodeMap=new Map;var Lo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Eo(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield _o.getNodeFromTree(t,n,o),c=en();return r&&(c=null!==(i=r.value.get(e))&&void 0!==i?i:c),c}))}function Uo(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield _o.getNodeFromTree(t,n,o),c=new So(0,0,0,0,0,0);return r&&(c=null!==(i=r.connectionValue.get(e))&&void 0!==i?i:c),c}))}function Fo(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=999){_o.addConceptToTree(t,e,n)}))}function Po(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=999){_o.addConnectionToTree(t,e,n)}))}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 Bo(t){return Go(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){throw 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())}))};function Do(t){return Vo(this,arguments,void 0,(function*(t,e=""){let n=[],o=yield Bo(t,e),i=t[0].composition;const r=o;let c=r.compositionIds,a=r.internalConnections,s=r.linkers,l=r.reverse;return n=yield Bn(c,a),yield Oo(s,n,i,l)}))}function Oo(t,e,n){return Vo(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Ln(t);for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield Be(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){}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield Be(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){}}}return i=e[n],i}))}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())}))},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 jo(t){return Mo(this,void 0,void 0,(function*(){var e;let o=yield function(t){return bo(this,void 0,void 0,(function*(){let e=[];try{var o=yield $();const i=yield h(n.ViewInternalDataUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;yield ct(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),Q(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}(t),i=[];for(let n=0;n<t.length;n++){let r=t[n],c=o[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield _t(r,c,t);e.data=n,e.id=r,i.push(e)}else{let t={};t.id=r;let n=yield Be(r),o={};n.type&&(o[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=o,i.push(t))}}return i}))}function Ho(t){const e=P();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e.characterValue=t.characterValue,e}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())}))},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 Jo(t){return Wo(this,arguments,void 0,(function*(t,e=""){var o=yield function(t){return $o(this,arguments,void 0,(function*(t,e=""){var o,i,r,c,a,s,l=yield W("application/json",e);const d=new URLSearchParams({composition:String(null!==(o=t.composition)&&void 0!==o?o:""),search:String(null!==(i=t.search)&&void 0!==i?i:""),internalComposition:String(null!==(r=t.internalComposition)&&void 0!==r?r:""),type:String(null!==(c=t.type)&&void 0!==c?c:""),inpage:String(null!==(a=t.inpage)&&void 0!==a?a:""),page:String(null!==(s=t.page)&&void 0!==s?s:"")}),u=`${n.SearchInternalWithAuthenticatedCcsUrl()}?${d.toString()}`;try{const t=yield h(u,{method:"GET",headers:l});if(t.ok)return yield t.json();Q(t)}catch(t){throw t}}))}(t,e);return yield jo(o)}))}var Qo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xo(t,e){return Qo(this,void 0,void 0,(function*(){let n=!0,o=yield pn(t),i=yield ge(e),r=[];for(let t=0;t<o.length;t++)for(let e=0;e<i.length;e++)o[t].typeId==i[e].id&&r.push(o[t].id);for(let t=0;t<r.length;t++){let e=yield Fe(r[t]);n=n&&e}return n}))}function Yo(t,e){return Qo(this,void 0,void 0,(function*(){let n=yield pn(t),o=yield ge(e),i=[];for(let t=0;t<n.length;t++)for(let e=0;e<o.length;e++)n[t].typeId==o[e].id&&i.push(n[t].id);return i}))}class zo{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Ko{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class qo{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Zo{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class ti{constructor(t){this.aiUrl="https://ai.freeschema.com",this.accessToken="",this.enableAi=!0,t&&Object.assign(this,t)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(t,e=!1){var n,o;return null!==(o=null===(n=this.flags)||void 0===n?void 0:n[t])&&void 0!==o?o:e}getParameter(t,e=""){var n,o;return null!==(o=null===(n=this.parameters)||void 0===n?void 0:n[t])&&void 0!==o?o:e}setFlag(t,e){this.flags||(this.flags={}),this.flags[t]=e}setParameter(t,e){this.parameters||(this.parameters={}),this.parameters[t]=e}}var ei=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ni{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),(0!=t.id||t.isTemp)&&w("localconnection",t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return ei(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isLocalConnectionLoaded)return t("done");setTimeout(ni.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return ei(this,void 0,void 0,(function*(){var e=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}getName(){return this.name}}ni.connectionArray=[],ni.connectionDictionary=[];var oi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ii(){return oi(this,void 0,void 0,(function*(){yield function(){return oi(this,void 0,void 0,(function*(){var t=yield k("connection");if(Array.isArray(t))for(var e=0;e<t.length;e++)it.AddConnectionToMemory(t[e])}))}()}))}function ri(){return oi(this,void 0,void 0,(function*(){yield function(){return oi(this,void 0,void 0,(function*(){var t=yield x("localconnection");if(Array.isArray(t))for(var e=0;e<t.length;e++)ni.AddConnection(t[e])}))}()}))}class ci{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(e.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var 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())}))};class si{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 ci(t.id,t,null,null);new ci(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return ai(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isLocalDataLoaded)return t("done");setTimeout(si.checkFlag,1e3,t)}static getNodeFromTree(t){return ai(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static removeNodeFromTree(t){return ai(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}si.root=null;var li=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class di{static waitForDataToLoad(){return li(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isLocalCharacterLoaded)return t("done");setTimeout(di.checkFlag,1e3,t)}static addNodeToTree(t){return li(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 ci(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 li(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}di.LocalCharacterRoot=null;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())}))};class hi{static addNodeToTree(t){return ui(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 ci(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 ui(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(S.isLocalTypeLoaded)return t("done");setTimeout(hi.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return ui(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}))}}hi.LocalTypeRoot=null;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())}))};class yi{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(w("localconcept",t),si.addConceptToTree(t),di.addConceptToTree(t),hi.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(si.addConceptToTree(t),di.addConceptToTree(t),hi.addConceptToTree(t))}static GetConcept(t){return fi(this,void 0,void 0,(function*(){var e=en(),n=yield si.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return fi(this,void 0,void 0,(function*(){var e=en(),n=di.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return fi(this,void 0,void 0,(function*(){var n=en(),o=yield di.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return fi(this,void 0,void 0,(function*(){let n=[];return n=yield hi.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}yi.localconceptsArray=[];var pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function vi(){return pi(this,void 0,void 0,(function*(){var t=yield x("localconcept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];yi.AddConceptToMemory(n)}}))}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())}))};class Ci{}Ci.isUpdated=!1,Ci.isOnlineSync=!1;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())}))};var mi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const Ni=1,wi=2,Ii=3,ki=4,Ai=5,xi=6,Si=7,Ri=8;class _i{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}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())}))};function Ei(t){return Li(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield vt(t[n].connectionTypeId);t[n].connectionType=o.characterValue,e[t[n].conceptId]||(e[t[n].conceptId]=[]),e[t[n].conceptId].push(t[n])}return e}))}function Ui(t){const e=t.split("_");if(3===e.length){let t=new _i;return t.conceptId=Number(e[0]),t.connectionTypeId=Number(e[1]),t.count=Number(e[2]),t}throw new Error("Input string must contain exactly three parts separated by underscores.")}function Fi(t){return t.startsWith("the_")?t.slice(4):t}var Pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gi(t,e,n){if(t in e){const o=Array.isArray(e[t])?e[t]:[e[t]];for(const t of o)t&&(n[t.connectionType+"_count"]=t.count)}}var Bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},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 Di(t,e,n){return Vi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield Be(t[u].ofTheConceptId),y=yield Be(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield Be(t[u].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;s.characterValue,s.characterValue.includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield Be(t[u].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){}}}return e}))}var Oi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bi(t,e="DESC"){return"ASC"==e?t.sort((function(t,e){return t.id-e.id})):t.sort((function(t,e){return e.id-t.id})),t}var Mi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var ji=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Hi(t,e){return ji(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=xi;let o,i=yield function(t){return mi(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){!function(t,e=""){if(t.status){let n=new J(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new J(t.message,!1,500,t.stack);throw n.setUrl(e),n}}(t,i)}}))}(t,""),r=i.conceptIds,c=(i.internalConnections,i.linkers),a=i.reverse,s=i.mainCompositionIds,l=i.countinfo,d=t.order,u=function(t=[]){let e=[];if(t.length>0)for(let n=0;n<(null==t?void 0:t.length);n++){let o=Ui(t[n]);e.push(o)}return e}(l);return o=e==wi?yield function(t,e,n,o,i){return Mi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Gn(t),a=yield Ei(i);c=bi(c,r);let s=[];s=yield function(t,e){return Bi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Be(t[u].ofTheConceptId),y=yield Be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){}}}return e}))}(c,s,o),s=yield function(t,e){return Bi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Be(t[u].ofTheConceptId),y=yield Be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Fi(o));let i={id:f.id,data:{[t]:e}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=t,r=Fi(r),c=!0);let a={id:y.id,data:{[t]:e}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(t){}}}return e}))}(c,s,o);let l=yield function(t,e,n,o){return Bi(this,arguments,void 0,(function*(t,e,n,o,i=[],r){var c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let e=0;e<t.length;e++)y.push(t[e].toTheConceptId),y.push(t[e].ofTheConceptId),y.push(t[e].typeId);for(let n=0;n<t.length;n++){let o=!1,f=yield Be(t[n].ofTheConceptId),y=yield Be(t[n].toTheConceptId);if(i.includes(t[n].id)&&(o=!0),1==o){if(0!=f.id&&0!=y.id&&y.id in e){let o,i=yield Be(t[n].typeId),s=null!==(a=null===(c=y.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",l=!1;t[n].toTheConceptId in e&&(l=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},e[t[n].toTheConceptId]=o),Gi(y.id,r,o);try{if(e[t[n].ofTheConceptId]){let r={id:f.id,data:e[t[n].ofTheConceptId],created_on:t[n].entryTimeStamp},c=i.characterValue+"_reverse";Array.isArray(o[s][c])?o[s][c].push(r):c.includes("_s_")?(o[s][c]=[],o[s][c].push(r)):o[s][c]=r}}catch(t){}}}else if(0!=f.id&&0!=y.id&&f.id in e){let o,i=yield Be(t[n].typeId),c=null!==(l=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"self",a=!1;t[n].toTheConceptId in e&&(a=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Gi(f.id,r,o);let p=!0,v=i.characterValue;""==v&&(v=y.characterValue,p=!0),""==v&&(v=null!==(u=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==y?void 0:y.type)||void 0===h||h.characterValue;let a=e[t[n].toTheConceptId];if(a){let s={id:y.id,data:e[t[n].toTheConceptId],created_on:t[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(a):Array.isArray(o[c][v])?o[c][i.characterValue].push(s):v.includes("_s_")?(o[c][v]=[],o[c][v].push(s)):o[c][v]=s,Gi(y.id,r,s)}}catch(t){}}}for(let t=0;t<o.length;t++){let n={};n.id=o[t];let i=yield Be(n.id);n.data=e[o[t]],n.created_on=i.entryTimeStamp,f.push(n)}return f}))}(c,s,[],n,o,a);return l}))}(c,r,s,a,u,d):e==Ii?yield function(t,e,n,o,i){return Mi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Gn(t),a=yield Ei(i);c=bi(c,r);let s=[];s=yield Di(c,s,o),s=yield function(t,e){return Pi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield Be(t[u].ofTheConceptId),y=yield Be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield Be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Fi(o));let i={id:f.id,[t]:e},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield Be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,a=!1;""==c&&(c=e,c=Fi(c),a=!0);let s={};s[e]={id:y.id,data:r,created_on:t[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=a?s[e]:s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s[e]))}catch(t){}}}return e}))}(c,s,o);let l=yield function(t,e,n){return Pi(this,arguments,void 0,(function*(t,e,n,o=[],i){var r,c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let e=0;e<t.length;e++)y.push(t[e].toTheConceptId),y.push(t[e].ofTheConceptId),y.push(t[e].typeId);for(let n=0;n<t.length;n++){let f=!1,y=yield Be(t[n].ofTheConceptId),p=yield Be(t[n].toTheConceptId);if(o.includes(t[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in e){let o,i=yield Be(t[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;t[n].toTheConceptId in e&&(s=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let r=e[t[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(t){}}}else if(0!=y.id&&0!=p.id&&y.id in e){let o,r=yield Be(t[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",f=!1;t[n].toTheConceptId in e&&(f=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Gi(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",a=e[t[n].toTheConceptId];if(a){let e={};e[r]={data:a[r],id:p.id,created_on:t[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(e):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(e[r]):o[c][g].push(e)):o[c][g]=v?e[r]:e,Gi(p.id,i,e)}}catch(t){}}}for(let t=0;t<n.length;t++){let o={};o=e[n[t]],o&&(o.id=n[t]),f.push(o)}return f}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):e==Ri?yield function(t,e,n,o,i){return Mi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Gn(t),a=yield Ei(i);c=bi(c,r);let s={};s=yield function(t){return Oi(this,arguments,void 0,(function*(t,e={},n=[]){var o,i,r,c,a;for(const s of t){const t=n.includes(s.id),l=yield Be(s.ofTheConceptId),d=yield Be(s.toTheConceptId),u=yield Be(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(a=u.characterValue)||void 0===a?void 0:a.includes("_s_");e[h.id]||(e[h.id]={}),e[h.id][y]||(e[h.id][y]={}),g&&(e[f.id]||(e[f.id]={}),e[f.id][p]=v)}return e}))}(c,s,o),s=yield function(t){return Oi(this,arguments,void 0,(function*(t,e={},n=[]){var o,i,r,c,a;for(const s of t){const t=n.includes(s.id),l=yield Be(s.ofTheConceptId),d=yield Be(s.toTheConceptId),u=yield Be(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(a=u.characterValue)&&void 0!==a?a:"";let C=""===g?Fi(p):g;const T=C.includes("_s_"),m=!isNaN(Number(C)),N={id:f.id,data:{[p]:v}};e[h.id]||(e[h.id]={}),y in e[h.id]&&"string"!=typeof e[h.id][y]||(e[h.id][y]=m?[]:{});try{if(T)continue;m?e[h.id][y].push(N):e[h.id][y][t?`${C}_reverse`:C]=N}catch(t){console.error("Error formatting concept data:",t)}}return e}))}(c,s,o);let l=yield function(t,e,n){return Oi(this,arguments,void 0,(function*(t,e,n,o=[],i){var r,c,a;const s=[];for(const n of t){const t=o.includes(n.id),s=yield Be(n.ofTheConceptId),l=yield Be(n.toTheConceptId),d=yield Be(n.typeId);if(0===s.id||0===l.id)continue;const u=t?l:s,h=t?s:l,f=u.id,y=h.id,p=null!==(c=null===(r=u.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",v=d.characterValue+"_reverse",g=d.characterValue||h.characterValue||(null===(a=h.type)||void 0===a?void 0:a.characterValue)||"";if(e[f]){const o=e[f][p],r=e[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Gi(f,i,e[f]);try{t?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(r):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],Gi(y,i,c)}catch(t){console.error("Error processing connection:",t)}}}for(const t of n){const n=yield Be(t);s.push({id:t,data:e[t],created_on:n.entryTimeStamp})}return s}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):yield function(t,e,n,o){return Mi(this,void 0,void 0,(function*(){let e=yield Gn(t);e=bi(e);let i=[];i=yield Di(e,i,o),i=yield function(t,e,n){return Vi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield Be(t[u].ofTheConceptId),y=yield Be(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield Be(t[u].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=s.characterValue;""==o&&(o=t,o=Fi(o));let i={[t]:e},l=o+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield Be(t[u].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=t,r=Fi(r),c=!0);let a={[t]:e};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?e:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(e))}catch(t){}}}return e}))}(e,i,o);let r=yield function(){return Vi(this,arguments,void 0,(function*(t=[],e=[],n=[],o,i=[]){var r,c,a,s,l,d;let u=[],h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;i.includes(t[n].id)&&(o=!0);let u=yield Be(t[n].ofTheConceptId),h=yield Be(t[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in e){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[i]={},e[t[n].toTheConceptId]=o);let a=yield Be(t[n].typeId);try{let r=a.characterValue+"_reverse",c=e[t[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(t){}}}else if(0!=u.id&&0!=h.id&&u.id in e){let o,i=null!==(s=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},e[t[n].ofTheConceptId]=o);let r=!1,c=(yield Be(t[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let a=e[t[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(t){}}}for(let t=0;t<n.length;t++){let o=e[n[t]];o&&(o.id=n[t],u.push(o))}return u}))}(e,i,n,[],o);return r}))}(c,0,s,a),o}))}class $i{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=Ni,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var Wi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ji(t,e){return Wi(this,arguments,void 0,(function*(t,e,n=!1){let o=[];if(n){let n=yield gn(t),i=yield Jt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield pn(t);for(let t=0;t<n.length;t++)it.AddConnection(n[t]);let i=yield Jt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function Qi(t,e,n){return Wi(this,arguments,void 0,(function*(t,e,n,o=!1){let i=[],r=[];if(i=o?yield Ji(e,n,o):yield Ji(t,n,o),o)for(let e=0;e<i.length;e++)i[e].ofTheConceptId==t&&r.push(i[e]);else for(let t=0;t<i.length;t++)i[t].toTheConceptId==e&&r.push(i[t]);return r}))}var 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())}))};function Yi(t){return Xi(this,void 0,void 0,(function*(){try{const e=yield $(),o=yield h(n.GetConnectionsBetweenUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),Q(o),new Error(`GetConnectionsBetweenApi error: ${o.status}`);return yield o.json()}catch(t){throw t instanceof Error?console.log("GetConnectionsBetweenApi error message: ",t.message):console.log("GetConnectionsBetweenApi unexpected error: ",t),t}}))}function zi(t){var e,n,o,i,r,c,a;return{ofTheConceptId:null!==(e=t.ofTheConceptId)&&void 0!==e?e:0,toTheConceptId:null!==(n=t.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(o=t.typeId)&&void 0!==o?o:0,type:null!==(i=t.type)&&void 0!==i?i:"",oldType:null!==(r=t.oldType)&&void 0!==r?r:"",reverse:null!==(c=t.reverse)&&void 0!==c&&c,isComposition:null!==(a=t.isComposition)&&void 0!==a&&a,connectionIds:[]}}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 qi{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return Ki(this,void 0,void 0,(function*(){yield le.initializeTransaction(this.transactionId)}))}markAction(){return Ki(this,void 0,void 0,(function*(){yield le.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Ki(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield le.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Ki(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield le.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Pe(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(t){return Ki(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([t])}))}DeleteConnectionsBetweenBulk(t){return Ki(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const e=t.map(zi),n=yield Yi(e),o=[];for(const t of n)o.push(...t.connectionIds);return this.pendingConnectionDeletions.push(...o),o}catch(t){throw console.log(t),this.success=!1,t}}))}MakeTheInstanceConcept(t,e){return Ki(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const a=yield we(t,e,n,o,i,r,c,this.actions);return yield this.markAction(),a}catch(t){throw console.log(t),this.success=!1,t}}))}CreateConnection(t,e,n){return Ki(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield fe(t,e,n,this.actions);return yield this.markAction(),o}catch(t){throw console.log(t),this.success=!1,t}}))}MakeTheTypeConcept(t,e,n,o){return Ki(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield fn(t,e,n,o,this.actions);return yield this.markAction(),i}catch(t){throw console.log(t),this.success=!1,t}}))}CreateTheConnectionGeneral(t,e,n,o,i,r,c){return Ki(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield he(t,e,n,o,i,r,c,a,s,l,this.actions);return yield this.markAction(),d}catch(t){throw console.log(t),this.success=!1,t}}))}}var Zi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tr(t=""){o.BearerAccessToken=t}function er(){return Zi(this,arguments,void 0,(function*(t="",e="",i="CCSApp",c){const a=c||new ti;if(n.BASE_URL=t,n.AI_URL=a.aiUrl,e&&(n.NODE_URL=e),a.hasOAuthCredentials()){const t=a.applicationName||i;o.setOAuthCredentials(a.clientId,a.clientSecret,t);const e=yield r(a.clientId,a.clientSecret,t,!0);if(!e.success)throw new Error(`OAuth token request failed: ${e.error||"unknown error"}`)}else a.hasAccessToken()&&(o.BearerAccessToken=a.accessToken);S.isDataLoaded=!1,S.isCharacterLoaded=!1,S.isTypeLoaded=!1,S.isLocalDataLoaded=!1,S.isLocalTypeLoaded=!1,S.isLocalCharacterLoaded=!1,S.isConnectionLoaded=!1,S.isConnectionTypeLoaded=!1,S.isLocalConnectionLoaded=!1,yield function(){return Ti(this,void 0,void 0,(function*(){return yield N("settings")[0]||new C(!0),yield function(){return gi(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([M().then((()=>{S.isDataLoaded=!0,S.isCharacterLoaded=!0,S.isTypeLoaded=!0})),vi().then((()=>{S.isLocalDataLoaded=!0,S.isLocalTypeLoaded=!0,S.isLocalCharacterLoaded=!0})),ri().then((()=>{S.isLocalConnectionLoaded=!0})),ii().then((()=>{S.isConnectionLoaded=!0,S.isConnectionTypeLoaded=!0}))])}))}var nr=e.BG,or=e.TR,ir=e.Tc,rr=e.U3,cr=e.Wg,ar=e.g2,sr=e.BO,lr=e.WW,dr=e.BS,ur=e.ji,hr=e.Ij,fr=e.Ng,yr=e.du,pr=e.RC,vr=e.d4,gr=e.Cd,Cr=e.IM,Tr=e.oI,mr=e.u9,Nr=e.B7,wr=e.mF,Ir=e.Q9,kr=e.wT,Ar=e.y0,xr=e.iw,Sr=e.pU,Rr=e.qN,_r=e.mZ,Lr=e.Ec,Er=e.L0,Ur=e.Te,Fr=e.vw,Pr=e.z8,Gr=e.k9,Br=e.sP,Vr=e.Y3,Dr=e.WC,Or=e.Nj,br=e.dF,Mr=e.cw,jr=e.p8,Hr=e.rv,$r=e.pX,Wr=e.iD,Jr=e.Mb,Qr=e.bq,Xr=e.ke,Yr=e.w1,zr=e.yz,Kr=e.RW,qr=e.WL,Zr=e.rh,tc=e.nW,ec=e.RH,nc=e.Aj,oc=e.cV,ic=e.jM,rc=e.nS,cc=e.Yu,ac=e.xf,sc=e.KS,lc=e.L6,dc=e.Z9,uc=e.Ny,hc=e.qY,fc=e.jQ,yc=e.NT,pc=e.Xr,vc=e.ab,gc=e.SV,Cc=e.EA,Tc=e.M2,mc=e.OY,Nc=e.ry,wc=e.cS,Ic=e.ZJ,kc=e.RA,Ac=e.BH,xc=e.SL,Sc=e.Ne,Rc=e.fg,_c=e.M4,Lc=e.UG,Ec=e.CT,Uc=e.yv,Fc=e.vI,Pc=e.XZ,Gc=e.ZE,Bc=e.pi,Vc=e.B8,Dc=e.yx,Oc=e.br,bc=e.eU,Mc=e.cf,jc=e.jy,Hc=e.cm,$c=e.qn,Wc=e.ss,Jc=e.pf,Qc=e.pZ,Xc=e.l4,Yc=e.f8,zc=e.Y6,Kc=e.FS,qc=e.bM,Zc=e.ZX,ta=e.CE,ea=e.Sf,na=e.tp,oa=e.Ry,ia=e.jh,ra=e.dp,ca=e.a2,aa=e.J5,sa=e.sc,la=e.x9,da=e.Py,ua=e.Xc,ha=e.Ts,fa=e.P$,ya=e.xX,pa=e.ae,va=e.zN,ga=e.dU,Ca=e.mA,Ta=e.En,ma=e.eD,Na=e.$Q;export{nr as ALLID,or as AddGhostConcept,ir as AddGhostConnection,rr as BaseUrl,cr as BinaryTree,ar as CCSConfig,sr as Composition,lr as CompositionBinaryTree,dr as CompositionNode,ur as Concept,hr as ConceptsData,fr as Connection,yr as ConnectionData,pr as CreateComposition,vr as CreateConnection,gr as CreateConnectionBetweenTwoConcepts,Cr as CreateConnectionBetweenTwoConceptsGeneral,Tr as CreateDefaultConcept,mr as CreateDefaultLConcept,Nr as CreateSession,wr as CreateSessionVisit,Ir as CreateTheCompositionWithCache,kr as CreateTheConnectionGeneral,Ar as DATAID,xr as DATAIDDATE,Sr as DATAV2,Rr as DeleteConceptById,_r as DeleteConnectionById,Lr as DeleteConnectionByIdBulk,Er as DeleteConnectionByTypeBulk,Ur as FilterSearch,Fr as FormatFromConnections,Pr as FreeSchemaResponse,Gr as FreeschemaQuery,Br as GetAllConnectionsOfComposition,Vr as GetAllConnectionsOfCompositionBulk,Dr as GetAllTheConnectionsByTypeAndOfTheConcept,Or as GetComposition,br as GetCompositionBulk,Mr as GetCompositionBulkWithDataId,jr as GetCompositionFromConnectionsWithDataId,Hr as GetCompositionFromConnectionsWithDataIdInObject,$r as GetCompositionList,Wr as GetCompositionListWithId,Jr as GetCompositionWithAllIds,Qr as GetCompositionWithCache,Xr as GetCompositionWithDataIdBulk,Yr as GetCompositionWithDataIdWithCache,zr as GetCompositionWithId,Kr as GetCompositionWithIdFromMemory,qr as GetCompositionWithIdFromMemoryFromConnections,Zr as GetConceptBulk,tc as GetConceptByCharacter,ec as GetConceptByCharacterAndCategoryDirectApi,nc as GetConceptByCharacterAndType,oc as GetConceptByTypeBulk,ic as GetConnectionBulk,rc as GetConnectionById,cc as GetConnectionByTypeBulk,ac as GetConnectionOfTheConcept,sc as GetConnectionsBetweenApi,lc as GetLink,dc as GetLinkRaw,uc as GetLinkerConnectionFromConcepts,hc as GetLinkerConnectionToConcepts,fc as GetRelation,yc as GetRelationRaw,pc as GetRequestHeader,vc as GetRequestHeaderWithAuthorization,gc as GetTheConcept,Cc as GetUserGhostConnectionId,Tc as GetUserGhostId,mc as GiveConnection,Nc as HandleHttpError,wc as HttpResponse,Ic as JUSTDATA,kc as LConcept,Ac as LConnection,xc as LISTNORMAL,Sc as LoginToBackend,Rc as MakeTheInstanceConcept,_c as MakeTheTimestamp,Lc as MakeTheTypeConcept,Ec as MakeTheTypeConceptApi,Uc as NORMAL,Fc as PatcherStructure,Pc as RAW,Gc as RecursiveSearchApi,Bc as ReservedConnectionIds,Vc as ReservedIds,Dc as SchemaQueryListener,Oc as SearchAllConcepts,bc as SearchLinkInternal,Mc as SearchLinkMultipleAll,jc as SearchLinkMultipleApi,Hc as SearchQuery,$c as SearchStructure,Wc as SearchWithLinker,Jc as SessionData,Qc as Signin,Xc as Signup,Yc as SplitStrings,zc as SyncData,Kc as TokenRefreshError,qc as TokenStorage,Zc as Transaction,ta as TrashTheConcept,ea as UpdateComposition,na as UserBinaryTree,oa as ViewInternalData,ia as buildFetchConnection,ra as convertFromLConceptToConcept,ca as deleteWithRetry,aa as fetchWithRetry,sa as getFromDatabaseWithType,la as getFromDatabaseWithTypeOld,da as getOAuthToken,ua as getWithRetry,ha as init,fa as patchWithRetry,ya as postWithRetry,pa as putWithRetry,va as recursiveFetch,ga as recursiveFetchNew,Ca as refreshOAuthToken,Ta as requestWithRetry,ma as storeToDatabase,Na as updateAccessToken};
|
|
1
|
+
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)},e={};t.d(e,{BG:()=>Li,TR:()=>Vo,Tc:()=>Do,U3:()=>n,Wg:()=>E,g2:()=>ii,BO:()=>co,WW:()=>no,BS:()=>to,ji:()=>F,Ij:()=>O,Ng:()=>z,du:()=>it,RC:()=>Re,d4:()=>ge,Cd:()=>Ke,IM:()=>tn,oI:()=>P,u9:()=>cn,B7:()=>wo,mF:()=>ko,Q9:()=>so,wT:()=>ve,y0:()=>Si,iw:()=>Ri,pU:()=>Ei,qN:()=>xn,mZ:()=>Ve,Ec:()=>De,L0:()=>Ko,Te:()=>ni,vw:()=>jo,z8:()=>J,k9:()=>qi,sP:()=>Ct,Y3:()=>ft,WC:()=>Yi,Nj:()=>Nt,dF:()=>Bn,cw:()=>Vn,p8:()=>Dn,rv:()=>bn,pX:()=>Bt,iD:()=>Vt,Mb:()=>wt,bq:()=>go,ke:()=>mo,w1:()=>To,yz:()=>Rt,RW:()=>kt,WL:()=>St,rh:()=>ct,nW:()=>Pt,RH:()=>bt,Aj:()=>me,cV:()=>Ne,jM:()=>Pn,nS:()=>Ge,Yu:()=>Zo,xf:()=>Le,KS:()=>Zi,L6:()=>nn,Z9:()=>on,Ny:()=>In,qY:()=>kn,jQ:()=>Ro,NT:()=>_o,Xr:()=>H,ab:()=>W,SV:()=>be,EA:()=>Bo,M2:()=>Go,OY:()=>zi,ry:()=>Q,cS:()=>l,ZJ:()=>xi,RA:()=>rn,BH:()=>Uo,SL:()=>Ui,Ne:()=>Hn,fg:()=>Se,M4:()=>Un,UG:()=>gn,CT:()=>Jt,yv:()=>Ai,vI:()=>ti,XZ:()=>_i,ZE:()=>Mn,pi:()=>re,B8:()=>ie,yx:()=>Qi,br:()=>fo,eU:()=>Yo,cf:()=>Mo,jy:()=>bo,cm:()=>En,qn:()=>oi,ss:()=>po,pf:()=>ei,pZ:()=>qn,l4:()=>Jn,f8:()=>M,Y6:()=>fe,FS:()=>s,bM:()=>o,ZX:()=>nr,CE:()=>_n,Sf:()=>uo,tp:()=>Fo,Ry:()=>Jo,jh:()=>tr,dp:()=>Qo,a2:()=>v,J5:()=>h,sc:()=>I,x9:()=>k,Py:()=>r,Xc:()=>y,Ts:()=>rr,P$:()=>g,xX:()=>f,ae:()=>p,zN:()=>_t,dU:()=>io,mA:()=>c,En:()=>u,eD:()=>w,$Q:()=>ir});class n{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}n.BASE_URL="https://localhost:7053/",n.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="http://localhost:5001/";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(t,e){this.BearerAccessToken=t,this.TOKEN_EXPIRY=e&&e>0?Date.now()+1e3*e:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const t=Date.now(),e=this.TOKEN_EXPIRY-t;return e>0?Math.floor(e/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(t,e,n){this.CLIENT_ID=t,this.CLIENT_SECRET=e,this.APPLICATION_NAME=n}}o.BearerAccessToken="",o.CLIENT_ID="",o.CLIENT_SECRET="",o.APPLICATION_NAME="",o.TOKEN_EXPIRY=0,o.EXPIRY_BUFFER_MS=3e5;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function r(t,e,r){return i(this,arguments,void 0,(function*(t,e,i,r=!0){try{const c=n.OAuthTokenUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("application_name",i);const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(r&&o.setToken(t,n),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}function c(t,e,r){return i(this,arguments,void 0,(function*(t,e,i,r=!0){try{const c=n.OAuthRefreshUrl(),a=new URLSearchParams;a.append("client_id",t),a.append("client_secret",e),a.append("refresh_token",i),a.append("grant_type","refresh_token");const s=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(s.ok){let t="",e="Bearer",n=0;const i=s.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield s.json();t=o.access_token||"",e=o.token_type||"Bearer",n=o.expires_in||0}catch(e){t=yield s.text()}else t=yield s.text();return t?(r&&o.setToken(t,n),{success:!0,access_token:t,token_type:e,expires_in:n}):{success:!1,error:"No access token in response"}}{const t=yield s.text();return{success:!1,error:`HTTP ${s.status}: ${t}`}}}catch(t){return t instanceof TypeError?{success:!1,error:`Network error: ${t.message}`}:{success:!1,error:`Unexpected error: ${t instanceof Error?t.message:String(t)}`}}}))}var a=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class s extends Error{constructor(t){super(t),this.name="TokenRefreshError"}}class l{constructor(t,e,n){this.status=t,this.body=e,this.headers=n}json(){return a(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return a(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return a(this,void 0,void 0,(function*(){if(!o.hasOAuthCredentials())return!1;try{return(yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0)).success}catch(t){return console.error("Token refresh failed:",t),!1}}))}function u(t,e,n,i){return a(this,arguments,void 0,(function*(t,e,n,i,r=1){var c,a;const u=Object.assign(Object.assign({},n),o.getAuthHeader()),h=["GET","HEAD","OPTIONS"].includes(t.toUpperCase());for(let n=0;n<=r;n++)try{const h={method:t,headers:u};void 0!==i&&("object"==typeof i?(u["Content-Type"]||u["content-type"]||(u["Content-Type"]="application/json"),(null===(c=u["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(a=u["content-type"])||void 0===a?void 0:a.includes("application/json"))?h.body=JSON.stringify(i):h.body=i):h.body=i),h.headers=u;const f=yield fetch(e,h),y=yield f.text(),p={};if(f.headers.forEach(((t,e)=>{p[e]=t})),401!==f.status)return new l(f.status,y,p);if(n<r){if(yield d()){Object.assign(u,o.getAuthHeader());continue}throw new s("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(t){if(t instanceof s)throw t;if(n>=r||!h)throw t;console.error(`Request failed (attempt ${n+1}/${r+1}):`,t)}throw new Error("Request failed after all retry attempts")}))}function h(t){return a(this,arguments,void 0,(function*(t,e={},n=1){return u(e.method||"GET",t,function(t){if(t){if(t instanceof Headers){const e={};return t.forEach(((t,n)=>{e[n]=t})),e}return Array.isArray(t)?t.reduce(((t,[e,n])=>(t[e]=n,t)),{}):t}}(e.headers),e.body,n)}))}function f(t,e,n){return a(this,void 0,void 0,(function*(){return u("POST",t,e,n)}))}function y(t,e,n){return a(this,void 0,void 0,(function*(){let o=t;if(n){const e=[];for(const t in n)n.hasOwnProperty(t)&&e.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(n[t]))}`);e.length>0&&(o=`${t}?${e.join("&")}`)}return u("GET",o,e)}))}function p(t,e,n){return a(this,void 0,void 0,(function*(){return u("PUT",t,e,n)}))}function v(t,e){return a(this,void 0,void 0,(function*(){return u("DELETE",t,e)}))}function g(t,e,n){return a(this,void 0,void 0,(function*(){return u("PATCH",t,e,n)}))}class C{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}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())}))};const m={};function N(t){return m[t]||(m[t]=[]),m[t]}function w(t,e){const n=N(t);if(e&&"number"==typeof e.id){const t=n.findIndex((t=>t&&t.id===e.id));if(t>=0)return void(n[t]=e)}n.push(e)}function I(t,e,n){return T(this,void 0,void 0,(function*(){return N(t).filter((t=>t&&t[e]===n))}))}function k(t){return T(this,void 0,void 0,(function*(){return N(t).slice()}))}function A(t,e){const n=N(t),o=n.findIndex((t=>t&&t.id===e));o>=0&&n.splice(o,1)}function S(t){return T(this,void 0,void 0,(function*(){return N(t).slice()}))}class x{}x.isTypeLoaded=!1,x.isCharacterLoaded=!1,x.isDataLoaded=!1,x.isLocalDataLoaded=!1,x.isLocalCharacterLoaded=!1,x.isLocalTypeLoaded=!1,x.isConnectionLoaded=!1,x.isConnectionTypeLoaded=!1,x.isLocalConnectionLoaded=!1;class R{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(e.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 _=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.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 L{static waitForDataToLoad(){return _(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isCharacterLoaded)return t("done");setTimeout(L.checkFlag,1e3,t)}static addNodeToTree(t){return _(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 _(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 R(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 _(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return _(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}L.characterRoot=null;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 E{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 U(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isDataLoaded)return t("done");setTimeout(E.checkFlag,1e3,t)}static addConceptToTree(t){var e=new R(t.id,t,null,null),n=new R(t.characterValue,t,null,null);L.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return U(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return U(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}}E.root=null;class F{constructor(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=t,this.userId=e,this.typeId=n,this.typeUserId=o,this.ghostId=t,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=a,this.characterValue=`${s}`,this.securityId=l,this.securityUserId=d,this.accessId=u,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=y,this.x=0,this.y=0,this.type=null,this.isNew=p,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function P(){let t=G(new Date),e=G(new Date);return new F(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function G(t){const e=t.getMonth()+1,n=t.getDate(),o=t.getFullYear();let i=t.getHours();const r=t.getMinutes(),c=t.getSeconds(),a=i>=12?"PM":"AM";i%=12,i=i||12;const s=t=>t.toString().padStart(2,"0");return`${e}/${n}/${o} ${i}:${s(r)}:${s(c)} ${a}`}var B=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class V{static addNodeToTree(t){return B(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 R(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 B(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isTypeLoaded)return t("done");setTimeout(V.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return B(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)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 B(this,void 0,void 0,(function*(){let n=P();var o=this.getNodeFromTree(e);if(o){o.value.characterValue==t&&(n=o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.characterValue==t&&(n=o.variants[e].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}V.typeRoot=null;var D=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class O{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(t=Date.now()){this.NPC=this.NPC.filter((e=>{const n=this.NPCMeta.get(e);return n&&n.expiresAt>t}))}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){var e;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(t)||this.NPC.push(t);const o=this.NPCMeta.get(t),i=(null!==(e=null==o?void 0:o.attempts)&&void 0!==e?e:0)+1;this.NPCMeta.set(t,{attempts:i,expiresAt:n+i*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(t){const e=Date.now();this.RemoveExpiredNpc(e);const n=this.NPCMeta.get(t);return!!(n&&n.expiresAt>e)}static AddConceptToStorage(t){t.id>0&&w("concept",t)}static AddConcept(t){t.id>0&&(w("concept",t),E.addConceptToTree(t),V.addConceptToTree(t),L.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(E.addConceptToTree(t),V.addConceptToTree(t),L.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);E.removeNodeFromTree(t.id),A("concept",t.id)}static GetConcept(t){return D(this,void 0,void 0,(function*(){var e=P(),n=yield E.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return D(this,void 0,void 0,(function*(){var e=P(),n=L.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return D(this,void 0,void 0,(function*(){var e=P(),n=L.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return D(this,void 0,void 0,(function*(){return P(),yield V.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return D(this,void 0,void 0,(function*(){var n=P(),o=yield L.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 D(this,void 0,void 0,(function*(){let n=[];return n=yield V.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return L.characterRoot}getName(){return this.name}}O.conceptsArray=[],O.NPC=[],O.NPCMeta=new Map,O.NPC_BACKOFF_SECONDS=30,O.conceptDictionary=[];var b=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $(){return b(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield k("concept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];O.AddConceptToMemory(n)}(new Date).getTime()}))}function M(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function H(){return j(this,arguments,void 0,(function*(t="application/json",e="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const t=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);t.success||console.error("Failed to refresh token:",t.error)}return{"Content-Type":t,Authorization:"Bearer "+o.BearerAccessToken,Accept:e}}))}function W(){return j(this,arguments,void 0,(function*(t="application/json",e="",n="application/json"){if(""!==e)return{"Content-Type":t,Authorization:"Bearer "+e,Accept:n};if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const t=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);t.success||console.error("Failed to refresh token:",t.error)}return{"Content-Type":t,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class J{constructor(t,e,o,i){this.url=n.BASE_URL,this.message=t,this.ok=e,this.status=o,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function Q(t){if(!t.ok){const e=t instanceof l,n=e?t.body||`HTTP error ${t.status}`:t.statusText||`HTTP error ${t.status}`;let o=new J(n,!1,t.status,"");throw o.setUrl(e?t.headers.url||"":t.url),o}}function q(t){if(!t.ok){const e=t.body||`HTTP error ${t.status}`;let n=new J(e,!1,t.status,t.body);throw n.setUrl(t.headers.url||""),n}}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())}))};function Y(t,e){return X(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",t),o.append("user_id",e.toString());var i=yield H("application/x-www-form-urlencoded");const c=yield h(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)O.AddConcept(t[r])}console.log("GetAllConceptsByType error",c.status),Q(c)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class z{constructor(t=0,e,n,o,i,r,c,a,s,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=P(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=t,this.typeUserId=a,this.orderId=s,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class K{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;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(e.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 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())}))};class tt{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 K(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return Z(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isConnectionLoaded)return t("done");setTimeout(tt.checkFlag,1e3,t)}static removeNodeFromTree(t){return Z(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return Z(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}tt.connectionroot=null;var et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class nt{static addNodeToTree(t){return et(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 et(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isConnectionTypeLoaded)return t("done");setTimeout(nt.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new K(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 et(this,void 0,void 0,(function*(){var e=[],n=this.getNodeFromTree(t);if(n){e.push(null==n?void 0:n.value);for(let t=0;t<n.variants.length;t++)e.push(n.variants[t].value);return e}}))}static getTypeVariantsFromTreeWithUserId(t,e){return et(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(t);if(o){o.value.userId==e&&n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId==e&&n.push(o.variants[t].value)}return n}))}}nt.connectionTypeRoot=null;var ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class it{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){w("connection",t)}static AddConnection(t){t.isTemp||(w("connection",t),tt.addConnectionToTree(t),nt.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(tt.addConnectionToTree(t),nt.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(A("connection",t.id),tt.removeNodeFromTree(t.id),nt.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return tt.connectionroot}static GetConnectionTypeTree(){return nt.connectionTypeRoot}static GetConnection(t){return ot(this,void 0,void 0,(function*(){var e=new z(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield tt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return ot(this,void 0,void 0,(function*(){var e=[],n=yield nt.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}}it.connectionArray=[],it.connectionDictionary=[];var rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(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 rt(this,void 0,void 0,(function*(){let e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield O.GetConcept(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=yield H();const t=yield h(n.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){let n=yield t.json();if(n.length>0)for(let t=0;t<n.length;t++){let o=n[t];e.push(o),O.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),Q(t);return e}}catch(t){throw t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),t}}))}var at=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function st(){return at(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 ct(e)}}))}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())}))};function dt(){return lt(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield it.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function ut(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||it.RemoveConnection(e[n]))}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())}))};function ft(){return ht(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var o=yield dt(t),i=yield function(){return ht(this,arguments,void 0,(function*(t=[]){var e=[];try{var o=yield H();const r=yield h(n.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)it.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),Q(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 ut(e=i,o),yield st(e),e}))}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())}))};const pt=new Map;function vt(t){return yt(this,void 0,void 0,(function*(){let e=P();if(pt.has(t))return pt.get(t)||e;const o=(()=>yt(this,void 0,void 0,(function*(){try{var o=yield O.GetConcept(t);let r=O.GetNpc(t);if(0!=o.id||r)return o;{var i=yield H("application/x-www-form-urlencoded");const o=yield h(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${t}`});return o.ok?(e=yield o.json(),e.id>0?O.AddConcept(e):O.AddNpc(t)):(console.log("Get the concept error",o.status,t),Q(o)),e}}catch(e){throw e instanceof Error?console.log("Get the concept error message: ",e.message,t):console.log("Get the concept unexpected error: ",e,t),e}finally{pt.delete(t)}})))();return pt.set(t,o),o}))}var gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ct(t){return gt(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield it.GetConnectionsOfCompositionLocal(t)).length)e=yield Tt(t);else{var n=yield Tt(t);ut(n,e),e=n}return e}))}function Tt(t){return gt(this,void 0,void 0,(function*(){var e=[];try{var o=yield H("application/x-www-form-urlencoded");const r=yield h(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${t}`});if(!r.ok)throw Q(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)it.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 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*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 wt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield Lt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function It(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 kt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 At(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield it.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 St(t,e){return mt(this,void 0,void 0,(function*(){for(var n,o,i={},r=[],c=0;c<e.length;c++)r.includes(e[c].ofTheConceptId)||r.push(e[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(t,e,r);i[null!==(o=null===(n=null==a?void 0:a.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s;var l={};return l.created_at=a.entryTimeStamp,l.data=i,l.id=t,l}))}function xt(t,e){return mt(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r={},c=yield O.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield vt(t));var a=yield _t(t,e,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a;var s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=t,s}))}function Rt(t){return mt(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield Ct(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield O.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield vt(t));var s=yield _t(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 _t(t,e,n){return mt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield O.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield vt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield O.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield O.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield vt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield O.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield _t(f,e,n,o);a[p]=t}}else{const t=yield _t(f,e,n,o);s[p]=t,a=s}}return a}))}function Lt(t,e,n){return mt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield O.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield vt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield O.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(var h=0;h<e.length;h++)if(e[h].ofTheConceptId==t){var f=e[h].toTheConceptId,y=yield O.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield vt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield O.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield vt(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const t=yield Lt(f,e,n);a[p]=t}}else{const t=yield Lt(f,e,n);s[p]=t,a=s}}return a}))}var Ut=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Et(t){return Ut(this,void 0,void 0,(function*(){let e=P();try{var o=yield H("application/x-www-form-urlencoded");const i=yield h(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${t}`});return i.ok?(e=yield i.json(),e.id>0&&O.AddConcept(e)):(console.log("Error in Getting concept by character value Error",i.status),Q(i)),e}catch(t){throw t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),t}}))}var Ft=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pt(t){return Ft(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Et(t),e=yield O.GetConceptByCharacter(t)),e}))}var Gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bt(t,e){return Gt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Pt(t),r=[];if(i){yield Y(t,e);for(var c=yield O.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield ft(s),l=a;l<a+n;l++)if(c[l]){var d=yield It(c[l].id);r.push(d)}}return r}))}function Vt(t,e){return Gt(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Pt(t),r=[];if(i){yield Y(t,e);for(var c=yield O.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield ft(s),l=a;l<a+n;l++)if(c[l]){var d=yield kt(c[l].id);r.push(d)}}return r}))}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())}))};const Ot=new Map;function bt(t,e){return Dt(this,void 0,void 0,(function*(){let o=P();if(Ot.has(t+e))return Ot.get(t+e)||o;const i=(()=>Dt(this,void 0,void 0,(function*(){try{var i=yield H("application/x-www-form-urlencoded");const r=yield h(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});if(r.ok){let t=yield r.json();o=t,O.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),Q(r);return o}catch(o){throw o instanceof Error?console.log(" This is the concept by category and character direct api error message: ",o.message,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",o,t,e,n.GetConceptByCharacterAndCategoryDirectUrl()),o}finally{Ot.delete(t+e)}})))();return Ot.set(t+e,i),i}))}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 Mt(t){return $t(this,void 0,void 0,(function*(){let e=P();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=t.length;var o=M(t);if(o.length>1){let n=1,i=yield Mt(o[0]);0!=i.id&&(n=i.id),e=yield function(t,e){return $t(this,void 0,void 0,(function*(){let n=yield O.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield bt(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return $t(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacterAndTypeLocal(t,49);return 0==e.id&&(e=yield Et(t)),e}))}(t):o[0]==t&&(e=yield function(t){return $t(this,void 0,void 0,(function*(){var e=yield O.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Et(t)),e}))}(t));return e}))}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())}))};const Ht=new Map,Wt=new Map;function Jt(t,e){return jt(this,void 0,void 0,(function*(){let e=P();if(Wt.has(t))return Wt.get(t);if(Ht.has(t))return Ht.get(t)||e;const o=(()=>jt(this,void 0,void 0,(function*(){try{if(e=yield Mt(t),0==e.id||4==e.typeId){var o=yield H("application/x-www-form-urlencoded");const i=yield h(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${t}`});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();e=r,e.id>0&&O.AddConcept(e)}return e.id>0&&Wt.set(t,e),e}catch(t){throw t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),t}finally{Ht.delete(t)}})))();return Ht.set(t,o),o}))}var Qt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let qt=!1,Xt=[];const Yt=()=>{Xt.length>0&&!qt&&Xt.shift()()};function zt(t){return Qt(this,void 0,void 0,(function*(){return new Promise(((e,o)=>{Xt.push((()=>Qt(this,void 0,void 0,(function*(){try{if(qt)return;if(qt=!0,!t&&re.connectionIds.length>10)return qt=!1,Yt(),e();const o=t?`${n.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(t)}).toString()}`:n.GetReservedConnectionIdUrl();var i=yield H("application/x-www-form-urlencoded");const c=yield h(o,{method:"GET",headers:i});if(!c.ok)throw Q(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();for(var r=0;r<a.length;r++)re.AddId(a[r]);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),o(t)}finally{qt=!1,Yt()}})))),Yt()}))}))}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())}))};let Zt=!1,te=[];const ee=()=>{te.length>0&&!Zt&&te.shift()()};function ne(){return Kt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{te.push((()=>Kt(this,void 0,void 0,(function*(){try{if(Zt)return;if(Zt=!0,ie.ids.length>10)return Zt=!1,ee(),t();var o=yield H("application/x-www-form-urlencoded");const e=yield h(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!e.ok)throw Q(e),new Error(`Error! status: ${e.status}`);const r=yield e.json();for(var i=0;i<r.length;i++)ie.AddId(r[i]);t()}catch(t){e(t)}finally{Zt=!1,ee()}})))),ee()}))}))}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 getId(){return oe(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield ne()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((t=>console.error("Reserved ID refill failed:",t))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield ne()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(t){Number.isFinite(t)&&t>0&&!this.ids.includes(t)&&this.ids.push(t)}}ie.ids=[],ie.pendingFetch=null;class re{static getId(){return oe(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield zt()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield zt()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(t){Number.isFinite(t)&&t>0&&!this.connectionIds.includes(t)&&this.connectionIds.push(t)}static warmUp(t){return oe(this,void 0,void 0,(function*(){const e=t-this.connectionIds.length;e<=0||(this.pendingFetch||(this.pendingFetch=(()=>oe(this,void 0,void 0,(function*(){try{yield zt(e)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}re.connectionIds=[],re.pendingFetch=null;function ce(t){return{id:t.id,userId:t.userId,characterValue:t.characterValue,typeId:t.typeId,categoryId:t.categoryId,accessId:t.accessId,referentId:t.referentId,sessionInformationId:t.sessionInformationId}}function ae(t){return e=this,o=void 0,r=function*(){let e=P();try{var o=yield H();const i=function(t){return Array.isArray(t)?t.map((t=>ce(t))):ce(t)}(t),r=yield f(n.CreateTheConceptUrl(),o,i);if(!r.ok)throw q(r),new Error(`Error! status: ${r.status}`);return e=yield r.json(),e}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t):console.log("Create the concept api unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}function se(t){return e=this,o=void 0,r=function*(){let e=new z(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield H();const i=function(t){return t.map((t=>function(t){return{id:t.id,ofTheConceptId:t.ofTheConceptId,toTheConceptId:t.toTheConceptId,ofTheConceptUserId:t.ofTheConceptUserId,toTheConceptUserId:t.toTheConceptUserId,typeId:t.typeId,userId:t.userId,orderId:t.orderId,accessId:t.accessId,sessionInformationId:t.sessionInformationId}}(t)))}(t),r=yield f(n.CreateTheConnectionUrl(),o,i);if(!r.ok)throw console.log("Create the connection error message: ",r),q(r),new Error(`Error! status: ${r.status}`);return e=yield r.json(),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,n){function c(t){try{s(r.next(t))}catch(t){n(t)}}function a(t){try{s(r.throw(t))}catch(t){n(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,o||[])).next())}));var e,o,i,r}var 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 de(t){return t?`[SyncData:${t}]`:"[SyncData]"}function ue(t,e){console.log(`${de(e)} ${t}`)}function he(t,e,n,o,i){o<100&&n!==o||n!==o&&1!==n&&n%100!=0||console.log(`${de(i)} ${t} ${e}: ${n}/${o} done, ${o-n} remaining`)}class fe{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(t){return le(this,void 0,void 0,(function*(){try{let e=[],n=[];if(t&&this.transactionCollections.some((e=>e.id==t))){const o=this.transactionCollections.find((e=>e.id==t));if(this.transactionCollections=this.transactionCollections.filter((e=>e.id==t||new Date(e.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;e=o.data.concepts.slice(),n=o.data.connections.slice(),ue(`starting online sync with ${e.length} concepts and ${n.length} connections`,t),e.length>0&&(ue(`sending ${e.length} concepts to backend`,t),yield ae(e),he("synced","concepts",e.length,e.length,t)),n.length>0&&(ue(`sending ${n.length} connections to backend`,t),yield se(n),he("synced","connections",n.length,n.length,t)),this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t)),ue("online sync complete",t)}else{const t=this.conceptsSyncArray.length,o=this.connectionSyncArray.length;ue(`starting online sync with ${t} queued concepts and ${o} queued connections`);for(let e=0;e<this.conceptsSyncArray.length;e++)O.AddConcept(this.conceptsSyncArray[e]),he("prepared local cache for","concepts",e+1,t);for(let t=0;t<this.connectionSyncArray.length;t++)it.AddConnection(this.connectionSyncArray[t]),he("prepared local cache for","connections",t+1,o);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),ue(`sending ${e.length} concepts to backend`),yield ae(e),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.some((e=>e.id===t.id)))),he("synced","concepts",e.length,e.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),ue(`sending ${n.length} connections to backend`),yield se(n),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!n.some((e=>e.id===t.id)))),he("synced","connections",n.length,n.length)),ue(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return le(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections.push({id:t,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(t){console.log("error in initializeTransaction",t)}}))}static markTransactionActions(t,e){return le(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==t?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(e))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.concepts.some((e=>e.id==t.id||e.ghostId==t.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!e.connections.some((e=>e.id==t.id||e.ghostId==t.id))))}catch(t){console.log("error in markTransactionActions",t)}}))}static rollbackTransaction(t,e){return le(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((e=>e.id==t)))return;this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t))}catch(t){console.log("LocalSyncData, roll",t)}}))}static syncDataLocalDb(){return le(this,void 0,void 0,(function*(){if(ue(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const t=this.conceptsSyncArray.length;for(let e=0;e<this.conceptsSyncArray.length;e++)w("localconcept",this.conceptsSyncArray[e]),he("stored locally","concepts",e+1,t);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const t=this.connectionSyncArray.length;for(let e=0;e<this.connectionSyncArray.length;e++)w("localconnection",this.connectionSyncArray[e]),he("stored locally","connections",e+1,t);this.connectionSyncArray=[]}return ue("local sync complete"),"done"}))}}function ye(t,e){const n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${e} must be a positive finite number. Received ${JSON.stringify(t)}.`);return n}fe.conceptsSyncArray=[],fe.connectionSyncArray=[],fe.transactionCollections=[];var pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ve(t,e,n,o,i,r,c){return pe(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999,d={concepts:[],connections:[]}){const u=function(t,e){const n=ye(t,"ofTheConceptId"),o=ye(e,"toTheConceptId");if(n===o)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:o}}(t,n);t=u.ofTheConceptId,n=u.toTheConceptId;let h=e,f=e,y=e;999!=l&&(y=l);let p=e,v=e,g=yield re.getId(),C=new z(g,t,n,e,o,y,i,f,a,h,0,p,s,v,r,c);return C.toUpdate=!0,C.isTemp=!1,fe.AddConnection(C),d.connections.push(C),C}))}function ge(t,e,n){return pe(this,arguments,void 0,(function*(t,e,n,o={concepts:[],connections:[]}){let i=yield Jt(n),r=t.userId;return yield ve(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}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())}))};const Te=new Map;function me(t,e){return Ce(this,void 0,void 0,(function*(){let o=yield O.GetConceptByCharacterAndTypeLocal(t,e),i=t+e;if(Te.has(i))return Te.get(i)||o;const r=(()=>Ce(this,void 0,void 0,(function*(){try{if(null==o||0==o.id){var r={character_value:`${t}`,type_id:e},c=JSON.stringify(r),a=yield H();const i=yield h(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:a,body:c});if(i.ok){let t=yield i.json();o=t,O.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),Q(i)}return o}catch(t){throw t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),t}finally{Te.delete(i)}})))();return Te.set(i,r),r}))}function Ne(t){return Ce(this,void 0,void 0,(function*(){let e=[],o=JSON.stringify(t);var i=yield H();const r=yield h(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let t=yield r.json();e=yield ct(t)}else console.log("This is the concept by type and character error",r.status),Q(r);return e}))}var we=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ie(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return we(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield ie.getId();let v=new Date,g=new Date;var C=new F(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,fe.AddConcept(C),y.concepts.push(C),C}))}function ke(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return we(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield ie.getId();let v=new Date,g=new Date;var C=new F(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,v,g);return O.AddConcept(C),C.updateRecursion=!0,fe.AddConcept(C),y.concepts.push(C),C}))}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Se(t,e){return Ae(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0,a={concepts:[],connections:[]}){let s,l=r,d=o,u=o,h=i,f=o,y=t.startsWith("the_")?t:"the_"+t,p=P();return n?(p=yield Jt(t),s=yield Ie(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a)):(p=yield Jt(y),s=yield me(e,p.id),0==s.id&&0==s.userId&&(s=yield ke(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a))),s.type=p,s}))}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){return xe(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){var a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=P();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){var h=d;u=p=yield Se(o,"",!0,a,s,l),h=p.id,d=p.id,yield Re(t[o],p.id,p.userId,h,i,r,c)}else{var f=null!=e?e:999,y=null!=n?n:999;h=d,u=p=yield Se(o,"",!0,a,s,l),yield ve(f,y,p.id,p.userId,h,l,p.userId),yield Re(t[o],p.id,p.userId,h,i,r,c)}else{f=null!=e?e:999,y=null!=n?n:10267,h=d;var p=yield Se(o,t[o].toString(),!1,a,s,l);yield ve(f,y,p.id,p.userId,h,l,p.userId)}return u}))}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 Le(t,e,o){return _e(this,arguments,void 0,(function*(t,e,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield H("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var 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())}))},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())}))},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())}))},Pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ge(t){return Pe(this,void 0,void 0,(function*(){var e=yield it.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var o=yield function(t){return Fe(this,void 0,void 0,(function*(){var e=yield it.GetConnection(t);try{if(0!=e.id)return e;{var o=yield H("application/x-www-form-urlencoded");const i=yield h(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${t}`});return i.ok?(e=yield i.json(),it.AddConnection(e)):(console.log("Get Connection Error",i.status),Q(i)),e}}catch(t){throw t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),t}}))}(t);e=o}return e}))}var 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 Ve(t){return Be(this,arguments,void 0,(function*(t,e=""){let o=!1;var i=yield Ge(t);return o=yield function(t){return Ee(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield H("application/x-www-form-urlencoded");""!=e&&(i=yield W("application/x-www-form-urlencoded",e));const r=new URLSearchParams;r.append("id",t.toString()),r.append("apiKey","nodeserver");const c=yield h(n.DeleteTheConnectionUrl(),{method:"POST",headers:i,body:r,redirect:"follow"});c.ok?o=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),Q(c))}catch(t){throw t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),t}return o}))}(t,e),A("connection",t),tt.removeNodeFromTree(t),nt.removeTypeConcept(i.typeId,t),o}))}function De(t){return Be(this,void 0,void 0,(function*(){let e=yield function(t){return Ue(this,void 0,void 0,(function*(){let e=!1;try{let o=yield W();const i=yield h(n.DeleteTheConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});i.ok?e=(yield i.json()).success:(console.log("Delete connection Bulk Api error status: ",i.status),Q(i))}catch(t){t instanceof Error?console.log("Delete connection Bulk Api error message: ",t.message):console.log("Delete connection Bulk Api unexpected error: ",t)}return e}))}(t);if(e)for(let e=0;e<t.length;e++){let n=t[e];n>0&&tt.removeNodeFromTree(n)}return e}))}var Oe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function be(t){return Oe(this,arguments,void 0,(function*(t,e=999){var n=P();if(t<0)return Qo(yield Go(e,t));if(null!=(n=yield O.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield vt(t)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var o=yield O.GetConcept(n.typeId);if(0!=o.id)n.type=o;else{var i=yield vt(n.typeId);0!=i.id&&(n.type=i)}}return n}))}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())}))};const Me=999,je=4,He=999,We=999,Je=1e3;function Qe(t){const e=`${null!=t?t:""}`.trim();if(0===e.length)throw new Error("Cannot create a typed connection without a linker name.");return e}function qe(t,e){return $e(this,void 0,void 0,(function*(){var n,o,i;if(null==t||null==t.id||0===t.id)throw new Error(`Cannot create a typed connection: ${e} must be a persisted concept.`);const r=t.type;if(null===(n=null==r?void 0:r.characterValue)||void 0===n?void 0:n.trim())return r.characterValue.trim();const c=(yield be(t.id,t.userId)).type;if(null===(o=null==c?void 0:c.characterValue)||void 0===o?void 0:o.trim())return t.type=c,c.characterValue.trim();if(null!=t.typeId&&0!==t.typeId){const e=yield be(t.typeId,t.typeUserId);if(0!==e.id&&(null===(i=e.characterValue)||void 0===i?void 0:i.trim()))return t.type=e,e.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${e} concept ${t.id} has no resolvable type.`)}))}function Xe(t){return $e(this,void 0,void 0,(function*(){return yield Se("connection",t,!1,Me,Me,He)}))}function Ye(t,e,n){return $e(this,void 0,void 0,(function*(){return yield ve(t.id,t.userId,e.id,e.userId,n.id,He,We,Je,je)}))}function ze(t,e,n){return $e(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){const r=Qe(n),c=t.userId;if(o){const n=yield function(t,e){return $e(this,void 0,void 0,(function*(){return`${yield qe(t,"toTheConcept")}_s_${e}_by`}))}(e,r);i&&(yield Ze(`${r}_by`,e,c));const o=yield Xe(n);yield Ye(e,t,o)}const a=yield function(t,e){return $e(this,void 0,void 0,(function*(){return`${yield qe(t,"ofTheConcept")}_s_${e}_s`}))}(t,r);i&&(yield Ze(`${r}_s`,t,c));const s=yield Xe(a);return yield Ye(t,e,s)}))}function Ke(t,e,n){return $e(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield ze(t,e,n,o,i)}))}function Ze(t,e){return $e(this,arguments,void 0,(function*(t,e,n=null){for(var o=e,i=null!=n?n:e.userId,r=999,c=Qe(t)+"_count",a=(yield qe(e,"concept"))+"_s_"+c,s=yield Se("connection",a,!1,i,4,r),l=yield Le(s.id,e.id,i,10,1),d=[],u=P(),h=0;h<l.length;h++){let t=yield be(l[h].toTheConceptId);d.push(t)}if(d.length<1)u=yield Se("count","1",!1,i,4,r);else{var f=d[0];let t=Number(f.characterValue),e=Number.isFinite(t)?t+1:1;u=yield Se("count",e.toString(),!1,i,4,r);for(let t=0;t<l.length;t++)yield Ve(l[t].id)}yield ve(o.id,o.userId,u.id,u.userId,s.id,r,We,Je,4,i)}))}function tn(t,e,n){return $e(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield ze(t,e,n,o,i)}))}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 nn(t,e){return en(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield be(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield me(a,16);if(s.id>0){for(var l=yield Le(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield ft(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield be(t),n=yield At(e.id);r.push(n)}}return r}))}function on(t,e){return en(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield be(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield me(a,16);if(s.id>0){for(var l=yield Le(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield be(t);r.push(e)}}return r}))}class rn{constructor(t,e,n,o,i,r,c,a=!1,s,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=a,this.typeCharacter=c,this.entryTimeStamp=s,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function cn(){let t=new Date,e=new Date;return new rn(0,0,0,0,0,"0","0",!1,t,e,0)}class an{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class sn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new an(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}sn.characterData=[];class ln{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var dn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},un=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function hn(t,e,o,i,r){return un(this,void 0,void 0,(function*(){return new an(e,t,o,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=yield H();const i=yield h(n.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw Q(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new an(r.userId,t.data,0,0,4,4,999,999,"",!1);return o.id=r.id,sn.AddCharacter(o),r}return new ln(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}()}))}var fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yn(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return fn(this,void 0,void 0,(function*(){var y=yield me(t,i),p=y;return 0==p.id&&(p=y=yield Ie(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gn(t,e,n,o){return vn(this,arguments,void 0,(function*(t,e,n,o,i={concepts:[],connections:[]}){var r=yield Pt(t);if(r&&(0==r.id||0==r.userId)){var c=M(t);if(c.length>0)if(c[0]==t){var a=yield function(t,e,n,o,i,r){return pn(this,void 0,void 0,(function*(){var i,c=e,a=e;i=e;var s,l=e,d=e,u=e;if(1==t.length){var h=t.charCodeAt(0);yield hn(t,e,n,o,r),s=yield yn(t,e,4,c,49,l,h,u,n,a,o,i,r,d)}else{var f=yield hn(t,e,n,o,r);f.isNew,s=yield yn(t,e,4,c,51,l,f.id,f.userId,n,a,o,i,r,d)}return s}))}(t,o,999,999,0,e);r=a}else{var s=yield gn(c[0],e,n,o,i),l=yield gn(c[1],e,n,o,i);l&&(r=yield ke(t,o,s.id,o,l.id,o,999,o,999,o,999,o,e,o,i))}}return r}))}var Cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Tn(t){return Cn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield H("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(t)}),a=yield h(`${n.GetAllLinkerConnectionOfConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(a.ok){const t=yield a.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"),Q(a);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),t}}))}var mn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nn(t){return mn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield H("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(t)}),a=yield h(`${n.GetAllLinkerConnectionToConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(a.ok){const t=yield a.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"),Q(a);return e}catch(t){throw t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),t}}))}var 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){return wn(this,void 0,void 0,(function*(){for(var e=yield Tn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield be(o);t.type=i}return e}))}function kn(t){return wn(this,void 0,void 0,(function*(){for(var e=yield Nn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield be(o);t.type=i}return e}))}var An=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},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,arguments,void 0,(function*(t,e=""){var o=yield be(t);yield E.removeNodeFromTree(t);var i=o.typeId,r=o.characterValue;yield V.removeTypeConcept(i,t),yield L.removeNodeByCharacter(r,t),A("concept",t);let c=yield function(t){return An(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield H("application/x-www-form-urlencoded");""!=e&&(i=yield W("application/x-www-form-urlencoded",e));const r=new FormData;r.append("id",t.toString()),r.append("apiKey","nodeserver");const c=yield h(n.DeleteConceptUrl(),{method:"POST",body:r});if(!c.ok)throw Q(c),new Error(`Error! status: ${c.status}`);o=(yield c.json()).success}catch(t){throw t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),t}return o}))}(t,e);return c}))}var Rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t,e){return Rn(this,void 0,void 0,(function*(){try{const o=new Headers;o.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield h(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw Q(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 Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Un(t,e,n,o){return Ln(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=n,a=n,s=n,l=t.startsWith("the_"),d=P();return r=l?t:"the_"+t,d=yield Jt(r),yield yn(e,n,4,n,d.id,d.userId,0,999,999,c,o,s,i,a)}))}class En{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 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(){return Fn(this,arguments,void 0,(function*(t=[]){var e=[];try{var o=[];for(let n=0;n<t.length;n++){let i=yield it.GetConnection(t[n]);0==i.id?o.push(t[n]):e.push(i)}if(0==o.length)return e;{var i=yield H();const t=yield h(n.GetConnectionBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(t.ok){const n=yield t.json();if(n.length>0){for(let t=0;t<n.length;t++){let o=n[t];e.push(o),it.AddConnection(o)}yield st(e)}}else console.log("Get Connection Bulk error",t.status),Q(t);return e}}catch(t){throw t instanceof Error?console.log("Get Connection Bulk error message: ",t.message):console.log("Get Connection Bulk unexpected error: ",t),t}}))}var 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 Bn(){return Gn(this,arguments,void 0,(function*(t=[]){yield ft(t);var e=[];for(let o=0;o<t.length;o++){var n=yield It(t[o]);e.push(n)}return e}))}function Vn(){return Gn(this,arguments,void 0,(function*(t=[]){yield ft(t);var e=[];for(let o=0;o<t.length;o++){var n=yield kt(t[o]);e.push(n)}return e}))}function Dn(){return Gn(this,arguments,void 0,(function*(t=[],e=[]){yield Pn(e),function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||it.RemoveConnection(e[n])}(e,yield dt(t));var n=[];for(let e=0;e<t.length;e++){var o=yield kt(t[e]);n.push(o)}return n}))}function On(){return Gn(this,arguments,void 0,(function*(t=[]){let e=[],n=[],o={};for(let o=0;o<(null==t?void 0:t.length);o++){let i=yield it.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}for(let n=0;n<e.length;n++)o[t[n]]=!1;let i=[],r=yield Pn(e);n=[...n,...r];for(let t=0;t<n.length;t++)i.push(n[t].ofTheConceptId),i.push(n[t].toTheConceptId),i.push(n[t].typeId);return yield ct(i),n}))}function bn(){return Gn(this,arguments,void 0,(function*(t=[],e=[]){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield it.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Pn(n);for(let t=0;t<i.length;t++)o.push(i[t]);let r={},c=[];for(var a=0;a<o.length;a++)c.includes(o[a].ofTheConceptId)||c.push(o[a].ofTheConceptId);console.time("start");for(let e=0;e<t.length;e++){let n=yield xt(t[e],o,c);r[t[e]]=n}return console.timeEnd("start"),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 Mn(){return $n(this,arguments,void 0,(function*(t=0,e=[],o="",i=[]){var r=[];try{var c=new En;c.composition=t,c.listLinkers=e,c.textSearch=o,c.fullLinkers=i;var a=JSON.stringify(c),s=yield H();const u=yield h(n.RecursiveSearchUrl(),{method:"POST",headers:s,body:a});if(u.ok){const t=yield u.json();var l=t.compositionIds,d=t.internalConnections;t.externalConnections,r=yield Dn(l,d)}else console.log("recursive search error ",u.status),Q(u);return r}catch(t){throw t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),t}}))}var jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Hn(t,e){return jn(this,void 0,void 0,(function*(){try{var i={email:t,password:e},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(i);const a=yield h(n.LoginUrl(),{method:"POST",headers:r,body:c});if(a.ok){const t=yield a.json();return o.BearerAccessToken=t.data.token,t}console.log("Login tsccs error message: ",a.status),Q(a)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}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 Jn(t){return Wn(this,void 0,void 0,(function*(){const e=yield function(){return Wn(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield h(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}:Q(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(n.SignupUrl(),t);return e}))}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){return Qn(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let o={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=n.LoginUrl();try{const t=yield h(r,{method:"POST",headers:i,body:e,redirect:"follow"}),n=yield t.json();return t.ok?o={message:"success",status:!0,statusCode:200,data:null==n?void 0:n.data}:Q(t),o}catch(t){throw console.log("Sign in api error",t),t}}))}function Xn(t,e){return-1===t.indexOf(e)&&t.push(e),t}function Yn(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 zn(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 Kn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function Zn(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class to{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&&(no.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(e.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 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 no{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 to(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return eo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return eo(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}}no.root=null;var oo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function io(t,e,n,o){return oo(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=ro(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield be(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=ro(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield be(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=ro(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield be(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield O.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield be(e),t.type=n)}const l="the_",u=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const t=yield io(d,e,n,o,i);a[u]=t}}else{const t=yield io(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function ro(t,e){let n=P();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class co{constructor(){this.id=0,this.mainConcept=P(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield io(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(),n.MQTT_CONNECTION&&n.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var 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=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=P();null==a&&(a=new co);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield Se(o,"",!0,s,l,d);if(null==e&&null==n){let e=u;h=f,e=f.id,u=f.id,a.concepts.push(f),a.id=f.id,yield so(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,y=u;h=f,a.concepts.push(f);const p=yield ve(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield so(t[o],f.id,f.userId,y,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=u,h=yield Se(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield ve(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}var lo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function uo(t){return lo(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=P(),a=P();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield be(l,e);if(!(t.id>0))return null;l=t.id}i=yield Ct(l);const h=[],f=new co,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)Xn(y,i[t].ofTheConceptId),Xn(h,i[t].ofTheConceptId),Xn(h,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<h.length;t++){const e=yield be(h[t]);l==h[t]&&(c=e),d==h[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=P();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield Se(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=Yn(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=zn(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield so(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield Se(t,l,!1,e,o,n);const c=Yn(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=zn(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield ve(d.id,d.userId,i.id,i.userId,c.id,n,e);r.push(i),f.connections.push(h)}for(let t=0;t<u.length;t++)Zn(f.connections,u[t]),Ve(u[t].id);for(let t=0;t<s.length;t++)Kn(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),no.addCompositionToTree(f),yield fe.SyncDataOnline(),f.GetDataCache()}))}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fo(t,e,o,i){return ho(this,arguments,void 0,(function*(t,e,o,i,r=10,c=1){var a=yield W("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",o),s.append("inpage",r.toString()),s.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield h(l,{method:"GET",headers:a});if(t.ok)return yield t.json();Q(t)}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 po(t){return yo(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){throw 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())}))};function go(t){return vo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=[];let l=yield O.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield vt(t));let d=[];d=e.length>0?Co(t,e):yield Ct(t),i=d;for(let t=0;t<i.length;t++)s.includes(i[t].ofTheConceptId)||(s.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);return a=yield _t(t,i,s,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,0==l.id?"":c}))}function Co(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function To(t){return vo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=[];let d=yield O.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield vt(t));let u=[];u=e.length>0?Co(t,e):yield Ct(t),r=u;for(let t=0;t<r.length;t++)l.includes(r[t].ofTheConceptId)||(l.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);return a=yield _t(t,r,l),s[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=d.entryTimeStamp,i.data=s,i.id=t,0==d.id?"":i}))}function mo(t,e){return vo(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Pn(e);for(let e=0;e<t.length;e++){const i=yield To(t[e],n);i&&o.push(i)}return o}))}var No=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wo(t){return No(this,void 0,void 0,(function*(){try{var e=yield H();const o=JSON.stringify(t),i=yield h(n.CreateSessionId(),{method:"POST",headers:e,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),Q(i),null)}catch(t){throw console.log("Creating session failed",t),t}}))}var Io=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ko(t,e){return Io(this,void 0,void 0,(function*(){try{var o=yield H("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield h(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),Q(r),null)}catch(t){throw console.log("Creating session url failed",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,e,o){return Ao(this,arguments,void 0,(function*(t,e,o,i=10,r=1){let c=[];try{var a=new URLSearchParams;a.append("typeId",`${t}`),a.append("toTheConceptId",`${e}`),a.append("userId",`${o}`),a.append("inpage",`${i}`),a.append("page",`${r}`);var s=yield H("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),Q(l)),c}catch(t){throw t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),t}}))}var 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 Ro(t,e){return xo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield be(t),a=yield Mt(e);if(a.id>0){let t=[],e=[];if(i){e=yield So(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield ft(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield be(n),i=yield At(o.id);r.push(i)}}else{e=yield Le(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield ft(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield be(n),i=yield At(o.id);r.push(i)}}}return r}))}function _o(t,e){return xo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield be(t),a=yield Mt(e),s=[],l=[];if(a.id>0){if(i){s=yield So(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield Le(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield ct(l)}return r}))}class Lo{constructor(t,e,n){this.value=new Map,this.connectionValue=new Map,this.key=t,e.id>0&&this.value.set(e.ghostId,e),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Uo{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=cn(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=o,this.ghostId=t,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=G(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}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 Fo{static compositeKey(t,e,n=999){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static 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(x.isDataLoaded)return t("done");setTimeout(Fo.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){const o=this.compositeKey(e,n,t.applicationId),i=this.nodeMap.get(o);i?t.id>0&&i.value.set(t.ghostId,t):this.nodeMap.set(o,new Lo(o,t,new Uo(0,0,0,0,0,0)))}static addConnectionToTree(t,e,n=999){const o=this.compositeKey(e,n,t.applicationId),i=this.nodeMap.get(o);i?t.id>0&&i.connectionValue.set(t.ghostId,t):this.nodeMap.set(o,new Lo(o,cn(),t))}static getNodeFromTree(t,e){return Eo(this,arguments,void 0,(function*(t,e,n=999){var o;const i=this.compositeKey(t,e,n);return null!==(o=this.nodeMap.get(i))&&void 0!==o?o:null}))}static removeNodeFromTree(t){return Eo(this,arguments,void 0,(function*(t,e=999,n=999){const o=this.compositeKey(t,e,n);this.nodeMap.delete(o)}))}static countNumberOfNodes(){return this.nodeMap.size}}Fo.nodeMap=new Map;var Po=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Go(t,e){return Po(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield Fo.getNodeFromTree(t,n,o),c=cn();return r&&(c=null!==(i=r.value.get(e))&&void 0!==i?i:c),c}))}function Bo(t,e){return Po(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield Fo.getNodeFromTree(t,n,o),c=new Uo(0,0,0,0,0,0);return r&&(c=null!==(i=r.connectionValue.get(e))&&void 0!==i?i:c),c}))}function Vo(t,e){return Po(this,arguments,void 0,(function*(t,e,n=999){Fo.addConceptToTree(t,e,n)}))}function Do(t,e){return Po(this,arguments,void 0,(function*(t,e,n=999){Fo.addConnectionToTree(t,e,n)}))}var Oo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bo(t){return Oo(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){throw t}}))}var $o=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mo(t){return $o(this,arguments,void 0,(function*(t,e=""){let n=[],o=yield bo(t,e),i=t[0].composition;const r=o;let c=r.compositionIds,a=r.internalConnections,s=r.linkers,l=r.reverse;return n=yield bn(c,a),yield jo(s,n,i,l)}))}function jo(t,e,n){return $o(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Pn(t);for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield be(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){}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield be(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){}}}return i=e[n],i}))}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())}))},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 Jo(t){return Wo(this,void 0,void 0,(function*(){var e;let o=yield function(t){return Ho(this,void 0,void 0,(function*(){let e=[];try{var o=yield H();const i=yield h(n.ViewInternalDataUrl(),{method:"POST",headers:o,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;yield ct(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),Q(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}(t),i=[];for(let n=0;n<t.length;n++){let r=t[n],c=o[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield _t(r,c,t);e.data=n,e.id=r,i.push(e)}else{let t={};t.id=r;let n=yield be(r),o={};n.type&&(o[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=o,i.push(t))}}return i}))}function Qo(t){const e=P();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e.characterValue=t.characterValue,e}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())}))},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,arguments,void 0,(function*(t,e=""){var o=yield function(t){return qo(this,arguments,void 0,(function*(t,e=""){var o,i,r,c,a,s,l=yield W("application/json",e);const d=new URLSearchParams({composition:String(null!==(o=t.composition)&&void 0!==o?o:""),search:String(null!==(i=t.search)&&void 0!==i?i:""),internalComposition:String(null!==(r=t.internalComposition)&&void 0!==r?r:""),type:String(null!==(c=t.type)&&void 0!==c?c:""),inpage:String(null!==(a=t.inpage)&&void 0!==a?a:""),page:String(null!==(s=t.page)&&void 0!==s?s:"")}),u=`${n.SearchInternalWithAuthenticatedCcsUrl()}?${d.toString()}`;try{const t=yield h(u,{method:"GET",headers:l});if(t.ok)return yield t.json();Q(t)}catch(t){throw t}}))}(t,e);return yield Jo(o)}))}var zo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ko(t,e){return zo(this,void 0,void 0,(function*(){let n=!0,o=yield Tn(t),i=yield Ne(e),r=[];for(let t=0;t<o.length;t++)for(let e=0;e<i.length;e++)o[t].typeId==i[e].id&&r.push(o[t].id);for(let t=0;t<r.length;t++){let e=yield Ve(r[t]);n=n&&e}return n}))}function Zo(t,e){return zo(this,void 0,void 0,(function*(){let n=yield Tn(t),o=yield Ne(e),i=[];for(let t=0;t<n.length;t++)for(let e=0;e<o.length;e++)n[t].typeId==o[e].id&&i.push(n[t].id);return i}))}class ti{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class ei{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class ni{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class oi{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class ii{constructor(t){this.aiUrl="https://ai.freeschema.com",this.accessToken="",this.enableAi=!0,t&&Object.assign(this,t)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(t,e=!1){var n,o;return null!==(o=null===(n=this.flags)||void 0===n?void 0:n[t])&&void 0!==o?o:e}getParameter(t,e=""){var n,o;return null!==(o=null===(n=this.parameters)||void 0===n?void 0:n[t])&&void 0!==o?o:e}setFlag(t,e){this.flags||(this.flags={}),this.flags[t]=e}setParameter(t,e){this.parameters||(this.parameters={}),this.parameters[t]=e}}var ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ci{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),(0!=t.id||t.isTemp)&&w("localconnection",t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return ri(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isLocalConnectionLoaded)return t("done");setTimeout(ci.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return ri(this,void 0,void 0,(function*(){var e=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}getName(){return this.name}}ci.connectionArray=[],ci.connectionDictionary=[];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(){return ai(this,void 0,void 0,(function*(){yield function(){return ai(this,void 0,void 0,(function*(){var t=yield k("connection");if(Array.isArray(t))for(var e=0;e<t.length;e++)it.AddConnectionToMemory(t[e])}))}()}))}function li(){return ai(this,void 0,void 0,(function*(){yield function(){return ai(this,void 0,void 0,(function*(){var t=yield S("localconnection");if(Array.isArray(t))for(var e=0;e<t.length;e++)ci.AddConnection(t[e])}))}()}))}class di{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(e.rightNode))+1,e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var 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())}))};class hi{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 di(t.id,t,null,null);new di(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return ui(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isLocalDataLoaded)return t("done");setTimeout(hi.checkFlag,1e3,t)}static getNodeFromTree(t){return ui(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static removeNodeFromTree(t){return ui(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}hi.root=null;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())}))};class yi{static waitForDataToLoad(){return fi(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isLocalCharacterLoaded)return t("done");setTimeout(yi.checkFlag,1e3,t)}static addNodeToTree(t){return fi(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 di(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 fi(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}yi.LocalCharacterRoot=null;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())}))};class vi{static addNodeToTree(t){return pi(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 di(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 pi(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(x.isLocalTypeLoaded)return t("done");setTimeout(vi.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return pi(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}))}}vi.LocalTypeRoot=null;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())}))};class Ci{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(w("localconcept",t),hi.addConceptToTree(t),yi.addConceptToTree(t),vi.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(hi.addConceptToTree(t),yi.addConceptToTree(t),vi.addConceptToTree(t))}static GetConcept(t){return gi(this,void 0,void 0,(function*(){var e=cn(),n=yield hi.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return gi(this,void 0,void 0,(function*(){var e=cn(),n=yi.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return gi(this,void 0,void 0,(function*(){var n=cn(),o=yield yi.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return gi(this,void 0,void 0,(function*(){let n=[];return n=yield vi.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}Ci.localconceptsArray=[];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 mi(){return Ti(this,void 0,void 0,(function*(){var t=yield S("localconcept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];Ci.AddConceptToMemory(n)}}))}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())}))};class wi{}wi.isUpdated=!1,wi.isOnlineSync=!1;var Ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var ki=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const Ai=1,Si=2,xi=3,Ri=4,_i=5,Li=6,Ui=7,Ei=8;class Fi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var Pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gi(t){return Pi(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield vt(t[n].connectionTypeId);t[n].connectionType=o.characterValue,e[t[n].conceptId]||(e[t[n].conceptId]=[]),e[t[n].conceptId].push(t[n])}return e}))}function Bi(t){const e=t.split("_");if(3===e.length){let t=new Fi;return t.conceptId=Number(e[0]),t.connectionTypeId=Number(e[1]),t.count=Number(e[2]),t}throw new Error("Input string must contain exactly three parts separated by underscores.")}function Vi(t){return t.startsWith("the_")?t.slice(4):t}var Di=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oi(t,e,n){if(t in e){const o=Array.isArray(e[t])?e[t]:[e[t]];for(const t of o)t&&(n[t.connectionType+"_count"]=t.count)}}var bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},$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 Mi(t,e,n){return $i(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield be(t[u].ofTheConceptId),y=yield be(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield be(t[u].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;s.characterValue,s.characterValue.includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield be(t[u].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){}}}return e}))}var ji=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Hi(t,e="DESC"){return"ASC"==e?t.sort((function(t,e){return t.id-e.id})):t.sort((function(t,e){return e.id-t.id})),t}var Wi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};var Ji=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qi(t,e){return Ji(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=Li;let o,i=yield function(t){return ki(this,arguments,void 0,(function*(t,e=""){var o=yield W("application/json",e);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(t);try{const t=yield h(i,{method:"POST",headers:o,body:r});if(t.ok)return yield t.json();Q(t)}catch(t){!function(t,e=""){if(t.status){let n=new J(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new J(t.message,!1,500,t.stack);throw n.setUrl(e),n}}(t,i)}}))}(t,""),r=i.conceptIds,c=(i.internalConnections,i.linkers),a=i.reverse,s=i.mainCompositionIds,l=i.countinfo,d=t.order,u=function(t=[]){let e=[];if(t.length>0)for(let n=0;n<(null==t?void 0:t.length);n++){let o=Bi(t[n]);e.push(o)}return e}(l);return o=e==Si?yield function(t,e,n,o,i){return Wi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield On(t),a=yield Gi(i);c=Hi(c,r);let s=[];s=yield function(t,e){return bi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield be(t[u].ofTheConceptId),y=yield be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?n=e[t[u].toTheConceptId]:(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n),e[y.id]={}}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?n=e[t[u].ofTheConceptId]:(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n),e[f.id]={}}catch(t){}}}return e}))}(c,s,o),s=yield function(t,e){return bi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield be(t[u].ofTheConceptId),y=yield be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Vi(o));let i={id:f.id,data:{[t]:e}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=t,r=Vi(r),c=!0);let a={id:y.id,data:{[t]:e}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a))}catch(t){}}}return e}))}(c,s,o);let l=yield function(t,e,n,o){return bi(this,arguments,void 0,(function*(t,e,n,o,i=[],r){var c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let e=0;e<t.length;e++)y.push(t[e].toTheConceptId),y.push(t[e].ofTheConceptId),y.push(t[e].typeId);for(let n=0;n<t.length;n++){let o=!1,f=yield be(t[n].ofTheConceptId),y=yield be(t[n].toTheConceptId);if(i.includes(t[n].id)&&(o=!0),1==o){if(0!=f.id&&0!=y.id&&y.id in e){let o,i=yield be(t[n].typeId),s=null!==(a=null===(c=y.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"self",l=!1;t[n].toTheConceptId in e&&(l=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},e[t[n].toTheConceptId]=o),Oi(y.id,r,o);try{if(e[t[n].ofTheConceptId]){let r={id:f.id,data:e[t[n].ofTheConceptId],created_on:t[n].entryTimeStamp},c=i.characterValue+"_reverse";Array.isArray(o[s][c])?o[s][c].push(r):c.includes("_s_")?(o[s][c]=[],o[s][c].push(r)):o[s][c]=r}}catch(t){}}}else if(0!=f.id&&0!=y.id&&f.id in e){let o,i=yield be(t[n].typeId),c=null!==(l=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"self",a=!1;t[n].toTheConceptId in e&&(a=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Oi(f.id,r,o);let p=!0,v=i.characterValue;""==v&&(v=y.characterValue,p=!0),""==v&&(v=null!==(u=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==y?void 0:y.type)||void 0===h||h.characterValue;let a=e[t[n].toTheConceptId];if(a){let s={id:y.id,data:e[t[n].toTheConceptId],created_on:t[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(a):Array.isArray(o[c][v])?o[c][i.characterValue].push(s):v.includes("_s_")?(o[c][v]=[],o[c][v].push(s)):o[c][v]=s,Oi(y.id,r,s)}}catch(t){}}}for(let t=0;t<o.length;t++){let n={};n.id=o[t];let i=yield be(n.id);n.data=e[o[t]],n.created_on=i.entryTimeStamp,f.push(n)}return f}))}(c,s,[],n,o,a);return l}))}(c,r,s,a,u,d):e==xi?yield function(t,e,n,o,i){return Wi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield On(t),a=yield Gi(i);c=Hi(c,r);let s=[];s=yield Mi(c,s,o),s=yield function(t,e){return Di(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);for(let u=0;u<t.length;u++){let h=!1,f=yield be(t[u].ofTheConceptId),y=yield be(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield be(t[u].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[u].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=a.characterValue;""==o&&(o=t,o=Vi(o));let i={id:f.id,[t]:e},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=yield be(t[u].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,a=!1;""==c&&(c=e,c=Vi(c),a=!0);let s={};s[e]={id:y.id,data:r,created_on:t[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=a?s[e]:s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s[e]))}catch(t){}}}return e}))}(c,s,o);let l=yield function(t,e,n){return Di(this,arguments,void 0,(function*(t,e,n,o=[],i){var r,c,a,s,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let e=0;e<t.length;e++)y.push(t[e].toTheConceptId),y.push(t[e].ofTheConceptId),y.push(t[e].typeId);for(let n=0;n<t.length;n++){let f=!1,y=yield be(t[n].ofTheConceptId),p=yield be(t[n].toTheConceptId);if(o.includes(t[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in e){let o,i=yield be(t[n].typeId),a=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;t[n].toTheConceptId in e&&(s=!0),t[n].toTheConceptId in e?(o=e[t[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let r=e[t[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(t){}}}else if(0!=y.id&&0!=p.id&&y.id in e){let o,r=yield be(t[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",f=!1;t[n].toTheConceptId in e&&(f=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Oi(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",a=e[t[n].toTheConceptId];if(a){let e={};e[r]={data:a[r],id:p.id,created_on:t[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(e):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(e[r]):o[c][g].push(e)):o[c][g]=v?e[r]:e,Oi(p.id,i,e)}}catch(t){}}}for(let t=0;t<n.length;t++){let o={};o=e[n[t]],o&&(o.id=n[t]),f.push(o)}return f}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):e==Ei?yield function(t,e,n,o,i){return Wi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield On(t),a=yield Gi(i);c=Hi(c,r);let s={};s=yield function(t){return ji(this,arguments,void 0,(function*(t,e={},n=[]){var o,i,r,c,a;for(const s of t){const t=n.includes(s.id),l=yield be(s.ofTheConceptId),d=yield be(s.toTheConceptId),u=yield be(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(a=u.characterValue)||void 0===a?void 0:a.includes("_s_");e[h.id]||(e[h.id]={}),e[h.id][y]||(e[h.id][y]={}),g&&(e[f.id]||(e[f.id]={}),e[f.id][p]=v)}return e}))}(c,s,o),s=yield function(t){return ji(this,arguments,void 0,(function*(t,e={},n=[]){var o,i,r,c,a;for(const s of t){const t=n.includes(s.id),l=yield be(s.ofTheConceptId),d=yield be(s.toTheConceptId),u=yield be(s.typeId);if(0===l.id||0===d.id)continue;const h=t?d:l,f=t?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(a=u.characterValue)&&void 0!==a?a:"";let C=""===g?Vi(p):g;const T=C.includes("_s_"),m=!isNaN(Number(C)),N={id:f.id,data:{[p]:v}};e[h.id]||(e[h.id]={}),y in e[h.id]&&"string"!=typeof e[h.id][y]||(e[h.id][y]=m?[]:{});try{if(T)continue;m?e[h.id][y].push(N):e[h.id][y][t?`${C}_reverse`:C]=N}catch(t){console.error("Error formatting concept data:",t)}}return e}))}(c,s,o);let l=yield function(t,e,n){return ji(this,arguments,void 0,(function*(t,e,n,o=[],i){var r,c,a;const s=[];for(const n of t){const t=o.includes(n.id),s=yield be(n.ofTheConceptId),l=yield be(n.toTheConceptId),d=yield be(n.typeId);if(0===s.id||0===l.id)continue;const u=t?l:s,h=t?s:l,f=u.id,y=h.id,p=null!==(c=null===(r=u.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",v=d.characterValue+"_reverse",g=d.characterValue||h.characterValue||(null===(a=h.type)||void 0===a?void 0:a.characterValue)||"";if(e[f]){const o=e[f][p],r=e[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Oi(f,i,e[f]);try{t?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(r):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],Oi(y,i,c)}catch(t){console.error("Error processing connection:",t)}}}for(const t of n){const n=yield be(t);s.push({id:t,data:e[t],created_on:n.entryTimeStamp})}return s}))}(c,s,n,o,a);return l}))}(c,r,s,a,u,d):yield function(t,e,n,o){return Wi(this,void 0,void 0,(function*(){let e=yield On(t);e=Hi(e);let i=[];i=yield Mi(e,i,o),i=yield function(t,e,n){return $i(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let u=[];for(let e=0;e<t.length;e++)u.push(t[e].toTheConceptId),u.push(t[e].ofTheConceptId),u.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let u=0;u<t.length;u++){let h=!1;n.includes(t[u].id)&&(h=!0);let f=yield be(t[u].ofTheConceptId),y=yield be(t[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[u].toTheConceptId in e?(n=e[t[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},e[t[u].toTheConceptId]=n);let s=yield be(t[u].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o=s.characterValue;""==o&&(o=t,o=Vi(o));let i={[t]:e},l=o+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(t){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[u].ofTheConceptId in e?(n=e[t[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},e[t[u].ofTheConceptId]=n);let i=yield be(t[u].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=t,r=Vi(r),c=!0);let a={[t]:e};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?e:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(e))}catch(t){}}}return e}))}(e,i,o);let r=yield function(){return $i(this,arguments,void 0,(function*(t=[],e=[],n=[],o,i=[]){var r,c,a,s,l,d;let u=[],h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;i.includes(t[n].id)&&(o=!0);let u=yield be(t[n].ofTheConceptId),h=yield be(t[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in e){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[i]={},e[t[n].toTheConceptId]=o);let a=yield be(t[n].typeId);try{let r=a.characterValue+"_reverse",c=e[t[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(t){}}}else if(0!=u.id&&0!=h.id&&u.id in e){let o,i=null!==(s=null===(a=u.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},e[t[n].ofTheConceptId]=o);let r=!1,c=(yield be(t[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let a=e[t[n].toTheConceptId];a&&(Array.isArray(o[i])?r?o[i].push(a[c]):o[i].push(a):Array.isArray(o[i][c])?o[i][c].push(a):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(a[c]):o[i][c].push(a)):o[i][c]=r?a[c]:a)}catch(t){}}}for(let t=0;t<n.length;t++){let o=e[n[t]];o&&(o.id=n[t],u.push(o))}return u}))}(e,i,n,[],o);return r}))}(c,0,s,a),o}))}class qi{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=Ai,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!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())}))};function Yi(t,e){return Xi(this,arguments,void 0,(function*(t,e,n=!1){let o=[];if(n){let n=yield Nn(t),i=yield Jt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield Tn(t);for(let t=0;t<n.length;t++)it.AddConnection(n[t]);let i=yield Jt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function zi(t,e,n){return Xi(this,arguments,void 0,(function*(t,e,n,o=!1){let i=[],r=[];if(i=o?yield Yi(e,n,o):yield Yi(t,n,o),o)for(let e=0;e<i.length;e++)i[e].ofTheConceptId==t&&r.push(i[e]);else for(let t=0;t<i.length;t++)i[t].toTheConceptId==e&&r.push(i[t]);return r}))}var Ki=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zi(t){return Ki(this,void 0,void 0,(function*(){try{const e=yield H(),o=yield h(n.GetConnectionsBetweenUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),Q(o),new Error(`GetConnectionsBetweenApi error: ${o.status}`);return yield o.json()}catch(t){throw t instanceof Error?console.log("GetConnectionsBetweenApi error message: ",t.message):console.log("GetConnectionsBetweenApi unexpected error: ",t),t}}))}function tr(t){var e,n,o,i,r,c,a;return{ofTheConceptId:null!==(e=t.ofTheConceptId)&&void 0!==e?e:0,toTheConceptId:null!==(n=t.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(o=t.typeId)&&void 0!==o?o:0,type:null!==(i=t.type)&&void 0!==i?i:"",oldType:null!==(r=t.oldType)&&void 0!==r?r:"",reverse:null!==(c=t.reverse)&&void 0!==c&&c,isComposition:null!==(a=t.isComposition)&&void 0!==a&&a,connectionIds:[]}}var er=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.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 nr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return er(this,void 0,void 0,(function*(){yield fe.initializeTransaction(this.transactionId)}))}markAction(){return er(this,void 0,void 0,(function*(){yield fe.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return er(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield fe.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return er(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield fe.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield De(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(t){return er(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([t])}))}DeleteConnectionsBetweenBulk(t){return er(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const e=t.map(tr),n=yield Zi(e),o=[];for(const t of n)o.push(...t.connectionIds);return this.pendingConnectionDeletions.push(...o),o}catch(t){throw console.log(t),this.success=!1,t}}))}MakeTheInstanceConcept(t,e){return er(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const a=yield Se(t,e,n,o,i,r,c,this.actions);return yield this.markAction(),a}catch(t){throw console.log(t),this.success=!1,t}}))}CreateConnection(t,e,n){return er(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield ge(t,e,n,this.actions);return yield this.markAction(),o}catch(t){throw console.log(t),this.success=!1,t}}))}MakeTheTypeConcept(t,e,n,o){return er(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield gn(t,e,n,o,this.actions);return yield this.markAction(),i}catch(t){throw console.log(t),this.success=!1,t}}))}CreateTheConnectionGeneral(t,e,n,o,i,r,c){return er(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a=1,s=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield ve(t,e,n,o,i,r,c,a,s,l,this.actions);return yield this.markAction(),d}catch(t){throw console.log(t),this.success=!1,t}}))}}var or=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ir(t=""){o.BearerAccessToken=t}function rr(){return or(this,arguments,void 0,(function*(t="",e="",i="CCSApp",c){const a=c||new ii;if(n.BASE_URL=t,n.AI_URL=a.aiUrl,e&&(n.NODE_URL=e),a.hasOAuthCredentials()){const t=a.applicationName||i;o.setOAuthCredentials(a.clientId,a.clientSecret,t);const e=yield r(a.clientId,a.clientSecret,t,!0);if(!e.success)throw new Error(`OAuth token request failed: ${e.error||"unknown error"}`)}else a.hasAccessToken()&&(o.BearerAccessToken=a.accessToken);x.isDataLoaded=!1,x.isCharacterLoaded=!1,x.isTypeLoaded=!1,x.isLocalDataLoaded=!1,x.isLocalTypeLoaded=!1,x.isLocalCharacterLoaded=!1,x.isConnectionLoaded=!1,x.isConnectionTypeLoaded=!1,x.isLocalConnectionLoaded=!1,yield function(){return Ii(this,void 0,void 0,(function*(){return yield N("settings")[0]||new C(!0),yield function(){return Ni(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([$().then((()=>{x.isDataLoaded=!0,x.isCharacterLoaded=!0,x.isTypeLoaded=!0})),mi().then((()=>{x.isLocalDataLoaded=!0,x.isLocalTypeLoaded=!0,x.isLocalCharacterLoaded=!0})),li().then((()=>{x.isLocalConnectionLoaded=!0})),si().then((()=>{x.isConnectionLoaded=!0,x.isConnectionTypeLoaded=!0}))])}))}var cr=e.BG,ar=e.TR,sr=e.Tc,lr=e.U3,dr=e.Wg,ur=e.g2,hr=e.BO,fr=e.WW,yr=e.BS,pr=e.ji,vr=e.Ij,gr=e.Ng,Cr=e.du,Tr=e.RC,mr=e.d4,Nr=e.Cd,wr=e.IM,Ir=e.oI,kr=e.u9,Ar=e.B7,Sr=e.mF,xr=e.Q9,Rr=e.wT,_r=e.y0,Lr=e.iw,Ur=e.pU,Er=e.qN,Fr=e.mZ,Pr=e.Ec,Gr=e.L0,Br=e.Te,Vr=e.vw,Dr=e.z8,Or=e.k9,br=e.sP,$r=e.Y3,Mr=e.WC,jr=e.Nj,Hr=e.dF,Wr=e.cw,Jr=e.p8,Qr=e.rv,qr=e.pX,Xr=e.iD,Yr=e.Mb,zr=e.bq,Kr=e.ke,Zr=e.w1,tc=e.yz,ec=e.RW,nc=e.WL,oc=e.rh,ic=e.nW,rc=e.RH,cc=e.Aj,ac=e.cV,sc=e.jM,lc=e.nS,dc=e.Yu,uc=e.xf,hc=e.KS,fc=e.L6,yc=e.Z9,pc=e.Ny,vc=e.qY,gc=e.jQ,Cc=e.NT,Tc=e.Xr,mc=e.ab,Nc=e.SV,wc=e.EA,Ic=e.M2,kc=e.OY,Ac=e.ry,Sc=e.cS,xc=e.ZJ,Rc=e.RA,_c=e.BH,Lc=e.SL,Uc=e.Ne,Ec=e.fg,Fc=e.M4,Pc=e.UG,Gc=e.CT,Bc=e.yv,Vc=e.vI,Dc=e.XZ,Oc=e.ZE,bc=e.pi,$c=e.B8,Mc=e.yx,jc=e.br,Hc=e.eU,Wc=e.cf,Jc=e.jy,Qc=e.cm,qc=e.qn,Xc=e.ss,Yc=e.pf,zc=e.pZ,Kc=e.l4,Zc=e.f8,ta=e.Y6,ea=e.FS,na=e.bM,oa=e.ZX,ia=e.CE,ra=e.Sf,ca=e.tp,aa=e.Ry,sa=e.jh,la=e.dp,da=e.a2,ua=e.J5,ha=e.sc,fa=e.x9,ya=e.Py,pa=e.Xc,va=e.Ts,ga=e.P$,Ca=e.xX,Ta=e.ae,ma=e.zN,Na=e.dU,wa=e.mA,Ia=e.En,ka=e.eD,Aa=e.$Q;export{cr as ALLID,ar as AddGhostConcept,sr as AddGhostConnection,lr as BaseUrl,dr as BinaryTree,ur as CCSConfig,hr as Composition,fr as CompositionBinaryTree,yr as CompositionNode,pr as Concept,vr as ConceptsData,gr as Connection,Cr as ConnectionData,Tr as CreateComposition,mr as CreateConnection,Nr as CreateConnectionBetweenTwoConcepts,wr as CreateConnectionBetweenTwoConceptsGeneral,Ir as CreateDefaultConcept,kr as CreateDefaultLConcept,Ar as CreateSession,Sr as CreateSessionVisit,xr as CreateTheCompositionWithCache,Rr as CreateTheConnectionGeneral,_r as DATAID,Lr as DATAIDDATE,Ur as DATAV2,Er as DeleteConceptById,Fr as DeleteConnectionById,Pr as DeleteConnectionByIdBulk,Gr as DeleteConnectionByTypeBulk,Br as FilterSearch,Vr as FormatFromConnections,Dr as FreeSchemaResponse,Or as FreeschemaQuery,br as GetAllConnectionsOfComposition,$r as GetAllConnectionsOfCompositionBulk,Mr as GetAllTheConnectionsByTypeAndOfTheConcept,jr as GetComposition,Hr as GetCompositionBulk,Wr as GetCompositionBulkWithDataId,Jr as GetCompositionFromConnectionsWithDataId,Qr as GetCompositionFromConnectionsWithDataIdInObject,qr as GetCompositionList,Xr as GetCompositionListWithId,Yr as GetCompositionWithAllIds,zr as GetCompositionWithCache,Kr as GetCompositionWithDataIdBulk,Zr as GetCompositionWithDataIdWithCache,tc as GetCompositionWithId,ec as GetCompositionWithIdFromMemory,nc as GetCompositionWithIdFromMemoryFromConnections,oc as GetConceptBulk,ic as GetConceptByCharacter,rc as GetConceptByCharacterAndCategoryDirectApi,cc as GetConceptByCharacterAndType,ac as GetConceptByTypeBulk,sc as GetConnectionBulk,lc as GetConnectionById,dc as GetConnectionByTypeBulk,uc as GetConnectionOfTheConcept,hc as GetConnectionsBetweenApi,fc as GetLink,yc as GetLinkRaw,pc as GetLinkerConnectionFromConcepts,vc as GetLinkerConnectionToConcepts,gc as GetRelation,Cc as GetRelationRaw,Tc as GetRequestHeader,mc as GetRequestHeaderWithAuthorization,Nc as GetTheConcept,wc as GetUserGhostConnectionId,Ic as GetUserGhostId,kc as GiveConnection,Ac as HandleHttpError,Sc as HttpResponse,xc as JUSTDATA,Rc as LConcept,_c as LConnection,Lc as LISTNORMAL,Uc as LoginToBackend,Ec as MakeTheInstanceConcept,Fc as MakeTheTimestamp,Pc as MakeTheTypeConcept,Gc as MakeTheTypeConceptApi,Bc as NORMAL,Vc as PatcherStructure,Dc as RAW,Oc as RecursiveSearchApi,bc as ReservedConnectionIds,$c as ReservedIds,Mc as SchemaQueryListener,jc as SearchAllConcepts,Hc as SearchLinkInternal,Wc as SearchLinkMultipleAll,Jc as SearchLinkMultipleApi,Qc as SearchQuery,qc as SearchStructure,Xc as SearchWithLinker,Yc as SessionData,zc as Signin,Kc as Signup,Zc as SplitStrings,ta as SyncData,ea as TokenRefreshError,na as TokenStorage,oa as Transaction,ia as TrashTheConcept,ra as UpdateComposition,ca as UserBinaryTree,aa as ViewInternalData,sa as buildFetchConnection,la as convertFromLConceptToConcept,da as deleteWithRetry,ua as fetchWithRetry,ha as getFromDatabaseWithType,fa as getFromDatabaseWithTypeOld,ya as getOAuthToken,pa as getWithRetry,va as init,ga as patchWithRetry,Ca as postWithRetry,Ta as putWithRetry,ma as recursiveFetch,Na as recursiveFetchNew,wa as refreshOAuthToken,Ia as requestWithRetry,ka as storeToDatabase,Aa as updateAccessToken};
|