mftsccs-node 0.0.77 → 0.0.79-dev
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/README.md +60 -50
- package/dist/bundle.js +1 -1
- package/dist/bundle.mjs +1 -1
- package/dist/types/Api/MakeTheTypeConceptApi.d.ts +1 -30
- package/dist/types/DataStructures/AccessControl/AccessControlModels.d.ts +176 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +2 -0
- package/dist/types/DataStructures/CCSConfig.d.ts +15 -1
- package/dist/types/DataStructures/Transaction/Transaction.d.ts +1 -0
- package/dist/types/Services/AccessControl/APIClientService.d.ts +162 -0
- package/dist/types/Services/AccessControl/AccessControlCacheService.d.ts +76 -18
- package/dist/types/Services/AccessControl/AccessControlService.d.ts +223 -237
- package/dist/types/Services/AccessControl/PermissionSet.d.ts +18 -3
- package/dist/types/Services/AccessControl/index.d.ts +15 -0
- package/dist/types/Services/CreateTypeConcept.d.ts +2 -0
- package/dist/types/app.d.ts +8 -1
- package/package.json +8 -3
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:()=>Fi,TR:()=>$o,Tc:()=>Mo,U3:()=>n,Wg:()=>G,g2:()=>si,BO:()=>uo,WW:()=>co,BS:()=>io,ji:()=>V,Ij:()=>H,Ng:()=>et,du:()=>st,RC:()=>Ue,d4:()=>Ne,Cd:()=>nn,IM:()=>rn,oI:()=>D,u9:()=>dn,B7:()=>So,mF:()=>xo,Q9:()=>fo,wT:()=>Te,y0:()=>Ei,iw:()=>Ui,pU:()=>Gi,qN:()=>Ln,mZ:()=>$e,Ec:()=>Me,L0:()=>ni,Te:()=>ci,vw:()=>Qo,z8:()=>Y,k9:()=>Ki,sP:()=>wt,Y3:()=>gt,WC:()=>tr,Nj:()=>kt,dF:()=>bn,cw:()=>$n,p8:()=>Mn,rv:()=>jn,pX:()=>bt,iD:()=>$t,Mb:()=>St,bq:()=>No,ke:()=>Ao,w1:()=>Io,yz:()=>Ut,RW:()=>xt,WL:()=>Et,rh:()=>dt,nW:()=>Dt,RH:()=>jt,Aj:()=>Ae,cV:()=>ke,jM:()=>Dn,nS:()=>Oe,Yu:()=>oi,xf:()=>Fe,KS:()=>or,L6:()=>an,Z9:()=>sn,Ny:()=>Rn,qY:()=>xn,jQ:()=>Uo,NT:()=>Po,Xr:()=>q,ab:()=>X,SV:()=>je,EA:()=>bo,M2:()=>Oo,OY:()=>er,ry:()=>z,cS:()=>l,ZJ:()=>Li,RA:()=>ln,BH:()=>Bo,SL:()=>Bi,Ne:()=>qn,fg:()=>Ee,M4:()=>Bn,UG:()=>Nn,CT:()=>Yt,yv:()=>_i,vI:()=>ii,XZ:()=>Pi,ZE:()=>Jn,pi:()=>le,B8:()=>se,yx:()=>zi,br:()=>go,eU:()=>ti,cf:()=>Jo,jy:()=>jo,cm:()=>Gn,qn:()=>ai,ss:()=>mo,pf:()=>ri,pZ:()=>Kn,l4:()=>Yn,f8:()=>J,Y6:()=>ge,FS:()=>s,bM:()=>o,ZX:()=>cr,CE:()=>Pn,Sf:()=>po,tp:()=>Vo,Ry:()=>Yo,jh:()=>ir,dp:()=>zo,a2:()=>v,C$:()=>N,J5:()=>h,sc:()=>R,x9:()=>x,Py:()=>r,Xc:()=>y,Ts:()=>lr,P$:()=>g,xX:()=>f,ae:()=>p,zN:()=>Pt,dU:()=>so,mA:()=>c,En:()=>u,eD:()=>S,$Q:()=>sr});class n{static setNodeCacheUrl(t=""){this.NODE_CACHE_URL=t,this.isNearestCache=!0}static setCacheServers(t=[]){this.CACHE_SERVERS=t.filter((t=>"string"==typeof t&&""!==t.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const t=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.BASE_URL].filter((t=>"string"==typeof t&&""!==t.trim())).map((t=>t.trim()));return Array.from(new Set(t))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetReadBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetReadBaseUrl()+"/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.NODE_CACHE_URL="",n.CACHE_SERVERS=[],n.isNearestCache=!0,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)}))}var C=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function m(t,e){return`${t.replace(/\/+$/,"")}${e}`}function T(t){return t.replace(/\/+$/,"")===n.BASE_URL.replace(/\/+$/,"")}function N(t){return C(this,arguments,void 0,(function*(t,e={},o=1){const i=n.GetReadBaseUrlCandidates();let r;for(const c of i){try{const i=yield h(m(c,t),e,o);if(i.ok||i.status<500||T(c))return T(c)||(n.NODE_CACHE_URL=c),i;r=new Error(`Cache server ${c} returned status ${i.status}`)}catch(t){r=t}n.isNearestCache=!1}throw r instanceof Error?r:new Error("All cache servers failed")}))}class w{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}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())}))};const A={};function k(t){return A[t]||(A[t]=[]),A[t]}function S(t,e){const n=k(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 R(t,e,n){return I(this,void 0,void 0,(function*(){return k(t).filter((t=>t&&t[e]===n))}))}function x(t){return I(this,void 0,void 0,(function*(){return k(t).slice()}))}function _(t,e){const n=k(t),o=n.findIndex((t=>t&&t.id===e));o>=0&&n.splice(o,1)}function E(t){return I(this,void 0,void 0,(function*(){return k(t).slice()}))}class L{}L.isTypeLoaded=!1,L.isCharacterLoaded=!1,L.isDataLoaded=!1,L.isLocalDataLoaded=!1,L.isLocalCharacterLoaded=!1,L.isLocalTypeLoaded=!1,L.isConnectionLoaded=!1,L.isConnectionTypeLoaded=!1,L.isLocalConnectionLoaded=!1;class U{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(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 P=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class F{static waitForDataToLoad(){return P(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isCharacterLoaded)return t("done");setTimeout(F.checkFlag,1e3,t)}static addNodeToTree(t){return P(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 P(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new U(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return P(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return P(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))}}F.characterRoot=null;var B=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class G{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 B(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isDataLoaded)return t("done");setTimeout(G.checkFlag,1e3,t)}static addConceptToTree(t){var e=new U(t.id,t,null,null),n=new U(t.characterValue,t,null,null);F.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return B(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return B(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}}G.root=null;class V{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 D(){let t=O(new Date),e=O(new Date);return new V(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,t,e)}function O(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 ${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 U(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeTypeConcept(t,e){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,t,e))}static getNodeFromTree(t){return this.typeRoot?this.typeRoot.getFromNode(t,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return b(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isTypeLoaded)return t("done");setTimeout($.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=D();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}}$.typeRoot=null;var M=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class H{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&&S("concept",t)}static AddConcept(t){t.id>0&&(S("concept",t),G.addConceptToTree(t),$.addConceptToTree(t),F.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(G.addConceptToTree(t),$.addConceptToTree(t),F.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);G.removeNodeFromTree(t.id),_("concept",t.id)}static GetConcept(t){return M(this,void 0,void 0,(function*(){var e=D(),n=yield G.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return M(this,void 0,void 0,(function*(){var e=D(),n=F.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return M(this,void 0,void 0,(function*(){var e=D(),n=F.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return M(this,void 0,void 0,(function*(){return D(),yield $.getTypeVariantsWithCharacterValue(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return M(this,void 0,void 0,(function*(){var n=D(),o=yield F.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return M(this,void 0,void 0,(function*(){let n=[];return n=yield $.getTypeVariantsFromTreeWithUserId(t,e),n}))}static GetBinaryCharacterTree(){return F.characterRoot}getName(){return this.name}}H.conceptsArray=[],H.NPC=[],H.NPCMeta=new Map,H.NPC_BACKOFF_SECONDS=30,H.conceptDictionary=[];var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function W(){return j(this,void 0,void 0,(function*(){(new Date).getTime();var t=yield x("concept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];H.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 Q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function q(){return Q(this,arguments,void 0,(function*(t="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 X(){return Q(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 Y{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 z(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 Y(n,!1,t.status,"");throw o.setUrl(e?t.headers.url||"":t.url),o}}function K(t){if(!t.ok){const e=t.body||`HTTP error ${t.status}`;let n=new Y(e,!1,t.status,t.body);throw n.setUrl(t.headers.url||""),n}}var Z=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tt(t,e){return Z(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",t),o.append("user_id",e.toString());var i=yield q("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++)H.AddConcept(t[r])}console.log("GetAllConceptsByType error",c.status),z(c)}catch(t){throw t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),t}}))}class et{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=D(),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=O(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class nt{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 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{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 nt(t.id,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return ot(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isConnectionLoaded)return t("done");setTimeout(it.checkFlag,1e3,t)}static removeNodeFromTree(t){return ot(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return ot(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}}it.connectionroot=null;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())}))};class ct{static addNodeToTree(t){return rt(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 rt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isConnectionTypeLoaded)return t("done");setTimeout(ct.checkFlag,1e3,t)}static addConnectionToTree(t){if(0!=t.typeId){var e=new nt(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 rt(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 rt(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}))}}ct.connectionTypeRoot=null;var at=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class st{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){S("connection",t)}static AddConnection(t){t.isTemp||(S("connection",t),it.addConnectionToTree(t),ct.addConnectionToTree(t))}static AddConnectionToMemory(t){t.isTemp||(it.addConnectionToTree(t),ct.addConnectionToTree(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(_("connection",t.id),it.removeNodeFromTree(t.id),ct.removeTypeConcept(t.typeId,t.id))}static GetConnectionTree(){return it.connectionroot}static GetConnectionTypeTree(){return ct.connectionTypeRoot}static GetConnection(t){return at(this,void 0,void 0,(function*(){var e=new et(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield it.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConnectionsOfCompositionLocal(t){return at(this,void 0,void 0,(function*(){var e=[],n=yield ct.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}}st.connectionArray=[],st.connectionDictionary=[];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(t){return lt(this,void 0,void 0,(function*(){let e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield H.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=yield q();const t=yield N("/api/get_concept_bulk",{method:"POST",headers:o,body:JSON.stringify(n)});if(t.ok){let n=yield t.json();if(n.length>0)for(let t=0;t<n.length;t++){let o=n[t];e.push(o),H.AddConcept(o)}}else console.log("Get Concept Bulk error",t.status),z(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 ut=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ht(){return ut(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 dt(e)}}))}var ft=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function yt(){return ft(this,arguments,void 0,(function*(t=[]){var e=[];for(let o=0;o<t.length;o++){var n=yield st.GetConnectionsOfCompositionLocal(t[o]);e.push(...n)}return e}))}function pt(t=[],e=[]){for(let n=0;n<e.length;n++)Array.isArray(t)&&(t.find((t=>t.id===e[n].id))||st.RemoveConnection(e[n]))}var vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function gt(){return vt(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;var o=yield yt(t),i=yield function(){return vt(this,arguments,void 0,(function*(t=[]){var e=[];try{var o=yield q();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++)st.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),z(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 pt(e=i,o),yield ht(e),e}))}var Ct=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};const mt=new Map;function Tt(t){return Ct(this,void 0,void 0,(function*(){let e=D();if(mt.has(t))return mt.get(t)||e;const o=(()=>Ct(this,void 0,void 0,(function*(){try{var o=yield H.GetConcept(t);let r=H.GetNpc(t);if(0!=o.id||r)return o;{var i=yield q("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?H.AddConcept(e):H.AddNpc(t)):(console.log("Get the concept error",o.status,t),z(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{mt.delete(t)}})))();return mt.set(t,o),o}))}var Nt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function wt(t){return Nt(this,void 0,void 0,(function*(){var e=[];if(0==(e=yield st.GetConnectionsOfCompositionLocal(t)).length)e=yield It(t);else{var n=yield It(t);pt(n,e),e=n}return e}))}function It(t){return Nt(this,void 0,void 0,(function*(){var e=[];try{var o=yield q("application/x-www-form-urlencoded");const r=yield h(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${t}`});if(!r.ok)throw z(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)st.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 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 kt(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function St(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Ft(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function Rt(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield st.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(t,o,r);return i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=s,i}))}function xt(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield st.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(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 _t(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield st.GetConnectionsOfCompositionLocal(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(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 Et(t,e){return At(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 H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(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 Lt(t,e){return At(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r={},c=yield H.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield Tt(t));var a=yield Pt(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 Ut(t){return At(this,void 0,void 0,(function*(){var e,n,o,i={};o=yield wt(t);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var a=yield H.GetConcept(t);0==a.id&&null!=t&&null!=t&&(a=yield Tt(t));var s=yield Pt(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 Pt(t,e,n){return At(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield H.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Tt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield H.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield Tt(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 H.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Tt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield H.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield Tt(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 Pt(f,e,n,o);a[p]=t}}else{const t=yield Pt(f,e,n,o);s[p]=t,a=s}}return a}))}function Ft(t,e,n){return At(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a={},s=[];if(0==t)return null;var l=yield H.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield Tt(t)),0!=l.id&&null==l.type){var d=l.typeId,u=yield H.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield Tt(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 H.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield Tt(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield H.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield Tt(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 Ft(f,e,n);a[p]=t}}else{const t=yield Ft(f,e,n);s[p]=t,a=s}}return a}))}var Bt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gt(t){return Bt(this,void 0,void 0,(function*(){let e=D();try{var o=yield q("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&&H.AddConcept(e)):(console.log("Error in Getting concept by character value Error",i.status),z(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 Vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dt(t){return Vt(this,void 0,void 0,(function*(){var e=yield H.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Gt(t),e=yield H.GetConceptByCharacter(t)),e}))}var Ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bt(t,e){return Ot(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Dt(t),r=[];if(i){yield tt(t,e);for(var c=yield H.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield gt(s),l=a;l<a+n;l++)if(c[l]){var d=yield Rt(c[l].id);r.push(d)}}return r}))}function $t(t,e){return Ot(this,arguments,void 0,(function*(t,e,n=10,o=1){var i=yield Dt(t),r=[];if(i){yield tt(t,e);for(var c=yield H.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[],l=a;l<a+n;l++)c[l]&&s.push(c[l].id);for(yield gt(s),l=a;l<a+n;l++)if(c[l]){var d=yield xt(c[l].id);r.push(d)}}return r}))}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())}))};const Ht=new Map;function jt(t,e){return Mt(this,void 0,void 0,(function*(){let o=D();if(Ht.has(t+e))return Ht.get(t+e)||o;const i=(()=>Mt(this,void 0,void 0,(function*(){try{var i=yield q("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,H.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),z(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{Ht.delete(t+e)}})))();return Ht.set(t+e,i),i}))}var Wt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jt(t){return Wt(this,void 0,void 0,(function*(){let e=D();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 Wt(this,void 0,void 0,(function*(){let n=yield H.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield jt(t,e)),n}))}(t,n)}else o[0]==t&&1==n?e=yield function(t){return Wt(this,void 0,void 0,(function*(){var e=yield H.GetConceptByCharacterAndTypeLocal(t,49);return 0==e.id&&(e=yield Gt(t)),e}))}(t):o[0]==t&&(e=yield function(t){return Wt(this,void 0,void 0,(function*(){var e=yield H.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Gt(t)),e}))}(t));return e}))}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())}))};const qt=new Map,Xt=new Map;function Yt(t,e){return Qt(this,void 0,void 0,(function*(){let e=D();if(Xt.has(t))return Xt.get(t);if(qt.has(t))return qt.get(t)||e;const o=(()=>Qt(this,void 0,void 0,(function*(){try{if(e=yield Jt(t),0==e.id||4==e.typeId){var o=yield q("application/x-www-form-urlencoded");const i=yield h(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${t}`});if(!i.ok)throw z(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();e=r,e.id>0&&H.AddConcept(e)}return e.id>0&&Xt.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{qt.delete(t)}})))();return qt.set(t,o),o}))}var zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};let Kt=!1,Zt=[];const te=()=>{Zt.length>0&&!Kt&&Zt.shift()()};function ee(t){return zt(this,void 0,void 0,(function*(){return new Promise(((e,o)=>{Zt.push((()=>zt(this,void 0,void 0,(function*(){try{if(Kt)return;if(Kt=!0,!t&&le.connectionIds.length>10)return Kt=!1,te(),e();const o=t?`${n.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(t)}).toString()}`:n.GetReservedConnectionIdUrl();var i=yield q("application/x-www-form-urlencoded");const c=yield h(o,{method:"GET",headers:i});if(!c.ok)throw z(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();for(var r=0;r<a.length;r++)le.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{Kt=!1,te()}})))),te()}))}))}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())}))};let oe=!1,ie=[];const re=()=>{ie.length>0&&!oe&&ie.shift()()};function ce(){return ne(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{ie.push((()=>ne(this,void 0,void 0,(function*(){try{if(oe)return;if(oe=!0,se.ids.length>10)return oe=!1,re(),t();var o=yield q("application/x-www-form-urlencoded");const e=yield h(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!e.ok)throw z(e),new Error(`Error! status: ${e.status}`);const r=yield e.json();for(var i=0;i<r.length;i++)se.AddId(r[i]);t()}catch(t){e(t)}finally{oe=!1,re()}})))),re()}))}))}var ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class se{static getId(){return ae(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ae(this,void 0,void 0,(function*(){try{yield ce()}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=(()=>ae(this,void 0,void 0,(function*(){try{yield ce()}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)}}se.ids=[],se.pendingFetch=null;class le{static getId(){return ae(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ae(this,void 0,void 0,(function*(){try{yield ee()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ae(this,void 0,void 0,(function*(){try{yield ee()}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 ae(this,void 0,void 0,(function*(){const e=t-this.connectionIds.length;e<=0||(this.pendingFetch||(this.pendingFetch=(()=>ae(this,void 0,void 0,(function*(){try{yield ee(e)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}le.connectionIds=[],le.pendingFetch=null;function de(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 ue(t){return e=this,o=void 0,r=function*(){let e=D();try{var o=yield q();const i=function(t){return Array.isArray(t)?t.map((t=>de(t))):de(t)}(t),r=yield f(n.CreateTheConceptUrl(),o,i);if(!r.ok)throw K(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 he(t){return e=this,o=void 0,r=function*(){let e=new et(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield q();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),K(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 fe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ye(t){return t?`[SyncData:${t}]`:"[SyncData]"}function pe(t,e){console.log(`${ye(e)} ${t}`)}function ve(t,e,n,o,i){o<100&&n!==o||n!==o&&1!==n&&n%100!=0||console.log(`${ye(i)} ${t} ${e}: ${n}/${o} done, ${o-n} remaining`)}class ge{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 fe(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(),pe(`starting online sync with ${e.length} concepts and ${n.length} connections`,t),e.length>0&&(pe(`sending ${e.length} concepts to backend`,t),yield ue(e),ve("synced","concepts",e.length,e.length,t)),n.length>0&&(pe(`sending ${n.length} connections to backend`,t),yield he(n),ve("synced","connections",n.length,n.length,t)),this.transactionCollections=this.transactionCollections.filter((e=>e.id!=t)),pe("online sync complete",t)}else{const t=this.conceptsSyncArray.length,o=this.connectionSyncArray.length;pe(`starting online sync with ${t} queued concepts and ${o} queued connections`);for(let e=0;e<this.conceptsSyncArray.length;e++)H.AddConcept(this.conceptsSyncArray[e]),ve("prepared local cache for","concepts",e+1,t);for(let t=0;t<this.connectionSyncArray.length;t++)st.AddConnection(this.connectionSyncArray[t]),ve("prepared local cache for","connections",t+1,o);this.conceptsSyncArray.length>0&&(e=this.conceptsSyncArray.slice(),pe(`sending ${e.length} concepts to backend`),yield ue(e),this.conceptsSyncArray=this.conceptsSyncArray.filter((t=>!e.some((e=>e.id===t.id)))),ve("synced","concepts",e.length,e.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),pe(`sending ${n.length} connections to backend`),yield he(n),this.connectionSyncArray=this.connectionSyncArray.filter((t=>!n.some((e=>e.id===t.id)))),ve("synced","connections",n.length,n.length)),pe(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(t){throw t}}))}static initializeTransaction(t){return fe(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 fe(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 fe(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 fe(this,void 0,void 0,(function*(){if(pe(`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++)S("localconcept",this.conceptsSyncArray[e]),ve("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++)S("localconnection",this.connectionSyncArray[e]),ve("stored locally","connections",e+1,t);this.connectionSyncArray=[]}return pe("local sync complete"),"done"}))}}function Ce(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}ge.conceptsSyncArray=[],ge.connectionSyncArray=[],ge.transactionCollections=[];var me=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Te(t,e,n,o,i,r,c){return me(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=Ce(t,"ofTheConceptId"),o=Ce(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 le.getId(),C=new et(g,t,n,e,o,y,i,f,a,h,0,p,s,v,r,c);return C.toUpdate=!0,C.isTemp=!1,ge.AddConnection(C),d.connections.push(C),C}))}function Ne(t,e,n){return me(this,arguments,void 0,(function*(t,e,n,o={concepts:[],connections:[]}){let i=yield Yt(n),r=t.userId;return yield Te(t.id,t.userId,e.id,e.userId,i.id,999,999,1e3,4,r,o)}))}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())}))};const Ie=new Map;function Ae(t,e){return we(this,void 0,void 0,(function*(){let o=yield H.GetConceptByCharacterAndTypeLocal(t,e),i=t+e;if(Ie.has(i))return Ie.get(i)||o;const r=(()=>we(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 q();const i=yield h(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:a,body:c});if(i.ok){let t=yield i.json();o=t,H.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),z(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{Ie.delete(i)}})))();return Ie.set(i,r),r}))}function ke(t){return we(this,void 0,void 0,(function*(){let e=[],o=JSON.stringify(t);var i=yield q();const r=yield h(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let t=yield r.json();e=yield dt(t)}else console.log("This is the concept by type and character error",r.status),z(r);return e}))}var Se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Re(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return Se(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 se.getId();let v=new Date,g=new Date;var C=new V(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!0,v,g);return C.isTemp=!1,ge.AddConcept(C),y.concepts.push(C),C}))}function xe(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return Se(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 se.getId();let v=new Date,g=new Date;var C=new V(p,e,i,r,n,o,c,a,t,s,l,d,u,h,f,!1,v,g);return H.AddConcept(C),C.updateRecursion=!0,ge.AddConcept(C),y.concepts.push(C),C}))}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 Ee(t,e){return _e(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=D();return n?(p=yield Yt(t),s=yield Re(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a)):(p=yield Yt(y),s=yield Ae(e,p.id),0==s.id&&0==s.userId&&(s=yield xe(e,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,a))),s.type=p,s}))}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 Ue(t){return Le(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=D();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 Ee(o,"",!0,a,s,l),h=p.id,d=p.id,yield Ue(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 Ee(o,"",!0,a,s,l),yield Te(f,y,p.id,p.userId,h,l,p.userId),yield Ue(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 Ee(o,t[o].toString(),!1,a,s,l);yield Te(f,y,p.id,p.userId,h,l,p.userId)}return u}))}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 Fe(t,e,o){return Pe(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 q("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),z(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 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())}))},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())}))},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())}))},De=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oe(t){return De(this,void 0,void 0,(function*(){var e=yield st.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){var o=yield function(t){return Ve(this,void 0,void 0,(function*(){var e=yield st.GetConnection(t);try{if(0!=e.id)return e;{var o=yield q("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(),st.AddConnection(e)):(console.log("Get Connection Error",i.status),z(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 $e(t){return be(this,arguments,void 0,(function*(t,e=""){let o=!1;var i=yield Oe(t);return o=yield function(t){return Ge(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield q("application/x-www-form-urlencoded");""!=e&&(i=yield X("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),z(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),_("connection",t),it.removeNodeFromTree(t),ct.removeTypeConcept(i.typeId,t),o}))}function Me(t){return be(this,void 0,void 0,(function*(){let e=yield function(t){return Be(this,void 0,void 0,(function*(){let e=!1;try{let o=yield X();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),z(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&&it.removeNodeFromTree(n)}return e}))}var He=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function je(t){return He(this,arguments,void 0,(function*(t,e=999){var n=D();if(t<0)return zo(yield Oo(e,t));if(null!=(n=yield H.GetConcept(t))&&0!=n.id||null==t||null==t||(n=yield Tt(t)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var o=yield H.GetConcept(n.typeId);if(0!=o.id)n.type=o;else{var i=yield Tt(n.typeId);0!=i.id&&(n.type=i)}}return n}))}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())}))};const Je=999,Qe=4,qe=999,Xe=999,Ye=1e3;function ze(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 Ke(t,e){return We(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 je(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 je(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 Ze(t){return We(this,void 0,void 0,(function*(){return yield Ee("connection",t,!1,Je,Je,qe)}))}function tn(t,e,n){return We(this,void 0,void 0,(function*(){return yield Te(t.id,t.userId,e.id,e.userId,n.id,qe,Xe,Ye,Qe)}))}function en(t,e,n){return We(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){const r=ze(n),c=t.userId;if(o){const n=yield function(t,e){return We(this,void 0,void 0,(function*(){return`${yield Ke(t,"toTheConcept")}_s_${e}_by`}))}(e,r);i&&(yield on(`${r}_by`,e,c));const o=yield Ze(n);yield tn(e,t,o)}const a=yield function(t,e){return We(this,void 0,void 0,(function*(){return`${yield Ke(t,"ofTheConcept")}_s_${e}_s`}))}(t,r);i&&(yield on(`${r}_s`,t,c));const s=yield Ze(a);return yield tn(t,e,s)}))}function nn(t,e,n){return We(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield en(t,e,n,o,i)}))}function on(t,e){return We(this,arguments,void 0,(function*(t,e,n=null){for(var o=e,i=null!=n?n:e.userId,r=999,c=ze(t)+"_count",a=(yield Ke(e,"concept"))+"_s_"+c,s=yield Ee("connection",a,!1,i,4,r),l=yield Fe(s.id,e.id,i,10,1),d=[],u=D(),h=0;h<l.length;h++){let t=yield je(l[h].toTheConceptId);d.push(t)}if(d.length<1)u=yield Ee("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 Ee("count",e.toString(),!1,i,4,r);for(let t=0;t<l.length;t++)yield $e(l[t].id)}yield Te(o.id,o.userId,u.id,u.userId,s.id,r,Xe,Ye,4,i)}))}function rn(t,e,n){return We(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){return yield en(t,e,n,o,i)}))}var cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function an(t,e){return cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield je(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ae(a,16);if(s.id>0){for(var l=yield Fe(s.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield gt(d),u=0;u<l.length;u++){let t=l[u].toTheConceptId,e=yield je(t),n=yield _t(e.id);r.push(n)}}return r}))}function sn(t,e){return cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i,r=[],c=yield je(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ae(a,16);if(s.id>0){for(var l=yield Fe(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 je(t);r.push(e)}}return r}))}class ln{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 dn(){let t=new Date,e=new Date;return new ln(0,0,0,0,0,"0","0",!1,t,e,0)}class un{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 hn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new un(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}}hn.characterData=[];class fn{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}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())}))},pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function vn(t,e,o,i,r){return pn(this,void 0,void 0,(function*(){return new un(e,t,o,e,i,e,r,e,"",!1),yield function(){return yn(this,void 0,void 0,(function*(){var t;try{if(0==(t=hn.GetCharacter(t.data)).id){var e=yield q();const i=yield h(n.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw z(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new un(r.userId,t.data,0,0,4,4,999,999,"",!1);return o.id=r.id,hn.AddCharacter(o),r}return new fn(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 gn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Cn(t,e,n,o,i,r,c,a,s,l,d,u,h,f){return gn(this,void 0,void 0,(function*(){var y=yield Ae(t,i),p=y;return 0==p.id&&(p=y=yield Re(t,e,n,o,i,r,c,a,s,l,d,u,h,f)),p}))}var mn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Tn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nn(t,e,n,o){return Tn(this,arguments,void 0,(function*(t,e,n,o,i={concepts:[],connections:[]}){var r=yield Dt(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 mn(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 vn(t,e,n,o,r),s=yield Cn(t,e,4,c,49,l,h,u,n,a,o,i,r,d)}else{var f=yield vn(t,e,n,o,r);f.isNew,s=yield Cn(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 Nn(c[0],e,n,o,i),l=yield Nn(c[1],e,n,o,i);l&&(r=yield xe(t,o,s.id,o,l.id,o,999,o,999,o,999,o,e,o,i))}}return r}))}var wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function In(t){return wn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield q("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"),z(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 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 kn(t){return An(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var o=yield q("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"),z(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 Sn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Rn(t){return Sn(this,void 0,void 0,(function*(){for(var e=yield In(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield je(o);t.type=i}return e}))}function xn(t){return Sn(this,void 0,void 0,(function*(){for(var e=yield kn(t),n=0;n<e.length;n++){let t=e[n];var o=t.typeId;let i=yield je(o);t.type=i}return e}))}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())}))},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 Ln(t){return En(this,arguments,void 0,(function*(t,e=""){var o=yield je(t);yield G.removeNodeFromTree(t);var i=o.typeId,r=o.characterValue;yield $.removeTypeConcept(i,t),yield F.removeNodeByCharacter(r,t),_("concept",t);let c=yield function(t){return _n(this,arguments,void 0,(function*(t,e=""){let o=!1;try{let i=yield q("application/x-www-form-urlencoded");""!=e&&(i=yield X("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 z(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 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 Pn(t,e){return Un(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 z(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){throw t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),t}}))}var Fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bn(t,e,n,o){return Fn(this,arguments,void 0,(function*(t,e,n,o,i=999){var r,c=n,a=n,s=n,l=t.startsWith("the_"),d=D();return r=l?t:"the_"+t,d=yield Yt(r),yield Cn(e,n,4,n,d.id,d.userId,0,999,999,c,o,s,i,a)}))}class Gn{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 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=[]){var e=[];try{var n=[];for(let o=0;o<t.length;o++){let i=yield st.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{var o=yield q();const t=yield N("/api/get_connection_bulk",{method:"POST",headers:o,body:JSON.stringify(n)});if(t.ok){const n=yield t.json();if(n.length>0){for(let t=0;t<n.length;t++){let o=n[t];e.push(o),st.AddConnection(o)}yield ht(e)}}else console.log("Get Connection Bulk error",t.status),z(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 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(){return On(this,arguments,void 0,(function*(t=[]){yield gt(t);var e=[];for(let o=0;o<t.length;o++){var n=yield Rt(t[o]);e.push(n)}return e}))}function $n(){return On(this,arguments,void 0,(function*(t=[]){yield gt(t);var e=[];for(let o=0;o<t.length;o++){var n=yield xt(t[o]);e.push(n)}return e}))}function Mn(){return On(this,arguments,void 0,(function*(t=[],e=[]){yield Dn(e),function(t=[],e=[]){for(let n=0;n<e.length;n++)t.includes(e[n].id)||st.RemoveConnection(e[n])}(e,yield yt(t));var n=[];for(let e=0;e<t.length;e++){var o=yield xt(t[e]);n.push(o)}return n}))}function Hn(){return On(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 st.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 Dn(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 dt(i),n}))}function jn(){return On(this,arguments,void 0,(function*(t=[],e=[]){let n=[],o=[];for(let t=0;t<e.length;t++){let i=yield st.GetConnection(e[t]);0==i.id?n.push(e[t]):o.push(i)}let i=yield Dn(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 Lt(t[e],o,c);r[t[e]]=n}return console.timeEnd("start"),r}))}var Wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jn(){return Wn(this,arguments,void 0,(function*(t=0,e=[],o="",i=[]){var r=[];try{var c=new Gn;c.composition=t,c.listLinkers=e,c.textSearch=o,c.fullLinkers=i;var a=JSON.stringify(c),s=yield q();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 Mn(l,d)}else console.log("recursive search error ",u.status),z(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 Qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qn(t,e){return Qn(this,void 0,void 0,(function*(){try{var 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),z(a)}catch(t){throw t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),t}}))}var Xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yn(t){return Xn(this,void 0,void 0,(function*(){const e=yield function(){return Xn(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield 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}:z(o),n}catch(t){throw console.log("Signup Error: ",t),t}}))}(n.SignupUrl(),t);return e}))}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 Kn(t){return zn(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}:z(t),o}catch(t){throw console.log("Sign in api error",t),t}}))}function Zn(t,e){return-1===t.indexOf(e)&&t.push(e),t}function to(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 eo(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 no(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function oo(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class io{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&&(co.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 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 co{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 io(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return ro(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return ro(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}}co.root=null;var ao=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function so(t,e,n,o){return ao(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=lo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield je(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=lo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield je(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=lo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield je(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield H.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield je(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 so(d,e,n,o,i);a[u]=t}}else{const t=yield so(d,e,n,o,i);s[u]=t,a=s}}}return a}))}function lo(t,e){let n=D();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class uo{constructor(){this.id=0,this.mainConcept=D(),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 so(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 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=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=D();null==a&&(a=new uo);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield Ee(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 fo(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 Te(s,l,f.id,f.userId,y,d,f.userId);a.connections.push(p),yield fo(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 Ee(o,t[o],!1,s,l,d);a.concepts.push(h);const f=yield Te(i,r,h.id,h.userId,c,d,h.userId);a.connections.push(f)}return h}))}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,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=D(),a=D();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let u=[];if(l<0){let t=yield je(l,e);if(!(t.id>0))return null;l=t.id}i=yield wt(l);const h=[],f=new uo,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)Zn(y,i[t].ofTheConceptId),Zn(h,i[t].ofTheConceptId),Zn(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 je(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=D();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield Ee(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=to(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=eo(f.connections,e[t].id);u=u.concat(n),s.push(e[t])}yield fo(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield Ee(t,l,!1,e,o,n);const c=to(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=eo(f.connections,c[t].id);u=u.concat(e),s.push(c[t])}}const h=yield Te(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++)oo(f.connections,u[t]),$e(u[t].id);for(let t=0;t<s.length;t++)no(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),co.addCompositionToTree(f),yield ge.SyncDataOnline(),f.GetDataCache()}))}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,e,o,i){return vo(this,arguments,void 0,(function*(t,e,o,i,r=10,c=1){var a=yield X("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();z(t)}catch(t){throw t}}))}var Co=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mo(t){return Co(this,arguments,void 0,(function*(t,e=""){var o=yield X("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();z(t)}catch(t){throw t}}))}var To=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function No(t){return To(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=[];let l=yield H.GetConcept(t);0==l.id&&null!=t&&null!=t&&(l=yield Tt(t));let d=[];d=e.length>0?wo(t,e):yield wt(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 Pt(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 wo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function Io(t){return To(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=[];let d=yield H.GetConcept(t);0==d.id&&null!=t&&null!=t&&(d=yield Tt(t));let u=[];u=e.length>0?wo(t,e):yield wt(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 Pt(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 Ao(t,e){return To(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Dn(e);for(let e=0;e<t.length;e++){const i=yield Io(t[e],n);i&&o.push(i)}return o}))}var ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function So(t){return ko(this,void 0,void 0,(function*(){try{var e=yield q();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()),z(i),null)}catch(t){throw console.log("Creating session failed",t),t}}))}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 xo(t,e){return Ro(this,void 0,void 0,(function*(){try{var o=yield q("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()),z(r),null)}catch(t){throw console.log("Creating session url failed",t),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 Eo(t,e,o){return _o(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 q("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),z(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 Lo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Uo(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield je(t),a=yield Jt(e);if(a.id>0){let t=[],e=[];if(i){e=yield Eo(a.id,c.id,c.userId,n,o);let t=[];for(let n=0;n<e.length;n++)t.push(e[n].ofTheConceptId);yield gt(t);for(let t=0;t<e.length;t++){let n=e[t].ofTheConceptId,o=yield je(n),i=yield _t(o.id);r.push(i)}}else{e=yield Fe(a.id,c.id,c.userId,n,o);for(let n=0;n<e.length;n++)t.push(e[n].toTheConceptId);yield gt(t);for(let t=0;t<e.length;t++){let n=e[t].toTheConceptId,o=yield je(n),i=yield _t(o.id);r.push(i)}}}return r}))}function Po(t,e){return Lo(this,arguments,void 0,(function*(t,e,n=10,o=1,i=!1){let r=[],c=yield je(t),a=yield Jt(e),s=[],l=[];if(a.id>0){if(i){s=yield Eo(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].ofTheConceptId)}else{s=yield Fe(a.id,c.id,c.userId,n,o);for(let t=0;t<s.length;t++)l.push(s[t].toTheConceptId)}r=yield dt(l)}return r}))}class Fo{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 Bo{constructor(t=0,e,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=dn(),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=O(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}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())}))};class Vo{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 Go(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isDataLoaded)return t("done");setTimeout(Vo.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 Fo(o,t,new Bo(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 Fo(o,dn(),t))}static getNodeFromTree(t,e){return Go(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 Go(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}}Vo.nodeMap=new Map;var Do=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oo(t,e){return Do(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield Vo.getNodeFromTree(t,n,o),c=dn();return r&&(c=null!==(i=r.value.get(e))&&void 0!==i?i:c),c}))}function bo(t,e){return Do(this,arguments,void 0,(function*(t,e,n=999,o=999){var i;let r=yield Vo.getNodeFromTree(t,n,o),c=new Bo(0,0,0,0,0,0);return r&&(c=null!==(i=r.connectionValue.get(e))&&void 0!==i?i:c),c}))}function $o(t,e){return Do(this,arguments,void 0,(function*(t,e,n=999){Vo.addConceptToTree(t,e,n)}))}function Mo(t,e){return Do(this,arguments,void 0,(function*(t,e,n=999){Vo.addConnectionToTree(t,e,n)}))}var Ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function jo(t){return Ho(this,arguments,void 0,(function*(t,e=""){var o=yield X("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();z(t)}catch(t){throw t}}))}var Wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Jo(t){return Wo(this,arguments,void 0,(function*(t,e=""){let n=[],o=yield jo(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 jn(c,a),yield Qo(s,n,i,l)}))}function Qo(t,e,n){return Wo(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Dn(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 je(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 je(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 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,void 0,void 0,(function*(){var e;let o=yield function(t){return qo(this,void 0,void 0,(function*(){let e=[];try{var o=yield q();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 dt(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),z(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 Pt(r,c,t);e.data=n,e.id=r,i.push(e)}else{let t={};t.id=r;let n=yield je(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 zo(t){const e=D();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 Ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},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 ti(t){return Zo(this,arguments,void 0,(function*(t,e=""){var o=yield function(t){return Ko(this,arguments,void 0,(function*(t,e=""){var o,i,r,c,a,s,l=yield X("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();z(t)}catch(t){throw t}}))}(t,e);return yield Yo(o)}))}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())}))};function ni(t,e){return ei(this,void 0,void 0,(function*(){let n=!0,o=yield In(t),i=yield ke(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 $e(r[t]);n=n&&e}return n}))}function oi(t,e){return ei(this,void 0,void 0,(function*(){let n=yield In(t),o=yield ke(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 ii{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class ri{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class ci{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class ai{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class si{constructor(t){this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],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 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{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)&&S("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 li(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isLocalConnectionLoaded)return t("done");setTimeout(di.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return li(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}}di.connectionArray=[],di.connectionDictionary=[];var ui=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function hi(){return ui(this,void 0,void 0,(function*(){yield function(){return ui(this,void 0,void 0,(function*(){var t=yield x("connection");if(Array.isArray(t))for(var e=0;e<t.length;e++)st.AddConnectionToMemory(t[e])}))}()}))}function fi(){return ui(this,void 0,void 0,(function*(){yield function(){return ui(this,void 0,void 0,(function*(){var t=yield E("localconnection");if(Array.isArray(t))for(var e=0;e<t.length;e++)di.AddConnection(t[e])}))}()}))}class yi{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 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){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 yi(t.id,t,null,null);new yi(t.characterValue,t,null,null),this.addNodeToTree(e)}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(L.isLocalDataLoaded)return t("done");setTimeout(vi.checkFlag,1e3,t)}static getNodeFromTree(t){return pi(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 pi(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}vi.root=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{static waitForDataToLoad(){return gi(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isLocalCharacterLoaded)return t("done");setTimeout(Ci.checkFlag,1e3,t)}static addNodeToTree(t){return gi(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 yi(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 gi(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))}}Ci.LocalCharacterRoot=null;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())}))};class Ti{static addNodeToTree(t){return mi(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 yi(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 mi(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(L.isLocalTypeLoaded)return t("done");setTimeout(Ti.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return mi(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}))}}Ti.LocalTypeRoot=null;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{constructor(){this.name="conceptsArray"}static AddConcept(t){t.id>0&&(S("localconcept",t),vi.addConceptToTree(t),Ci.addConceptToTree(t),Ti.addConceptToTree(t),this.localconceptsArray.push(t))}static AddConceptToMemory(t){t.id>0&&(vi.addConceptToTree(t),Ci.addConceptToTree(t),Ti.addConceptToTree(t))}static GetConcept(t){return Ni(this,void 0,void 0,(function*(){var e=dn(),n=yield vi.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return Ni(this,void 0,void 0,(function*(){var e=dn(),n=Ci.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return Ni(this,void 0,void 0,(function*(){var n=dn(),o=yield Ci.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 Ni(this,void 0,void 0,(function*(){let n=[];return n=yield Ti.getTypeVariantsFromTreeWithUserId(t,e),n}))}getName(){return this.name}}wi.localconceptsArray=[];var Ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ai(){return Ii(this,void 0,void 0,(function*(){var t=yield E("localconcept");if(Array.isArray(t))for(var e=0;e<t.length;e++){let n=t[e];wi.AddConceptToMemory(n)}}))}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 Si{}Si.isUpdated=!1,Si.isOnlineSync=!1;var Ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};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())}))};const _i=1,Ei=2,Li=3,Ui=4,Pi=5,Fi=6,Bi=7,Gi=8;class Vi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}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){return Di(this,void 0,void 0,(function*(){let e={};for(let n=0;n<t.length;n++){let o=yield Tt(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 Vi;return t.conceptId=Number(e[0]),t.connectionTypeId=Number(e[1]),t.count=Number(e[2]),t}throw new Error("Input string must contain exactly three parts separated by underscores.")}function $i(t){return t.startsWith("the_")?t.slice(4):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())}))};function Hi(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 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())}))},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,n){return Wi(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 je(t[u].ofTheConceptId),y=yield je(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 je(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 je(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 Qi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(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="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 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())}))};var Yi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function zi(t,e){return Yi(this,void 0,void 0,(function*(){let e=t.outputFormat;t.outputFormat=Fi;let o,i=yield function(t){return xi(this,arguments,void 0,(function*(t,e=""){var o=yield X("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();z(t)}catch(t){!function(t,e=""){if(t.status){let n=new Y(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new Y(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==Ei?yield function(t,e,n,o,i){return Xi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Hn(t),a=yield Oi(i);c=qi(c,r);let s=[];s=yield function(t,e){return ji(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 je(t[u].ofTheConceptId),y=yield je(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield je(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 je(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 ji(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 je(t[u].ofTheConceptId),y=yield je(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield je(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=$i(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 je(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=$i(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 ji(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 je(t[n].ofTheConceptId),y=yield je(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 je(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),Hi(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 je(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),Hi(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,Hi(y.id,r,s)}}catch(t){}}}for(let t=0;t<o.length;t++){let n={};n.id=o[t];let i=yield je(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==Li?yield function(t,e,n,o,i){return Xi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Hn(t),a=yield Oi(i);c=qi(c,r);let s=[];s=yield Ji(c,s,o),s=yield function(t,e){return Mi(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 je(t[u].ofTheConceptId),y=yield je(t[u].toTheConceptId);if(n.includes(t[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,a=yield je(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=$i(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 je(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=$i(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 Mi(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 je(t[n].ofTheConceptId),p=yield je(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 je(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 je(t[n].typeId),c=null!==(s=null===(a=y.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",f=!1;t[n].toTheConceptId in e&&(f=!0),t[n].ofTheConceptId in e?(o=e[t[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},e[t[n].ofTheConceptId]=o),Hi(y.id,i,o);let v=!1,g=r.characterValue;""==g&&(g=p.characterValue,v=!0),""==g&&(g=null!==(d=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let r=null!==(h=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==h?h:"none",a=e[t[n].toTheConceptId];if(a){let e={};e[r]={data:a[r],id:p.id,created_on:t[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(a[g]):o[c].push(a):Array.isArray(o[c][g])?o[c][g].push(e):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(e[r]):o[c][g].push(e)):o[c][g]=v?e[r]:e,Hi(p.id,i,e)}}catch(t){}}}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==Gi?yield function(t,e,n,o,i){return Xi(this,arguments,void 0,(function*(t,e,n,o,i,r="DESC"){let c=yield Hn(t),a=yield Oi(i);c=qi(c,r);let s={};s=yield function(t){return Qi(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 je(s.ofTheConceptId),d=yield je(s.toTheConceptId),u=yield je(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 Qi(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 je(s.ofTheConceptId),d=yield je(s.toTheConceptId),u=yield je(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?$i(p):g;const m=C.includes("_s_"),T=!isNaN(Number(C)),N={id:f.id,data:{[p]:v}};e[h.id]||(e[h.id]={}),y in e[h.id]&&"string"!=typeof e[h.id][y]||(e[h.id][y]=T?[]:{});try{if(m)continue;T?e[h.id][y].push(N):e[h.id][y][t?`${C}_reverse`:C]=N}catch(t){console.error("Error formatting concept data:",t)}}return e}))}(c,s,o);let l=yield function(t,e,n){return Qi(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 je(n.ofTheConceptId),l=yield je(n.toTheConceptId),d=yield je(n.typeId);if(0===s.id||0===l.id)continue;const u=t?l:s,h=t?s:l,f=u.id,y=h.id,p=null!==(c=null===(r=u.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",v=d.characterValue+"_reverse",g=d.characterValue||h.characterValue||(null===(a=h.type)||void 0===a?void 0:a.characterValue)||"";if(e[f]){const o=e[f][p],r=e[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Hi(f,i,e[f]);try{t?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(r):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],Hi(y,i,c)}catch(t){console.error("Error processing connection:",t)}}}for(const t of n){const n=yield je(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 Xi(this,void 0,void 0,(function*(){let e=yield Hn(t);e=qi(e);let i=[];i=yield Ji(e,i,o),i=yield function(t,e,n){return Wi(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 je(t[u].ofTheConceptId),y=yield je(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 je(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=$i(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 je(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=$i(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 Wi(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 je(t[n].ofTheConceptId),h=yield je(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 je(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 je(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 Ki{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=_i,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var Zi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tr(t,e){return Zi(this,arguments,void 0,(function*(t,e,n=!1){let o=[];if(n){let n=yield kn(t),i=yield Yt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}else{let n=yield In(t);for(let t=0;t<n.length;t++)st.AddConnection(n[t]);let i=yield Yt(e);for(let t=0;t<n.length;t++)n[t].typeId==i.id&&o.push(n[t])}return o}))}function er(t,e,n){return Zi(this,arguments,void 0,(function*(t,e,n,o=!1){let i=[],r=[];if(i=o?yield tr(e,n,o):yield tr(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 nr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function or(t){return nr(this,void 0,void 0,(function*(){try{const e=yield q(),o=yield h(n.GetConnectionsBetweenUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),z(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 ir(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 rr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.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 cr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return rr(this,void 0,void 0,(function*(){yield ge.initializeTransaction(this.transactionId)}))}markAction(){return rr(this,void 0,void 0,(function*(){yield ge.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return rr(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield ge.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return rr(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield ge.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Me(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(t){return rr(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([t])}))}DeleteConnectionsBetweenBulk(t){return rr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const e=t.map(ir),n=yield or(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 rr(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 Ee(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 rr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Ne(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 rr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield Nn(t,e,n,o,this.actions);return yield this.markAction(),i}catch(t){throw console.log(t),this.success=!1,t}}))}CreateTheConnectionGeneral(t,e,n,o,i,r,c){return rr(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 Te(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 ar=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function sr(t=""){o.BearerAccessToken=t}function lr(){return ar(this,arguments,void 0,(function*(t="",e="",i="CCSApp",c){const a=c||new si;n.BASE_URL=t,n.AI_URL=a.aiUrl,e&&(n.NODE_URL=e);const s=a.cacheServers.length>0?a.cacheServers:function(t=""){const e=t.trim();if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.filter((t=>"string"==typeof t&&""!==t.trim()))}catch(t){}return e.split(",").map((t=>t.trim())).filter(Boolean)}(a.getParameter("cacheServers",""));n.setCacheServers(s);const l=a.cacheServerUrl||a.getParameter("cacheServerUrl","");if(l?n.setNodeCacheUrl(l):0===s.length&&n.setNodeCacheUrl(""),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);L.isDataLoaded=!1,L.isCharacterLoaded=!1,L.isTypeLoaded=!1,L.isLocalDataLoaded=!1,L.isLocalTypeLoaded=!1,L.isLocalCharacterLoaded=!1,L.isConnectionLoaded=!1,L.isConnectionTypeLoaded=!1,L.isLocalConnectionLoaded=!1,yield function(){return Ri(this,void 0,void 0,(function*(){return yield k("settings")[0]||new w(!0),yield function(){return ki(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([W().then((()=>{L.isDataLoaded=!0,L.isCharacterLoaded=!0,L.isTypeLoaded=!0})),Ai().then((()=>{L.isLocalDataLoaded=!0,L.isLocalTypeLoaded=!0,L.isLocalCharacterLoaded=!0})),fi().then((()=>{L.isLocalConnectionLoaded=!0})),hi().then((()=>{L.isConnectionLoaded=!0,L.isConnectionTypeLoaded=!0}))])}))}var dr=e.BG,ur=e.TR,hr=e.Tc,fr=e.U3,yr=e.Wg,pr=e.g2,vr=e.BO,gr=e.WW,Cr=e.BS,mr=e.ji,Tr=e.Ij,Nr=e.Ng,wr=e.du,Ir=e.RC,Ar=e.d4,kr=e.Cd,Sr=e.IM,Rr=e.oI,xr=e.u9,_r=e.B7,Er=e.mF,Lr=e.Q9,Ur=e.wT,Pr=e.y0,Fr=e.iw,Br=e.pU,Gr=e.qN,Vr=e.mZ,Dr=e.Ec,Or=e.L0,br=e.Te,$r=e.vw,Mr=e.z8,Hr=e.k9,jr=e.sP,Wr=e.Y3,Jr=e.WC,Qr=e.Nj,qr=e.dF,Xr=e.cw,Yr=e.p8,zr=e.rv,Kr=e.pX,Zr=e.iD,tc=e.Mb,ec=e.bq,nc=e.ke,oc=e.w1,ic=e.yz,rc=e.RW,cc=e.WL,ac=e.rh,sc=e.nW,lc=e.RH,dc=e.Aj,uc=e.cV,hc=e.jM,fc=e.nS,yc=e.Yu,pc=e.xf,vc=e.KS,gc=e.L6,Cc=e.Z9,mc=e.Ny,Tc=e.qY,Nc=e.jQ,wc=e.NT,Ic=e.Xr,Ac=e.ab,kc=e.SV,Sc=e.EA,Rc=e.M2,xc=e.OY,_c=e.ry,Ec=e.cS,Lc=e.ZJ,Uc=e.RA,Pc=e.BH,Fc=e.SL,Bc=e.Ne,Gc=e.fg,Vc=e.M4,Dc=e.UG,Oc=e.CT,bc=e.yv,$c=e.vI,Mc=e.XZ,Hc=e.ZE,jc=e.pi,Wc=e.B8,Jc=e.yx,Qc=e.br,qc=e.eU,Xc=e.cf,Yc=e.jy,zc=e.cm,Kc=e.qn,Zc=e.ss,ta=e.pf,ea=e.pZ,na=e.l4,oa=e.f8,ia=e.Y6,ra=e.FS,ca=e.bM,aa=e.ZX,sa=e.CE,la=e.Sf,da=e.tp,ua=e.Ry,ha=e.jh,fa=e.dp,ya=e.a2,pa=e.C$,va=e.J5,ga=e.sc,Ca=e.x9,ma=e.Py,Ta=e.Xc,Na=e.Ts,wa=e.P$,Ia=e.xX,Aa=e.ae,ka=e.zN,Sa=e.dU,Ra=e.mA,xa=e.En,_a=e.eD,Ea=e.$Q;export{dr as ALLID,ur as AddGhostConcept,hr as AddGhostConnection,fr as BaseUrl,yr as BinaryTree,pr as CCSConfig,vr as Composition,gr as CompositionBinaryTree,Cr as CompositionNode,mr as Concept,Tr as ConceptsData,Nr as Connection,wr as ConnectionData,Ir as CreateComposition,Ar as CreateConnection,kr as CreateConnectionBetweenTwoConcepts,Sr as CreateConnectionBetweenTwoConceptsGeneral,Rr as CreateDefaultConcept,xr as CreateDefaultLConcept,_r as CreateSession,Er as CreateSessionVisit,Lr as CreateTheCompositionWithCache,Ur as CreateTheConnectionGeneral,Pr as DATAID,Fr as DATAIDDATE,Br as DATAV2,Gr as DeleteConceptById,Vr as DeleteConnectionById,Dr as DeleteConnectionByIdBulk,Or as DeleteConnectionByTypeBulk,br as FilterSearch,$r as FormatFromConnections,Mr as FreeSchemaResponse,Hr as FreeschemaQuery,jr as GetAllConnectionsOfComposition,Wr as GetAllConnectionsOfCompositionBulk,Jr as GetAllTheConnectionsByTypeAndOfTheConcept,Qr as GetComposition,qr as GetCompositionBulk,Xr as GetCompositionBulkWithDataId,Yr as GetCompositionFromConnectionsWithDataId,zr as GetCompositionFromConnectionsWithDataIdInObject,Kr as GetCompositionList,Zr as GetCompositionListWithId,tc as GetCompositionWithAllIds,ec as GetCompositionWithCache,nc as GetCompositionWithDataIdBulk,oc as GetCompositionWithDataIdWithCache,ic as GetCompositionWithId,rc as GetCompositionWithIdFromMemory,cc as GetCompositionWithIdFromMemoryFromConnections,ac as GetConceptBulk,sc as GetConceptByCharacter,lc as GetConceptByCharacterAndCategoryDirectApi,dc as GetConceptByCharacterAndType,uc as GetConceptByTypeBulk,hc as GetConnectionBulk,fc as GetConnectionById,yc as GetConnectionByTypeBulk,pc as GetConnectionOfTheConcept,vc as GetConnectionsBetweenApi,gc as GetLink,Cc as GetLinkRaw,mc as GetLinkerConnectionFromConcepts,Tc as GetLinkerConnectionToConcepts,Nc as GetRelation,wc as GetRelationRaw,Ic as GetRequestHeader,Ac as GetRequestHeaderWithAuthorization,kc as GetTheConcept,Sc as GetUserGhostConnectionId,Rc as GetUserGhostId,xc as GiveConnection,_c as HandleHttpError,Ec as HttpResponse,Lc as JUSTDATA,Uc as LConcept,Pc as LConnection,Fc as LISTNORMAL,Bc as LoginToBackend,Gc as MakeTheInstanceConcept,Vc as MakeTheTimestamp,Dc as MakeTheTypeConcept,Oc as MakeTheTypeConceptApi,bc as NORMAL,$c as PatcherStructure,Mc as RAW,Hc as RecursiveSearchApi,jc as ReservedConnectionIds,Wc as ReservedIds,Jc as SchemaQueryListener,Qc as SearchAllConcepts,qc as SearchLinkInternal,Xc as SearchLinkMultipleAll,Yc as SearchLinkMultipleApi,zc as SearchQuery,Kc as SearchStructure,Zc as SearchWithLinker,ta as SessionData,ea as Signin,na as Signup,oa as SplitStrings,ia as SyncData,ra as TokenRefreshError,ca as TokenStorage,aa as Transaction,sa as TrashTheConcept,la as UpdateComposition,da as UserBinaryTree,ua as ViewInternalData,ha as buildFetchConnection,fa as convertFromLConceptToConcept,ya as deleteWithRetry,pa as fetchWithCacheServerFallback,va as fetchWithRetry,ga as getFromDatabaseWithType,Ca as getFromDatabaseWithTypeOld,ma as getOAuthToken,Ta as getWithRetry,Na as init,wa as patchWithRetry,Ia as postWithRetry,Aa as putWithRetry,ka as recursiveFetch,Sa as recursiveFetchNew,Ra as refreshOAuthToken,xa as requestWithRetry,_a as storeToDatabase,Ea as updateAccessToken};
|
|
1
|
+
var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{BG:()=>Hi,$e:()=>bi,TR:()=>Ho,Tc:()=>Wo,U3:()=>n,Wg:()=>G,g2:()=>hi,BO:()=>yo,WW:()=>lo,BS:()=>so,ji:()=>F,Ij:()=>M,Ng:()=>ee,du:()=>se,RC:()=>Bt,d4:()=>Tt,Cd:()=>tn,IM:()=>on,oI:()=>b,u9:()=>hn,B7:()=>Eo,mF:()=>Bo,Q9:()=>vo,wT:()=>mt,hZ:()=>sn,y0:()=>Oi,iw:()=>Mi,pU:()=>Ji,qN:()=>Pn,mZ:()=>Ot,Ec:()=>Vt,L0:()=>ri,Te:()=>li,vw:()=>Ko,z8:()=>Q,k9:()=>ar,sP:()=>we,Y3:()=>ve,WC:()=>dr,Nj:()=>Ae,dF:()=>jn,cw:()=>Hn,p8:()=>Wn,rv:()=>qn,pX:()=>$e,iD:()=>Oe,Mb:()=>ke,bq:()=>Ao,ke:()=>xo,w1:()=>So,yz:()=>Be,RW:()=>xe,WL:()=>Ee,rh:()=>le,nW:()=>be,RH:()=>je,Aj:()=>Nt,cV:()=>At,jM:()=>Vn,nS:()=>Dt,Yu:()=>ci,xf:()=>Lt,KS:()=>fr,L6:()=>ln,Z9:()=>dn,Ny:()=>En,qY:()=>_n,jQ:()=>Go,NT:()=>Fo,Xr:()=>q,ab:()=>z,SV:()=>jt,EA:()=>jo,M2:()=>Mo,OY:()=>ur,ry:()=>K,cS:()=>l,ZJ:()=>Vi,RA:()=>un,BH:()=>Do,SL:()=>Wi,Ne:()=>Xn,fg:()=>Et,M4:()=>Dn,UG:()=>Nn,CT:()=>Qe,yv:()=>$i,vI:()=>si,oe:()=>Li,XZ:()=>ji,ZE:()=>Qn,pi:()=>at,B8:()=>st,yx:()=>sr,br:()=>To,eU:()=>oi,cf:()=>Qo,jy:()=>qo,cm:()=>$n,qn:()=>di,ss:()=>Io,pf:()=>ai,pZ:()=>to,l4:()=>Zn,f8:()=>W,Y6:()=>vt,FS:()=>a,bM:()=>o,ZX:()=>vr,CE:()=>Fn,Sf:()=>Co,tp:()=>Oo,Ry:()=>Zo,jh:()=>yr,dp:()=>ei,a2:()=>v,C$:()=>T,J5:()=>h,sc:()=>S,x9:()=>x,Py:()=>r,Xc:()=>y,Ts:()=>mr,P$:()=>g,xX:()=>f,ae:()=>p,zN:()=>Ue,dU:()=>ho,mA:()=>c,En:()=>u,eD:()=>k,$Q:()=>Cr});class n{static setNodeCacheUrl(e=""){this.NODE_CACHE_URL=e,this.isNearestCache=!0}static setCacheServers(e=[]){this.CACHE_SERVERS=e.filter((e=>"string"==typeof e&&""!==e.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetNodeBaseUrl(){return this.NODE_URL&&""!==this.NODE_URL.trim()?this.NODE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const e=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.GetNodeBaseUrl(),this.BASE_URL].filter((e=>"string"==typeof e&&""!==e.trim())).map((e=>e.trim()));return Array.from(new Set(e))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetNodeBaseUrl()+"/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 CreateTypeConceptUrl(){return this.BASE_URL+"/api/create_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.NODE_CACHE_URL="",n.CACHE_SERVERS=[],n.isNearestCache=!0,n.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(e,t){this.BearerAccessToken=e,this.TOKEN_EXPIRY=t&&t>0?Date.now()+1e3*t:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const e=Date.now(),t=this.TOKEN_EXPIRY-e;return t>0?Math.floor(t/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(e,t,n){this.CLIENT_ID=e,this.CLIENT_SECRET=t,this.APPLICATION_NAME=n}}o.BearerAccessToken="",o.CLIENT_ID="",o.CLIENT_SECRET="",o.APPLICATION_NAME="",o.TOKEN_EXPIRY=0,o.EXPIRY_BUFFER_MS=3e5;var i=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function r(e,t,r){return i(this,arguments,void 0,(function*(e,t,i,r=!0){try{const c=n.OAuthTokenUrl(),s=new URLSearchParams;s.append("client_id",e),s.append("client_secret",t),s.append("application_name",i);const a=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()});if(a.ok){let e="",t="Bearer",n=0;const i=a.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield a.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield a.text()}else e=yield a.text();return e?(r&&o.setToken(e,n),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield a.text();return{success:!1,error:`HTTP ${a.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}function c(e,t,r){return i(this,arguments,void 0,(function*(e,t,i,r=!0){try{const c=n.OAuthRefreshUrl(),s=new URLSearchParams;s.append("client_id",e),s.append("client_secret",t),s.append("refresh_token",i),s.append("grant_type","refresh_token");const a=yield fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()});if(a.ok){let e="",t="Bearer",n=0;const i=a.headers.get("content-type");if(i&&i.includes("application/json"))try{const o=yield a.json();e=o.access_token||"",t=o.token_type||"Bearer",n=o.expires_in||0}catch(t){e=yield a.text()}else e=yield a.text();return e?(r&&o.setToken(e,n),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield a.text();return{success:!1,error:`HTTP ${a.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}var s=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class a extends Error{constructor(e){super(e),this.name="TokenRefreshError"}}class l{constructor(e,t,n){this.status=e,this.body=t,this.headers=n}json(){return s(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return s(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function d(){return s(this,void 0,void 0,(function*(){if(!o.hasOAuthCredentials())return!1;try{return(yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0)).success}catch(e){return console.error("Token refresh failed:",e),!1}}))}function u(e,t,n,i){return s(this,arguments,void 0,(function*(e,t,n,i,r=1){var c,s;const u=Object.assign(Object.assign({},n),o.getAuthHeader()),h=["GET","HEAD","OPTIONS"].includes(e.toUpperCase());for(let n=0;n<=r;n++)try{const h={method:e,headers:u};void 0!==i&&("object"==typeof i?(u["Content-Type"]||u["content-type"]||(u["Content-Type"]="application/json"),(null===(c=u["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(s=u["content-type"])||void 0===s?void 0:s.includes("application/json"))?h.body=JSON.stringify(i):h.body=i):h.body=i),h.headers=u;const f=yield fetch(t,h),y=yield f.text(),p={};if(f.headers.forEach(((e,t)=>{p[t]=e})),401!==f.status)return new l(f.status,y,p);if(n<r){if(yield d()){Object.assign(u,o.getAuthHeader());continue}throw new a("Token refresh failed. Please check OAuth credentials.")}return new l(f.status,y,p)}catch(e){if(e instanceof a)throw e;if(n>=r||!h)throw e;console.error(`Request failed (attempt ${n+1}/${r+1}):`,e)}throw new Error("Request failed after all retry attempts")}))}function h(e){return s(this,arguments,void 0,(function*(e,t={},n=1){return u(t.method||"GET",e,function(e){if(e){if(e instanceof Headers){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}return Array.isArray(e)?e.reduce(((e,[t,n])=>(e[t]=n,e)),{}):e}}(t.headers),t.body,n)}))}function f(e,t,n){return s(this,void 0,void 0,(function*(){return u("POST",e,t,n)}))}function y(e,t,n){return s(this,void 0,void 0,(function*(){let o=e;if(n){const t=[];for(const e in n)n.hasOwnProperty(e)&&t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n[e]))}`);t.length>0&&(o=`${e}?${t.join("&")}`)}return u("GET",o,t)}))}function p(e,t,n){return s(this,void 0,void 0,(function*(){return u("PUT",e,t,n)}))}function v(e,t){return s(this,void 0,void 0,(function*(){return u("DELETE",e,t)}))}function g(e,t,n){return s(this,void 0,void 0,(function*(){return u("PATCH",e,t,n)}))}var C=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function m(e,t){return`${e.replace(/\/+$/,"")}${t}`}function T(e){return C(this,arguments,void 0,(function*(e,t={},o=1){const i=n.GetReadBaseUrlCandidates();let r;for(const c of i){try{const i=yield h(m(c,e),t,o);if(c.replace(/\/+$/,"")===n.BASE_URL.replace(/\/+$/,""))return i;if(i.ok)return n.NODE_CACHE_URL=c,i;r=new Error(`Cache server ${c} returned status ${i.status}`)}catch(e){r=e}n.isNearestCache=!1}throw r instanceof Error?r:new Error("All cache servers failed")}))}class w{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var I=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const N={};function A(e){return N[e]||(N[e]=[]),N[e]}function k(e,t){const n=A(e);if(t&&"number"==typeof t.id){const e=n.findIndex((e=>e&&e.id===t.id));if(e>=0)return void(n[e]=t)}n.push(t)}function S(e,t,n){return I(this,void 0,void 0,(function*(){return A(e).filter((e=>e&&e[t]===n))}))}function x(e){return I(this,void 0,void 0,(function*(){return A(e).slice()}))}function R(e,t){const n=A(e),o=n.findIndex((e=>e&&e.id===t));o>=0&&n.splice(o,1)}function E(e){return I(this,void 0,void 0,(function*(){return A(e).slice()}))}class _{}_.isTypeLoaded=!1,_.isCharacterLoaded=!1,_.isDataLoaded=!1,_.isLocalDataLoaded=!1,_.isLocalCharacterLoaded=!1,_.isLocalTypeLoaded=!1,_.isConnectionLoaded=!1,_.isConnectionTypeLoaded=!1,_.isLocalConnectionLoaded=!1;class B{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var U=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class L{static waitForDataToLoad(){return U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isCharacterLoaded)return e("done");setTimeout(L.checkFlag,1e3,e)}static addNodeToTree(e){return U(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return U(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new B(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return U(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}L.characterRoot=null;var P=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class G{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return P(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isDataLoaded)return e("done");setTimeout(G.checkFlag,1e3,e)}static addConceptToTree(e){var t=new B(e.id,e,null,null),n=new B(e.characterValue,e,null,null);L.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return P(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return P(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}G.root=null;class F{constructor(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y,p=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=o,this.ghostId=e,this.categoryId=i,this.categoryUserId=r,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,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 b(){let e=D(new Date),t=D(new Date);return new F(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function D(e){const t=e.getMonth()+1,n=e.getDate(),o=e.getFullYear();let i=e.getHours();const r=e.getMinutes(),c=e.getSeconds(),s=i>=12?"PM":"AM";i%=12,i=i||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${o} ${i}:${a(r)}:${a(c)} ${s}`}var $=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class O{static addNodeToTree(e){return $(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new B(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return $(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isTypeLoaded)return e("done");setTimeout(O.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return $(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)if(o.variants[e].value.userId==t){var i=!1;for(let t=0;t<n.length;t++)n[t].id==o.variants[e].value.id&&(i=!0);i||n.push(o.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return $(this,void 0,void 0,(function*(){let n=b();var o=this.getNodeFromTree(t);if(o){o.value.characterValue==e&&(n=o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.characterValue==e&&(n=o.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}O.typeRoot=null;var V=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class M{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(e=Date.now()){this.NPC=this.NPC.filter((t=>{const n=this.NPCMeta.get(t);return n&&n.expiresAt>e}))}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){var t;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(e)||this.NPC.push(e);const o=this.NPCMeta.get(e),i=(null!==(t=null==o?void 0:o.attempts)&&void 0!==t?t:0)+1;this.NPCMeta.set(e,{attempts:i,expiresAt:n+i*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(e){const t=Date.now();this.RemoveExpiredNpc(t);const n=this.NPCMeta.get(e);return!!(n&&n.expiresAt>t)}static AddConceptToStorage(e){e.id>0&&k("concept",e)}static AddConcept(e){e.id>0&&(k("concept",e),G.addConceptToTree(e),O.addConceptToTree(e),L.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(G.addConceptToTree(e),O.addConceptToTree(e),L.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);G.removeNodeFromTree(e.id),R("concept",e.id)}static GetConcept(e){return V(this,void 0,void 0,(function*(){var t=b(),n=yield G.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return V(this,void 0,void 0,(function*(){var t=b(),n=L.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return V(this,void 0,void 0,(function*(){var t=b(),n=L.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return V(this,void 0,void 0,(function*(){return b(),yield O.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return V(this,void 0,void 0,(function*(){var n=b(),o=yield L.getCharacterAndCategoryFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return V(this,void 0,void 0,(function*(){let n=[];return n=yield O.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return L.characterRoot}getName(){return this.name}}M.conceptsArray=[],M.NPC=[],M.NPCMeta=new Map,M.NPC_BACKOFF_SECONDS=30,M.conceptDictionary=[];var j=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function H(){return j(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield x("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];M.AddConceptToMemory(n)}(new Date).getTime()}))}function W(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var J=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function q(){return J(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:t}}))}function z(){return J(this,arguments,void 0,(function*(e="application/json",t="",n="application/json"){if(""!==t)return{"Content-Type":e,Authorization:"Bearer "+t,Accept:n};if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class Q{constructor(e,t,o,i){this.url=n.BASE_URL,this.message=e,this.ok=t,this.status=o,this.data=i}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function K(e){if(!e.ok){const t=e instanceof l,n=t?e.body||`HTTP error ${e.status}`:e.statusText||`HTTP error ${e.status}`;let o=new Q(n,!1,e.status,"");throw o.setUrl(t?e.headers.url||"":e.url),o}}function X(e){if(!e.ok){const t=e.body||`HTTP error ${e.status}`;let n=new Q(t,!1,e.status,e.body);throw n.setUrl(e.headers.url||""),n}}var Y=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Z(e,t){return Y(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",e),o.append("user_id",t.toString());var i=yield q("application/x-www-form-urlencoded");const c=yield h(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++)M.AddConcept(e[r])}console.log("GetAllConceptsByType error",c.status),K(c)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class ee{constructor(e=0,t,n,o,i,r,c,s,a,l,d,u,h,f,y,p){this.isTemp=!1,this.toUpdate=!1,this.type=b(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=i,this.userId=r,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=d,this.securityUserId=u,this.accessId=h,this.accessUserId=f,this.sessionInformationId=y,this.sessionInformationUserId=p,this.entryTimeStamp=D(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class te{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class oe{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new te(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return ne(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isConnectionLoaded)return e("done");setTimeout(oe.checkFlag,1e3,e)}static removeNodeFromTree(e){return ne(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return ne(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}oe.connectionroot=null;var ie=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class re{static addNodeToTree(e){return ie(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return ie(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isConnectionTypeLoaded)return e("done");setTimeout(re.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new te(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return ie(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return ie(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}re.connectionTypeRoot=null;var ce=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class se{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){k("connection",e)}static AddConnection(e){e.isTemp||(k("connection",e),oe.addConnectionToTree(e),re.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(oe.addConnectionToTree(e),re.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(R("connection",e.id),oe.removeNodeFromTree(e.id),re.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return oe.connectionroot}static GetConnectionTypeTree(){return re.connectionTypeRoot}static GetConnection(e){return ce(this,void 0,void 0,(function*(){var t=new ee(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield oe.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return ce(this,void 0,void 0,(function*(){var t=[],n=yield re.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;if(o){let e=o;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}se.connectionArray=[],se.connectionDictionary=[];var ae=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function le(e){return ae(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield M.GetConcept(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{const e=JSON.stringify(n);var o=yield q();const i=yield T("/api/get_concept_bulk",{method:"POST",headers:o,body:e});if(console.log("[DEBUG] GetConceptBulk response:",{status:i.status,ok:i.ok}),i.ok){let e=yield i.json();if(e.length>0)for(let n=0;n<e.length;n++){let o=e[n];t.push(o),M.AddConcept(o)}}else console.log("Get Concept Bulk error",i.status),K(i);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var de=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ue(){return de(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield le(t)}}))}var he=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function fe(){return he(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield se.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function ye(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||se.RemoveConnection(t[n]))}var pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ve(){return pe(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var o=yield fe(e),i=yield function(){return pe(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=yield q();const r=yield h(n.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});if(r.ok){const e=yield r.json();for(var i=0;i<e.length;i++)se.AddConnection(e[i]),t.push(e[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),K(r);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return ye(t=i,o),yield ue(t),t}))}var ge=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Ce=new Map;function me(e){return ge(this,void 0,void 0,(function*(){let t=b();if(Ce.has(e))return Ce.get(e)||t;const o=(()=>ge(this,void 0,void 0,(function*(){try{var o=yield M.GetConcept(e);let r=M.GetNpc(e);if(0!=o.id||r)return o;{var i=yield q("application/x-www-form-urlencoded");const o=n.GetConceptUrl();console.log("[DEBUG] GetConcept request:",{url:o,method:"POST",headers:i,conceptId:e});const r=yield h(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${e}`});return console.log("[DEBUG] GetConcept response:",{status:r.status,ok:r.ok,conceptId:e}),r.ok?(t=yield r.json(),t.id>0?M.AddConcept(t):M.AddNpc(e)):(console.log("Get the concept error",r.status,e),K(r)),t}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message,e):console.log("Get the concept unexpected error: ",t,e),t}finally{Ce.delete(e)}})))();return Ce.set(e,o),o}))}var Te=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function we(e){return Te(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield se.GetConnectionsOfCompositionLocal(e)).length)t=yield Ie(e);else{var n=yield Ie(e);ye(n,t),t=n}return t}))}function Ie(e){return Te(this,void 0,void 0,(function*(){var t=[];try{var o=yield q("application/x-www-form-urlencoded");const r=yield h(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${e}`});if(!r.ok)throw K(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)se.AddConnection(c[i]),t.push(c[i]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var Ne=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ae(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function ke(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Le(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function Se(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);return i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,i}))}function xe(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=i,l.id=e,l}))}function Re(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield se.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=i,l.id=e,l.created_at=s.entryTimeStamp,l}))}function Ee(e,t){return Ne(this,void 0,void 0,(function*(){for(var n,o,i={},r=[],c=0;c<t.length;c++)r.includes(t[c].ofTheConceptId)||r.push(t[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,t,r);i[null!==(o=null===(n=null==s?void 0:s.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=i,l.id=e,l}))}function _e(e,t){return Ne(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r={},c=yield M.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield me(e));var s=yield Ue(e,t,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=r,a.id=e,a}))}function Be(e){return Ne(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield we(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield M.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield me(e));var a=yield Ue(e,o,r);i[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=i,l.id=e,l}))}function Ue(e,t,n){return Ne(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield M.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield me(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield M.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield M.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield me(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield M.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ue(f,t,n,o);s[p]=e}}else{const e=yield Ue(f,t,n,o);a[p]=e,s=a}}return s}))}function Le(e,t,n){return Ne(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield M.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield me(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield M.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),l.type=u)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e),s.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield M.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield me(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield M.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield me(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Le(f,t,n);s[p]=e}}else{const e=yield Le(f,t,n);a[p]=e,s=a}}return s}))}var Pe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ge(e){return Pe(this,void 0,void 0,(function*(){let t=b();try{var o=yield q("application/x-www-form-urlencoded");const i=yield h(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${e}`});return i.ok?(t=yield i.json(),t.id>0&&M.AddConcept(t)):(console.log("Error in Getting concept by character value Error",i.status),K(i)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var Fe=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function be(e){return Fe(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Ge(e),t=yield M.GetConceptByCharacter(e)),t}))}var De=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function $e(e,t){return De(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield be(e),r=[];if(i){yield Z(e,t);for(var c=yield M.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ve(a),l=s;l<s+n;l++)if(c[l]){var d=yield Se(c[l].id);r.push(d)}}return r}))}function Oe(e,t){return De(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield be(e),r=[];if(i){yield Z(e,t);for(var c=yield M.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ve(a),l=s;l<s+n;l++)if(c[l]){var d=yield xe(c[l].id);r.push(d)}}return r}))}var Ve=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Me=new Map;function je(e,t){return Ve(this,void 0,void 0,(function*(){let o=b();if(Me.has(e+t))return Me.get(e+t)||o;const i=(()=>Ve(this,void 0,void 0,(function*(){try{var i=yield q("application/x-www-form-urlencoded");const r=yield h(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${e}&category_id=${t}`});if(r.ok){let e=yield r.json();o=e,M.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),K(r);return o}catch(o){throw o instanceof Error?console.log(" This is the concept by category and character direct api error message: ",o.message,e,t,n.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",o,e,t,n.GetConceptByCharacterAndCategoryDirectUrl()),o}finally{Me.delete(e+t)}})))();return Me.set(e+t,i),i}))}var He=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function We(e){return He(this,void 0,void 0,(function*(){let t=b();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=W(e);if(o.length>1){let n=1,i=yield We(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return He(this,void 0,void 0,(function*(){let n=yield M.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield je(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return He(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacterAndTypeLocal(e,49);return 0==t.id&&(t=yield Ge(e)),t}))}(e):o[0]==e&&(t=yield function(e){return He(this,void 0,void 0,(function*(){var t=yield M.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Ge(e)),t}))}(e));return t}))}var Je=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const qe=new Map,ze=new Map;function Qe(e,t){return Je(this,void 0,void 0,(function*(){let t=b();if(ze.has(e))return ze.get(e);if(qe.has(e))return qe.get(e)||t;const o=(()=>Je(this,void 0,void 0,(function*(){try{if(t=yield We(e),0==t.id||4==t.typeId){var o=yield q("application/x-www-form-urlencoded");const i=yield h(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${e}`});if(!i.ok)throw K(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();t=r,t.id>0&&M.AddConcept(t)}return t.id>0&&ze.set(e,t),t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{qe.delete(e)}})))();return qe.set(e,o),o}))}var Ke=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};let Xe=!1,Ye=[];const Ze=()=>{Ye.length>0&&!Xe&&Ye.shift()()};function et(e){return Ke(this,void 0,void 0,(function*(){return new Promise(((t,o)=>{Ye.push((()=>Ke(this,void 0,void 0,(function*(){try{if(Xe)return;if(Xe=!0,!e&&at.connectionIds.length>10)return Xe=!1,Ze(),t();const o=e?`${n.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(e)}).toString()}`:n.GetReservedConnectionIdUrl();var i=yield q("application/x-www-form-urlencoded");const c=yield h(o,{method:"GET",headers:i});if(!c.ok)throw K(c),new Error(`Error! status: ${c.status}`);const s=yield c.json();for(var r=0;r<s.length;r++)at.AddId(s[r]);t()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),o(e)}finally{Xe=!1,Ze()}})))),Ze()}))}))}var tt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};let nt=!1,ot=[];const it=()=>{ot.length>0&&!nt&&ot.shift()()};function rt(){return tt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{ot.push((()=>tt(this,void 0,void 0,(function*(){try{if(nt)return;if(nt=!0,st.ids.length>10)return nt=!1,it(),e();var o=yield q("application/x-www-form-urlencoded");const t=yield h(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!t.ok)throw K(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)st.AddId(r[i]);e()}catch(e){t(e)}finally{nt=!1,it()}})))),it()}))}))}var ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class st{static getId(){return ct(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield rt()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((e=>console.error("Reserved ID refill failed:",e))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield rt()}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(e){Number.isFinite(e)&&e>0&&!this.ids.includes(e)&&this.ids.push(e)}}st.ids=[],st.pendingFetch=null;class at{static getId(){return ct(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et()}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(e){Number.isFinite(e)&&e>0&&!this.connectionIds.includes(e)&&this.connectionIds.push(e)}static warmUp(e){return ct(this,void 0,void 0,(function*(){const t=e-this.connectionIds.length;t<=0||(this.pendingFetch||(this.pendingFetch=(()=>ct(this,void 0,void 0,(function*(){try{yield et(t)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}at.connectionIds=[],at.pendingFetch=null;function lt(e){return{id:e.id,userId:e.userId,characterValue:e.characterValue,typeId:e.typeId,categoryId:e.categoryId,accessId:e.accessId,referentId:e.referentId,sessionInformationId:e.sessionInformationId}}function dt(e){return t=this,o=void 0,r=function*(){let t=b();try{var o=yield q();const i=function(e){return Array.isArray(e)?e.map((e=>lt(e))):lt(e)}(e),r=yield f(n.CreateTheConceptUrl(),o,i);if(!r.ok)throw X(r),new Error(`Error! status: ${r.status}`);return t=yield r.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((i=void 0)||(i=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,o||[])).next())}));var t,o,i,r}function ut(e){return t=this,o=void 0,r=function*(){let t=new ee(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield q();const i=function(e){return e.map((e=>function(e){return{id:e.id,ofTheConceptId:e.ofTheConceptId,toTheConceptId:e.toTheConceptId,ofTheConceptUserId:e.ofTheConceptUserId,toTheConceptUserId:e.toTheConceptUserId,typeId:e.typeId,userId:e.userId,orderId:e.orderId,accessId:e.accessId,sessionInformationId:e.sessionInformationId}}(e)))}(e),r=yield f(n.CreateTheConnectionUrl(),o,i);if(!r.ok)throw console.log("Create the connection error message: ",r),X(r),new Error(`Error! status: ${r.status}`);return t=yield r.json(),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((i=void 0)||(i=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,o||[])).next())}));var t,o,i,r}var ht=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ft(e){return e?`[SyncData:${e}]`:"[SyncData]"}function yt(e,t){console.log(`${ft(t)} ${e}`)}function pt(e,t,n,o,i){o<100&&n!==o||n!==o&&1!==n&&n%100!=0||console.log(`${ft(i)} ${e} ${t}: ${n}/${o} done, ${o-n} remaining`)}class vt{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(e){return ht(this,void 0,void 0,(function*(){try{let t=[],n=[];if(e&&this.transactionCollections.some((t=>t.id==e))){const o=this.transactionCollections.find((t=>t.id==e));if(this.transactionCollections=this.transactionCollections.filter((t=>t.id==e||new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;t=o.data.concepts.slice(),n=o.data.connections.slice(),yt(`starting online sync with ${t.length} concepts and ${n.length} connections`,e),t.length>0&&(yt(`sending ${t.length} concepts to backend`,e),yield dt(t),pt("synced","concepts",t.length,t.length,e)),n.length>0&&(yt(`sending ${n.length} connections to backend`,e),yield ut(n),pt("synced","connections",n.length,n.length,e)),this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e)),yt("online sync complete",e)}else{const e=this.conceptsSyncArray.length,o=this.connectionSyncArray.length;yt(`starting online sync with ${e} queued concepts and ${o} queued connections`);for(let t=0;t<this.conceptsSyncArray.length;t++)M.AddConcept(this.conceptsSyncArray[t]),pt("prepared local cache for","concepts",t+1,e);for(let e=0;e<this.connectionSyncArray.length;e++)se.AddConnection(this.connectionSyncArray[e]),pt("prepared local cache for","connections",e+1,o);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),yt(`sending ${t.length} concepts to backend`),yield dt(t),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.some((t=>t.id===e.id)))),pt("synced","concepts",t.length,t.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),yt(`sending ${n.length} connections to backend`),yield ut(n),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!n.some((t=>t.id===e.id)))),pt("synced","connections",n.length,n.length)),yt(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return ht(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections.push({id:e,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(e){console.log("error in initializeTransaction",e)}}))}static markTransactionActions(e,t){return ht(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==e?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(t))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.concepts.some((t=>t.id==e.id||t.ghostId==e.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!t.connections.some((t=>t.id==e.id||t.ghostId==e.id))))}catch(e){console.log("error in markTransactionActions",e)}}))}static rollbackTransaction(e,t){return ht(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e))}catch(e){console.log("LocalSyncData, roll",e)}}))}static syncDataLocalDb(){return ht(this,void 0,void 0,(function*(){if(yt(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const e=this.conceptsSyncArray.length;for(let t=0;t<this.conceptsSyncArray.length;t++)k("localconcept",this.conceptsSyncArray[t]),pt("stored locally","concepts",t+1,e);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const e=this.connectionSyncArray.length;for(let t=0;t<this.connectionSyncArray.length;t++)k("localconnection",this.connectionSyncArray[t]),pt("stored locally","connections",t+1,e);this.connectionSyncArray=[]}return yt("local sync complete"),"done"}))}}function gt(e,t){const n=Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${t} must be a positive finite number. Received ${JSON.stringify(e)}.`);return n}vt.conceptsSyncArray=[],vt.connectionSyncArray=[],vt.transactionCollections=[];var Ct=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function mt(e,t,n,o,i,r,c){return Ct(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s=1,a=4,l=999,d={concepts:[],connections:[]}){const u=function(e,t){const n=gt(e,"ofTheConceptId"),o=gt(t,"toTheConceptId");if(n===o)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:o}}(e,n);e=u.ofTheConceptId,n=u.toTheConceptId;let h=t,f=t,y=t;999!=l&&(y=l);let p=t,v=t,g=yield at.getId(),C=new ee(g,e,n,t,o,y,i,f,s,h,0,p,a,v,r,c);return C.toUpdate=!0,C.isTemp=!1,vt.AddConnection(C),d.connections.push(C),C}))}function Tt(e,t,n){return Ct(this,arguments,void 0,(function*(e,t,n,o={concepts:[],connections:[]}){let i=yield Qe(n),r=e.userId;return yield mt(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,r,o)}))}var wt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const It=new Map;function Nt(e,t){return wt(this,void 0,void 0,(function*(){let o=yield M.GetConceptByCharacterAndTypeLocal(e,t),i=e+t;if(It.has(i))return It.get(i)||o;const r=(()=>wt(this,void 0,void 0,(function*(){try{if(null==o||0==o.id){var r={character_value:`${e}`,type_id:t},c=JSON.stringify(r),s=yield q();const i=yield h(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:s,body:c});if(i.ok){let e=yield i.json();o=e,M.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),K(i)}return o}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{It.delete(i)}})))();return It.set(i,r),r}))}function At(e){return wt(this,void 0,void 0,(function*(){let t=[],o=JSON.stringify(e);var i=yield q();const r=yield h(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let e=yield r.json();t=yield le(e)}else console.log("This is the concept by type and character error",r.status),K(r);return t}))}var kt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function St(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return kt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield st.getId();let v=new Date,g=new Date;var C=new F(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!0,v,g);return C.isTemp=!1,vt.AddConcept(C),y.concepts.push(C),C}))}function xt(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return kt(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s,a,l,d,u,h,f,y={concepts:[],connections:[]}){var p=yield st.getId();let v=new Date,g=new Date;var C=new F(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!1,v,g);return M.AddConcept(C),C.updateRecursion=!0,vt.AddConcept(C),y.concepts.push(C),C}))}var Rt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Et(e,t){return Rt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0,s={concepts:[],connections:[]}){let a,l=r,d=o=n?o:999,u=o,h=i,f=o,y=e.startsWith("the_")?e:"the_"+e,p=b();return n?(p=yield Qe(e),a=yield St(t,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,s)):(p=yield Qe(y),a=yield Nt(t,p.id),0==a.id&&0==a.userId&&(a=yield xt(t,o,4,o,p.id,p.userId,c,999,999,d,h,f,l,u,s))),a.type=p,a}))}var _t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Bt(e){return _t(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null){var s=null!=i?i:999,a=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,u=b();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=p=yield Et(o,"",!0,s,a,l),h=p.id,d=p.id,yield Bt(e[o],p.id,p.userId,h,i,r,c)}else{var f=null!=t?t:999,y=null!=n?n:999;h=d,u=p=yield Et(o,"",!0,s,a,l),yield mt(f,y,p.id,p.userId,h,l,p.userId),yield Bt(e[o],p.id,p.userId,h,i,r,c)}else{f=null!=t?t:999,y=null!=n?n:10267,h=d;var p=yield Et(o,e[o].toString(),!1,s,a,l);yield mt(f,y,p.id,p.userId,h,l,p.userId)}return u}))}var Ut=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Lt(e,t,o){return Ut(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("ofTheConceptId",`${t}`),s.append("userId",`${o}`),s.append("inpage",`${i}`),s.append("page",`${r}`);var a=yield q("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),K(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Pt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Gt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Ft=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},bt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Dt(e){return bt(this,void 0,void 0,(function*(){var t=yield se.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var o=yield function(e){return Ft(this,void 0,void 0,(function*(){var t=yield se.GetConnection(e);try{if(0!=t.id)return t;{var o=yield q("application/x-www-form-urlencoded");const i=yield h(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${e}`});return i.ok?(t=yield i.json(),se.AddConnection(t)):(console.log("Get Connection Error",i.status),K(i)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=o}return t}))}var $t=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ot(e){return $t(this,arguments,void 0,(function*(e,t=""){let o=!1;var i=yield Dt(e);return o=yield function(e){return Gt(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield yield z("",t),r=yield{Authorization:i.Authorization,Accept:"application/json"};const c=new URLSearchParams;c.append("id",e.toString()),c.append("apiKey","nodeserver");const s=yield h(n.DeleteTheConnectionUrl(),{method:"POST",headers:r,body:c,redirect:"follow"});s.ok?o=(yield s.json()).success:(console.log("Delete connection error status: ",s.status),K(s))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return o}))}(e,t),R("connection",e),oe.removeNodeFromTree(e),re.removeTypeConcept(i.typeId,e),o}))}function Vt(e){return $t(this,void 0,void 0,(function*(){let t=yield function(e){return Pt(this,void 0,void 0,(function*(){let t=!1;try{let o=yield z();const i=yield h(n.DeleteTheConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});i.ok?t=(yield i.json()).success:(console.log("Delete connection Bulk Api error status: ",i.status),K(i))}catch(e){e instanceof Error?console.log("Delete connection Bulk Api error message: ",e.message):console.log("Delete connection Bulk Api unexpected error: ",e)}return t}))}(e);if(t)for(let t=0;t<e.length;t++){let n=e[t];n>0&&oe.removeNodeFromTree(n)}return t}))}var Mt=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function jt(e){return Mt(this,arguments,void 0,(function*(e,t=999){var n=b();if(e<0)return ei(yield Mo(t,e));if(null!=(n=yield M.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield me(e)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var o=yield M.GetConcept(n.typeId);if(0!=o.id)n.type=o;else{var i=yield me(n.typeId);0!=i.id&&(n.type=i)}}return n}))}var Ht=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const Wt=999,Jt=4,qt=999,zt=999,Qt=1e3;function Kt(e){const t=`${null!=e?e:""}`.trim();if(0===t.length)throw new Error("Cannot create a typed connection without a linker name.");return t}function Xt(e,t){return Ht(this,void 0,void 0,(function*(){var n,o,i;if(null==e||null==e.id||0===e.id)throw new Error(`Cannot create a typed connection: ${t} must be a persisted concept.`);const r=e.type;if(null===(n=null==r?void 0:r.characterValue)||void 0===n?void 0:n.trim())return r.characterValue.trim();const c=(yield jt(e.id,e.userId)).type;if(null===(o=null==c?void 0:c.characterValue)||void 0===o?void 0:o.trim())return e.type=c,c.characterValue.trim();if(null!=e.typeId&&0!==e.typeId){const t=yield jt(e.typeId,e.typeUserId);if(0!==t.id&&(null===(i=t.characterValue)||void 0===i?void 0:i.trim()))return e.type=t,t.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${t} concept ${e.id} has no resolvable type.`)}))}function Yt(e){return Ht(this,void 0,void 0,(function*(){return yield Et("connection",e,!1,Wt,Wt,qt)}))}function Zt(e,t,n){return Ht(this,void 0,void 0,(function*(){return yield mt(e.id,e.userId,t.id,t.userId,n.id,qt,zt,Qt,Jt)}))}function en(e,t,n){return Ht(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){const r=Kt(n),c=e.userId;if(o){const n=yield function(e,t){return Ht(this,void 0,void 0,(function*(){return`${yield Xt(e,"toTheConcept")}_s_${t}_by`}))}(t,r);i&&(yield nn(`${r}_by`,t,c));const o=yield Yt(n);yield Zt(t,e,o)}const s=yield function(e,t){return Ht(this,void 0,void 0,(function*(){return`${yield Xt(e,"ofTheConcept")}_s_${t}_s`}))}(e,r);i&&(yield nn(`${r}_s`,e,c));const a=yield Yt(s);return yield Zt(e,t,a)}))}function tn(e,t,n){return Ht(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){return yield en(e,t,n,o,i)}))}function nn(e,t){return Ht(this,arguments,void 0,(function*(e,t,n=null){for(var o=t,i=null!=n?n:t.userId,r=999,c=Kt(e)+"_count",s=(yield Xt(t,"concept"))+"_s_"+c,a=yield Et("connection",s,!1,i,4,r),l=yield Lt(a.id,t.id,i,10,1),d=[],u=b(),h=0;h<l.length;h++){let e=yield jt(l[h].toTheConceptId);d.push(e)}if(d.length<1)u=yield Et("count","1",!1,i,4,r);else{var f=d[0];let e=Number(f.characterValue),t=Number.isFinite(e)?e+1:1;u=yield Et("count",t.toString(),!1,i,4,r);for(let e=0;e<l.length;e++)yield Ot(l[e].id)}yield mt(o.id,o.userId,u.id,u.userId,a.id,r,zt,Qt,4,i)}))}function on(e,t,n){return Ht(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){return yield en(e,t,n,o,i)}))}var rn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function cn(e){return encodeURIComponent(String(e))}function sn(e,t){return rn(this,arguments,void 0,(function*(e,t,o=("number"==typeof e?999:e.userId),i=("number"==typeof e?4:e.accessId),r=999){const c="number"==typeof e?e:e.id,s="number"==typeof e?o:e.userId,a=yield q("application/x-www-form-urlencoded"),l=[`character_value=${cn(t)}`,`type_id=${cn(c)}`,`type_user_id=${cn(s)}`,`access_id=${cn(i)}`,`session_information_id=${cn(r)}`].join("&"),d=yield h(n.CreateTypeConceptUrl(),{method:"POST",headers:a,body:l});if(!d.ok)throw K(d),new Error(`Error! status: ${d.status}`);const u=yield d.json();return"number"!=typeof e&&(u.type=e),M.AddConcept(u),u}))}var an=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ln(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield jt(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield Nt(s,16);if(a.id>0){for(var l=yield Lt(a.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield ve(d),u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield jt(e),n=yield Re(t.id);r.push(n)}}return r}))}function dn(e,t){return an(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield jt(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield Nt(s,16);if(a.id>0){for(var l=yield Lt(a.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield jt(e);r.push(t)}}return r}))}class un{constructor(e,t,n,o,i,r,c,s=!1,a,l,d,u=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=o,this.characterValue=r,this.accessId=i,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=d,this.applicationId=u}getType(){console.log(this.typeId)}}function hn(){let e=new Date,t=new Date;return new un(0,0,0,0,0,"0","0",!1,e,t,0)}class fn{constructor(e,t,n,o,i,r,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class yn{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new fn(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}yn.characterData=[];class pn{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var vn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Cn(e,t,o,i,r){return gn(this,void 0,void 0,(function*(){return new fn(t,e,o,t,i,t,r,t,"",!1),yield function(){return vn(this,void 0,void 0,(function*(){var e;try{if(0==(e=yn.GetCharacter(e.data)).id){var t=yield q();const i=yield h(n.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!i.ok)throw K(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new fn(r.userId,e.data,0,0,4,4,999,999,"",!1);return o.id=r.id,yn.AddCharacter(o),r}return new pn(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Tn(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return mn(this,void 0,void 0,(function*(){var y=yield Nt(e,i),p=y;return 0==p.id&&(p=y=yield St(e,t,n,o,i,r,c,s,a,l,d,u,h,f)),p}))}var wn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},In=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Nn(e,t,n,o){return In(this,arguments,void 0,(function*(e,t,n,o,i={concepts:[],connections:[]}){var r=yield be(e);if(r&&(0==r.id||0==r.userId)){var c=W(e);if(c.length>0)if(c[0]==e){var s=yield function(e,t,n,o,i,r){return wn(this,void 0,void 0,(function*(){var i,c=t,s=t;i=t;var a,l=t,d=t,u=t;if(1==e.length){var h=e.charCodeAt(0);yield Cn(e,t,n,o,r),a=yield Tn(e,t,4,c,49,l,h,u,n,s,o,i,r,d)}else{var f=yield Cn(e,t,n,o,r);f.isNew,a=yield Tn(e,t,4,c,51,l,f.id,f.userId,n,s,o,i,r,d)}return a}))}(e,o,999,999,0,t);r=s}else{var a=yield Nn(c[0],t,n,o,i),l=yield Nn(c[1],t,n,o,i);l&&(r=yield xt(e,o,a.id,o,l.id,o,999,o,999,o,999,o,t,o,i))}}return r}))}var An=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function kn(e){return An(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield q("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield h(`${n.GetAllLinkerConnectionOfConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(s.ok){const e=yield s.json();for(var i=0;i<e.length;i++){var r=e[i];t.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),K(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var Sn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function xn(e){return Sn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield q("application/x-www-form-urlencoded");const c=new URLSearchParams({conceptId:String(e)}),s=yield h(`${n.GetAllLinkerConnectionToConceptUrl()}?${c.toString()}`,{method:"GET",headers:o});if(s.ok){const e=yield s.json();for(var i=0;i<e.length;i++){var r=e[i];t.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),K(s);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var Rn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function En(e){return Rn(this,void 0,void 0,(function*(){for(var t=yield kn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield jt(o);e.type=i}return t}))}function _n(e){return Rn(this,void 0,void 0,(function*(){for(var t=yield xn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield jt(o);e.type=i}return t}))}var Bn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Un=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n},Ln=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Pn(e){return Ln(this,arguments,void 0,(function*(e,t=""){var o=yield jt(e);yield G.removeNodeFromTree(e);var i=o.typeId,r=o.characterValue;yield O.removeTypeConcept(i,e),yield L.removeNodeByCharacter(r,e),R("concept",e);let c=yield function(e){return Bn(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield yield yield z("application/x-www-form-urlencoded",t);const r=new FormData;r.append("id",e.toString()),r.append("apiKey","nodeserver");const{"Content-Type":c}=i,s=Un(i,["Content-Type"]),a=yield h(n.DeleteConceptUrl(),{method:"POST",headers:s,body:r});if(!a.ok)throw K(a),new Error(`Error! status: ${a.status}`);o=(yield a.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return o}))}(e,t);return c}))}var Gn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Fn(e,t){return Gn(this,void 0,void 0,(function*(){try{const o=new Headers;o.append("Authorization","Bearer "+t);const i=new FormData;i.append("id",e.toString());const r=yield h(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw K(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var bn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Dn(e,t,n,o){return bn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,s=n,a=n,l=e.startsWith("the_"),d=b();return r=l?e:"the_"+e,d=yield Qe(r),yield Tn(t,n,4,n,d.id,d.userId,0,999,999,c,o,a,i,s)}))}class $n{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 On=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Vn(){return On(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let o=0;o<e.length;o++){let i=yield se.GetConnection(e[o]);0==i.id?n.push(e[o]):t.push(i)}if(0==n.length)return t;{var o=yield q();const e=yield T("/api/get_connection_bulk",{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let o=n[e];t.push(o),se.AddConnection(o)}yield ue(t)}}else console.log("Get Connection Bulk error",e.status),K(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var Mn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function jn(){return Mn(this,arguments,void 0,(function*(e=[]){yield ve(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Se(e[o]);t.push(n)}return t}))}function Hn(){return Mn(this,arguments,void 0,(function*(e=[]){yield ve(e);var t=[];for(let o=0;o<e.length;o++){var n=yield xe(e[o]);t.push(n)}return t}))}function Wn(){return Mn(this,arguments,void 0,(function*(e=[],t=[]){yield Vn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||se.RemoveConnection(t[n])}(t,yield fe(e));var n=[];for(let t=0;t<e.length;t++){var o=yield xe(e[t]);n.push(o)}return n}))}function Jn(){return Mn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],o={};for(let o=0;o<(null==e?void 0:e.length);o++){let i=yield se.GetConnection(e[o]);0==i.id?t.push(e[o]):n.push(i)}for(let n=0;n<t.length;n++)o[e[n]]=!1;let i=[],r=yield Vn(t);n=[...n,...r];for(let e=0;e<n.length;e++)i.push(n[e].ofTheConceptId),i.push(n[e].toTheConceptId),i.push(n[e].typeId);return yield le(i),n}))}function qn(){return Mn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],o=[];for(let e=0;e<t.length;e++){let i=yield se.GetConnection(t[e]);0==i.id?n.push(t[e]):o.push(i)}let i=yield Vn(n);for(let e=0;e<i.length;e++)o.push(i[e]);let r={},c=[];for(var s=0;s<o.length;s++)c.includes(o[s].ofTheConceptId)||c.push(o[s].ofTheConceptId);for(let t=0;t<e.length;t++){let n=yield _e(e[t],o,c);r[e[t]]=n}return r}))}var zn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Qn(){return zn(this,arguments,void 0,(function*(e=0,t=[],o="",i=[]){var r=[];try{var c=new $n;c.composition=e,c.listLinkers=t,c.textSearch=o,c.fullLinkers=i;var s=JSON.stringify(c),a=yield q();const u=yield h(n.RecursiveSearchUrl(),{method:"POST",headers:a,body:s});if(u.ok){const e=yield u.json();var l=e.compositionIds,d=e.internalConnections;e.externalConnections,r=yield Wn(l,d)}else console.log("recursive search error ",u.status),K(u);return r}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var Kn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Xn(e,t){return Kn(this,void 0,void 0,(function*(){try{var i={email:e,password:t},r=new Headers;r.append("Content-Type","application/json");var c=JSON.stringify(i);const s=yield h(n.LoginUrl(),{method:"POST",headers:r,body:c});if(s.ok){const e=yield s.json();return o.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",s.status),K(s)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var Yn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Zn(e){return Yn(this,void 0,void 0,(function*(){const t=yield function(){return Yn(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield h(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:K(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(n.SignupUrl(),e);return t}))}var eo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function to(e){return eo(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let o={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=n.LoginUrl();try{const e=yield h(r,{method:"POST",headers:i,body:t,redirect:"follow"}),n=yield e.json();return e.ok?o={message:"success",status:!0,statusCode:200,data:null==n?void 0:n.data}:K(e),o}catch(e){throw console.log("Sign in api error",e),e}}))}function no(e,t){return-1===e.indexOf(t)&&e.push(t),e}function oo(e=[],t){var n,o;let i=[],r=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(o=e[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&r!=c||i.push(e[n])}return i}function io(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const i=e.find((e=>e.ofTheConceptId==t));i&&n.push(i)}return n}function ro(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function co(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class so{constructor(e,t,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(lo.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var ao=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class lo{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new so(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return ao(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return ao(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}lo.root=null;var uo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ho(e,t,n,o){return uo(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let s={};const a=[];if(0==e)return"";let l=fo(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield jt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=fo(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield jt(e),l.type=t)}if(!o.includes(e))return null==l?void 0:l.characterValue;if(i.includes(e))return"";i.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const d=t[l].toTheConceptId;if(o.includes(e)){let e=fo(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield jt(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield M.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield jt(t),e.type=n)}const l="the_",u=(null!==(c=null===(r=null==e?void 0:e.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(u))){if(u){const e=yield ho(d,t,n,o,i);s[u]=e}}else{const e=yield ho(d,t,n,o,i);a[u]=e,s=a}}}return s}))}function fo(e,t){let n=b();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class yo{constructor(){this.id=0,this.mainConcept=b(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,o=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield ho(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}));var e,t,n,o}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),n.MQTT_CONNECTION&&n.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const o={};o[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function vo(e){return po(this,arguments,void 0,(function*(e,t=null,n=null,o=null,i=null,r=null,c=null,s=null){const a=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let u=null!=o?o:0,h=b();null==s&&(s=new yo);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield Et(o,"",!0,a,l,d);if(null==t&&null==n){let t=u;h=f,t=f.id,u=f.id,s.concepts.push(f),s.id=f.id,yield vo(e[o],f.id,f.userId,t,i,r,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,y=u;h=f,s.concepts.push(f);const p=yield mt(a,l,f.id,f.userId,y,d,f.userId);s.connections.push(p),yield vo(e[o],f.id,f.userId,y,i,r,c,s)}null!=e[o]&&null!=e[o]&&s.subcompositions.push(f.id)}else{const i=null!=t?t:999,r=null!=n?n:999,c=u,h=yield Et(o,e[o],!1,a,l,d);s.concepts.push(h);const f=yield mt(i,r,h.id,h.userId,c,d,h.userId);s.connections.push(f)}return h}))}var go=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Co(e){return go(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=b(),s=b();const a=[];let l=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(l<0){let e=yield jt(l,t);if(!(e.id>0))return null;l=e.id}i=yield we(l);const h=[],f=new yo,y=[];f.id=l,f.isUpdating();let p=[];for(let e=0;e<i.length;e++)no(y,i[e].ofTheConceptId),no(h,i[e].ofTheConceptId),no(h,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let e=0;e<h.length;e++){const t=yield jt(h[e]);l==h[e]&&(c=t),d==h[e]&&(s=t),r.push(t)}const v=e.patchObject;for(const e in v){let i=b();const l=v[e];let d=c;if(s.id>0&&(d=s),Array.isArray(l)||"object"==typeof l){i=yield Et(e,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const t=oo(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=io(f.connections,t[e].id);u=u.concat(n),a.push(t[e])}yield vo(v[e],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield Et(e,l,!1,t,o,n);const c=oo(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=io(f.connections,c[e].id);u=u.concat(t),a.push(c[e])}}const h=yield mt(d.id,d.userId,i.id,i.userId,c.id,n,t);r.push(i),f.connections.push(h)}for(let e=0;e<u.length;e++)co(f.connections,u[e]),Ot(u[e].id);for(let e=0;e<a.length;e++)ro(r,a[e]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),lo.addCompositionToTree(f),yield vt.SyncDataOnline(),f.GetDataCache()}))}var mo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function To(e,t,o,i){return mo(this,arguments,void 0,(function*(e,t,o,i,r=10,c=1){var s=yield z("application/x-www-form-urlencoded",i),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",o),a.append("inpage",r.toString()),a.append("page",c.toString());const l=n.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield h(l,{method:"GET",headers:s});if(e.ok)return yield e.json();K(e)}catch(e){throw e}}))}var wo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Io(e){return wo(this,arguments,void 0,(function*(e,t=""){var o=yield z("application/json",t);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();K(e)}catch(e){throw e}}))}var No=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ao(e){return No(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},s={};const a=[];let l=yield M.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield me(e));let d=[];d=t.length>0?ko(e,t):yield we(e),i=d;for(let e=0;e<i.length;e++)a.includes(i[e].ofTheConceptId)||(a.push(i[e].ofTheConceptId),r.push(i[e].ofTheConceptId)),r.includes(i[e].toTheConceptId)||r.push(i[e].toTheConceptId);return s=yield Ue(e,i,a,[]),c[null!==(o=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s,0==l.id?"":c}))}function ko(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function So(e){return No(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let s;const a={},l=[];let d=yield M.GetConcept(e);0==d.id&&null!=e&&null!=e&&(d=yield me(e));let u=[];u=t.length>0?ko(e,t):yield we(e),r=u;for(let e=0;e<r.length;e++)l.includes(r[e].ofTheConceptId)||(l.push(r[e].ofTheConceptId),c.push(r[e].ofTheConceptId)),c.includes(r[e].toTheConceptId)||c.push(r[e].toTheConceptId);return s=yield Ue(e,r,l),a[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s,i.created_at=d.entryTimeStamp,i.data=a,i.id=e,0==d.id?"":i}))}function xo(e,t){return No(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Vn(t);for(let t=0;t<e.length;t++){const i=yield So(e[t],n);i&&o.push(i)}return o}))}var Ro=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Eo(e){return Ro(this,void 0,void 0,(function*(){try{var t=yield q();const o=JSON.stringify(e),i=yield h(n.CreateSessionId(),{method:"POST",headers:t,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),K(i),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var _o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Bo(e,t){return _o(this,void 0,void 0,(function*(){try{var o=yield q("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",e.toString()),i.append("url",t);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()),K(r),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Uo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Lo(e,t,o){return Uo(this,arguments,void 0,(function*(e,t,o,i=10,r=1){let c=[];try{var s=new URLSearchParams;s.append("typeId",`${e}`),s.append("toTheConceptId",`${t}`),s.append("userId",`${o}`),s.append("inpage",`${i}`),s.append("page",`${r}`);var a=yield q("application/x-www-form-urlencoded");const l=yield h(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),K(l)),c}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Go(e,t){return Po(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield jt(e),s=yield We(t);if(s.id>0){let e=[],t=[];if(i){t=yield Lo(s.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield ve(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield jt(n),i=yield Re(o.id);r.push(i)}}else{t=yield Lt(s.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield ve(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield jt(n),i=yield Re(o.id);r.push(i)}}}return r}))}function Fo(e,t){return Po(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield jt(e),s=yield We(t),a=[],l=[];if(s.id>0){if(i){a=yield Lo(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield Lt(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}r=yield le(l)}return r}))}class bo{constructor(e,t,n){this.value=new Map,this.connectionValue=new Map,this.key=e,t.id>0&&this.value.set(t.ghostId,t),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Do{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=hn(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=o,this.ghostId=e,this.orderId=i,this.typeCharacter="",this.accessId=r,this.entryTimeStamp=D(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var $o=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Oo{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return $o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isDataLoaded)return e("done");setTimeout(Oo.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){const o=this.compositeKey(t,n,e.applicationId),i=this.nodeMap.get(o);i?e.id>0&&i.value.set(e.ghostId,e):this.nodeMap.set(o,new bo(o,e,new Do(0,0,0,0,0,0)))}static addConnectionToTree(e,t,n=999){const o=this.compositeKey(t,n,e.applicationId),i=this.nodeMap.get(o);i?e.id>0&&i.connectionValue.set(e.ghostId,e):this.nodeMap.set(o,new bo(o,hn(),e))}static getNodeFromTree(e,t){return $o(this,arguments,void 0,(function*(e,t,n=999){var o;const i=this.compositeKey(e,t,n);return null!==(o=this.nodeMap.get(i))&&void 0!==o?o:null}))}static removeNodeFromTree(e){return $o(this,arguments,void 0,(function*(e,t=999,n=999){const o=this.compositeKey(e,t,n);this.nodeMap.delete(o)}))}static countNumberOfNodes(){return this.nodeMap.size}}Oo.nodeMap=new Map;var Vo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Mo(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=999,o=999){var i;let r=yield Oo.getNodeFromTree(e,n,o),c=hn();return r&&(c=null!==(i=r.value.get(t))&&void 0!==i?i:c),c}))}function jo(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=999,o=999){var i;let r=yield Oo.getNodeFromTree(e,n,o),c=new Do(0,0,0,0,0,0);return r&&(c=null!==(i=r.connectionValue.get(t))&&void 0!==i?i:c),c}))}function Ho(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=999){Oo.addConceptToTree(e,t,n)}))}function Wo(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=999){Oo.addConnectionToTree(e,t,n)}))}var Jo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function qo(e){return Jo(this,arguments,void 0,(function*(e,t=""){var o=yield z("application/json",t);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();K(e)}catch(e){throw e}}))}var zo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Qo(e){return zo(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield qo(e,t),i=e[0].composition;const r=o;let c=r.compositionIds,s=r.internalConnections,a=r.linkers,l=r.reverse;return n=yield qn(c,s),yield Ko(a,n,i,l)}))}function Ko(e,t,n){return zo(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield Vn(e);for(let e=0;e<r.length;e++){let n=!1;if(o.includes(r[e].id)&&(n=!0),1==n){if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].toTheConceptId],o=yield jt(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(t[r[e].ofTheConceptId])}catch(e){}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield jt(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(t[r[e].toTheConceptId])}catch(e){}}}return i=t[n],i}))}var Xo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},Yo=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Zo(e){return Yo(this,void 0,void 0,(function*(){var t;let o=yield function(e){return Xo(this,void 0,void 0,(function*(){let t=[];try{var o=yield q();const i=yield h(n.ViewInternalDataUrl(),{method:"POST",headers:o,body:JSON.stringify(e)});if(i.ok){let e=yield i.json(),n={};for(let o=0;o<e.length;o++){let i=e[o].concepts;t=e[o].connections;let r=e[o].id;yield le(i),n[r]=t}return n}return console.log("View Internal Data error",i.status),K(i),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),i=[];for(let n=0;n<e.length;n++){let r=e[n],c=o[r];if(r&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield Ue(r,c,e);t.data=n,t.id=r,i.push(t)}else{let e={};e.id=r;let n=yield jt(r),o={};n.type&&(o[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=o,i.push(e))}}return i}))}function ei(e){const t=b();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}var ti=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},ni=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function oi(e){return ni(this,arguments,void 0,(function*(e,t=""){var o=yield function(e){return ti(this,arguments,void 0,(function*(e,t=""){var o,i,r,c,s,a,l=yield z("application/json",t);const d=new URLSearchParams({composition:String(null!==(o=e.composition)&&void 0!==o?o:""),search:String(null!==(i=e.search)&&void 0!==i?i:""),internalComposition:String(null!==(r=e.internalComposition)&&void 0!==r?r:""),type:String(null!==(c=e.type)&&void 0!==c?c:""),inpage:String(null!==(s=e.inpage)&&void 0!==s?s:""),page:String(null!==(a=e.page)&&void 0!==a?a:"")}),u=`${n.SearchInternalWithAuthenticatedCcsUrl()}?${d.toString()}`;try{const e=yield h(u,{method:"GET",headers:l});if(e.ok)return yield e.json();K(e)}catch(e){throw e}}))}(e,t);return yield Zo(o)}))}var ii=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ri(e,t){return ii(this,void 0,void 0,(function*(){let n=!0,o=yield kn(e),i=yield At(t),r=[];for(let e=0;e<o.length;e++)for(let t=0;t<i.length;t++)o[e].typeId==i[t].id&&r.push(o[e].id);for(let e=0;e<r.length;e++){let t=yield Ot(r[e]);n=n&&t}return n}))}function ci(e,t){return ii(this,void 0,void 0,(function*(){let n=yield kn(e),o=yield At(t),i=[];for(let e=0;e<n.length;e++)for(let t=0;t<o.length;t++)n[e].typeId==o[t].id&&i.push(n[e].id);return i}))}class si{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class ai{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 li{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class di{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}function ui(e){if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()));if("string"!=typeof e)return[];const t=e.trim();if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()))}catch(e){}return t.split(",").map((e=>e.trim())).filter(Boolean)}class hi{constructor(e){var t;this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],this.accessToken="",this.enableAi=!0,this.enableAccessControl=!1,e&&(Object.assign(this,e),this.cacheServers=ui(null!==(t=e.cacheServers)&&void 0!==t?t:e.cache_servers),this.cacheServerUrl=e.cacheServerUrl||e.cacheServer||this.cacheServerUrl)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(e,t=!1){var n,o;return null!==(o=null===(n=this.flags)||void 0===n?void 0:n[e])&&void 0!==o?o:t}getParameter(e,t=""){var n,o;return null!==(o=null===(n=this.parameters)||void 0===n?void 0:n[e])&&void 0!==o?o:t}setFlag(e,t){this.flags||(this.flags={}),this.flags[e]=t}setParameter(e,t){this.parameters||(this.parameters={}),this.parameters[e]=t}}var fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class yi{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),(0!=e.id||e.isTemp)&&k("localconnection",e),this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return fi(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isLocalConnectionLoaded)return e("done");setTimeout(yi.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return fi(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}yi.connectionArray=[],yi.connectionDictionary=[];var pi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function vi(){return pi(this,void 0,void 0,(function*(){yield function(){return pi(this,void 0,void 0,(function*(){var e=yield x("connection");if(Array.isArray(e))for(var t=0;t<e.length;t++)se.AddConnectionToMemory(e[t])}))}()}))}function gi(){return pi(this,void 0,void 0,(function*(){yield function(){return pi(this,void 0,void 0,(function*(){var e=yield E("localconnection");if(Array.isArray(e))for(var t=0;t<e.length;t++)yi.AddConnection(e[t])}))}()}))}class Ci{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var mi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Ti{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new Ci(e.id,e,null,null);new Ci(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return mi(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isLocalDataLoaded)return e("done");setTimeout(Ti.checkFlag,1e3,e)}static getNodeFromTree(e){return mi(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return mi(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Ti.root=null;var wi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Ii{static waitForDataToLoad(){return wi(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isLocalCharacterLoaded)return e("done");setTimeout(Ii.checkFlag,1e3,e)}static addNodeToTree(e){return wi(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new Ci(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return wi(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}Ii.LocalCharacterRoot=null;var Ni=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Ai{static addNodeToTree(e){return Ni(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new Ci(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return Ni(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(_.isLocalTypeLoaded)return e("done");setTimeout(Ai.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Ni(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}Ai.LocalTypeRoot=null;var ki=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Si{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(k("localconcept",e),Ti.addConceptToTree(e),Ii.addConceptToTree(e),Ai.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Ti.addConceptToTree(e),Ii.addConceptToTree(e),Ai.addConceptToTree(e))}static GetConcept(e){return ki(this,void 0,void 0,(function*(){var t=hn(),n=yield Ti.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return ki(this,void 0,void 0,(function*(){var t=hn(),n=Ii.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return ki(this,void 0,void 0,(function*(){var n=hn(),o=yield Ii.getCharacterAndTypeFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return ki(this,void 0,void 0,(function*(){let n=[];return n=yield Ai.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Si.localconceptsArray=[];var xi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Ri(){return xi(this,void 0,void 0,(function*(){var e=yield E("localconcept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Si.AddConceptToMemory(n)}}))}var Ei=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class _i{}_i.isUpdated=!1,_i.isOnlineSync=!1;var Bi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Ui{constructor(){this.accessCache=new Map,this.accessIndex=new Map,this.entityIndex=new Map,this.setCounter=0}generateKey(e,t,n){return`${e}:${t.toLowerCase()}:${null!=n?n:0}`}get(e,t,n){const o=this.generateKey(e,t,n),i=this.accessCache.get(o);return void 0===i?null:Date.now()>i.expiresAt?(this.accessCache.delete(o),null):i.value}set(e,t,n,o){const i=this.generateKey(e,t,n);this.accessCache.set(i,{value:o,expiresAt:Date.now()+3e5}),this.accessIndex.has(e)||this.accessIndex.set(e,new Set),this.accessIndex.get(e).add(i);const r=null!=n?n:0;this.entityIndex.has(r)||this.entityIndex.set(r,new Set),this.entityIndex.get(r).add(i),this.setCounter++,this.setCounter>=100&&(this.setCounter=0,this.sweepExpired())}remove(e,t,n){const o=this.generateKey(e,t,n);this.accessCache.delete(o);const i=this.accessIndex.get(e);i&&i.delete(o);const r=null!=n?n:0,c=this.entityIndex.get(r);c&&c.delete(o)}clear(){this.accessCache.clear(),this.accessIndex.clear(),this.entityIndex.clear(),this.setCounter=0}sweepExpired(){const e=Date.now();for(const[t,n]of this.accessCache)if(e>n.expiresAt){this.accessCache.delete(t);const e=t.split(":"),n=parseInt(e[0]),o=parseInt(e[2]),i=this.accessIndex.get(n);i&&(i.delete(t),0===i.size&&this.accessIndex.delete(n));const r=this.entityIndex.get(o);r&&(r.delete(t),0===r.size&&this.entityIndex.delete(o))}for(const[t,n]of Ui.superAdminCache)e>n.expiresAt&&Ui.superAdminCache.delete(t)}getPermissionsByAccessAndEntity(e,t){const n=new Map,o=this.accessIndex.get(e),i=Date.now();if(o){const e=null!=t?t:0;for(const t of o){const o=this.accessCache.get(t);if(o&&i<=o.expiresAt){const i=t.split(":");parseInt(i[2])===e&&n.set(i[1],o.value)}}}return n}getPermissionsByAccess(e){const t=new Map,n=this.accessIndex.get(e),o=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&o<=n.expiresAt){const o=e.split(":"),i=parseInt(o[2]),r=o[1];t.set(`${i}:${r}`,n.value)}}return t}getPermissionsByEntity(e){const t=new Map,n=this.entityIndex.get(e),o=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&o<=n.expiresAt){const o=e.split(":"),i=parseInt(o[0]),r=o[1];t.set(`${i}:${r}`,n.value)}}return t}getSuperAdmin(e){const t=Ui.superAdminCache.get(e);return void 0===t?null:Date.now()>t.expiresAt?(Ui.superAdminCache.delete(e),null):t.value}setSuperAdmin(e,t){Ui.superAdminCache.set(e,{value:t,expiresAt:Date.now()+6e5})}clearSuperAdminCache(){Ui.superAdminCache.clear()}}Ui.superAdminCache=new Map;var Li,Pi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class Gi{constructor(e){if(this.baseUrl=e||process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("Access Control base URL is not configured")}getAsync(e){return Pi(this,void 0,void 0,(function*(){const t=yield fetch(`${this.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`GET '${e}' failed with status ${t.status}`);const n=yield t.json();if(null==n)throw new Error(`The response for GET '${e}' returned null.`);return n}))}postAsync(e,t){return Pi(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST '${e}' failed with status ${n.status}`);const o=yield n.json();if(null==o)throw new Error(`The response for POST '${e}' returned null.`);return o}))}deleteAsync(e,t){return Pi(this,void 0,void 0,(function*(){const n={method:"DELETE",headers:{"Content-Type":"application/json"}};null!=t&&(n.body=JSON.stringify(t));const o=yield fetch(`${this.baseUrl}/${e}`,n);if(!o.ok)throw new Error(`DELETE '${e}' failed with status ${o.status}`);const i=yield o.json();if(null==i)throw new Error(`The response for DELETE '${e}' returned null.`);return i}))}assignAccessAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/assign",e)}))}checkAccessAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/check",e)}))}revokeAccessAsync(e){return Pi(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke",e)}))}assignAccessBulkAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/assign/bulk",e)}))}revokeAccessBulkAsync(e){return Pi(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke/bulk",e)}))}checkAccessBulkAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/check/bulk",e)}))}getAccessByIdAsync(e){return Pi(this,void 0,void 0,(function*(){return this.getAsync(`access/${e}`)}))}setAccessInheritanceAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance",e)}))}getAccessInheritanceStatusAsync(e){return Pi(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/status?accessId=${e}&connectionTypeId=${t}`)}))}assignSuperAdminAccessAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin",e)}))}revokeSuperAdminAccessAsync(e){return Pi(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin",e)}))}checkSuperAdminStatusAsync(e){return Pi(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin?accessId=${e}`)}))}setParentAccessInheritanceAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent",e)}))}removeParentAccessInheritanceAsync(e,t){return Pi(this,void 0,void 0,(function*(){let n=`access/inheritance/parent?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.deleteAsync(n)}))}hasParentAccessInheritanceAsync(e,t){return Pi(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/status?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.getAsync(n)}))}getParentAccessIdAsync(e){return Pi(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent?accessId=${e}`)}))}setParentAccessInheritanceByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept",e)}))}setParentAccessInheritanceBulkByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept/bulk",e)}))}removeParentAccessInheritanceByConceptAsync(e,t){return Pi(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.deleteAsync(n)}))}removeParentAccessInheritanceBulkByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.deleteAsync("access/inheritance/parent/concept/bulk",e)}))}hasParentAccessInheritanceByConceptAsync(e,t){return Pi(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept/status?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.getAsync(n)}))}getParentAccessIdByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent/concept?childConceptId=${e}`)}))}assignSuperAdminByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin/concept",e)}))}revokeSuperAdminByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin/concept",e)}))}checkSuperAdminByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin/concept?conceptId=${e}`)}))}setAccessInheritanceByConceptAsync(e){return Pi(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/concept",e)}))}getAccessInheritanceStatusByConceptAsync(e){return Pi(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/concept/status?conceptId=${e}&connectionTypeId=${t}`)}))}}!function(e){e[e.None=0]="None",e[e.Read=1]="Read",e[e.Write=2]="Write",e[e.Execute=4]="Execute",e[e.Delete=8]="Delete"}(Li||(Li={}));var Fi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class bi{static initialize(){console.log("AccessControlService initialized with access control disabled by default.")}static setEnabled(e){this.isAccessControlEnabled=e}static getEnabled(){return this.isAccessControlEnabled}static setBaseUrl(e){this.apiClient=new Gi(e)}static checkAccess(e,t,n){return Fi(this,void 0,void 0,(function*(){var o;if(t===Li.None)throw new Error("Permission is required");return null!==(o=(yield this.checkAccessBulk([e],t,n)).get(e))&&void 0!==o&&o}))}static checkAccessBulk(e,t,o){return Fi(this,void 0,void 0,(function*(){var i,r,c,s,a,l;if(t===Li.None)throw new Error("Permission is required");const d=this.permissionSetToString(t),u=new Map;if(!e||0===e.length)return u;if(!this.isAccessControlEnabled){for(const t of e)u.set(t,!0);return u}if(null!=o&&o>0)try{if(yield this.isSuperAdmin(o)){for(const t of e)u.set(t,!0);return u}}catch(e){}const f=[],y=new Set,p=new Map;let v=null;if(null!=o&&o>0)try{v=yield jt(o)}catch(e){}let g=0;try{const e=yield function(){return e=this,t=void 0,i=function*(){let e=b();try{var t=yield q("application/x-www-form-urlencoded");const o=yield h(n.GetConceptByCharacterAndCategoryUrl(),{method:"POST",headers:t,body:"character_value=the_parent_access_inheritance"});return o.ok?(e=yield o.json(),M.AddConcept(e)):(console.log("This is the concept by category and character error",o.status),K(o)),e}catch(e){throw e instanceof Error?console.log(" This is the concept by category and character error message: ",e.message):console.log(" This is the concept by category and character unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(n,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((i=i.apply(e,t||[])).next())}));var e,t,o,i}();e&&e.id&&(g=e.id)}catch(e){}const C=yield le(e),m=new Map;for(const e of C)m.set(e.id,e);const T=new Map;for(const t of e){const e=null!==(i=m.get(t))&&void 0!==i?i:yield jt(t);if(!e||0===e.id){u.set(t,!1);continue}const n=null!==(r=e.accessId)&&void 0!==r?r:0,o=null!==(c=e.typeId)&&void 0!==c?c:0;if(v&&v.userId&&v.userId===e.userId){u.set(t,!0);continue}if(n<1e4){u.set(t,!0);continue}let a=0;if(o>0){let e=T.get(o);if(!e)try{e=yield jt(o),T.set(o,e)}catch(e){}e&&(a=null!==(s=e.accessId)&&void 0!==s?s:0)}f.push({conceptId:t,accessId:n,typeAccessId:a}),n>0&&(y.add(n),p.set(n,t)),a>0&&y.add(a)}if(0===f.length)return u;const w=yield this.resolveBulkInheritanceGraph(y,g,p),I=[],N=new Set;for(const e of w.values())for(const t of e)N.has(t)||(N.add(t),I.push(t));const A=yield this.resolveSubjects(o),k=yield this.resolveBulkDecisions(I,d,A);for(const e of f){const t=null!==(a=w.get(e.accessId))&&void 0!==a?a:[e.accessId],n=e.typeAccessId>0?null!==(l=w.get(e.typeAccessId))&&void 0!==l?l:[e.typeAccessId]:[],o=this.hasAnyGrant(t,n,A,k);u.set(e.conceptId,o)}return u}))}static getConceptIdsWithPermission(e,t,n){return Fi(this,void 0,void 0,(function*(){if(e===Li.None)throw new Error("Permission is required");if(!t||0===t.length)return[];if(!this.isAccessControlEnabled)return t;const o=yield this.checkAccessBulk(t,e,n);return t.filter((e=>!0===o.get(e)))}))}static resolveBulkInheritanceGraph(e,t,n){return Fi(this,void 0,void 0,(function*(){var o;const i=new Map,r=new Set;let c=new Set(e),s=0;for(;c.size>0;){if(s>=10){console.warn("[AccessControl] BFS depth limit (10) reached. Stopping inheritance traversal.");break}s++;const e=new Set;for(const e of c)r.add(e);const a=Array.from(c);if(t>0)for(const t of a)try{const n=yield ci(t,["the_parent_access_inheritance"]);if(n&&n.length>0){const o=yield Vn(n);for(const n of o){const o=n.toTheConceptId;o&&o>0&&!r.has(o)&&(i.has(t)||i.set(t,[]),i.get(t).push(o),e.add(o))}}}catch(e){}for(const t of a)try{const n=yield this.apiClient.getParentAccessIdAsync(t);if(!0===(null==n?void 0:n.status)&&void 0!==n.data&&null!==n.data){const o=this.parseIntData(n);null!==o&&o>0&&!r.has(o)&&(i.has(t)||i.set(t,[]),i.get(t).push(o),e.add(o))}}catch(e){}for(const c of a)try{const s=yield this.apiClient.getAccessInheritanceStatusAsync(c);if(!this.parseBoolData(s))continue;const a=n.get(c);if(!a||0===a)continue;const l=yield kn(a);if(!l||0===l.length)continue;for(const s of l){if(s.ofTheConceptId!==a)continue;if(t>0&&s.typeId!==t)continue;const l=s.toTheConceptId;if(l&&0!==l)try{const t=yield jt(l),s=null!==(o=null==t?void 0:t.accessId)&&void 0!==o?o:0;s>0&&!r.has(s)&&(i.has(c)||i.set(c,[]),i.get(c).push(s),n.set(s,l),e.add(s))}catch(e){}}}catch(e){}for(const t of r)e.delete(t);c=e}const a=new Map;for(const t of e){const e=[t],n=new Set([t]),o=[t];for(;o.length>0&&e.length<100;){const t=o.shift(),r=i.get(t);if(r)for(const t of r)n.has(t)||(n.add(t),e.push(t),o.push(t))}a.set(t,e)}return a}))}static resolveBulkDecisions(e,t,n){return Fi(this,void 0,void 0,(function*(){var o;const i=new Map,r=new Map;for(let o=0;o<n.length;o++){const c=n[o];for(const n of e){const e=this.cacheService.get(n,t,c),s=`${n}:${null!=c?c:0}`;null!==e?i.set(s,e):(r.has(o)||r.set(o,[]),r.get(o).push(n))}}for(const[e,c]of r){if(0===c.length)continue;const r=n[e];try{const e={accessIds:c,permission:t,entityId:r},n=yield this.apiClient.checkAccessBulkAsync(e);if(!0===(null==n?void 0:n.status)&&n.data&&Array.isArray(n.data)){const e=new Map;for(const t of n.data)e.set(t.accessId,t.hasAccess);for(const n of c){const c=null!==(o=e.get(n))&&void 0!==o&&o;this.cacheService.set(n,t,r,c),i.set(`${n}:${null!=r?r:0}`,c)}}else for(const e of c)this.cacheService.set(e,t,r,!1),i.set(`${e}:${null!=r?r:0}`,!1)}catch(e){for(const e of c)i.set(`${e}:${null!=r?r:0}`,!1)}}return i}))}static resolveSubjects(e){return Fi(this,void 0,void 0,(function*(){const t=[null];if(null!=e&&e>0){t.push(e);try{const n=yield ci(e,["the_entity_s_group"]);if(n&&n.length>0){const e=yield Vn(n);for(const n of e)n.toTheConceptId&&n.toTheConceptId>0&&t.push(n.toTheConceptId)}}catch(e){}}return t}))}static hasAnyGrant(e,t,n,o){for(const t of e)for(const e of n){const n=`${t}:${null!=e?e:0}`;if(!0===o.get(n))return!0}for(const e of t)for(const t of n){const n=`${e}:${null!=t?t:0}`;if(!0===o.get(n))return!0}return!1}static assignAccess(e,t,n){return Fi(this,void 0,void 0,(function*(){var o;if(t===Li.None)throw new Error("Permission is required");try{const i=null!==(o=(yield jt(e)).accessId)&&void 0!==o?o:0,r=this.permissionSetToString(t),c=yield this.apiClient.assignAccessAsync({accessId:i,permission:r,entityId:n});if(!0===(null==c?void 0:c.status)&&c.data){const e=c.data;return this.cacheService.set(e.accessId,e.permission,e.entityId,e.hasAccess),!0}return!1}catch(o){throw new Error(`Error assigning access for conceptId ${e}, permission '${t}', entityId ${n}: ${o}`)}}))}static assignAccessBulk(e){return Fi(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{const n=yield this.apiClient.assignAccessBulkAsync(e);if(!0!==(null==n?void 0:n.status))throw new Error((null==n?void 0:n.message)||"Failed to assign bulk access");const o=[];for(const n of e.targets)for(const i of n.permissions){const r=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(r,i,n.entityId,!0),o.push({accessId:r,permission:i,entityId:n.entityId,hasAccess:!0})}return o}catch(e){throw console.error("Failed to assign bulk access:",e),e}}))}static revokeAccess(e,t,n){return Fi(this,void 0,void 0,(function*(){var o;try{const i=null!==(o=(yield jt(e)).accessId)&&void 0!==o?o:0,r=this.permissionSetToString(t);if(0===i)throw new Error(`Concept with ID ${e} does not have a valid accessId`);const c=yield this.apiClient.revokeAccessAsync({accessId:i,permission:r,entityId:n}),s=!0===(null==c?void 0:c.status);return this.cacheService.set(i,r,n,!s),s}catch(o){throw new Error(`Error revoking access for concept ${e}, permission '${t}', entityId ${n}: ${o}`)}}))}static revokeAccessBulk(e){return Fi(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{yield this.apiClient.revokeAccessBulkAsync(e);const n=[];for(const o of e.targets)for(const i of o.permissions){const r=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(r,i,o.entityId,!1),n.push({accessId:r,permission:i,entityId:o.entityId,hasAccess:!1})}return n}catch(e){throw console.error("Failed to revoke bulk access:",e),e}}))}static setAccessInheritance(e){return Fi(this,void 0,void 0,(function*(){var t;try{const n=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,connectionTypeId:999});return null!==(t=null==n?void 0:n.status)&&void 0!==t&&t}catch(t){throw new Error(`Error setting access inheritance for conceptId ${e}: ${t}`)}}))}static getAccessInheritanceStatus(e){return Fi(this,arguments,void 0,(function*(e,t=999){try{const n=yield this.apiClient.getAccessInheritanceStatusByConceptAsync(e,t);return this.parseBoolData(n)}catch(n){throw new Error(`Error getting access inheritance status for conceptId ${e}, connectionTypeId ${t}: ${n}`)}}))}static setAccessInheritanceStatus(e,t){return Fi(this,arguments,void 0,(function*(e,t,n=999){var o;try{const i=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,enable:t,connectionTypeId:n});return null!==(o=null==i?void 0:i.status)&&void 0!==o&&o}catch(t){throw new Error(`Error setting access inheritance status for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritance(e,t){return Fi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceByConceptAsync({parentConceptId:t,childConceptId:e});if(!0===(null==n?void 0:n.status)){const e=this.parseIntData(n);if(null!==e&&e>0)return e}return 0}catch(t){throw new Error(`Error setting parent access inheritance for conceptId ${e}: ${t}`)}}))}static removeParentAccessInheritance(e,t){return Fi(this,void 0,void 0,(function*(){var n;try{const o=yield this.apiClient.removeParentAccessInheritanceByConceptAsync(e,t);return null!==(n=null==o?void 0:o.message)&&void 0!==n?n:"Parent access inheritance removal failed"}catch(t){throw new Error(`Error removing parent access inheritance for conceptId ${e}: ${t}`)}}))}static hasParentAccessInheritance(e,t){return Fi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.hasParentAccessInheritanceByConceptAsync(e,t);return this.parseBoolData(n)}catch(t){throw new Error(`Error checking parent access inheritance for conceptId ${e}: ${t}`)}}))}static getParentAccessId(e){return Fi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.getParentAccessIdByConceptAsync(e);return this.parseIntData(t)}catch(t){throw new Error(`Error getting parent access ID for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritanceBulk(e,t){return Fi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceBulkByConceptAsync({parentConceptId:t,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error setting bulk parent access inheritance for parentConceptId ${t}: ${e}`)}}))}static removeParentAccessInheritanceBulk(e,t){return Fi(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.removeParentAccessInheritanceBulkByConceptAsync({parentConceptId:null!=t?t:0,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error removing bulk parent access inheritance: ${e}`)}}))}static isSuperAdmin(e){return Fi(this,void 0,void 0,(function*(){try{if(0===e)return!1;const t=this.cacheService.getSuperAdmin(e);if(null!==t)return t;const n=yield this.apiClient.checkSuperAdminByConceptAsync(e);if(!0===(null==n?void 0:n.status)&&void 0!==n.data){const t=this.parseBoolData(n);return this.cacheService.setSuperAdmin(e,t),t}return!1}catch(t){throw new Error(`Error checking super admin status for entityId ${e}: ${t}`)}}))}static assignSuperAdmin(e){return Fi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.assignSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&void 0!==t.data?(this.cacheService.setSuperAdmin(e,!0),e):0}catch(t){throw new Error(`Failed to assign super admin for entityId ${e}: ${t}`)}}))}static revokeSuperAdmin(e){return Fi(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.revokeSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&t.message?(this.cacheService.setSuperAdmin(e,!1),t.message):"Super admin access deletion failed"}catch(t){throw new Error(`Failed to revoke super admin for entityId ${e}: ${t}`)}}))}static parseBoolData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return!1;const t=e.data;if("boolean"==typeof t)return t;if("string"==typeof t)return"true"===t.toLowerCase();if("number"==typeof t)return 0!==t;if("object"==typeof t)for(const e of["enabled","Enabled","isEnabled","IsEnabled","status","Status","hasAccess","HasAccess"])if(e in t){const n=t[e];if("boolean"==typeof n)return n;if("string"==typeof n)return"true"===n.toLowerCase()}return!1}static parseIntData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return null;const t=e.data;if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?null:e}if("object"==typeof t)for(const e of["id","Id","accessId","AccessId","parentAccessId","ParentAccessId"])if(e in t){const n=t[e];if("number"==typeof n)return n;if("string"==typeof n){const e=parseInt(n,10);if(!isNaN(e))return e}}return null}static permissionSetToString(e){return function(e){const t=[];return e&Li.Read&&t.push("read"),e&Li.Write&&t.push("write"),e&Li.Execute&&t.push("execute"),e&Li.Delete&&t.push("delete"),t}(e)[0]||"read"}static clearCache(){this.cacheService.clear()}static clearSuperAdminCache(){this.cacheService.clearSuperAdminCache()}static updateAccessCache(e,t,n,o){this.cacheService.set(e,t,n,o)}static updateSuperAdminCache(e,t){this.cacheService.setSuperAdmin(e,t)}}bi.cacheService=new Ui,bi.apiClient=new Gi,bi.isAccessControlEnabled=!1,bi.initialize();var Di=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};const $i=1,Oi=2,Vi=3,Mi=4,ji=5,Hi=6,Wi=7,Ji=8;class qi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var zi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Qi(e){return zi(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield me(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]||(t[e[n].conceptId]=[]),t[e[n].conceptId].push(e[n])}return t}))}function Ki(e){const t=e.split("_");if(3===t.length){let e=new qi;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function Xi(e){return e.startsWith("the_")?e.slice(4):e}var Yi=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Zi(e,t,n){if(e in t){const o=Array.isArray(t[e])?t[e]:[t[e]];for(const e of o)e&&(n[e.connectionType+"_count"]=e.count)}}var er=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))},tr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function nr(e,t,n){return tr(this,void 0,void 0,(function*(){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield jt(e[u].ofTheConceptId),y=yield jt(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[s]={},t[e[u].toTheConceptId]=n);let a=yield jt(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;a.characterValue,a.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield jt(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}var or=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function ir(e,t="DESC"){return"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var rr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};var cr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function sr(e,t){return cr(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=Hi;let o,i=yield function(e){return Di(this,arguments,void 0,(function*(e,t=""){var o=yield z("application/json",t);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(e);try{const e=yield h(i,{method:"POST",headers:o,body:r});if(e.ok)return yield e.json();K(e)}catch(e){!function(e,t=""){if(e.status){let n=new Q(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new Q(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,i)}}))}(e,""),r=i.conceptIds,c=(i.internalConnections,i.linkers),s=i.reverse,a=i.mainCompositionIds,l=i.countinfo,d=e.order,u=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let o=Ki(e[n]);t.push(o)}return t}(l);return o=t==Oi?yield function(e,t,n,o,i){return rr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield Qi(i);c=ir(c,r);let a=[];a=yield function(e,t){return er(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield jt(e[u].ofTheConceptId),y=yield jt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield jt(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?n=t[e[u].toTheConceptId]:(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(s.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[y.id]={}}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield jt(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?n=t[e[u].ofTheConceptId]:(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}(c,a,o),a=yield function(e,t){return er(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield jt(e[u].ofTheConceptId),y=yield jt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield jt(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=Xi(o));let i={id:f.id,data:{[e]:t}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield jt(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=o.characterValue,c=!1;""==r&&(r=e,r=Xi(r),c=!0);let s={id:y.id,data:{[e]:t}};isNaN(Number(r))?r.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][r]=s):(Array.isArray(n[i])||(n[i]=[]),n[i].push(s))}catch(e){}}}return t}))}(c,a,o);let l=yield function(e,t,n,o){return er(this,arguments,void 0,(function*(e,t,n,o,i=[],r){var c,s,a,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let o=!1,f=yield jt(e[n].ofTheConceptId),y=yield jt(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=f.id&&0!=y.id&&y.id in t){let o,i=yield jt(e[n].typeId),a=null!==(s=null===(c=y.type)||void 0===c?void 0:c.characterValue)&&void 0!==s?s:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[a]&&(o[a]={})):(o={},o[a]={},t[e[n].toTheConceptId]=o),Zi(y.id,r,o);try{if(t[e[n].ofTheConceptId]){let r={id:f.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(e){}}}else if(0!=f.id&&0!=y.id&&f.id in t){let o,i=yield jt(e[n].typeId),c=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),Zi(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 s=t[e[n].toTheConceptId];if(s){let a={id:y.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(s):Array.isArray(o[c][v])?o[c][i.characterValue].push(a):v.includes("_s_")?(o[c][v]=[],o[c][v].push(a)):o[c][v]=a,Zi(y.id,r,a)}}catch(e){}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e];let i=yield jt(n.id);n.data=t[o[e]],n.created_on=i.entryTimeStamp,f.push(n)}return f}))}(c,a,[],n,o,s);return l}))}(c,r,a,s,u,d):t==Vi?yield function(e,t,n,o,i){return rr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield Qi(i);c=ir(c,r);let a=[];a=yield nr(c,a,o),a=yield function(e,t){return Yi(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);for(let u=0;u<e.length;u++){let h=!1,f=yield jt(e[u].ofTheConceptId),y=yield jt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield jt(e[u].typeId),a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[u].toTheConceptId]=n);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=Xi(o));let i={id:f.id,[e]:t},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=yield jt(e[u].typeId),i=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},t[e[u].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",r=y.characterValue,c=o.characterValue,s=!1;""==c&&(c=t,c=Xi(c),s=!0);let a={};a[t]={id:y.id,data:r,created_on:e[u].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][c]=s?a[t]:a):(Array.isArray(n[i])||(n[i]=[]),n[i].push(a[t]))}catch(e){}}}return t}))}(c,a,o);let l=yield function(e,t,n){return Yi(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,s,a,l,d,u,h;(new Date).getTime();let f=[],y=[];for(let t=0;t<e.length;t++)y.push(e[t].toTheConceptId),y.push(e[t].ofTheConceptId),y.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,y=yield jt(e[n].ofTheConceptId),p=yield jt(e[n].toTheConceptId);if(o.includes(e[n].id)&&(f=!0),1==f){if(0!=y.id&&0!=p.id&&p.id in t){let o,i=yield jt(e[n].typeId),s=null!==(c=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].toTheConceptId in t?(o=t[e[n].toTheConceptId],"string"==typeof o[s]&&(o[s]={})):(o={},o[s]={},t[e[n].toTheConceptId]=o);try{if(t[e[n].ofTheConceptId]){let r=t[e[n].ofTheConceptId];r&&(r.id=y.id,r.created_on=y.entryTimeStamp);let 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(e){}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield jt(e[n].typeId),c=null!==(a=null===(s=y.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[c]&&(o[c]={})):(o={},o[c]={},t[e[n].ofTheConceptId]=o),Zi(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",s=t[e[n].toTheConceptId];if(s){let t={};t[r]={data:s[r],id:p.id,created_on:e[n].entryTimeStamp},Array.isArray(o[c])?v?o[c].push(s[g]):o[c].push(s):Array.isArray(o[c][g])?o[c][g].push(t):g.includes("_s_")?(o[c][g]=[],v?o[c][g].push(t[r]):o[c][g].push(t)):o[c][g]=v?t[r]:t,Zi(p.id,i,t)}}catch(e){}}}for(let e=0;e<n.length;e++){let o={};o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,a,n,o,s);return l}))}(c,r,a,s,u,d):t==Ji?yield function(e,t,n,o,i){return rr(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Jn(e),s=yield Qi(i);c=ir(c,r);let a={};a=yield function(e){return or(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,s;for(const a of e){const e=n.includes(a.id),l=yield jt(a.ofTheConceptId),d=yield jt(a.toTheConceptId),u=yield jt(a.typeId);if(0===l.id||0===d.id)continue;const h=e?d:l,f=e?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(s=u.characterValue)||void 0===s?void 0:s.includes("_s_");t[h.id]||(t[h.id]={}),t[h.id][y]||(t[h.id][y]={}),g&&(t[f.id]||(t[f.id]={}),t[f.id][p]=v)}return t}))}(c,a,o),a=yield function(e){return or(this,arguments,void 0,(function*(e,t={},n=[]){var o,i,r,c,s;for(const a of e){const e=n.includes(a.id),l=yield jt(a.ofTheConceptId),d=yield jt(a.toTheConceptId),u=yield jt(a.typeId);if(0===l.id||0===d.id)continue;const h=e?d:l,f=e?l:d,y=null!==(i=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self",p=null!==(c=null===(r=f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=u.characterValue)&&void 0!==s?s:"";let C=""===g?Xi(p):g;const m=C.includes("_s_"),T=!isNaN(Number(C)),w={id:f.id,data:{[p]:v}};t[h.id]||(t[h.id]={}),y in t[h.id]&&"string"!=typeof t[h.id][y]||(t[h.id][y]=T?[]:{});try{if(m)continue;T?t[h.id][y].push(w):t[h.id][y][e?`${C}_reverse`:C]=w}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,o);let l=yield function(e,t,n){return or(this,arguments,void 0,(function*(e,t,n,o=[],i){var r,c,s;const a=[];for(const n of e){const e=o.includes(n.id),a=yield jt(n.ofTheConceptId),l=yield jt(n.toTheConceptId),d=yield jt(n.typeId);if(0===a.id||0===l.id)continue;const u=e?l:a,h=e?a: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===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const o=t[f][p],r=t[y],c={id:h.id,data:r,created_on:n.entryTimeStamp};Zi(f,i,t[f]);try{e?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(r):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],Zi(y,i,c)}catch(e){console.error("Error processing connection:",e)}}}for(const e of n){const n=yield jt(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,o,s);return l}))}(c,r,a,s,u,d):yield function(e,t,n,o){return rr(this,void 0,void 0,(function*(){let t=yield Jn(e);t=ir(t);let i=[];i=yield nr(t,i,o),i=yield function(e,t,n){return tr(this,void 0,void 0,(function*(){var o,i,r,c,s,a,l,d;let u=[];for(let t=0;t<e.length;t++)u.push(e[t].toTheConceptId),u.push(e[t].ofTheConceptId),u.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let u=0;u<e.length;u++){let h=!1;n.includes(e[u].id)&&(h=!0);let f=yield jt(e[u].ofTheConceptId),y=yield jt(e[u].toTheConceptId);if(1==h){if(0!=f.id&&0!=y.id){let n,s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";e[u].toTheConceptId in t?(n=t[e[u].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[u].toTheConceptId]=n);let a=yield jt(e[u].typeId);try{let e=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=Xi(o));let i={[e]:t},l=o+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[u].ofTheConceptId in t?(n=t[e[u].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[u].ofTheConceptId]=n);let i=yield jt(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",t=y.characterValue,r=i.characterValue,c=(i.characterValue,!1);""==r&&(r=e,r=Xi(r),c=!0);let s={[e]:t};isNaN(Number(r))?i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][r]=c?t:s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){}}}return t}))}(t,i,o);let r=yield function(){return tr(this,arguments,void 0,(function*(e=[],t=[],n=[],o,i=[]){var r,c,s,a,l,d;let u=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let o=!1;i.includes(e[n].id)&&(o=!0);let u=yield jt(e[n].ofTheConceptId),h=yield jt(e[n].toTheConceptId);if(1==o){if(0!=u.id&&0!=h.id&&h.id in t){let o,i=null!==(c=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?o=t[e[n].toTheConceptId]:(o={},o[i]={},t[e[n].toTheConceptId]=o);let s=yield jt(e[n].typeId);try{let r=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):s.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(e){}}}else if(0!=u.id&&0!=h.id&&u.id in t){let o,i=null!==(a=null===(s=u.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[n].ofTheConceptId in t?(o=t[e[n].ofTheConceptId],"string"==typeof o[i]&&(o[i]={})):(o={},o[i]={},t[e[n].ofTheConceptId]=o);let r=!1,c=(yield jt(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,r=!0),""==c&&(c=null!==(d=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(o[i])?r?o[i].push(s[c]):o[i].push(s):Array.isArray(o[i][c])?o[i][c].push(s):c.includes("_s_")?(o[i][c]=[],r?o[i][c].push(s[c]):o[i][c].push(s)):o[i][c]=r?s[c]:s)}catch(e){}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],u.push(o))}return u}))}(t,i,n,[],o);return r}))}(c,0,a,s),o}))}class ar{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=$i,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var lr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function dr(e,t){return lr(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield xn(e),i=yield Qe(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield kn(e);for(let e=0;e<n.length;e++)se.AddConnection(n[e]);let i=yield Qe(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function ur(e,t,n){return lr(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield dr(t,n,o):yield dr(e,n,o),o)for(let t=0;t<i.length;t++)i[t].ofTheConceptId==e&&r.push(i[t]);else for(let e=0;e<i.length;e++)i[e].toTheConceptId==t&&r.push(i[e]);return r}))}var hr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function fr(e){return hr(this,void 0,void 0,(function*(){try{const t=yield q(),o=yield h(n.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw console.log("GetConnectionsBetweenApi error status: ",o.status),K(o),new Error(`GetConnectionsBetweenApi error: ${o.status}`);return yield o.json()}catch(e){throw e instanceof Error?console.log("GetConnectionsBetweenApi error message: ",e.message):console.log("GetConnectionsBetweenApi unexpected error: ",e),e}}))}function yr(e){var t,n,o,i,r,c,s;return{ofTheConceptId:null!==(t=e.ofTheConceptId)&&void 0!==t?t:0,toTheConceptId:null!==(n=e.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(o=e.typeId)&&void 0!==o?o:0,type:null!==(i=e.type)&&void 0!==i?i:"",oldType:null!==(r=e.oldType)&&void 0!==r?r:"",reverse:null!==(c=e.reverse)&&void 0!==c&&c,isComposition:null!==(s=e.isComposition)&&void 0!==s&&s,connectionIds:[]}}var pr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};class vr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return pr(this,void 0,void 0,(function*(){yield vt.initializeTransaction(this.transactionId)}))}markAction(){return pr(this,void 0,void 0,(function*(){yield vt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return pr(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield vt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return pr(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield vt.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Vt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return pr(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return pr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const t=e.map(yr),n=yield fr(t),o=[];for(const e of n)o.push(...e.connectionIds);return this.pendingConnectionDeletions.push(...o),o}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return pr(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield Et(e,t,n,o,i,r,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTypeConcept(e,t){return pr(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),o=("number"==typeof e?4:e.accessId),i=999){try{if(!this.success)throw Error("Query Transaction Expired");return yield sn(e,t,n,o,i)}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return pr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Tt(e,t,n,this.actions);return yield this.markAction(),o}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheTypeConcept(e,t,n,o){return pr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield Nn(e,t,n,o,this.actions);return yield this.markAction(),i}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,o,i,r,c){return pr(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const d=yield mt(e,t,n,o,i,r,c,s,a,l,this.actions);return yield this.markAction(),d}catch(e){throw console.log(e),this.success=!1,e}}))}}var gr=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((o=o.apply(e,t||[])).next())}))};function Cr(e=""){o.BearerAccessToken=e}function mr(){return gr(this,arguments,void 0,(function*(e="",t="",i="CCSApp",c){var s,a;const l=c||new hi;bi.setBaseUrl(l.accessControlBaseUrl),bi.setEnabled(l.enableAccessControl),n.BASE_URL=e,n.AI_URL=l.aiUrl,t&&(n.NODE_URL=t);const d=l.cacheServers.length>0?l.cacheServers:ui(null!==(a=null===(s=l.parameters)||void 0===s?void 0:s.cacheServers)&&void 0!==a?a:l.getParameter("cacheServers",""));n.setCacheServers(d);const u=l.cacheServerUrl||l.getParameter("cacheServerUrl","");if(u?n.setNodeCacheUrl(u):0===d.length&&n.setNodeCacheUrl(""),l.hasOAuthCredentials()){const e=l.applicationName||i;o.setOAuthCredentials(l.clientId,l.clientSecret,e);const t=yield r(l.clientId,l.clientSecret,e,!0);if(!t.success)throw new Error(`OAuth token request failed: ${t.error||"unknown error"}`)}else l.hasAccessToken()&&(o.BearerAccessToken=l.accessToken);_.isDataLoaded=!1,_.isCharacterLoaded=!1,_.isTypeLoaded=!1,_.isLocalDataLoaded=!1,_.isLocalTypeLoaded=!1,_.isLocalCharacterLoaded=!1,_.isConnectionLoaded=!1,_.isConnectionTypeLoaded=!1,_.isLocalConnectionLoaded=!1,yield function(){return Bi(this,void 0,void 0,(function*(){return yield A("settings")[0]||new w(!0),yield function(){return Ei(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([H().then((()=>{_.isDataLoaded=!0,_.isCharacterLoaded=!0,_.isTypeLoaded=!0})),Ri().then((()=>{_.isLocalDataLoaded=!0,_.isLocalTypeLoaded=!0,_.isLocalCharacterLoaded=!0})),gi().then((()=>{_.isLocalConnectionLoaded=!0})),vi().then((()=>{_.isConnectionLoaded=!0,_.isConnectionTypeLoaded=!0}))])}))}var Tr=t.BG,wr=t.$e,Ir=t.TR,Nr=t.Tc,Ar=t.U3,kr=t.Wg,Sr=t.g2,xr=t.BO,Rr=t.WW,Er=t.BS,_r=t.ji,Br=t.Ij,Ur=t.Ng,Lr=t.du,Pr=t.RC,Gr=t.d4,Fr=t.Cd,br=t.IM,Dr=t.oI,$r=t.u9,Or=t.B7,Vr=t.mF,Mr=t.Q9,jr=t.wT,Hr=t.hZ,Wr=t.y0,Jr=t.iw,qr=t.pU,zr=t.qN,Qr=t.mZ,Kr=t.Ec,Xr=t.L0,Yr=t.Te,Zr=t.vw,ec=t.z8,tc=t.k9,nc=t.sP,oc=t.Y3,ic=t.WC,rc=t.Nj,cc=t.dF,sc=t.cw,ac=t.p8,lc=t.rv,dc=t.pX,uc=t.iD,hc=t.Mb,fc=t.bq,yc=t.ke,pc=t.w1,vc=t.yz,gc=t.RW,Cc=t.WL,mc=t.rh,Tc=t.nW,wc=t.RH,Ic=t.Aj,Nc=t.cV,Ac=t.jM,kc=t.nS,Sc=t.Yu,xc=t.xf,Rc=t.KS,Ec=t.L6,_c=t.Z9,Bc=t.Ny,Uc=t.qY,Lc=t.jQ,Pc=t.NT,Gc=t.Xr,Fc=t.ab,bc=t.SV,Dc=t.EA,$c=t.M2,Oc=t.OY,Vc=t.ry,Mc=t.cS,jc=t.ZJ,Hc=t.RA,Wc=t.BH,Jc=t.SL,qc=t.Ne,zc=t.fg,Qc=t.M4,Kc=t.UG,Xc=t.CT,Yc=t.yv,Zc=t.vI,es=t.oe,ts=t.XZ,ns=t.ZE,os=t.pi,is=t.B8,rs=t.yx,cs=t.br,ss=t.eU,as=t.cf,ls=t.jy,ds=t.cm,us=t.qn,hs=t.ss,fs=t.pf,ys=t.pZ,ps=t.l4,vs=t.f8,gs=t.Y6,Cs=t.FS,ms=t.bM,Ts=t.ZX,ws=t.CE,Is=t.Sf,Ns=t.tp,As=t.Ry,ks=t.jh,Ss=t.dp,xs=t.a2,Rs=t.C$,Es=t.J5,_s=t.sc,Bs=t.x9,Us=t.Py,Ls=t.Xc,Ps=t.Ts,Gs=t.P$,Fs=t.xX,bs=t.ae,Ds=t.zN,$s=t.dU,Os=t.mA,Vs=t.En,Ms=t.eD,js=t.$Q;export{Tr as ALLID,wr as AccessControlService,Ir as AddGhostConcept,Nr as AddGhostConnection,Ar as BaseUrl,kr as BinaryTree,Sr as CCSConfig,xr as Composition,Rr as CompositionBinaryTree,Er as CompositionNode,_r as Concept,Br as ConceptsData,Ur as Connection,Lr as ConnectionData,Pr as CreateComposition,Gr as CreateConnection,Fr as CreateConnectionBetweenTwoConcepts,br as CreateConnectionBetweenTwoConceptsGeneral,Dr as CreateDefaultConcept,$r as CreateDefaultLConcept,Or as CreateSession,Vr as CreateSessionVisit,Mr as CreateTheCompositionWithCache,jr as CreateTheConnectionGeneral,Hr as CreateTypeConcept,Wr as DATAID,Jr as DATAIDDATE,qr as DATAV2,zr as DeleteConceptById,Qr as DeleteConnectionById,Kr as DeleteConnectionByIdBulk,Xr as DeleteConnectionByTypeBulk,Yr as FilterSearch,Zr as FormatFromConnections,ec as FreeSchemaResponse,tc as FreeschemaQuery,nc as GetAllConnectionsOfComposition,oc as GetAllConnectionsOfCompositionBulk,ic as GetAllTheConnectionsByTypeAndOfTheConcept,rc as GetComposition,cc as GetCompositionBulk,sc as GetCompositionBulkWithDataId,ac as GetCompositionFromConnectionsWithDataId,lc as GetCompositionFromConnectionsWithDataIdInObject,dc as GetCompositionList,uc as GetCompositionListWithId,hc as GetCompositionWithAllIds,fc as GetCompositionWithCache,yc as GetCompositionWithDataIdBulk,pc as GetCompositionWithDataIdWithCache,vc as GetCompositionWithId,gc as GetCompositionWithIdFromMemory,Cc as GetCompositionWithIdFromMemoryFromConnections,mc as GetConceptBulk,Tc as GetConceptByCharacter,wc as GetConceptByCharacterAndCategoryDirectApi,Ic as GetConceptByCharacterAndType,Nc as GetConceptByTypeBulk,Ac as GetConnectionBulk,kc as GetConnectionById,Sc as GetConnectionByTypeBulk,xc as GetConnectionOfTheConcept,Rc as GetConnectionsBetweenApi,Ec as GetLink,_c as GetLinkRaw,Bc as GetLinkerConnectionFromConcepts,Uc as GetLinkerConnectionToConcepts,Lc as GetRelation,Pc as GetRelationRaw,Gc as GetRequestHeader,Fc as GetRequestHeaderWithAuthorization,bc as GetTheConcept,Dc as GetUserGhostConnectionId,$c as GetUserGhostId,Oc as GiveConnection,Vc as HandleHttpError,Mc as HttpResponse,jc as JUSTDATA,Hc as LConcept,Wc as LConnection,Jc as LISTNORMAL,qc as LoginToBackend,zc as MakeTheInstanceConcept,Qc as MakeTheTimestamp,Kc as MakeTheTypeConcept,Xc as MakeTheTypeConceptApi,Yc as NORMAL,Zc as PatcherStructure,es as PermissionSet,ts as RAW,ns as RecursiveSearchApi,os as ReservedConnectionIds,is as ReservedIds,rs as SchemaQueryListener,cs as SearchAllConcepts,ss as SearchLinkInternal,as as SearchLinkMultipleAll,ls as SearchLinkMultipleApi,ds as SearchQuery,us as SearchStructure,hs as SearchWithLinker,fs as SessionData,ys as Signin,ps as Signup,vs as SplitStrings,gs as SyncData,Cs as TokenRefreshError,ms as TokenStorage,Ts as Transaction,ws as TrashTheConcept,Is as UpdateComposition,Ns as UserBinaryTree,As as ViewInternalData,ks as buildFetchConnection,Ss as convertFromLConceptToConcept,xs as deleteWithRetry,Rs as fetchWithCacheServerFallback,Es as fetchWithRetry,_s as getFromDatabaseWithType,Bs as getFromDatabaseWithTypeOld,Us as getOAuthToken,Ls as getWithRetry,Ps as init,Gs as patchWithRetry,Fs as postWithRetry,bs as putWithRetry,Ds as recursiveFetch,$s as recursiveFetchNew,Os as refreshOAuthToken,Vs as requestWithRetry,Ms as storeToDatabase,js as updateAccessToken};
|