mftsccs-node 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -2
- package/dist/types/DataStructures/BaseUrl.d.ts +10 -0
- package/dist/types/DataStructures/CCSConfig.d.ts +169 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +74 -1
- package/dist/types/Services/Common/ErrorPosting.d.ts +2 -0
- package/dist/types/Services/Http/HttpClient.service.d.ts +205 -0
- package/dist/types/Services/Security/GetRequestHeader.d.ts +58 -10
- package/dist/types/Services/auth/AuthService.d.ts +0 -1
- package/dist/types/Services/oauth/CallOauth.service.d.ts +101 -0
- package/dist/types/app.d.ts +53 -14
- package/package.json +1 -3
package/dist/bundle.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e={144:(e,t,n)=>{const o=n(3908);e.exports=(e,t,n=!1)=>{if(e instanceof o)return e;try{return new o(e,t)}catch(e){if(!n)return null;throw e}}},181:e=>{"use strict";e.exports=require("buffer")},270:(e,t,n)=>{const o=n(3908),r=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new r(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&1!==c.compare(e)||(i=e,c=new o(i,n)))})),i}},560:(e,t,n)=>{const o=n(3908);e.exports=(e,t,n)=>new o(e,n).compare(new o(t,n))},855:(e,t,n)=>{var o=n(6585);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var r=o(e);if(void 0===r)return;return Math.floor(n+r/1e3)}return"number"==typeof e?n+e:void 0}},909:(e,t,n)=>{const o=n(3908);e.exports=(e,t,n)=>{const r=new o(e,n),i=new o(t,n);return r.compare(i)||r.compareBuild(i)}},1045:(e,t,n)=>{"use strict";var o=n(181).Buffer,r=n(181).SlowBuffer;function i(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}e.exports=i,i.install=function(){o.prototype.equal=r.prototype.equal=function(e){return i(this,e)}};var c=o.prototype.equal,s=r.prototype.equal;i.restore=function(){o.prototype.equal=c,r.prototype.equal=s}},1123:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const o=t.test(e),r=t.test(n);return o&&r&&(e=+e,n=+n),e===n?0:o&&!r?-1:r&&!o?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},1261:(e,t,n)=>{const o=n(3908),r=n(8311),i=n(5580);e.exports=(e,t)=>{e=new r(e,t);let n=new o("0.0.0");if(e.test(n))return n;if(n=new o("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t<e.set.length;++t){const r=e.set[t];let c=null;r.forEach((e=>{const t=new o(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":c&&!i(t,c)||(c=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!c||n&&!i(n,c)||(n=c)}return n&&e.test(n)?n:null}},1691:(e,t,n)=>{const o=n(1741),r=n(3726),i=n(8980),c=n(7260),s=n(855),a=n(7019),l=n(4977),u=n(5747),{KeyObject:d,createSecretKey:h,createPublicKey:f}=n(6982),p=["RS256","RS384","RS512"],y=["ES256","ES384","ES512"],v=["RS256","RS384","RS512"],g=["HS256","HS384","HS512"];l&&(p.splice(p.length,0,"PS256","PS384","PS512"),v.splice(v.length,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,l){let m;if("function"!=typeof n||l||(l=n,n={}),n||(n={}),n=Object.assign({},n),m=l||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return m(new o("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return m(new o("nonce must be a non-empty string"));if(void 0!==n.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof n.allowInvalidAsymmetricKeyTypes)return m(new o("allowInvalidAsymmetricKeyTypes must be a boolean"));const C=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return m(new o("jwt must be provided"));if("string"!=typeof e)return m(new o("jwt must be a string"));const T=e.split(".");if(3!==T.length)return m(new o("jwt malformed"));let w;try{w=c(e,{complete:!0})}catch(e){return m(e)}if(!w)return m(new o("invalid token"));const N=w.header;let I;if("function"==typeof t){if(!l)return m(new o("verify must be called asynchronous if secret or public key is provided as a callback"));I=t}else I=function(e,n){return n(null,t)};return I(N,(function(t,c){if(t)return m(new o("error in secret or public key callback: "+t.message));const l=""!==T[2].trim();if(!l&&c)return m(new o("jwt signature is required"));if(l&&!c)return m(new o("secret or public key must be provided"));if(!l&&!n.algorithms)return m(new o('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=c&&!(c instanceof d))try{c=f(c)}catch(e){try{c=h("string"==typeof c?Buffer.from(c):c)}catch(e){return m(new o("secretOrPublicKey is not valid key material"))}}if(n.algorithms||("secret"===c.type?n.algorithms=g:["rsa","rsa-pss"].includes(c.asymmetricKeyType)?n.algorithms=v:"ec"===c.asymmetricKeyType?n.algorithms=y:n.algorithms=p),-1===n.algorithms.indexOf(w.header.alg))return m(new o("invalid algorithm"));if(N.alg.startsWith("HS")&&"secret"!==c.type)return m(new o(`secretOrPublicKey must be a symmetric key when using ${N.alg}`));if(/^(?:RS|PS|ES)/.test(N.alg)&&"public"!==c.type)return m(new o(`secretOrPublicKey must be an asymmetric key when using ${N.alg}`));if(!n.allowInvalidAsymmetricKeyTypes)try{a(N.alg,c)}catch(e){return m(e)}let I;try{I=u.verify(e,w.header.alg,c)}catch(e){return m(e)}if(!I)return m(new o("invalid signature"));const A=w.payload;if(void 0!==A.nbf&&!n.ignoreNotBefore){if("number"!=typeof A.nbf)return m(new o("invalid nbf value"));if(A.nbf>C+(n.clockTolerance||0))return m(new r("jwt not active",new Date(1e3*A.nbf)))}if(void 0!==A.exp&&!n.ignoreExpiration){if("number"!=typeof A.exp)return m(new o("invalid exp value"));if(C>=A.exp+(n.clockTolerance||0))return m(new i("jwt expired",new Date(1e3*A.exp)))}if(n.audience){const e=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(A.aud)?A.aud:[A.aud]).some((function(t){return e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))})))return m(new o("jwt audience invalid. expected: "+e.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&A.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(A.iss)))return m(new o("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&A.sub!==n.subject)return m(new o("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&A.jti!==n.jwtid)return m(new o("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&A.nonce!==n.nonce)return m(new o("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof A.iat)return m(new o("iat required when maxAge is specified"));const e=s(n.maxAge,A.iat);if(void 0===e)return m(new o('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(C>=e+(n.clockTolerance||0))return m(new i("maxAge exceeded",new Date(1e3*e)))}if(!0===n.complete){const e=w.signature;return m(null,{header:N,payload:A,signature:e})}return m(null,A)}))}},1729:(e,t,n)=>{const o=n(144);e.exports=(e,t)=>{const n=o(e,t);return n&&n.prerelease.length?n.prerelease:null}},1741:e=>{var t=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(t.prototype=Object.create(Error.prototype)).constructor=t,e.exports=t},1763:(e,t,n)=>{const o=n(560);e.exports=(e,t)=>o(e,t,!0)},1832:(e,t,n)=>{const o=n(144);e.exports=(e,t)=>{const n=o(e,null,!0),r=o(t,null,!0),i=n.compare(r);if(0===i)return null;const c=i>0,s=c?n:r,a=c?r:n,l=!!s.prerelease.length;if(a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(0===a.compareMain(s))return a.minor&&!a.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==r.major?u+"major":n.minor!==r.minor?u+"minor":n.patch!==r.patch?u+"patch":"prerelease"}},1977:(e,t,n)=>{const o=n(9589);e.exports=o.satisfies(process.version,">=15.7.0")},2010:(e,t,n)=>{"use strict";var o=n(2861).Buffer,r=n(3527);function i(e){if(o.isBuffer(e))return e;if("string"==typeof e)return o.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function c(e,t,n){for(var o=0;t+o<n&&0===e[t+o];)++o;return e[t+o]>=128&&--o,o}e.exports={derToJose:function(e,t){e=i(e);var n=r(t),c=n+1,s=e.length,a=0;if(48!==e[a++])throw new Error('Could not find expected "seq"');var l=e[a++];if(129===l&&(l=e[a++]),s-a<l)throw new Error('"seq" specified length of "'+l+'", only "'+(s-a)+'" remaining');if(2!==e[a++])throw new Error('Could not find expected "int" for "r"');var u=e[a++];if(s-a-2<u)throw new Error('"r" specified length of "'+u+'", only "'+(s-a-2)+'" available');if(c<u)throw new Error('"r" specified length of "'+u+'", max of "'+c+'" is acceptable');var d=a;if(a+=u,2!==e[a++])throw new Error('Could not find expected "int" for "s"');var h=e[a++];if(s-a!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(s-a)+'"');if(c<h)throw new Error('"s" specified length of "'+h+'", max of "'+c+'" is acceptable');var f=a;if((a+=h)!==s)throw new Error('Expected to consume entire buffer, but "'+(s-a)+'" bytes remain');var p=n-u,y=n-h,v=o.allocUnsafe(p+u+y+h);for(a=0;a<p;++a)v[a]=0;e.copy(v,a,d+Math.max(-p,0),d+u);for(var g=a=n;a<g+y;++a)v[a]=0;return e.copy(v,a,f+Math.max(-y,0),f+h),(v=v.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=i(e);var n=r(t),s=e.length;if(s!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+s+'"');var a=c(e,0,n),l=c(e,n,e.length),u=n-a,d=n-l,h=2+u+1+1+d,f=h<128,p=o.allocUnsafe((f?2:3)+h),y=0;return p[y++]=48,f?p[y++]=h:(p[y++]=129,p[y++]=255&h),p[y++]=2,p[y++]=u,a<0?(p[y++]=0,y+=e.copy(p,y,0,n)):y+=e.copy(p,y,a,n),p[y++]=2,p[y++]=d,l<0?(p[y++]=0,e.copy(p,y,n)):e.copy(p,y,n+l),p}}},2111:(e,t,n)=>{const o=n(4641),r=n(3999),i=n(5580),c=n(4089),s=n(7059),a=n(5200);e.exports=(e,t,n,l)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return o(e,n,l);case"!=":return r(e,n,l);case">":return i(e,n,l);case">=":return c(e,n,l);case"<":return s(e,n,l);case"<=":return a(e,n,l);default:throw new TypeError(`Invalid operator: ${t}`)}}},2203:e=>{"use strict";e.exports=require("stream")},2525:(e,t,n)=>{const o=n(7638),r=n(560);e.exports=(e,t,n)=>{const i=[];let c=null,s=null;const a=e.sort(((e,t)=>r(e,t,n)));for(const e of a)o(e,t,n)?(s=e,c||(c=e)):(s&&i.push([c,s]),s=null,c=null);c&&i.push([c,null]);const l=[];for(const[e,t]of i)e===t?l.push(e):t||e!==a[0]?t?e===a[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`):l.push("*");const u=l.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},2851:(e,t,n)=>{var o=n(181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||o.isBuffer(e)?e.toString():JSON.stringify(e)}},2861:(e,t,n)=>{var o=n(181),r=o.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function c(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?e.exports=o:(i(o,t),t.Buffer=c),c.prototype=Object.create(r.prototype),i(r,c),c.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},c.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=r(e);return void 0!==t?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o},c.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},c.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},2938:(e,t,n)=>{const o=n(3908);e.exports=(e,t)=>new o(e,t).major},3007:(e,t,n)=>{const o=n(3908);e.exports=(e,t,n,r,i)=>{"string"==typeof n&&(i=r,r=n,n=void 0);try{return new o(e instanceof o?e.version:e,n).inc(t,r,i).version}catch(e){return null}}},3387:(e,t,n)=>{var o=n(2861).Buffer,r=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023);function l(e,t){return o.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){var t=e.header,n=e.payload,o=e.secret||e.privateKey,r=e.encoding,c=i(t.alg),u=function(e,t,n){n=n||"utf8";var o=l(s(e),"binary"),r=l(s(t),n);return a.format("%s.%s",o,r)}(t,n,r),d=c.sign(u,o);return a.format("%s.%s",u,d)}function d(e){var t=e.secret||e.privateKey||e.key,n=new r(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new r(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}a.inherits(d,c),d.prototype.sign=function(){try{var e=u({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=u,e.exports=d},3527:e=>{"use strict";function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},3639:e=>{var t=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==t.call(e)}},3726:(e,t,n)=>{var o=n(1741),r=function(e,t){o.call(this,e),this.name="NotBeforeError",this.date=t};(r.prototype=Object.create(o.prototype)).constructor=r,e.exports=r},3874:(e,t,n)=>{const o=n(8311);e.exports=(e,t)=>{try{return new o(e,t).range||"*"}catch(e){return null}}},3904:(e,t,n)=>{const o=Symbol("SemVer ANY");class r{static get ANY(){return o}constructor(e,t){if(t=i(t),e instanceof r){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),l("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===o?this.value="":this.value=this.operator+this.semver.version,l("comp",this)}parse(e){const t=this.options.loose?c[s.COMPARATORLOOSE]:c[s.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new u(n[2],this.options.loose):this.semver=o}toString(){return this.value}test(e){if(l("Comparator.test",e,this.options.loose),this.semver===o||e===o)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return a(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=i(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(a(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(a(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}e.exports=r;const i=n(8587),{safeRe:c,t:s}=n(9718),a=n(2111),l=n(7272),u=n(3908),d=n(8311)},3908:(e,t,n)=>{const o=n(7272),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=n(6874),{safeRe:c,safeSrc:s,t:a}=n(9718),l=n(8587),{compareIdentifiers:u}=n(1123);class d{constructor(e,t){if(t=l(t),e instanceof d){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>r)throw new TypeError(`version is longer than ${r} characters`);o("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?c[a.LOOSE]:c[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(o("SemVer.compare",this.version,this.options,e),!(e instanceof d)){if("string"==typeof e&&e===this.version)return 0;e=new d(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof d||(e=new d(e,this.options)),u(this.major,e.major)||u(this.minor,e.minor)||u(this.patch,e.patch)}comparePre(e){if(e instanceof d||(e=new d(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],r=e.prerelease[t];if(o("prerelease compare",t,n,r),void 0===n&&void 0===r)return 0;if(void 0===r)return 1;if(void 0===n)return-1;if(n!==r)return u(n,r)}while(++t)}compareBuild(e){e instanceof d||(e=new d(e,this.options));let t=0;do{const n=this.build[t],r=e.build[t];if(o("build compare",t,n,r),void 0===n&&void 0===r)return 0;if(void 0===r)return 1;if(void 0===n)return-1;if(n!==r)return u(n,r)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=new RegExp(`^${this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]}$`),n=`-${t}`.match(e);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let o=this.prerelease.length;for(;--o>=0;)"number"==typeof this.prerelease[o]&&(this.prerelease[o]++,o=-2);if(-1===o){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let o=[t,e];!1===n&&(o=[t]),0===u(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=d},3927:(e,t,n)=>{const o=n(909);e.exports=(e,t)=>e.sort(((e,n)=>o(e,n,t)))},3999:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>0!==o(e,t,n)},4040:(e,t,n)=>{e.exports={decode:n(7260),verify:n(1691),sign:n(7651),JsonWebTokenError:n(1741),NotBeforeError:n(3726),TokenExpiredError:n(8980)}},4089:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>o(e,t,n)>=0},4277:(e,t,n)=>{const o=n(909);e.exports=(e,t)=>e.sort(((e,n)=>o(n,e,t)))},4493:(e,t,n)=>{const o=n(3908);e.exports=(e,t)=>new o(e,t).patch},4623:(e,t,n)=>{const o=n(9589);e.exports=o.satisfies(process.version,">=16.9.0")},4641:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>0===o(e,t,n)},4977:(e,t,n)=>{var o=n(9589);e.exports=o.satisfies(process.version,"^6.12.0 || >=8.0.0")},5032:(e,t,n)=>{const o=n(8311),r=n(3904),{ANY:i}=r,c=n(7638),s=n(560),a=[new r(">=0.0.0-0")],l=[new r(">=0.0.0")],u=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===i){if(1===t.length&&t[0].semver===i)return!0;e=n.includePrerelease?a:l}if(1===t.length&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}const o=new Set;let r,u,f,p,y,v,g;for(const t of e)">"===t.operator||">="===t.operator?r=d(r,t,n):"<"===t.operator||"<="===t.operator?u=h(u,t,n):o.add(t.semver);if(o.size>1)return null;if(r&&u){if(f=s(r.semver,u.semver,n),f>0)return null;if(0===f&&(">="!==r.operator||"<="!==u.operator))return null}for(const e of o){if(r&&!c(e,String(r),n))return null;if(u&&!c(e,String(u),n))return null;for(const o of t)if(!c(e,String(o),n))return!1;return!0}let m=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver,C=!(!r||n.includePrerelease||!r.semver.prerelease.length)&&r.semver;m&&1===m.prerelease.length&&"<"===u.operator&&0===m.prerelease[0]&&(m=!1);for(const e of t){if(g=g||">"===e.operator||">="===e.operator,v=v||"<"===e.operator||"<="===e.operator,r)if(C&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===C.major&&e.semver.minor===C.minor&&e.semver.patch===C.patch&&(C=!1),">"===e.operator||">="===e.operator){if(p=d(r,e,n),p===e&&p!==r)return!1}else if(">="===r.operator&&!c(r.semver,String(e),n))return!1;if(u)if(m&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch&&(m=!1),"<"===e.operator||"<="===e.operator){if(y=h(u,e,n),y===e&&y!==u)return!1}else if("<="===u.operator&&!c(u.semver,String(e),n))return!1;if(!e.operator&&(u||r)&&0!==f)return!1}return!(r&&v&&!u&&0!==f||u&&g&&!r&&0!==f||C||m)},d=(e,t,n)=>{if(!e)return t;const o=s(e.semver,t.semver,n);return o>0?e:o<0||">"===t.operator&&">="===e.operator?t:e},h=(e,t,n)=>{if(!e)return t;const o=s(e.semver,t.semver,n);return o<0?e:o>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new o(e,n),t=new o(t,n);let r=!1;e:for(const o of e.set){for(const e of t.set){const t=u(o,e,n);if(r=r||null!==t,t)continue e}if(r)return!1}return!0}},5200:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>o(e,t,n)<=0},5342:(e,t,n)=>{const o=n(7075);e.exports=(e,t,n)=>o(e,t,"<",n)},5571:(e,t,n)=>{const o=n(7075);e.exports=(e,t,n)=>o(e,t,">",n)},5580:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>o(e,t,n)>0},5747:(e,t,n)=>{var o=n(3387),r=n(7599);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=o.sign,t.verify=r.verify,t.decode=r.decode,t.isValid=r.isValid,t.createSign=function(e){return new o(e)},t.createVerify=function(e){return new r(e)}},5931:e=>{var t=Object.prototype.toString,n=Array.isArray;e.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==t.call(e)}},6111:e=>{var t=1/0,n=9007199254740991,o=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=/^(?:0|[1-9]\d*)$/,a=parseInt;function l(e){return e!=e}var u,d,h=Object.prototype,f=h.hasOwnProperty,p=h.toString,y=h.propertyIsEnumerable,v=(u=Object.keys,d=Object,function(e){return u(d(e))}),g=Math.max;function m(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||s.test(e))&&e>-1&&e%1==0&&e<t}var C=Array.isArray;function T(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=w(e)?p.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function w(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function N(e){return!!e&&"object"==typeof e}e.exports=function(e,n,s,u){var d;e=T(e)?e:(d=e)?function(e,t){return function(t){for(var n=-1,o=t?t.length:0,r=Array(o);++n<o;)r[n]=(i=t[n],e[i]);var i;return r}(t)}(d,function(e){return T(e)?function(e,t){var n=C(e)||function(e){return function(e){return N(e)&&T(e)}(e)&&f.call(e,"callee")&&(!y.call(e,"callee")||"[object Arguments]"==p.call(e))}(e)?function(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}(e.length,String):[],o=n.length,r=!!o;for(var i in e)!t&&!f.call(e,i)||r&&("length"==i||m(i,o))||n.push(i);return n}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||h))return v(e);var t,n,o=[];for(var r in Object(e))f.call(e,r)&&"constructor"!=r&&o.push(r);return o}(e)}(d)):[],s=s&&!u?function(e){var n=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||N(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(w(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=w(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=i.test(e);return n||c.test(e)?a(e.slice(2),n?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),s=n%1;return n==n?s?n-s:n:0}(s):0;var I=e.length;return s<0&&(s=g(I+s,0)),function(e){return"string"==typeof e||!C(e)&&N(e)&&"[object String]"==p.call(e)}(e)?s<=I&&e.indexOf(n,s)>-1:!!I&&function(e,t,n){if(t!=t)return function(e,t,n){for(var o=e.length,r=n+-1;++r<o;)if(t(e[r],r,e))return r;return-1}(e,l,n);for(var o=n-1,r=e.length;++o<r;)if(e[o]===t)return o;return-1}(e,n,s)>-1}},6170:(e,t,n)=>{const o=n(3908),r=n(144),{safeRe:i,t:c}=n(9718);e.exports=(e,t)=>{if(e instanceof o)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const o=t.includePrerelease?i[c.COERCERTLFULL]:i[c.COERCERTL];let r;for(;(r=o.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&r.index+r[0].length===n.index+n[0].length||(n=r),o.lastIndex=r.index+r[1].length+r[2].length;o.lastIndex=-1}else n=e.match(t.includePrerelease?i[c.COERCEFULL]:i[c.COERCE]);if(null===n)return null;const s=n[2],a=n[3]||"0",l=n[4]||"0",u=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return r(`${s}.${a}.${l}${u}${d}`,t)}},6254:(e,t,n)=>{const o=n(3908);e.exports=(e,t)=>new o(e,t).minor},6585:e=>{var t=1e3,n=60*t,o=60*n,r=24*o,i=7*r;function c(e,t,n,o){var r=t>=1.5*n;return Math.round(e/n)+" "+o+(r?"s":"")}e.exports=function(e,s){s=s||{};var a,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(c){var s=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return s*i;case"days":case"day":case"d":return s*r;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===u&&isFinite(e))return s.long?(a=e,(l=Math.abs(a))>=r?c(a,l,r,"day"):l>=o?c(a,l,o,"hour"):l>=n?c(a,l,n,"minute"):l>=t?c(a,l,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=r?Math.round(e/r)+"d":i>=o?Math.round(e/o)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},6780:(e,t,n)=>{const o=n(8311);e.exports=(e,t,n)=>(e=new o(e,n),t=new o(t,n),e.intersects(t,n))},6874:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},6953:(e,t,n)=>{const o=n(144);e.exports=(e,t)=>{const n=o(e,t);return n?n.version:null}},6982:e=>{"use strict";e.exports=require("crypto")},7019:(e,t,n)=>{const o=n(1977),r=n(4623),i={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},c={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};e.exports=function(e,t){if(!e||!t)return;const n=t.asymmetricKeyType;if(!n)return;const s=i[n];if(!s)throw new Error(`Unknown key type "${n}".`);if(!s.includes(e))throw new Error(`"alg" parameter for "${n}" key type must be one of: ${s.join(", ")}.`);if(o)switch(n){case"ec":const n=t.asymmetricKeyDetails.namedCurve,o=c[e];if(n!==o)throw new Error(`"alg" parameter "${e}" requires curve "${o}".`);break;case"rsa-pss":if(r){const n=parseInt(e.slice(-3),10),{hashAlgorithm:o,mgf1HashAlgorithm:r,saltLength:i}=t.asymmetricKeyDetails;if(o!==`sha${n}`||r!==o)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==i&&i>n>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}}},7059:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>o(e,t,n)<0},7075:(e,t,n)=>{const o=n(3908),r=n(3904),{ANY:i}=r,c=n(8311),s=n(7638),a=n(5580),l=n(7059),u=n(5200),d=n(4089);e.exports=(e,t,n,h)=>{let f,p,y,v,g;switch(e=new o(e,h),t=new c(t,h),n){case">":f=a,p=u,y=l,v=">",g=">=";break;case"<":f=l,p=d,y=a,v="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(e,t,h))return!1;for(let n=0;n<t.set.length;++n){const o=t.set[n];let c=null,s=null;if(o.forEach((e=>{e.semver===i&&(e=new r(">=0.0.0")),c=c||e,s=s||e,f(e.semver,c.semver,h)?c=e:y(e.semver,s.semver,h)&&(s=e)})),c.operator===v||c.operator===g)return!1;if((!s.operator||s.operator===v)&&p(e,s.semver))return!1;if(s.operator===g&&y(e,s.semver))return!1}return!0}},7083:e=>{var t=1/0,n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return function(e,l){var u;if("function"!=typeof l)throw new TypeError("Expected a function");return e=function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=r.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):o.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e),function(){return--e>0&&(u=l.apply(this,arguments)),e<=1&&(l=void 0),u}}(2,e)}},7260:(e,t,n)=>{var o=n(5747);e.exports=function(e,t){t=t||{};var n=o.decode(e,t);if(!n)return null;var r=n.payload;if("string"==typeof r)try{var i=JSON.parse(r);null!==i&&"object"==typeof i&&(r=i)}catch(e){}return!0===t.complete?{header:n.header,payload:r,signature:n.signature}:r}},7272:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},7414:(e,t,n)=>{const o=n(144);e.exports=(e,t)=>{const n=o(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},7599:(e,t,n)=>{var o=n(2861).Buffer,r=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023),l=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){var t=e.split(".",1)[0];return function(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}(o.from(t,"base64").toString("binary"))}function d(e){return e.split(".")[2]}function h(e){return l.test(e)&&!!u(e)}function f(e,t,n){if(!t){var o=new Error("Missing algorithm parameter for jws.verify");throw o.code="MISSING_ALGORITHM",o}var r=d(e=s(e)),c=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(c,r,n)}function p(e,t){if(t=t||{},!h(e=s(e)))return null;var n=u(e);if(!n)return null;var r=function(e,t){t=t||"utf8";var n=e.split(".")[1];return o.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(r=JSON.parse(r,t.encoding)),{header:n,payload:r,signature:d(e)}}function y(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new r(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new r(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}a.inherits(y,c),y.prototype.verify=function(){try{var e=f(this.signature.buffer,this.algorithm,this.key.buffer),t=p(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},y.decode=p,y.isValid=h,y.verify=f,e.exports=y},7631:(e,t,n)=>{const o=n(8311);e.exports=(e,t)=>new o(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},7638:(e,t,n)=>{const o=n(8311);e.exports=(e,t,n)=>{try{t=new o(t,n)}catch(e){return!1}return t.test(e)}},7651:(e,t,n)=>{const o=n(855),r=n(4977),i=n(7019),c=n(5747),s=n(6111),a=n(7914),l=n(8928),u=n(3639),d=n(9001),h=n(5931),f=n(7083),{KeyObject:p,createSecretKey:y,createPrivateKey:v}=n(6982),g=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];r&&g.splice(3,0,"PS256","PS384","PS512");const m={expiresIn:{isValid:function(e){return l(e)||h(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return l(e)||h(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return h(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:s.bind(null,g),message:'"algorithm" must be a valid string enum value'},header:{isValid:d,message:'"header" must be an object'},encoding:{isValid:h,message:'"encoding" must be a string'},issuer:{isValid:h,message:'"issuer" must be a string'},subject:{isValid:h,message:'"subject" must be a string'},jwtid:{isValid:h,message:'"jwtid" must be a string'},noTimestamp:{isValid:a,message:'"noTimestamp" must be a boolean'},keyid:{isValid:h,message:'"keyid" must be a string'},mutatePayload:{isValid:a,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:a,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:a,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},C={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function T(e,t,n,o){if(!d(n))throw new Error('Expected "'+o+'" to be a plain object.');Object.keys(n).forEach((function(r){const i=e[r];if(i){if(!i.isValid(n[r]))throw new Error(i.message)}else if(!t)throw new Error('"'+r+'" is not allowed in "'+o+'"')}))}const w={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},N=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,t,n,r){"function"==typeof n?(r=n,n={}):n=n||{};const s="object"==typeof e&&!Buffer.isBuffer(e),a=Object.assign({alg:n.algorithm||"HS256",typ:s?"JWT":void 0,kid:n.keyid},n.header);function l(e){if(r)return r(e);throw e}if(!t&&"none"!==n.algorithm)return l(new Error("secretOrPrivateKey must have a value"));if(null!=t&&!(t instanceof p))try{t=v(t)}catch(e){try{t=y("string"==typeof t?Buffer.from(t):t)}catch(e){return l(new Error("secretOrPrivateKey is not valid key material"))}}if(a.alg.startsWith("HS")&&"secret"!==t.type)return l(new Error(`secretOrPrivateKey must be a symmetric key when using ${a.alg}`));if(/^(?:RS|PS|ES)/.test(a.alg)){if("private"!==t.type)return l(new Error(`secretOrPrivateKey must be an asymmetric key when using ${a.alg}`));if(!n.allowInsecureKeySizes&&!a.alg.startsWith("ES")&&void 0!==t.asymmetricKeyDetails&&t.asymmetricKeyDetails.modulusLength<2048)return l(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`))}if(void 0===e)return l(new Error("payload is required"));if(s){try{!function(e){T(C,!0,e,"payload")}(e)}catch(e){return l(e)}n.mutatePayload||(e=Object.assign({},e))}else{const t=N.filter((function(e){return void 0!==n[e]}));if(t.length>0)return l(new Error("invalid "+t.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return l(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return l(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){T(m,!1,e,"options")}(n)}catch(e){return l(e)}if(!n.allowInvalidAsymmetricKeyTypes)try{i(a.alg,t)}catch(e){return l(e)}const u=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:s&&(e.iat=u),void 0!==n.notBefore){try{e.nbf=o(n.notBefore,u)}catch(e){return l(e)}if(void 0===e.nbf)return l(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=o(n.expiresIn,u)}catch(e){return l(e)}if(void 0===e.exp)return l(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(w).forEach((function(t){const o=w[t];if(void 0!==n[t]){if(void 0!==e[o])return l(new Error('Bad "options.'+t+'" option. The payload already has an "'+o+'" property.'));e[o]=n[t]}}));const d=n.encoding||"utf8";if("function"!=typeof r){let o=c.sign({header:a,payload:e,secret:t,encoding:d});if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&o.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`);return o}r=r&&f(r),c.createSign({header:a,privateKey:t,payload:e,encoding:d}).once("error",r).once("done",(function(e){if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&e.length<256)return r(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`));r(null,e)}))}},7914:e=>{var t=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==t.call(e)}},8311:(e,t,n)=>{const o=/\s+/g;class r{constructor(e,t){if(t=c(t),e instanceof r)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new r(e.raw,t);if(e instanceof s)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(o," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&y)|(this.options.loose&&v))+":"+e,n=i.get(t);if(n)return n;const o=this.options.loose,r=o?u[d.HYPHENRANGELOOSE]:u[d.HYPHENRANGE];e=e.replace(r,x(this.options.includePrerelease)),a("hyphen replace",e),e=e.replace(u[d.COMPARATORTRIM],h),a("comparator trim",e),e=e.replace(u[d.TILDETRIM],f),a("tilde trim",e),e=e.replace(u[d.CARETTRIM],p),a("caret trim",e);let c=e.split(" ").map((e=>T(e,this.options))).join(" ").split(/\s+/).map((e=>k(e,this.options)));o&&(c=c.filter((e=>(a("loose invalid filter",e,this.options),!!e.match(u[d.COMPARATORLOOSE]))))),a("range list",c);const l=new Map,m=c.map((e=>new s(e,this.options)));for(const e of m){if(g(e))return[e];l.set(e.value,e)}l.size>1&&l.has("")&&l.delete("");const C=[...l.values()];return i.set(t,C),C}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some((n=>C(n,t)&&e.set.some((e=>C(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(L(this.set[t],e,this.options))return!0;return!1}}e.exports=r;const i=new(n(8794)),c=n(8587),s=n(3904),a=n(7272),l=n(3908),{safeRe:u,t:d,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:p}=n(9718),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:v}=n(6874),g=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,C=(e,t)=>{let n=!0;const o=e.slice();let r=o.pop();for(;n&&o.length;)n=o.every((e=>r.intersects(e,t))),r=o.pop();return n},T=(e,t)=>(a("comp",e,t),e=A(e,t),a("caret",e),e=N(e,t),a("tildes",e),e=S(e,t),a("xrange",e),e=b(e,t),a("stars",e),e),w=e=>!e||"x"===e.toLowerCase()||"*"===e,N=(e,t)=>e.trim().split(/\s+/).map((e=>I(e,t))).join(" "),I=(e,t)=>{const n=t.loose?u[d.TILDELOOSE]:u[d.TILDE];return e.replace(n,((t,n,o,r,i)=>{let c;return a("tilde",e,t,n,o,r,i),w(n)?c="":w(o)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:w(r)?c=`>=${n}.${o}.0 <${n}.${+o+1}.0-0`:i?(a("replaceTilde pr",i),c=`>=${n}.${o}.${r}-${i} <${n}.${+o+1}.0-0`):c=`>=${n}.${o}.${r} <${n}.${+o+1}.0-0`,a("tilde return",c),c}))},A=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{a("caret",e,t);const n=t.loose?u[d.CARETLOOSE]:u[d.CARET],o=t.includePrerelease?"-0":"";return e.replace(n,((t,n,r,i,c)=>{let s;return a("caret",e,t,n,r,i,c),w(n)?s="":w(r)?s=`>=${n}.0.0${o} <${+n+1}.0.0-0`:w(i)?s="0"===n?`>=${n}.${r}.0${o} <${n}.${+r+1}.0-0`:`>=${n}.${r}.0${o} <${+n+1}.0.0-0`:c?(a("replaceCaret pr",c),s="0"===n?"0"===r?`>=${n}.${r}.${i}-${c} <${n}.${r}.${+i+1}-0`:`>=${n}.${r}.${i}-${c} <${n}.${+r+1}.0-0`:`>=${n}.${r}.${i}-${c} <${+n+1}.0.0-0`):(a("no pr"),s="0"===n?"0"===r?`>=${n}.${r}.${i}${o} <${n}.${r}.${+i+1}-0`:`>=${n}.${r}.${i}${o} <${n}.${+r+1}.0-0`:`>=${n}.${r}.${i} <${+n+1}.0.0-0`),a("caret return",s),s}))},S=(e,t)=>(a("replaceXRanges",e,t),e.split(/\s+/).map((e=>R(e,t))).join(" ")),R=(e,t)=>{e=e.trim();const n=t.loose?u[d.XRANGELOOSE]:u[d.XRANGE];return e.replace(n,((n,o,r,i,c,s)=>{a("xRange",e,n,o,r,i,c,s);const l=w(r),u=l||w(i),d=u||w(c),h=d;return"="===o&&h&&(o=""),s=t.includePrerelease?"-0":"",l?n=">"===o||"<"===o?"<0.0.0-0":"*":o&&h?(u&&(i=0),c=0,">"===o?(o=">=",u?(r=+r+1,i=0,c=0):(i=+i+1,c=0)):"<="===o&&(o="<",u?r=+r+1:i=+i+1),"<"===o&&(s="-0"),n=`${o+r}.${i}.${c}${s}`):u?n=`>=${r}.0.0${s} <${+r+1}.0.0-0`:d&&(n=`>=${r}.${i}.0${s} <${r}.${+i+1}.0-0`),a("xRange return",n),n}))},b=(e,t)=>(a("replaceStars",e,t),e.trim().replace(u[d.STAR],"")),k=(e,t)=>(a("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?d.GTE0PRE:d.GTE0],"")),x=e=>(t,n,o,r,i,c,s,a,l,u,d,h)=>`${n=w(o)?"":w(r)?`>=${o}.0.0${e?"-0":""}`:w(i)?`>=${o}.${r}.0${e?"-0":""}`:c?`>=${n}`:`>=${n}${e?"-0":""}`} ${a=w(l)?"":w(u)?`<${+l+1}.0.0-0`:w(d)?`<${l}.${+u+1}.0-0`:h?`<=${l}.${u}.${d}-${h}`:e?`<${l}.${u}.${+d+1}-0`:`<=${a}`}`.trim(),L=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(a(e[n].semver),e[n].semver!==s.ANY&&e[n].semver.prerelease.length>0){const o=e[n].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0}},8587:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},8789:(e,t,n)=>{var o=n(1045),r=n(2861).Buffer,i=n(6982),c=n(2010),s=n(9023),a="secret must be a string or buffer",l="key must be a string or a buffer",u="function"==typeof i.createPublicKey;function d(e){if(!r.isBuffer(e)&&"string"!=typeof e){if(!u)throw y(l);if("object"!=typeof e)throw y(l);if("string"!=typeof e.type)throw y(l);if("string"!=typeof e.asymmetricKeyType)throw y(l);if("function"!=typeof e.export)throw y(l)}}function h(e){if(!r.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw y("key must be a string, a buffer or an object")}function f(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function y(e){var t=[].slice.call(arguments,1),n=s.format.bind(s,e).apply(null,t);return new TypeError(n)}function v(e){var t;return t=e,r.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function g(e){return function(t,n){!function(e){if(!r.isBuffer(e)){if("string"==typeof e)return e;if(!u)throw y(a);if("object"!=typeof e)throw y(a);if("secret"!==e.type)throw y(a);if("function"!=typeof e.export)throw y(a)}}(n),t=v(t);var o=i.createHmac("sha"+e,n);return f((o.update(t),o.digest("base64")))}}function m(e){return function(t,n,i){var c=g(e)(t,i);return o(r.from(n),r.from(c))}}function C(e){return function(t,n){h(n),t=v(t);var o=i.createSign("RSA-SHA"+e);return f((o.update(t),o.sign(n,"base64")))}}function T(e){return function(t,n,o){d(o),t=v(t),n=p(n);var r=i.createVerify("RSA-SHA"+e);return r.update(t),r.verify(o,n,"base64")}}function w(e){return function(t,n){h(n),t=v(t);var o=i.createSign("RSA-SHA"+e);return f((o.update(t),o.sign({key:n,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function N(e){return function(t,n,o){d(o),t=v(t),n=p(n);var r=i.createVerify("RSA-SHA"+e);return r.update(t),r.verify({key:o,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function I(e){var t=C(e);return function(){var n=t.apply(null,arguments);return c.derToJose(n,"ES"+e)}}function A(e){var t=T(e);return function(n,o,r){return o=c.joseToDer(o,"ES"+e).toString("base64"),t(n,o,r)}}function E(){return function(){return""}}function S(){return function(e,t){return""===t}}u&&(l+=" or a KeyObject",a+="or a KeyObject"),e.exports=function(e){var t={hs:g,rs:C,ps:w,es:I,none:E},n={hs:m,rs:T,ps:N,es:A,none:S},o=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!o)throw y('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var r=(o[1]||o[3]).toLowerCase(),i=o[2];return{sign:t[r](i),verify:n[r](i)}}},8794:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},8928:e=>{var t=1/0,n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=r.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):o.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e)}},8948:(e,t,n)=>{var o=n(2861).Buffer,r=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=o.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=o.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(9023).inherits(i,r),i.prototype.write=function(e){this.buffer=o.concat([this.buffer,o.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},8980:(e,t,n)=>{var o=n(1741),r=function(e,t){o.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(r.prototype=Object.create(o.prototype)).constructor=r,e.exports=r},9001:e=>{var t,n,o=Function.prototype,r=Object.prototype,i=o.toString,c=r.hasOwnProperty,s=i.call(Object),a=r.toString,l=(t=Object.getPrototypeOf,n=Object,function(e){return t(n(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var n=c.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&i.call(n)==s}},9023:e=>{"use strict";e.exports=require("util")},9589:(e,t,n)=>{const o=n(9718),r=n(6874),i=n(3908),c=n(1123),s=n(144),a=n(6953),l=n(7414),u=n(3007),d=n(1832),h=n(2938),f=n(6254),p=n(4493),y=n(1729),v=n(560),g=n(9970),m=n(1763),C=n(909),T=n(3927),w=n(4277),N=n(5580),I=n(7059),A=n(4641),E=n(3999),S=n(4089),R=n(5200),b=n(2111),k=n(6170),x=n(3904),L=n(8311),O=n(7638),_=n(7631),P=n(9628),$=n(270),F=n(1261),G=n(3874),U=n(7075),B=n(5571),D=n(5342),V=n(6780),j=n(2525),M=n(5032);e.exports={parse:s,valid:a,clean:l,inc:u,diff:d,major:h,minor:f,patch:p,prerelease:y,compare:v,rcompare:g,compareLoose:m,compareBuild:C,sort:T,rsort:w,gt:N,lt:I,eq:A,neq:E,gte:S,lte:R,cmp:b,coerce:k,Comparator:x,Range:L,satisfies:O,toComparators:_,maxSatisfying:P,minSatisfying:$,minVersion:F,validRange:G,outside:U,gtr:B,ltr:D,intersects:V,simplifyRange:j,subset:M,SemVer:i,re:o.re,src:o.src,tokens:o.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}},9628:(e,t,n)=>{const o=n(3908),r=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new r(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&-1!==c.compare(e)||(i=e,c=new o(i,n)))})),i}},9718:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=n(6874),c=n(7272),s=(t=e.exports={}).re=[],a=t.safeRe=[],l=t.src=[],u=t.safeSrc=[],d=t.t={};let h=0;const f="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[f,r]],y=(e,t,n)=>{const o=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),r=h++;c(e,r,t),d[e]=r,l[r]=t,u[r]=o,s[r]=new RegExp(t,n?"g":void 0),a[r]=new RegExp(o,n?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${l[d.NUMERICIDENTIFIER]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${l[d.NUMERICIDENTIFIERLOOSE]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASE",`(?:-(${l[d.PRERELEASEIDENTIFIER]}(?:\\.${l[d.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${l[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[d.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${l[d.BUILDIDENTIFIER]}(?:\\.${l[d.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${l[d.MAINVERSION]}${l[d.PRERELEASE]}?${l[d.BUILD]}?`),y("FULL",`^${l[d.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${l[d.MAINVERSIONLOOSE]}${l[d.PRERELEASELOOSE]}?${l[d.BUILD]}?`),y("LOOSE",`^${l[d.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${l[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${l[d.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:${l[d.PRERELEASE]})?${l[d.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:${l[d.PRERELEASELOOSE]})?${l[d.BUILD]}?)?)?`),y("XRANGE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${o}})(?:\\.(\\d{1,${o}}))?(?:\\.(\\d{1,${o}}))?`),y("COERCE",`${l[d.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",l[d.COERCEPLAIN]+`(?:${l[d.PRERELEASE]})?`+`(?:${l[d.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",l[d.COERCE],!0),y("COERCERTLFULL",l[d.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${l[d.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${l[d.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${l[d.LONECARET]}${l[d.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${l[d.LONECARET]}${l[d.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${l[d.GTLT]}\\s*(${l[d.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]}|${l[d.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${l[d.XRANGEPLAIN]})\\s+-\\s+(${l[d.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${l[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[d.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},9970:(e,t,n)=>{const o=n(560);e.exports=(e,t,n)=>o(t,e,n)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{ALLID:()=>mr,AccessControlService:()=>Hr,AddGhostConcept:()=>Fo,AddGhostConnection:()=>Go,BaseUrl:()=>I,BinaryTree:()=>f,Composition:()=>co,CompositionBinaryTree:()=>no,CompositionNode:()=>eo,Concept:()=>p,ConceptsData:()=>T,Connection:()=>P,ConnectionData:()=>V,CreateComposition:()=>gt,CreateConnection:()=>_t,CreateConnectionBetweenTwoConcepts:()=>Mt,CreateConnectionBetweenTwoConceptsGeneral:()=>Wt,CreateDefaultConcept:()=>y,CreateDefaultLConcept:()=>ke,CreateSession:()=>No,CreateSessionVisit:()=>Ao,CreateTheCompositionLocal:()=>bt,CreateTheCompositionWithCache:()=>ao,CreateTheConnection:()=>Je,CreateTheConnectionGeneral:()=>Ot,CreateTheConnectionLocal:()=>Ct,DATAID:()=>pr,DATAIDDATE:()=>vr,DATAV2:()=>Tr,DeleteConceptById:()=>En,DeleteConnectionById:()=>Bt,DeleteConnectionByTypeBulk:()=>tr,FilterSearch:()=>ir,FormatFromConnections:()=>jo,FreeSchemaResponse:()=>x,FreeschemaQuery:()=>Fr,GetAllConnectionsOfComposition:()=>te,GetAllConnectionsOfCompositionBulk:()=>q,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Br,GetComposition:()=>re,GetCompositionBulk:()=>Pn,GetCompositionBulkWithDataId:()=>$n,GetCompositionFromConnectionsWithDataId:()=>Fn,GetCompositionFromConnectionsWithDataIdInObject:()=>Un,GetCompositionList:()=>Ce,GetCompositionListLocal:()=>Ve,GetCompositionListLocalWithId:()=>je,GetCompositionListWithId:()=>Te,GetCompositionLocal:()=>$e,GetCompositionLocalWithId:()=>Fe,GetCompositionWithAllIds:()=>ie,GetCompositionWithCache:()=>go,GetCompositionWithDataIdBulk:()=>To,GetCompositionWithDataIdWithCache:()=>Co,GetCompositionWithId:()=>de,GetCompositionWithIdFromMemory:()=>se,GetCompositionWithIdFromMemoryFromConnections:()=>le,GetConceptBulk:()=>M,GetConceptByCharacter:()=>ge,GetConceptByCharacterAndCategoryDirectApi:()=>ln,GetConceptByCharacterAndType:()=>Qe,GetConceptByTypeBulk:()=>Ye,GetConnectionBulk:()=>On,GetConnectionById:()=>Gt,GetConnectionByTypeBulk:()=>nr,GetConnectionOfTheConcept:()=>xt,GetLink:()=>Jt,GetLinkRaw:()=>Xt,GetLinkerConnectionFromConcepts:()=>Tn,GetLinkerConnectionToConcepts:()=>wn,GetRelation:()=>bo,GetRelationRaw:()=>ko,GetTheConcept:()=>Vt,GetUserGhostConnectionId:()=>$o,GetUserGhostId:()=>Po,GiveConnection:()=>Dr,HandleHttpError:()=>L,JUSTDATA:()=>yr,LConcept:()=>be,LConnection:()=>mt,LISTNORMAL:()=>Cr,LoginToBackend:()=>jn,MakeTheInstanceConcept:()=>yt,MakeTheInstanceConceptLocal:()=>St,MakeTheTimestamp:()=>kn,MakeTheTypeConcept:()=>cn,MakeTheTypeConceptApi:()=>pn,NORMAL:()=>fr,PatcherStructure:()=>or,PermissionSet:()=>Gr,RAW:()=>gr,RecursiveSearchApi:()=>Dn,SchemaQueryListener:()=>$r,SearchAllConcepts:()=>fo,SearchLinkInternal:()=>Zo,SearchLinkMultipleAll:()=>Vo,SearchLinkMultipleApi:()=>Bo,SearchQuery:()=>xn,SearchStructure:()=>cr,SearchWithLinker:()=>yo,SessionData:()=>rr,Signin:()=>Kn,Signup:()=>Hn,SplitStrings:()=>N,SyncData:()=>Ke,Transaction:()=>Kr,TrashTheConcept:()=>Rn,UpdateComposition:()=>uo,UpdateCompositionLocal:()=>Jo,UserBinaryTree:()=>Oo,ViewInternalData:()=>qo,convertFromLConceptToConcept:()=>Ho,getFromDatabaseWithType:()=>i,getFromDatabaseWithTypeOld:()=>c,init:()=>Xr,recursiveFetch:()=>he,recursiveFetchNew:()=>ro,storeToDatabase:()=>r,updateAccessToken:()=>Jr});class e{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var t=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){}function i(e,n,o){return t(this,void 0,void 0,(function*(){}))}function c(e){return t(this,void 0,void 0,(function*(){}))}function s(e){return t(this,void 0,void 0,(function*(){}))}class a{}a.isTypeLoaded=!1,a.isCharacterLoaded=!1,a.isDataLoaded=!1,a.isLocalDataLoaded=!1,a.isLocalCharacterLoaded=!1,a.isLocalTypeLoaded=!1,a.isConnectionLoaded=!1,a.isConnectionTypeLoaded=!1,a.isLocalConnectionLoaded=!1;class l{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var r=this.inOrderSuccessor(e.rightNode);return e.value=r.value,e.key=r.key,e.variants=r.variants,e.currentNode=r.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,r.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(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 d{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(a.isCharacterLoaded)return e("done");setTimeout(d.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 l(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return 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))}}d.characterRoot=null;var h=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 f{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return h(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isDataLoaded)return e("done");setTimeout(f.checkFlag,1e3,e)}static addConceptToTree(e){var t=new l(e.id,e,null,null),n=new l(e.characterValue,e,null,null);d.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return h(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return h(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}f.root=null;class p{constructor(e,t,n,o,r,i,c,s,a,l,u,d,h,f,p,y=!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=r,this.categoryUserId=i,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,this.securityId=l,this.securityUserId=u,this.accessId=d,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=p,this.x=0,this.y=0,this.type=null,this.isNew=y,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function y(){let e=v(new Date),t=v(new Date);return new p(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function v(e){const t=e.getMonth()+1,n=e.getDate(),o=e.getFullYear();let r=e.getHours();const i=e.getMinutes(),c=e.getSeconds(),s=r>=12?"PM":"AM";r%=12,r=r||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${o} ${r}:${a(i)}:${a(c)} ${s}`}var g=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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{static addNodeToTree(e){return g(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new l(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return g(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isTypeLoaded)return e("done");setTimeout(m.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return g(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)if(o.variants[e].value.userId==t){var r=!1;for(let t=0;t<n.length;t++)n[t].id==o.variants[e].value.id&&(r=!0);r||n.push(o.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return g(this,void 0,void 0,(function*(){let n=y();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}}m.typeRoot=null;var C=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 T{constructor(){this.name="conceptsArray"}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){this.NPC.includes(e)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(e))}static GetNpc(e){return!!this.NPC.includes(e)}static AddConceptToStorage(e){e.id}static AddConcept(e){e.id>0&&(f.addConceptToTree(e),m.addConceptToTree(e),d.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(f.addConceptToTree(e),m.addConceptToTree(e),d.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);f.removeNodeFromTree(e.id),e.id}static GetConcept(e){return C(this,void 0,void 0,(function*(){var t=y(),n=yield f.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return C(this,void 0,void 0,(function*(){var t=y(),n=d.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return C(this,void 0,void 0,(function*(){var t=y(),n=d.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return C(this,void 0,void 0,(function*(){return y(),yield m.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return C(this,void 0,void 0,(function*(){var n=y(),o=yield d.getCharacterAndCategoryFromTree(e,t);return o&&(n=o.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return C(this,void 0,void 0,(function*(){let n=[];return n=yield m.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return d.characterRoot}getName(){return this.name}}T.conceptsArray=[],T.NPC=[],T.conceptDictionary=[];var w=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 N(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}class I{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}}I.BASE_URL="https://localhost:7053/",I.AI_URL="https://ai.freeschema.com",I.MQTT_URL="192.168.1.249",I.NODE_URL="http://localhost:5001/";class A{}A.BearerAccessToken="",A.JwtSecret="";var E=n(4040),S=n.n(E);const R=()=>{const e={server:!0,timestamp:Date.now(),unique_name:"999",email:"info@boomconsole.com",upn:"100144987",primarysid:"102321705",sub:"node-server"};return S().sign(e,A.JwtSecret,{algorithm:"HS256",expiresIn:"1h"})};function b(e="application/json",t="application/json"){return{"Content-Type":e,Authorization:"Bearer "+(A.BearerAccessToken||R()),Accept:t}}function k(e="application/json",t="",n="application/json"){return""==t&&(t=A.BearerAccessToken||R()),{"Content-Type":e,Authorization:"Bearer "+t,Accept:n}}class x{constructor(e,t,n,o){this.url=I.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=o}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function L(e){if(e.status>=400){let t=new x(e.statusText,!1,e.status,"");throw t.setUrl(e.url),t}}var O=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t){return O(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.toString());var o=b("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllConceptsByTypeUrl(),{method:"POST",headers:o,body:n});if(i.ok){const e=yield i.json();for(var r=0;r<e.length;r++)T.AddConcept(e[r])}console.log("GetAllConceptsByType error",i.status),L(i)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class P{constructor(e=0,t,n,o,r,i,c,s,a,l,u,d,h,f,p,g){this.isTemp=!1,this.toUpdate=!1,this.type=y(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=o,this.toTheConceptUserId=r,this.userId=i,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=u,this.securityUserId=d,this.accessId=h,this.accessUserId=f,this.sessionInformationId=p,this.sessionInformationUserId=g,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class ${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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var r=this.inOrderSuccessor(e.rightNode);return e.value=r.value,e.key=r.key,e.variants=r.variants,e.currentNode=r.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,r.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var F=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new $(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isConnectionLoaded)return e("done");setTimeout(G.checkFlag,1e3,e)}static removeNodeFromTree(e){return F(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return F(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}G.connectionroot=null;var U=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 B{static addNodeToTree(e){return U(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 U(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isConnectionTypeLoaded)return e("done");setTimeout(B.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new $(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 U(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 U(this,void 0,void 0,(function*(){var n=[],o=this.getNodeFromTree(e);if(o){o.value.userId==t&&n.push(null==o?void 0:o.value);for(let e=0;e<o.variants.length;e++)o.variants[e].value.userId==t&&n.push(o.variants[e].value)}return n}))}}B.connectionTypeRoot=null;var D=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 V{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){}static AddConnection(e){e.isTemp||(G.addConnectionToTree(e),B.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(G.addConnectionToTree(e),B.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(e.id,G.removeNodeFromTree(e.id),B.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return G.connectionroot}static GetConnectionTypeTree(){return B.connectionTypeRoot}static GetConnection(e){return D(this,void 0,void 0,(function*(){var t=new P(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield G.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return D(this,void 0,void 0,(function*(){var t=[],n=yield B.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;if(o){let e=o;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}V.connectionArray=[],V.connectionDictionary=[];var j=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return j(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let o=0;o<e.length;o++){let r=yield T.GetConcept(e[o]);0==r.id?n.push(e[o]):t.push(r)}if(0==n.length)return t;{var o=b();const e=yield fetch(I.GetConceptBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){let n=yield e.json();if(n.length>0)for(let e=0;e<n.length;e++){let o=n[e];t.push(o),T.AddConcept(o)}}else console.log("Get Concept Bulk error",e.status),L(e);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var H=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 W(){return H(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield M(t)}}))}var K=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 J(){return K(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield V.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function X(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||V.RemoveConnection(t[n]))}var z=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 z(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield J(e),o=yield function(){return z(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=b();const r=yield fetch(I.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(r.ok){const e=yield r.json();for(var o=0;o<e.length;o++)V.AddConnection(e[o]),t.push(e[o])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),L(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 X(t=o,n),yield W(t),t}))}var Q=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Y=new Map;function Z(e){return Q(this,void 0,void 0,(function*(){let t=y();if(Y.has(e))return Y.get(e)||t;const n=(()=>Q(this,void 0,void 0,(function*(){try{var n=yield T.GetConcept(e);let r=T.GetNpc(e);if(0!=n.id||r)return n;{var o=b("application/x-www-form-urlencoded");const n=yield fetch(I.GetConceptUrl(),{method:"POST",headers:o,body:`id=${e}`});return n.ok?(t=yield n.json(),t.id>0?T.AddConcept(t):T.AddNpc(e)):(console.log("Get the concept error",n.status,e),L(n)),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{Y.delete(e)}})))();return Y.set(e,n),n}))}var ee=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 te(e){return ee(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield V.GetConnectionsOfCompositionLocal(e)).length)t=yield ne(e);else{var n=yield ne(e);X(n,t),t=n}return t}))}function ne(e){return ee(this,void 0,void 0,(function*(){var t=[];try{var n=b("application/x-www-form-urlencoded");const r=yield fetch(I.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});if(!r.ok)throw L(r),new Error(`Error! status: ${r.status}`);const i=yield r.json();for(var o=0;o<i.length;o++)V.AddConnection(i[o]),t.push(i[o]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var oe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 re(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield te(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,o,i);return r[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,r}))}function ie(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield te(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield fe(e,o,i);return r[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,r}))}function ce(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield V.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,o,i);return r[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,r}))}function se(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield V.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,o,i);r[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=r,l.id=e,l}))}function ae(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield V.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,o,i);r[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=r,l.id=e,l.created_at=s.entryTimeStamp,l}))}function le(e,t){return oe(this,void 0,void 0,(function*(){for(var n,o,r={},i=[],c=0;c<t.length;c++)i.includes(t[c].ofTheConceptId)||i.push(t[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,t,i);r[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=r,l.id=e,l}))}function ue(e,t){return oe(this,arguments,void 0,(function*(e,t,n=[]){var o,r,i={},c=yield T.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield Z(e));var s=yield he(e,t,n);i[null!==(r=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=i,a.id=e,a}))}function de(e){return oe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield te(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield T.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Z(e));var a=yield he(e,o,i);r[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=r,l.id=e,l}))}function he(e,t,n){return oe(this,arguments,void 0,(function*(e,t,n,o=[]){var r,i,c,s={},a=[];if(0==e)return null;var l=yield T.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Z(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield T.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Z(u),l.type=d)}if(null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.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,p=yield T.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Z(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield T.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Z(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield he(f,t,n,o);s[y]=e}}else{const e=yield he(f,t,n,o);a[y]=e,s=a}}return s}))}function fe(e,t,n){return oe(this,arguments,void 0,(function*(e,t,n,o=[]){var r,i,c,s={},a=[];if(0==e)return null;var l=yield T.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Z(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield T.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Z(u),l.type=d)}if(null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.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,p=yield T.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Z(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield T.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Z(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield fe(f,t,n);s[y]=e}}else{const e=yield fe(f,t,n);a[y]=e,s=a}}return s}))}var pe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ye(e){return pe(this,void 0,void 0,(function*(){let t=y();try{var n=b("application/x-www-form-urlencoded");const o=yield fetch(I.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return o.ok?(t=yield o.json(),t.id>0&&T.AddConcept(t)):(console.log("Error in Getting concept by character value Error",o.status),L(o)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var ve=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ve(this,void 0,void 0,(function*(){var t=yield T.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield ye(e),t=yield T.GetConceptByCharacter(e)),t}))}var me=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ce(e,t){return me(this,arguments,void 0,(function*(e,t,n=10,o=1){var r=yield ge(e),i=[];if(r){yield _(e,t);for(var c=yield T.GetConceptsByTypeIdAndUser(r.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield q(a),l=s;l<s+n;l++)if(c[l]){var u=yield ce(c[l].id);i.push(u)}}return i}))}function Te(e,t){return me(this,arguments,void 0,(function*(e,t,n=10,o=1){var r=yield ge(e),i=[];if(r){yield _(e,t);for(var c=yield T.GetConceptsByTypeIdAndUser(r.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield q(a),l=s;l<s+n;l++)if(c[l]){var u=yield se(c[l].id);i.push(u)}}return i}))}class we{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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-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,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var r=this.inOrderSuccessor(e.rightNode);return e.value=r.value,e.key=r.key,e.variants=r.variants,e.currentNode=r.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,r.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 Ne=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ie{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 we(e.id,e,null,null);new we(e.characterValue,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(a.isLocalDataLoaded)return e("done");setTimeout(Ie.checkFlag,1e3,e)}static getNodeFromTree(e){return Ne(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 Ne(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Ie.root=null;var Ae=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ee{static waitForDataToLoad(){return Ae(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isLocalCharacterLoaded)return e("done");setTimeout(Ee.checkFlag,1e3,e)}static addNodeToTree(e){return Ae(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 we(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 Ae(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))}}Ee.LocalCharacterRoot=null;var Se=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Se(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 we(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 Se(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isLocalTypeLoaded)return e("done");setTimeout(Re.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Se(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.LocalTypeRoot=null;class be{constructor(e,t,n,o,r,i,c,s=!1,a,l,u,d=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=i,this.accessId=r,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=u,this.applicationId=d}getType(){console.log(this.typeId)}}function ke(){let e=new Date,t=new Date;return new be(0,0,0,0,0,"0","0",!1,e,t,0)}var xe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Le{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(Ie.addConceptToTree(e),Ee.addConceptToTree(e),Re.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Ie.addConceptToTree(e),Ee.addConceptToTree(e),Re.addConceptToTree(e))}static GetConcept(e){return xe(this,void 0,void 0,(function*(){var t=ke(),n=yield Ie.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return xe(this,void 0,void 0,(function*(){var t=ke(),n=Ee.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return xe(this,void 0,void 0,(function*(){var n=ke(),o=yield Ee.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 xe(this,void 0,void 0,(function*(){let n=[];return n=yield Re.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Le.localconceptsArray=[];var Oe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 _e{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),0!=e.id||e.isTemp,this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return Oe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isLocalConnectionLoaded)return e("done");setTimeout(_e.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return Oe(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}}_e.connectionArray=[],_e.connectionDictionary=[];var Pe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Pe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield _e.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield Le.GetConcept(e),a=yield Ge(e,o,i);return r[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=a,r}))}function Fe(e){return Pe(this,void 0,void 0,(function*(){var t,n,o,r={};o=yield _e.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<o.length;c++)i.includes(o[c].ofTheConceptId)||i.push(o[c].ofTheConceptId);var s=yield Le.GetConcept(e);if(0!=s.id){var a=yield Ge(e,o,i);r[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"top"]=a;var l={}}return l.data=r,l.id=e,l}))}function Ge(e,t,n){return Pe(this,arguments,void 0,(function*(e,t,n,o=[]){var r,i,c,s={},a=[],l=yield Le.GetConcept(e);if(0!=l.id&&null==l.type){var u=l.typeId,d=yield Le.GetConcept(u);l.type=d}if(null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.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,p=yield Le.GetConcept(f);0!=p.id&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield Le.GetConcept(u),p.type=d);var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Ge(f,t,n);s[y]=e}}else{const e=yield Ge(f,t,n);a[y]=e,s=a}}return s}))}var Ue=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ue(this,void 0,void 0,(function*(){return yield Le.GetConceptByCharacter(e)}))}var De=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(e,t){return De(this,void 0,void 0,(function*(){var n=yield Be(e),o=[];if(n)for(var r=yield Le.GetConceptsByTypeIdAndUser(n.id,t),i=0;i<r.length;i++){var c=yield $e(r[i].id);o.push(c)}return o}))}function je(e,t){return De(this,void 0,void 0,(function*(){var n=yield Be(e),o=[];if(n)for(var r=yield Le.GetConceptsByTypeIdAndUser(n.id,t),i=0;i<r.length;i++){var c=yield Fe(r[i].id);o.push(c)}return o}))}function Me(e){return t=this,n=void 0,r=function*(){let t=y();try{var n=b();const o=yield fetch(I.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(!o.ok)throw L(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,n||[])).next())}));var t,n,o,r}function He(e){return t=this,n=void 0,r=function*(){let t=new P(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=b(),o=JSON.stringify(e);const r=yield fetch(I.CreateTheConnectionUrl(),{method:"POST",headers:n,body:o});return r.ok?yield r.json():(console.log("Create the connection error message: ",r),L(r)),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((o=void 0)||(o=Promise))((function(e,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,n||[])).next())}));var t,n,o,r}var We=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ke{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 We(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)),this.transactionCollections=this.transactionCollections.filter((e=>new Date(e.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;t=o.data.concepts.slice(),n=o.data.connections.slice(),t.length>0&&(yield Me(t)),n.length>0&&(yield He(n))}else{for(let e=0;e<this.conceptsSyncArray.length;e++)T.AddConcept(this.conceptsSyncArray[e]);for(let e=0;e<this.connectionSyncArray.length;e++)V.AddConnection(this.connectionSyncArray[e]);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield Me(t)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield He(n))}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return We(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 We(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 We(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 We(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e];this.connectionSyncArray=[]}return"done"}))}}function Je(e,t,n,o,r,i,c){var s=new P(0,e,n,t,o,t,r,t,1,t,0,t,4,t,i,c);return e==n?(s.ofTheConceptId=0,s.toTheConceptId=1,s):(s.isTemp=!0,s.id=Math.floor(1e8*Math.random()),Ke.AddConnection(s),s)}Ke.conceptsSyncArray=[],Ke.connectionSyncArray=[],Ke.transactionCollections=[];var Xe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},ze=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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;function Qe(e,t){return ze(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndTypeLocal(e,t),o=e+t;if(qe.has(o))return qe.get(o)||n;const r=(()=>ze(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var r={character_value:`${e}`,type_id:t},i=JSON.stringify(r),c=b();const o=yield fetch(I.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:i});if(o.ok){let e=yield o.json();n=e,T.AddConcept(n)}else console.log("This is the concept by type and character error",o.status),L(o)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{qe.delete(o)}})))();return qe.set(o,r),r}))}function Ye(e){return ze(this,void 0,void 0,(function*(){let t=[],n=JSON.stringify(e);var o=b();const r=yield fetch(I.GetConceptConnectionByType(),{method:"POST",headers:o,body:n});if(r.ok){let e=yield r.json();t=yield M(e)}else console.log("This is the concept by type and character error",r.status),L(r);return t}))}class Ze{constructor(e,t,n,o,r,i,c,s,a,l){this.id=0,this.userId=e,this.data=t,this.securityId=n,this.securityUserId=o,this.accessId=r,this.accessUserId=i,this.sessionId=c,this.sessionUserId=s,this.entryTimestamp=a,this.isNew=l}}var et=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 tt=!1,nt=[];const ot=()=>{nt.length>0&&!tt&&nt.shift()()};var rt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 it=!1,ct=[];const st=()=>{ct.length>0&&!it&&ct.shift()()};var at=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 lt{static getId(){return at(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return rt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{console.log("trying to fetch more concepts"),ct.push((()=>rt(this,void 0,void 0,(function*(){try{if(it)return;if(it=!0,lt.ids.length>10)return console.log("Enough IDs available, skipping fetch."),it=!1,st(),e();var n=b("application/x-www-form-urlencoded");const t=yield fetch(I.GetReservedIdUrl(),{method:"GET",headers:n});if(!t.ok)throw L(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var o=0;o<r.length;o++)lt.AddId(r[o]);console.log("Ids Fetch Success"),e()}catch(e){e instanceof Error?console.log("get reserved ids error message: ",e.message,I.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",e),t(e)}finally{it=!1,st()}})))),st()}))}))}());var e=this.ids[0];return this.ids.shift(),e}))}static AddId(e){this.ids.includes(e)||this.ids.push(e)}}lt.ids=[];class ut{static getId(){return at(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return et(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{nt.push((()=>et(this,void 0,void 0,(function*(){try{if(tt)return;if(tt=!0,ut.connectionIds.length>10)return tt=!1,ot(),e();var n=b("application/x-www-form-urlencoded");const t=yield fetch(I.GetReservedConnectionIdUrl(),{method:"GET",headers:n});if(!t.ok)throw L(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var o=0;o<r.length;o++)ut.AddId(r[o]);e()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),t(e)}finally{tt=!1,ot()}})))),ot()}))}))}());var e=this.connectionIds[0];return this.connectionIds.shift(),e}))}static AddId(e){this.connectionIds.includes(e)||this.connectionIds.push(e)}}ut.connectionIds=[];var dt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ht(e,t,n,o,r,i,c,s,a,l,u,d,h,f){return dt(this,arguments,void 0,(function*(e,t,n,o,r,i,c,s,a,l,u,d,h,f,y={concepts:[],connections:[]}){var v=yield lt.getId();let g=new Date,m=new Date;var C=new p(v,t,r,i,n,o,c,s,e,a,l,u,d,h,f,!0,g,m);return C.isTemp=!1,Ke.AddConcept(C),y.concepts.push(C),C}))}function ft(e,t,n,o,r,i,c,s,a,l,u,d,h,f){return dt(this,arguments,void 0,(function*(e,t,n,o,r,i,c,s,a,l,u,d,h,f,y={concepts:[],connections:[]}){var v=yield lt.getId();let g=new Date,m=new Date;var C=new p(v,t,r,i,n,o,c,s,e,a,l,u,d,h,f,!1,g,m);return T.AddConcept(C),C.updateRecursion=!0,Ke.AddConcept(C),y.concepts.push(C),C}))}var pt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 yt(e,t){return pt(this,arguments,void 0,(function*(e,t,n=!1,o,r,i=999,c=0,s={concepts:[],connections:[]}){let a,l=i,u=(o=n?o:999,999),d=o,h=o,f=r,p=o,v="",g=t.length,m=y();v=e.startsWith("the_")?e:"the_"+e;(new Date).getTime();if(n)m=yield pn(e),a=yield ht(t,o,4,o,m.id,m.userId,c,999,u,d,f,p,l,h,s),(new Date).getTime();else if(g>255)m=yield pn(v),a=yield ht(t,o,4,o,m.id,m.userId,c,999,u,d,f,p,l,h,s),function(e){Xe(this,void 0,void 0,(function*(){try{var t=b();const n=yield fetch(I.CreateTheTextDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw L(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("Create the text error message: ",e.message):console.log("Create the text unexpected error: ",e),e}}))}(new Ze(o,t,u,d,f,p,l,h,Date.now().toString(),!0)),(new Date).getTime();else{m=yield pn(v);let e=yield Qe(t,m.id);a=e,0==e.id&&0==e.userId&&(a=yield ft(t,o,4,o,m.id,m.userId,12,12,u,d,f,p,l,h,s)),(new Date).getTime()}return a.type=m,a}))}var vt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 gt(e){return vt(this,arguments,void 0,(function*(e,t=null,n=null,o=null,r=null,i=null,c=null){var s=null!=r?r:999,a=null!=i?i:4,l=null!=c?c:999,u=null!=o?o:0,d=y();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=u;d=v=yield yt(o,"",!0,s,a,l),h=v.id,u=v.id,yield gt(e[o],v.id,v.userId,h,r,i,c)}else{var f=null!=t?t:999,p=null!=n?n:999;h=u,d=v=yield yt(o,"",!0,s,a,l),yield Je(f,p,v.id,v.userId,h,l,v.userId),yield gt(e[o],v.id,v.userId,h,r,i,c)}else{f=null!=t?t:999,p=null!=n?n:10267,h=u;var v=yield yt(o,e[o].toString(),!1,s,a,l);yield Je(f,p,v.id,v.userId,h,l,v.userId)}return d}))}class mt{constructor(e=0,t,n,o,r,i,c=999){this.isTemp=!1,this.applicationId=999,this.type=ke(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=o,this.ghostId=e,this.orderId=r,this.typeCharacter="",this.accessId=i,this.entryTimeStamp=v(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function Ct(e,t,n,o=1){Math.floor(1e8*Math.random());let r=0,i=0,c=0;r=e,i=t,c=n;let s=new mt(0,0,0,0,0,0);return e!=t&&(s=new mt(0,e,t,n,o,4),s.isTemp=!0,s.id=Math.floor(1e8*Math.random()),_e.AddConnection(s)),s}var Tt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 wt(e,t,n,o,r,i){return Tt(this,arguments,void 0,(function*(e,t,n,o,r,i,c=0){var s=Math.floor(1e8*Math.random());let a=new Date,l=new Date;var u=new be(s,n,r,o,i,e,t,!0,a,l,c);return u.isTemp=!0,Le.AddConcept(u),u}))}var Nt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},It=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 At(e,t,n,o){return It(this,void 0,void 0,(function*(){var r=yield Be(e);if(r&&(0==r.id||0==r.userId)){var i=N(e);if(i[0]==e){var c=yield function(e,t,n){return Nt(this,void 0,void 0,(function*(){var t=yield Le.GetConceptByCharacterAndTypeLocal(e,51),o=t;return 0==o.id&&(o=t=yield wt(e,"the",n,4,51,4)),o}))}(e,0,o);r=c}else{var s=yield At(i[0],t,n,o),a=yield At(i[1],t,n,o);a&&(r=c=yield wt(e,i[1],o,s.id,a.id,4))}}return r}))}var Et=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Et(this,arguments,void 0,(function*(e,t,n=!1,o,r,i=999,c=0){var s,a,l,u=o=n?o:999,d=t.length;if(l=e.startsWith("the_")?e:"the_"+e,n)s=yield At(e,999,o,o),a=yield wt(t,e,o,4,s.id,4,c);else if(d>255)s=yield At(l,999,u,o),a=yield wt(t,l,o,4,s.id,4);else{s=yield At(l,999,u,o);var h=yield Le.GetConceptByCharacterAndTypeLocal(t,s.id);a=h,0==h.id&&0==h.userId&&(a=yield wt(t,l,o,4,s.id,4))}return a.type=s,a}))}var Rt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Rt(this,arguments,void 0,(function*(e,t=null,n=null,o=null,r=null,i=null,c=null){var s=null!=r?r:999,a=null!=i?i:999,l=null!=c?c:4,u=null!=o?o:0,d=ke();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=u;d=p=yield St(o,"",!0,s,a,l),h=p.id,u=p.id,yield bt(e[o],p.id,p.userId,h,r,i,c)}else{var f=null!=t?t:999,p=(h=u,yield St(o,"",!0,s,a,l));yield Ct(f,p.id,h),yield bt(e[o],p.id,p.userId,h,r,i,c)}else f=null!=t?t:999,h=u,p=yield St(o,e[o].toString(),!1,s,a,l),yield Ct(f,p.id,h);return d}))}var kt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 xt(e,t,n){return kt(this,arguments,void 0,(function*(e,t,n,o=10,r=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("ofTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${r}`);var s=b("application/x-www-form-urlencoded");const a=yield fetch(I.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:c});return a.ok?i=yield a.json():(console.log("Get connection of concept error",a.status),L(a)),i}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 Lt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t,n,o,r,i,c){return Lt(this,arguments,void 0,(function*(e,t,n,o,r,i,c,s=1,a=4,l=999,u={concepts:[],connections:[]}){let d=t,h=t,f=t;999!=l&&(f=l);let p=t,y=t,v=yield ut.getId(),g=new P(v,e,n,t,o,f,r,h,s,d,0,p,a,y,i,c);return e==n?(g.ofTheConceptId=0,g.toTheConceptId=1,g):(g.toUpdate=!0,g.isTemp=!1,Ke.AddConnection(g),u.connections.push(g),g)}))}function _t(e,t,n){return Lt(this,arguments,void 0,(function*(e,t,n,o={concepts:[],connections:[]}){let r=yield pn(n),i=e.userId;return yield Ot(e.id,e.userId,t.id,t.userId,r.id,999,999,1e3,4,i,o)}))}var Pt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},$t=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Gt(e){return Ft(this,void 0,void 0,(function*(){var t=yield V.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return $t(this,void 0,void 0,(function*(){var t=yield V.GetConnection(e);try{if(0!=t.id)return t;{var n=b("application/x-www-form-urlencoded");const o=yield fetch(I.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return o.ok?(t=yield o.json(),V.AddConnection(t)):(console.log("Get Connection Error",o.status),L(o)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var Ut=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ut(this,arguments,void 0,(function*(e,t=""){let n=!1;var o=yield Gt(e);return n=yield function(e){return Pt(this,arguments,void 0,(function*(e,t=""){let n=!1;try{const o=new FormData;let r=b("application/x-www-form-urlencoded");""!=t&&(r=k("application/x-www-form-urlencoded",t)),o.append("id",e.toString()),o.append("apiKey","nodeserver");const i=yield fetch(I.DeleteTheConnectionUrl(),{method:"POST",body:o,redirect:"follow"});i.ok?n=(yield i.json()).success:(console.log("Delete connection error status: ",i.status),L(i))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),G.removeNodeFromTree(e),B.removeTypeConcept(o.typeId,e),n}))}var Dt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Vt(e){return Dt(this,arguments,void 0,(function*(e,t=999){var n=y();if(e<0)return Ho(yield Po(t,e));if(null!=(n=yield T.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield Z(e)),0!=n.id&&null==n.type&&null==(yield T.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield Z(n.typeId);n.type=o}return n}))}var jt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return jt(this,arguments,void 0,(function*(e,t,n,o=!1,r=!1){var i,c,s=e.userId,a=s,l=s;if(o){let o=n+"_by",c=(null===(i=t.type)||void 0===i?void 0:i.characterValue)+"_s_"+o;r&&(yield Ht(o,t,s));var u=yield yt("connection",c,!1,999,999,999);let d=new P(0,t.id,e.id,t.userId,e.userId,t.userId,u.id,u.userId,1e3,s,999,a,4,l,999,999);Ke.AddConnection(d)}let d=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+d;r&&(yield Ht(d,e,s));var f=yield yt("connection",h,!1,999,999,999);let p=new P(0,e.id,t.id,e.userId,t.userId,e.userId,f.id,f.userId,1e3,s,999,a,4,l,999,999);return Ke.AddConnection(p),p}))}function Ht(e,t){return jt(this,arguments,void 0,(function*(e,t,n=null){for(var o,r=t,i=null!=n?n:t.userId,c=i,s=i,a=999,l=e+"_count",u=(null===(o=t.type)||void 0===o?void 0:o.characterValue)+"_s_"+l,d=yield yt("connection",u,!1,i,4,a),h=yield xt(d.id,t.id,i,10,1),f=[],p=y(),v=0;v<h.length;v++){let e=yield Vt(h[v].toTheConceptId);f.push(e)}if(f.length<1)p=yield yt("count","1",!1,i,4,a);else{var g=f[0];let e=0;try{e=Number(g.characterValue)}catch(t){e=0}e+=1,p=yield yt("count",e.toString(),!1,i,4,a);for(let e=0;e<h.length;e++)Bt(h[e].id)}let m=new P(0,r.id,p.id,r.userId,p.userId,r.userId,d.id,d.userId,1e3,i,999,c,4,s,a,999);yield Ke.AddConnection(m)}))}function Wt(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,o=!1,r=!1){var i,c,s=e.userId,a=s,l=s;if(o){let o=n+"_by",c=(null===(i=t.type)||void 0===i?void 0:i.characterValue)+"_s_"+o;r&&(yield Ht(o,t,s));var u=yield yt("connection",c,!1,999,999,999);let d=new P(0,t.id,e.id,t.userId,e.userId,t.userId,u.id,u.userId,1e3,s,999,a,4,l,999,999);Ke.AddConnection(d)}let d=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+d;r&&(yield Ht(d,e,s));var f=yield yt("connection",h,!1,999,999,999);return yield Ot(e.id,e.userId,t.id,t.userId,f.id,999,999,1e3,4)}))}var Kt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t){return Kt(this,arguments,void 0,(function*(e,t,n=10,o=1){var r,i=[],c=yield Vt(e),s=(null===(r=c.type)||void 0===r?void 0:r.characterValue)+"_s_"+t,a=yield Qe(s,16);if(a.id>0){for(var l=yield xt(a.id,c.id,c.userId,n,o),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(yield q(u),d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield Vt(e),n=yield ae(t.id);i.push(n)}}return i}))}function Xt(e,t){return Kt(this,arguments,void 0,(function*(e,t,n=10,o=1){var r,i=[],c=yield Vt(e),s=(null===(r=c.type)||void 0===r?void 0:r.characterValue)+"_s_"+t,a=yield Qe(s,16);if(a.id>0){for(var l=yield xt(a.id,c.id,c.userId,n,o),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield Vt(e);i.push(t)}}return i}))}class zt{constructor(e,t,n,o,r,i,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=o,this.accessId=r,this.accessUserId=i,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class qt{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new zt(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}}qt.characterData=[];class Qt{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var Yt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},Zt=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t,n,o,r){return Zt(this,void 0,void 0,(function*(){return new zt(t,e,n,t,o,t,r,t,"",!1),yield function(){return Yt(this,void 0,void 0,(function*(){var e;try{if(0==(e=qt.GetCharacter(e.data)).id){var t=b();const o=yield fetch(I.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw L(o),new Error(`Error! status: ${o.status}`);const r=yield o.json();var n=new zt(r.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=r.id,qt.AddCharacter(n),r}return new Qt(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 tn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,r,i,c,s,a,l,u,d,h,f){return tn(this,void 0,void 0,(function*(){var p=yield Qe(e,r),y=p;return 0==y.id&&(y=p=yield ht(e,t,n,o,r,i,c,s,a,l,u,d,h,f)),y}))}var on=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},rn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,n,o){return rn(this,arguments,void 0,(function*(e,t,n,o,r={concepts:[],connections:[]}){var i=yield ge(e);if(i&&(0==i.id||0==i.userId)){var c=N(e);if(c.length>0)if(console.log(c),c[0]==e){var s=yield function(e,t,n,o,r,i){return on(this,void 0,void 0,(function*(){var r,c=t,s=t;r=t;var a,l=t,u=t,d=t;if(1==e.length){var h=e.charCodeAt(0);yield en(e,t,n,o,i),a=nn(e,t,4,c,h,d,49,l,n,s,o,r,i,u)}else{var f=yield en(e,t,n,o,i);f.isNew,a=yield nn(e,t,4,c,51,l,f.id,f.userId,n,s,o,r,i,u)}return a}))}(e,o,999,999,0,t);i=s}else{var a=yield cn(c[0],t,n,o,r),l=yield cn(c[1],t,n,o,r);l&&(i=yield ft(e,o,a.id,o,l.id,o,999,o,999,o,999,o,t,o,r))}}return i}))}var sn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 an=new Map;function ln(e,t){return sn(this,void 0,void 0,(function*(){let n=y();if(an.has(e+t))return an.get(e+t)||n;const o=(()=>sn(this,void 0,void 0,(function*(){try{var o=b("application/x-www-form-urlencoded");const r=yield fetch(I.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:o,body:`character_value=${e}&category_id=${t}`});if(r.ok){let e=yield r.json();n=e,T.AddConcept(n)}else console.log("This is the concept by category and character direct api error",r.status),L(r);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,e,t,I.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,I.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{an.delete(e+t)}})))();return an.set(e+t,o),o}))}var un=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return un(this,void 0,void 0,(function*(){let t=y();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=N(e);if(o.length>1){let n=1,r=yield dn(o[0]);0!=r.id&&(n=r.id),t=yield function(e,t){return un(this,void 0,void 0,(function*(){let n=yield T.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield ln(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return un(this,void 0,void 0,(function*(){console.log("inside the character length function",e);var t=yield T.GetConceptByCharacterAndTypeLocal(e,49);return console.log("inside the character length function after",t),0==t.id&&(t=yield ye(e)),t}))}(e):o[0]==e&&(t=yield function(e){return un(this,void 0,void 0,(function*(){var t=yield T.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield ye(e)),t}))}(e));return t}))}var hn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 fn=new Map;function pn(e,t){return hn(this,void 0,void 0,(function*(){let t=y();if(fn.has(e))return fn.get(e)||t;const n=(()=>hn(this,void 0,void 0,(function*(){try{if(t=yield dn(e),0==t.id||4==t.typeId){var n=b("application/x-www-form-urlencoded");const o=yield fetch(I.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!o.ok)throw L(o),new Error(`Error! status: ${o.status}`);let r=yield o.json();t=r,t.id>0&&T.AddConcept(t)}return t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{fn.delete(e)}})))();return fn.set(e,n),n}))}var yn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(e){return yn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=b("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++){var r=e[o];t.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),L(i);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 gn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 mn(e){return gn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=b("application/x-www-form-urlencoded");const i=yield fetch(I.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:n});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++){var r=e[o];t.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),L(i);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 Cn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Cn(this,void 0,void 0,(function*(){for(var t=yield vn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let r=yield Vt(o);e.type=r}return t}))}function wn(e){return Cn(this,void 0,void 0,(function*(){for(var t=yield mn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let r=yield Vt(o);e.type=r}return t}))}var Nn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){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 r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n},An=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 An(this,arguments,void 0,(function*(e,t=""){var n=yield Vt(e);yield f.removeNodeFromTree(e);var o=n.typeId,r=n.characterValue;yield m.removeTypeConcept(o,e),yield d.removeNodeByCharacter(r,e);let i=yield function(e){return Nn(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let o=k("application/x-www-form-urlencoded",t);const r=new FormData;r.append("id",e.toString()),r.append("apiKey","nodeserver");const{"Content-Type":i}=o,c=In(o,["Content-Type"]),s=yield fetch(I.DeleteConceptUrl(),{method:"POST",headers:c,body:r});if(!s.ok)throw L(s),new Error(`Error! status: ${s.status}`);n=(yield s.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t);return i}))}var Sn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Rn(e,t){return Sn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const o=new FormData;o.append("id",e.toString());const r=yield fetch(I.DeleteConceptUrl(),{method:"POST",body:o,headers:n});if(!r.ok)throw L(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(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t,n,o){return bn(this,arguments,void 0,(function*(e,t,n,o,r=999){var i,c=n,s=n,a=n,l=e.startsWith("the_"),u=y();return i=l?e:"the_"+e,u=yield pn(i),yield nn(t,n,4,n,u.id,u.userId,0,999,999,c,4,a,999,s)}))}class xn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var Ln=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 On(){return Ln(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let o=0;o<e.length;o++){let r=yield V.GetConnection(e[o]);0==r.id?n.push(e[o]):t.push(r)}if(0==n.length)return t;{var o=b();const e=yield fetch(I.GetConnectionBulkUrl(),{method:"POST",headers:o,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let o=n[e];t.push(o),V.AddConnection(o)}yield W(t)}}else console.log("Get Connection Bulk error",e.status),L(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 _n=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(){return _n(this,arguments,void 0,(function*(e=[]){yield q(e);var t=[];for(let o=0;o<e.length;o++){var n=yield ce(e[o]);t.push(n)}return t}))}function $n(){return _n(this,arguments,void 0,(function*(e=[]){yield q(e);var t=[];for(let o=0;o<e.length;o++){var n=yield se(e[o]);t.push(n)}return t}))}function Fn(){return _n(this,arguments,void 0,(function*(e=[],t=[]){yield On(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||V.RemoveConnection(t[n])}(t,yield J(e));var n=[];for(let t=0;t<e.length;t++){var o=yield se(e[t]);n.push(o)}return n}))}function Gn(){return _n(this,arguments,void 0,(function*(e=[]){let t=[],n=[],o={};for(let o=0;o<(null==e?void 0:e.length);o++){let r=yield V.GetConnection(e[o]);0==r.id?t.push(e[o]):n.push(r)}for(let n=0;n<t.length;n++)o[e[n]]=!1;let r=[],i=yield On(t);n=[...n,...i];for(let e=0;e<n.length;e++)r.push(n[e].ofTheConceptId),r.push(n[e].toTheConceptId),r.push(n[e].typeId);return yield M(r),n}))}function Un(){return _n(this,arguments,void 0,(function*(e=[],t=[]){let n=[],o=[];for(let e=0;e<t.length;e++){let r=yield V.GetConnection(t[e]);0==r.id?n.push(t[e]):o.push(r)}let r=yield On(n);for(let e=0;e<r.length;e++)o.push(r[e]);let i={},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 ue(e[t],o,c);i[e[t]]=n}return i}))}var Bn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(){return Bn(this,arguments,void 0,(function*(e=0,t=[],n=""){var o=[];try{var r=new xn;r.composition=e,r.listLinkers=t,r.textSearch=n;var i=JSON.stringify(r),c=b();const l=yield fetch(I.RecursiveSearchUrl(),{method:"POST",headers:c,body:i});if(l.ok){const e=yield l.json();var s=e.compositionIds,a=e.internalConnections;e.externalConnections,o=yield Fn(s,a)}else console.log("recursive search error ",l.status),L(l);return o}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var Vn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(e,t){return Vn(this,void 0,void 0,(function*(){try{var n={email:e,password:t},o=new Headers;o.append("Content-Type","application/json");var r=JSON.stringify(n);const i=yield fetch(I.LoginUrl(),{method:"POST",headers:o,body:r});if(i.ok){const e=yield i.json();return A.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",i.status),L(i)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var Mn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Hn(e){return Mn(this,void 0,void 0,(function*(){const t=yield function(){return Mn(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),r=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:r}:L(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(I.SignupUrl(),e);return t}))}var Wn=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Wn(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const o=new Headers;o.append("Content-Type","application/json");const r=I.LoginUrl();try{const e=yield fetch(r,{method:"POST",headers:o,body:t,redirect:"follow"}),i=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==i?void 0:i.data}:L(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function Jn(e,t){return-1===e.indexOf(t)&&e.push(t),e}function Xn(e=[],t){var n,o;let r=[],i=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==i?void 0:i.startsWith("the_"))||(i="the_"+i),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&&i!=c||r.push(e[n])}return r}function zn(e=[],t){let n=[],o=t.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(e))for(let r=0;r<e.length;r++){let i=e[r].typeCharacter;(null==i?void 0:i.startsWith("the_"))||(i="the_"+i),t.typeId!=e[r].typeId&&o!=i||n.push(e[r])}return n}function qn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const r=e.find((e=>e.ofTheConceptId==t));r&&n.push(r)}return n}function Qn(e=[],t){let n=[];if(Array.isArray(e)){const o=e.find((e=>e.toTheConceptId==t));o&&n.push(o);const r=e.find((e=>e.ofTheConceptId==t));r&&n.push(r)}return n}function Yn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function Zn(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class eo{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&&(no.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,r=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,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const i=this.getBalanceFactor(t);if(i>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(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var to=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 no{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 eo(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return to(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return to(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}}no.root=null;var oo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ro(e,t,n,o){return oo(this,arguments,void 0,(function*(e,t,n,o,r=[]){var i,c;let s={};const a=[];if(0==e)return"";let l=io(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Vt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=io(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Vt(e),l.type=t)}if(!o.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const u=t[l].toTheConceptId;if(o.includes(e)){let e=io(n,u);if(null!=e&&0!=e.id||null==u||null==u||(e=yield Vt(u)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield T.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Vt(t),e.type=n)}const l="the_",d=(null!==(c=null===(i=null==e?void 0:e.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const e=yield ro(u,t,n,o,r);s[d]=e}}else{const e=yield ro(u,t,n,o,r);a[d]=e,s=a}}}return s}))}function io(e,t){let n=y();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class co{constructor(){this.id=0,this.mainConcept=y(),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 ro(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(),I.MQTT_CONNECTION&&I.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const o={};o[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const r={};return r.data=o,r.id=this.id,r}}var so=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 so(this,arguments,void 0,(function*(e,t=null,n=null,o=null,r=null,i=null,c=null,s=null){const a=null!=r?r:999,l=null!=i?i:4,u=null!=c?c:999;let d=null!=o?o:0,h=y();null==s&&(s=new co);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield yt(o,"",!0,a,l,u);if(null==t&&null==n){let t=d;h=f,t=f.id,d=f.id,s.concepts.push(f),s.id=f.id,yield ao(e[o],f.id,f.userId,t,r,i,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,p=d;h=f,s.concepts.push(f);const y=yield Je(a,l,f.id,f.userId,p,u,f.userId);s.connections.push(y),yield ao(e[o],f.id,f.userId,p,r,i,c,s)}null!=e[o]&&null!=e[o]&&s.subcompositions.push(f.id)}else{const r=null!=t?t:999,i=null!=n?n:999,c=d,h=yield yt(o,e[o],!1,a,l,u);s.concepts.push(h);const f=yield Je(r,i,h.id,h.userId,c,u,h.userId);s.connections.push(f)}return h}))}var lo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 uo(e){return lo(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let r=[];const i=[];let c=y(),s=y();const a=[];let l=e.compositionId;const u=e.ofTheCompositionId;let d=[];if(l<0){let e=yield Vt(l,t);if(!(e.id>0))return null;l=e.id}r=yield te(l);const h=[],f=new co,p=[];f.id=l,f.isUpdating();let v=[];for(let e=0;e<r.length;e++)Jn(p,r[e].ofTheConceptId),Jn(h,r[e].ofTheConceptId),Jn(h,r[e].toTheConceptId),v.push(r[e].ofTheConceptId);f.subcompositions=p,f.connections=r;for(let e=0;e<h.length;e++){const t=yield Vt(h[e]);l==h[e]&&(c=t),u==h[e]&&(s=t),i.push(t)}const g=e.patchObject;for(const e in g){let r=y();const l=g[e];let u=c;if(s.id>0&&(u=s),Array.isArray(l)||"object"==typeof l){r=yield yt(e,"",!0,c.userId,4,999),f.subcompositions.push(r.id);const t=Xn(i,r);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=qn(f.connections,t[e].id);d=d.concat(n),a.push(t[e])}yield ao(g[e],r.id,r.userId,c.id,c.userId,4,999,f)}else{r=yield yt(e,l,!1,t,o,n);const c=Xn(i,r);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=qn(f.connections,c[e].id);d=d.concat(t),a.push(c[e])}}const h=yield Je(u.id,u.userId,r.id,r.userId,c.id,n,t);i.push(r),f.connections.push(h)}for(let e=0;e<d.length;e++)Zn(f.connections,d[e]),Bt(d[e].id);for(let e=0;e<a.length;e++)Yn(i,a[e]);return f.concepts=f.concepts.concat(i),f.mainConcept=c,f.id=c.id,yield f.updateCache(),no.addCompositionToTree(f),yield Ke.SyncDataOnline(),f.GetDataCache()}))}var ho=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 fo(e,t,n,o){return ho(this,arguments,void 0,(function*(e,t,n,o,r=10,i=1){var c=k("application/x-www-form-urlencoded",o),s=new URLSearchParams;s.append("type",e),s.append("search",t),s.append("composition",n),s.append("inpage",r.toString()),s.append("page",i.toString());const a=I.SearchCompositionsUrl()+"?"+s.toString();try{const e=yield fetch(a,{method:"GET",headers:c});return e.ok?yield e.json():(L(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var po=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 yo(e){return po(this,arguments,void 0,(function*(e,t=""){var n=k("application/json",t);const o=I.SearchLinkMultipleAll(),r=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:r});return e.ok?yield e.json():(console.log("This is the searching error",e.status),L(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var vo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return vo(this,arguments,void 0,(function*(e,t=[]){var n,o;let r=[];const i=[];let c={},s={};const a=[];let l=yield T.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield Z(e));let u=[];u=t.length>0?mo(e,t):yield te(e),r=u;for(let e=0;e<r.length;e++)a.includes(r[e].ofTheConceptId)||(a.push(r[e].ofTheConceptId),i.push(r[e].ofTheConceptId)),i.includes(r[e].toTheConceptId)||i.push(r[e].toTheConceptId);return s=yield he(e,r,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 mo(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function Co(e){return vo(this,arguments,void 0,(function*(e,t=[]){var n,o;let r={},i=[];const c=[];let s;const a={},l=[];let u=yield T.GetConcept(e);0==u.id&&null!=e&&null!=e&&(u=yield Z(e));let d=[];d=t.length>0?mo(e,t):yield te(e),i=d;for(let e=0;e<i.length;e++)l.includes(i[e].ofTheConceptId)||(l.push(i[e].ofTheConceptId),c.push(i[e].ofTheConceptId)),c.includes(i[e].toTheConceptId)||c.push(i[e].toTheConceptId);return s=yield he(e,i,l),a[null!==(o=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=s,r.created_at=u.entryTimeStamp,r.data=a,r.id=e,0==u.id?"":r}))}function To(e,t){return vo(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield On(t);for(let t=0;t<e.length;t++){const r=yield Co(e[t],n);r&&o.push(r)}return o}))}var wo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 No(e){return wo(this,void 0,void 0,(function*(){try{var t=b();const n=JSON.stringify(e),o=yield fetch(I.CreateSessionId(),{method:"POST",headers:t,body:n});return o.ok?o.json():(console.log("Creating session failed",yield o.json()),L(o),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Io=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,t){return Io(this,void 0,void 0,(function*(){try{var n=b("application/x-www-form-urlencoded");const o=new URLSearchParams;o.append("sessionId",e.toString()),o.append("url",t);const r=yield fetch(I.CreateSessionVisitUrl(),{method:"POST",headers:n,body:o});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),L(r),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Eo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 So(e,t,n){return Eo(this,arguments,void 0,(function*(e,t,n,o=10,r=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("toTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${o}`),c.append("page",`${r}`);var s=b("application/x-www-form-urlencoded");const a=yield fetch(I.GetAllConnectionsToConceptUrl(),{method:"POST",headers:s,body:c});return a.ok?i=yield a.json():(console.log("Get connection of concept error",a.status),L(a)),i}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 Ro=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Ro(this,arguments,void 0,(function*(e,t,n=10,o=1,r=!1){let i=[],c=yield Vt(e),s=yield dn(t);if(s.id>0){let e=[],t=[];if(r){t=yield So(s.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield q(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield Vt(n),r=yield ae(o.id);i.push(r)}}else{t=yield xt(s.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield q(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield Vt(n),r=yield ae(o.id);i.push(r)}}}return i}))}function ko(e,t){return Ro(this,arguments,void 0,(function*(e,t,n=10,o=1,r=!1){let i=[],c=yield Vt(e),s=yield dn(t),a=[],l=[];if(s.id>0){if(r){a=yield So(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield xt(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}i=yield M(l)}return i}))}class xo{constructor(e,t,n,o,r){this.connectionValue=[],this.value=[],this.height=1,this.key=e,t.id>0&&this.value.push(t),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=r}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,r=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t.value.push(...e.value),t.connectionValue.push(...e.connectionValue),t;t.rightNode=this.addNode(e,r,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>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(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.rightNode=this.removeNode(e.rightNode,n.key),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Lo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 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 Lo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(a.isDataLoaded)return e("done");setTimeout(Oo.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),r=new mt(0,0,0,0,0,0);var i=new xo(o,e,r,null,null);this.addNodeToTree(i)}static addConnectionToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),r=ke();var i=new xo(o,r,e,null,null);this.addNodeToTree(i)}static getNodeFromTree(e,t){return Lo(this,arguments,void 0,(function*(e,t,n=999){let o=this.compositeKey(e,t,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(e){return Lo(this,arguments,void 0,(function*(e,t=999,n=999){if(this.root){let o=this.compositeKey(e,t,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Oo.root=null;var _o=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Po(e,t){return _o(this,arguments,void 0,(function*(e,t,n=999,o=999){let r=yield Oo.getNodeFromTree(e,n,o),i=ke();if(r)for(let e=0;e<r.value.length;e++){let n=r.value[e];n.ghostId==t&&(i=n)}return i}))}function $o(e,t){return _o(this,arguments,void 0,(function*(e,t,n=999,o=999){let r=yield Oo.getNodeFromTree(e,n,o),i=new mt(0,0,0,0,0,0);if(r)for(let e=0;e<r.connectionValue.length;e++){let n=r.connectionValue[e];n.ghostId==t&&(i=n)}return i}))}function Fo(e,t){return _o(this,arguments,void 0,(function*(e,t,n=999){Oo.addConceptToTree(e,t,n)}))}function Go(e,t){return _o(this,arguments,void 0,(function*(e,t,n=999){Oo.addConnectionToTree(e,t,n)}))}var Uo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Uo(this,arguments,void 0,(function*(e,t=""){var n=k("application/json",t);const o=I.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:r});return e.ok?yield e.json():(console.log("This is the searching multiple error",e.status),L(e),[])}catch(e){throw console.log("This is the searching multiple error",e),e}}))}var Do=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Do(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield Bo(e,t),r=e[0].composition;const i=o;let c=i.compositionIds,s=i.internalConnections,a=i.linkers,l=i.reverse;return n=yield Un(c,s),yield jo(a,n,r,l)}))}function jo(e,t,n){return Do(this,arguments,void 0,(function*(e,t,n,o=[]){let r={},i=yield On(e);for(let e=0;e<i.length;e++){let n=!1;if(o.includes(i[e].id)&&(n=!0),1==n){if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].toTheConceptId],o=yield Vt(i[e].typeId),r=null==n?void 0:n.data,c=Object.keys(r)[0];try{let n=o.characterValue+"_reverse";"string"==typeof r&&(r={}),Array.isArray(r[c][n])||("string"==typeof r[c]&&(r[c]={}),r[c][n]=[]),r[c][n].push(t[i[e].ofTheConceptId])}catch(e){console.log("this is error",e)}}}else if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].ofTheConceptId],o=yield Vt(i[e].typeId),r=null==n?void 0:n.data,c=Object.keys(r)[0];try{"string"==typeof r&&(r={}),Array.isArray(r[c][o.characterValue])||("string"==typeof r[c]&&(r[c]={}),r[c][o.characterValue]=[]),r[c][o.characterValue].push(t[i[e].toTheConceptId])}catch(e){console.log("this is error",e)}}}return r=t[n],r}))}function Mo(e){var t,n;const o=ke();return o.id=e.id,o.ghostId=e.ghostId,o.userId=e.userId,o.accessId=e.accessId,o.categoryId=e.categoryId,o.characterValue=e.characterValue,o.entryTimeStamp=e.entryTimeStamp,o.typeId=e.typeId,o.type=e.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"",o}function Ho(e){const t=y();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}function Wo(e){const t=new mt(0,0,0,0,0,0);return t.id=e.id,t.ghostId=e.ghostId,t.accessId=e.accessId,t.ofTheConceptId=e.ofTheConceptId,t.toTheConceptId=e.toTheConceptId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.isTemp=!1,t}var Ko=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Jo(e){return Ko(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let r=[];const i=[];let c=ke(),s=ke();const a=[],l=e.compositionId,u=e.ofTheCompositionId;let d=[],h=yield te(l);for(let e=0;e<h.length;e++)r.push(Wo(h[e]));const f=[],p=[];let y=[];for(let e=0;e<r.length;e++)Jn(p,r[e].ofTheConceptId),Jn(f,r[e].ofTheConceptId),Jn(f,r[e].toTheConceptId),y.push(r[e].ofTheConceptId);for(let e=0;e<f.length;e++){const t=yield Vt(f[e]);l==f[e]&&(c=Mo(t)),u==f[e]&&(s=Mo(t)),i.push(Mo(t))}const v=e.patchObject;for(const e in v){let l=ke();const u=v[e];let h=c;s.id>0&&(h=s),Array.isArray(u)||"object"==typeof u?(l=yield St(e,"",!0,c.userId,4,999),yield bt(v[e],l.id,l.userId,c.id,c.userId,4,999)):l=yield St(e,u,!1,t,o,n);const f=zn(i,l);for(let e=0;e<f.length;e++)if(f[e].id>0){const t=Qn(r,f[e].id);d=d.concat(t),a.push(f[e])}yield Ct(h.id,l.id,c.id,2),i.push(l)}for(let e=0;e<d.length;e++)Bt(d[e].id);Ke.SyncDataOnline()}))}var Xo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},zo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,void 0,void 0,(function*(){var t;let n=yield function(e){return Xo(this,void 0,void 0,(function*(){let t=[];try{var n=b();const o=yield fetch(I.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){let e=yield o.json(),n={};for(let o=0;o<e.length;o++){let r=e[o].concepts;t=e[o].connections;let i=e[o].id;M(r),n[i]=t}return n}return console.log("View Internal Data error",o.status),L(o),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),o=[];for(let r=0;r<e.length;r++){let i=e[r],c=n[i];if(i&&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 he(i,c,e);t.data=n,t.id=i,o.push(t)}else{let e={};e.id=i;let n=yield Vt(i),r={};n.type&&(r[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=r,o.push(e))}}return o}))}var Qo=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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,arguments,void 0,(function*(e,t=""){var n=yield function(e){return Qo(this,arguments,void 0,(function*(e,t=""){var n=k("application/json",t);let o=I.SearchInternalWithAuthenticatedCcsUrl();o=o+"?composition="+e.composition+"&search="+e.search+"&internalComposition="+e.internalComposition+"&type="+e.type+"&inpage="+e.inpage+"&page="+e.page;try{const e=yield fetch(o,{method:"GET",headers:n});return e.ok?yield e.json():(console.log("This is the searching internal error",e.status),L(e),[])}catch(e){throw console.log("This is the searching internal error",e),e}}))}(e,t);return yield qo(n)}))}var er=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 tr(e,t){return er(this,void 0,void 0,(function*(){let n=!0,o=yield vn(e),r=yield Ye(t),i=[];for(let e=0;e<o.length;e++)for(let t=0;t<r.length;t++)o[e].typeId==r[t].id&&i.push(o[e].id);for(let e=0;e<i.length;e++){let t=yield Bt(i[e]);n=n&&t}return n}))}function nr(e,t){return er(this,void 0,void 0,(function*(){let n=yield vn(e),o=yield Ye(t),r=[];for(let e=0;e<n.length;e++)for(let t=0;t<o.length;t++)n[e].typeId==o[t].id&&r.push(n[e].id);return r}))}class or{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class rr{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 ir{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class cr{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}var sr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ar=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},lr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 ur{}ur.isUpdated=!1,ur.isOnlineSync=!1;var dr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 hr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 fr=1,pr=2,yr=3,vr=4,gr=5,mr=6,Cr=7,Tr=8;class wr{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var Nr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Nr(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield Z(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]=e[n]}return t}))}function Ar(e){const t=e.split("_");if(3===t.length){let e=new wr;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 Er(e){return e.startsWith("the_")?e.slice(4):e}var Sr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},Rr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 br(e,t,n){return Rr(this,void 0,void 0,(function*(){var o,r,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Vt(e[d].ofTheConceptId),p=yield Vt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(r=null===(o=p.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Vt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.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[p.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=p.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[o]={},t[e[d].ofTheConceptId]=n);let r=yield Vt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;r.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}var kr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 xr(e,t,n){if(e in t){let o=t[e];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}var Lr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Or(e,t="DESC"){return console.log("this is the order",t),"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var _r=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Pr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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){return Pr(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=mr;let n,o=yield function(e){return hr(this,arguments,void 0,(function*(e,t=""){var n=k("application/json",t);const o=I.FreeschemaQueryUrl(),r=JSON.stringify(e);try{const e=yield fetch(o,{method:"POST",headers:n,body:r});return e.ok?yield e.json():(L(e),console.log("This is the freeschema query error",e.status),[])}catch(e){console.log("This is the freeschema query error others",e),function(e,t=""){if(e.status){let n=new x(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new x(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,o)}}))}(e,""),r=o.conceptIds,i=(o.internalConnections,o.linkers),c=o.reverse,s=o.mainCompositionIds,a=o.countinfo,l=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=Ar(e[n]);t.push(o)}return t}(a);return n=t==pr?yield function(e,t,n,o,r){return _r(this,arguments,void 0,(function*(e,t,n,o,r,i="DESC"){let c=yield Gn(e),s=yield Ir(r);c=Or(c,i);let a=[];a=yield function(e,t){return Sr(this,arguments,void 0,(function*(e,t,n=[]){var o,r,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Vt(e[d].ofTheConceptId),p=yield Vt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Vt(e[d].typeId),a=null!==(r=null===(o=p.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.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[p.id]={}}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=p.id){let n,o=yield Vt(e[d].typeId),r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[r]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;o.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}(c,a,o),a=yield function(e,t){return Sr(this,arguments,void 0,(function*(e,t,n=[]){var o,r,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Vt(e[d].ofTheConceptId),p=yield Vt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Vt(e[d].typeId),a=null!==(r=null===(o=p.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=Er(o));let r={id:f.id,data:{[e]:t}},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=r)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=p.id){let n,o=yield Vt(e[d].typeId),r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],r in n||(n[r]={})):(n={},n[r]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=o.characterValue,c=!1;""==i&&(i=e,i=Er(i),c=!0);let s={id:p.id,data:{[e]:t}};isNaN(Number(i))?i.includes("_s_")||("string"==typeof n[r]&&(n[r]={}),n[r][i]=s):(Array.isArray(n[r])||(n[r]=[]),n[r].push(s))}catch(e){console.log("this is error",e)}}}return t}))}(c,a,o);let l=yield function(e,t,n,o){return Sr(this,arguments,void 0,(function*(e,t,n,o,r=[],i){var c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let o=!1,i=yield Vt(e[n].ofTheConceptId),f=yield Vt(e[n].toTheConceptId);if(r.includes(e[n].id)&&(o=!0),1==o){if(0!=i.id&&0!=f.id&&f.id in t){let o,r=yield Vt(e[n].typeId),a=null!==(s=null===(c=f.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);try{if(t[e[n].ofTheConceptId]){let c={id:i.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},s=r.characterValue+"_reverse";Array.isArray(o[a][s])?o[a][s].push(c):s.includes("_s_")?(o[a][s]=[],o[a][s].push(c)):o[a][s]=c}}catch(e){console.log("this is error",e)}}}else if(0!=i.id&&0!=f.id&&i.id in t){let o,r=yield Vt(e[n].typeId),c=null!==(l=null===(a=i.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);let p=!0,y=r.characterValue;""==y&&(y=f.characterValue,p=!0),""==y&&(y=null!==(d=null===(u=null==f?void 0:f.type)||void 0===u?void 0:u.characterValue)&&void 0!==d?d:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let i=t[e[n].toTheConceptId];if(i){let s={id:f.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(i):Array.isArray(o[c][y])?o[c][r.characterValue].push(s):y.includes("_s_")?(o[c][y]=[],o[c][y].push(s)):o[c][y]=s}}catch(e){console.log("this is error",e)}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e],n.data=t[o[e]],f.push(n)}return f}))}(c,a,[],n,o,s);return l}))}(i,r,s,c,u,l):t==yr?yield function(e,t,n,o,r){return _r(this,arguments,void 0,(function*(e,t,n,o,r,i="DESC"){let c=yield Gn(e),s=yield Ir(r);c=Or(c,i);let a=[];a=yield br(c,a,o),a=yield function(e,t){return kr(this,arguments,void 0,(function*(e,t,n=[]){var o,r,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Vt(e[d].ofTheConceptId),p=yield Vt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Vt(e[d].typeId),a=null!==(r=null===(o=p.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=s.characterValue;""==o&&(o=e,o=Er(o));let r={id:f.id,[e]:t},l=o+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=r)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=p.id){let n,o=yield Vt(e[d].typeId),r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],r in n||(n[r]={})):(n={},n[r]={},t[e[d].ofTheConceptId]=n);try{let t=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",i=p.characterValue,c=o.characterValue,s=!1;""==c&&(c=t,c=Er(c),s=!0);let a={};a[t]={id:p.id,data:i,created_on:e[d].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[r]&&(n[r]={}),n[r][c]=s?a[t]:a):(Array.isArray(n[r])||(n[r]=[]),n[r].push(a[t]))}catch(e){console.log("this is error",e)}}}return t}))}(c,a,o);let l=yield function(e,t,n){return kr(this,arguments,void 0,(function*(e,t,n,o=[],r){var i,c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,p=yield Vt(e[n].ofTheConceptId),y=yield Vt(e[n].toTheConceptId);if(o.includes(e[n].id)&&(f=!0),1==f){if(0!=p.id&&0!=y.id&&y.id in t){let o,r=yield Vt(e[n].typeId),s=null!==(c=null===(i=y.type)||void 0===i?void 0:i.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 i=t[e[n].ofTheConceptId];i&&(i.id=p.id,i.created_on=p.entryTimeStamp);let c=r.characterValue+"_reverse";Array.isArray(o[s][c])?o[s][c].push(i):c.includes("_s_")?(o[s][c]=[],o[s][c].push(i)):o[s][c]=i}}catch(e){console.log("this is error",e)}}}else if(0!=p.id&&0!=y.id&&p.id in t){let o,i=yield Vt(e[n].typeId),c=null!==(a=null===(s=p.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),xr(p.id,r,o);let v=!1,g=i.characterValue;""==g&&(g=y.characterValue,v=!0),""==g&&(g=null!==(u=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let i=null!==(h=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"none",s=t[e[n].toTheConceptId];if(s){let t={};t[i]={data:s[i],id:y.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[i]):o[c][g].push(t)):o[c][g]=v?t[i]:t,xr(y.id,r,t)}}catch(e){console.log("this is error",e)}}}console.log("this is the main compositions",n);for(let e=0;e<n.length;e++){let o={};console.log("this is the main compositions DATA",t[n[e]]),o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,a,n,o,s);return l}))}(i,r,s,c,u,l):t==Tr?yield function(e,t,n,o,r){return _r(this,arguments,void 0,(function*(e,t,n,o,r,i="DESC"){let c=yield Gn(e),s=yield Ir(r);c=Or(c,i);let a={};a=yield function(e){return Lr(this,arguments,void 0,(function*(e,t={},n=[]){var o,r,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Vt(a.ofTheConceptId),u=yield Vt(a.toTheConceptId),d=yield Vt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(r=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue;null===(s=d.characterValue)||void 0===s||s.includes("_s_"),t[h.id]||(t[h.id]={}),t[h.id][p]||(t[h.id][p]={}),t[f.id]||(t[f.id]={}),t[f.id][y]=v}return t}))}(c,a,o),a=yield function(e){return Lr(this,arguments,void 0,(function*(e,t={},n=[]){var o,r,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Vt(a.ofTheConceptId),u=yield Vt(a.toTheConceptId),d=yield Vt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(r=null===(o=h.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=d.characterValue)&&void 0!==s?s:"";let m=""===g?Er(y):g;const C=m.includes("_s_"),T=!isNaN(Number(m)),w={id:f.id,data:{[y]:v}};t[h.id]||(t[h.id]={}),p in t[h.id]&&"string"!=typeof t[h.id][p]||(t[h.id][p]=T?[]:{});try{if(C)continue;T?t[h.id][p].push(w):t[h.id][p][e?`${m}_reverse`:m]=w}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,o);let l=yield function(e,t,n){return Lr(this,arguments,void 0,(function*(e,t,n,o=[],r){var i,c,s;const a=[];for(const n of e){const e=o.includes(n.id),a=yield Vt(n.ofTheConceptId),l=yield Vt(n.toTheConceptId),u=yield Vt(n.typeId);if(0===a.id||0===l.id)continue;const d=e?l:a,h=e?a:l,f=d.id,p=h.id,y=null!==(c=null===(i=d.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",v=u.characterValue+"_reverse",g=u.characterValue||h.characterValue||(null===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const o=t[f][y],i=t[p],c={id:h.id,data:i,created_on:n.entryTimeStamp};xr(f,r,t[f]);try{e?Array.isArray(o[v])?o[v].push(c):o[v]=[c]:Array.isArray(o)?o.push(i):Array.isArray(o[g])?o[g].push(c):g.includes("_s_")?(o[g]=[],o[g].push(c)):o[g]=[c],xr(p,r,c)}catch(e){console.error("Error processing connection:",e)}}else console.log("This is the error in the source")}for(const e of n){const n=yield Vt(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,o,s);return l}))}(i,r,s,c,u,l):yield function(e,t,n,o){return _r(this,void 0,void 0,(function*(){let t=yield Gn(e);t=Or(t);let r=[];r=yield br(t,r,o),r=yield function(e,t,n){return Rr(this,void 0,void 0,(function*(){var o,r,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Vt(e[d].ofTheConceptId),p=yield Vt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(r=null===(o=p.type)||void 0===o?void 0:o.characterValue)&&void 0!==r?r:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Vt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,o=a.characterValue;""==o&&(o=e,o=Er(o));let r={[e]:t},l=o+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=r)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=p.id){let n,o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);let r=yield Vt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=r.characterValue,c=(r.characterValue,!1);""==i&&(i=e,i=Er(i),c=!0);let s={[e]:t};isNaN(Number(i))?r.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i]=c?t:s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(t))}catch(e){console.log("this is error",e)}}}return t}))}(t,r,o);let i=yield function(){return Rr(this,arguments,void 0,(function*(e=[],t=[],n=[],o,r=[]){var i,c,s,a,l,u;let d=[],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;r.includes(e[n].id)&&(o=!0);let d=yield Vt(e[n].ofTheConceptId),h=yield Vt(e[n].toTheConceptId);if(1==o){if(0!=d.id&&0!=h.id&&h.id in t){let o,r=null!==(c=null===(i=h.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?o=t[e[n].toTheConceptId]:(o={},o[r]={},t[e[n].toTheConceptId]=o);let s=yield Vt(e[n].typeId);try{let i=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(o[r][i])?o[r][i].push(c):s.characterValue.includes("_s_")?(o[r][i]=[],o[r][i].push(c)):o[r][i]=c)}catch(e){console.log("this is error",e)}}}else if(0!=d.id&&0!=h.id&&d.id in t){let o,r=null!==(a=null===(s=d.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[r]&&(o[r]={})):(o={},o[r]={},t[e[n].ofTheConceptId]=o);let i=!1,c=(yield Vt(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,i=!0),""==c&&(c=null!==(u=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(o[r])?i?o[r].push(s[c]):o[r].push(s):Array.isArray(o[r][c])?o[r][c].push(s):c.includes("_s_")?(o[r][c]=[],i?o[r][c].push(s[c]):o[r][c].push(s)):o[r][c]=i?s[c]:s)}catch(e){console.log("this is error",e)}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],d.push(o))}return d}))}(t,r,n,[],o);return i}))}(i,0,s,c),n}))}class Fr{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=fr,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var Gr,Ur=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Br(e,t){return Ur(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield mn(e),r=yield pn(t);for(let e=0;e<n.length;e++)n[e].typeId==r.id&&o.push(n[e])}else{let n=yield vn(e);for(let e=0;e<n.length;e++)V.AddConnection(n[e]);let r=yield pn(t);for(let e=0;e<n.length;e++)n[e].typeId==r.id&&o.push(n[e])}return o}))}function Dr(e,t,n){return Ur(this,arguments,void 0,(function*(e,t,n,o=!1){let r=[],i=[];if(r=o?yield Br(t,n,o):yield Br(e,n,o),o)for(let t=0;t<r.length;t++)r[t].ofTheConceptId==e&&i.push(r[t]);else for(let e=0;e<r.length;e++)r[e].toTheConceptId==t&&i.push(r[e]);return i}))}function Vr(e){let t=Gr.None;for(const n of e)switch(n){case"read":t|=Gr.Read;break;case"write":t|=Gr.Write;break;case"execute":t|=Gr.Execute;break;case"delete":t|=Gr.Delete}return 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"}(Gr||(Gr={}));var jr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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())}))},Mr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Hr{static initialize(){if(this.baseUrl=process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("ACCESS_CONTROL_BASE_URL is not defined in environment");console.log("AccessControlService initialized.")}static checkAccessOfConcept(e,t,n,o){return Mr(this,void 0,void 0,(function*(){var r;const i=yield Vt(n);if(999===i.userId||i.userId===e)return!0;const c=null!==(r=i.accessId)&&void 0!==r?r:0;return o=o||this.getEntityIdConceptByUserId(e),yield this.accessCache.hasAccess(o,c,t)}))}static checkAccessOfConceptList(e,t,n,o){return Mr(this,void 0,void 0,(function*(){const r=yield M(n),i=Array.from(r.values()).filter((t=>t.userId!==e&&999!==t.userId)).map((e=>{var t;return null!==(t=e.accessId)&&void 0!==t?t:0})).filter(((e,t,n)=>n.indexOf(e)===t));return o=o||this.getEntityIdConceptByUserId(e),(yield this.accessCache.getAccessibleConcepts(o,i,t)).length===n.length}))}static filterConceptListByAccess(e,t,n,o){return Mr(this,void 0,void 0,(function*(){var r;const i=yield M(n),c=Array.from(i.values()).filter((t=>t.userId!==e&&999!==t.userId)).map((e=>{var t;return null!==(t=e.accessId)&&void 0!==t?t:0})).filter(((e,t,n)=>n.indexOf(e)===t));o=o||this.getEntityIdConceptByUserId(e);const s=new Set(yield this.accessCache.getAccessibleConcepts(o,c,t)),a=[];for(const t of i.values())(t.userId===e||999===t.userId||s.has(null!==(r=t.accessId)&&void 0!==r?r:0))&&a.push(t.id);return a}))}static getEntityIdConceptByUserId(e){return e}static assignAccessToEntity(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access",e,"Failed to assign access to entity")}))}static assignPublicAccess(e){return Mr(this,void 0,void 0,(function*(){var t,n;return this._post("/api/access-control/public-access",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0,conceptIdList:null!==(n=e.conceptIdList)&&void 0!==n?n:[]}),"Failed to assign public access")}))}static assignPublicAccessBlukConcept(e){return Mr(this,void 0,void 0,(function*(){var t,n;return this._post("/api/access-control/public-access",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0,conceptId:null!==(n=e.conceptId)&&void 0!==n?n:0}),"Failed to assign public access")}))}static assignAccessToEntityBulk(e){return Mr(this,void 0,void 0,(function*(){var t;return this._post("/api/access-control/access/bulk",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0}),"Failed to assign access in bulk")}))}static assignAccessByUser(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/user-access",e,"Failed to assign access by user")}))}static revokeAccess(e){return Mr(this,void 0,void 0,(function*(){const{conceptId:t,access:n,entityId:o}=e,r=`/api/access-control/access?conceptId=${t}&access=${encodeURIComponent(n)}&entityId=${o}`;return this._delete(r,void 0,"Failed to revoke access")}))}static revokeAccessBulk(e){return Mr(this,void 0,void 0,(function*(){return this._delete("/api/access-control/access/bulk",e,"Failed to revoke access in bulk")}))}static getAccessList(e,t){return Mr(this,void 0,void 0,(function*(){const n=`/api/access-control/access-list?conceptId=${e}&userId=${t}`;return this._get(n,"Failed to get access list")}))}static getPublicAccessList(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/by-concept-ids",e,"Failed to get public access list")}))}static revokePublicAccess(e){return Mr(this,void 0,void 0,(function*(){return this._delete("/api/access-control/public-access",e,"Failed to revoke public access")}))}static checkAccess(e){return Mr(this,void 0,void 0,(function*(){const t=`/api/access-control/access/check?conceptId=${e.conceptId}&permission=${encodeURIComponent(e.permission)}&entityId=${e.entityId}`;return this._get(t,"Failed to check access")}))}static checkAccessByUser(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/user-access/check",e,"Failed to check access by user")}))}static filterConceptsByAccess(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/concepts/filter-by-access",e,"Failed to filter concepts by access")}))}static checkAccessOfConceptBulk(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/concepts/check-access-bulk",e,"Failed to check access of concept bulk")}))}static getEntitiesByAccess(e,t){return Mr(this,void 0,void 0,(function*(){const n=`/api/access-control/entities/by-access?conceptId=${e}&access=${encodeURIComponent(t)}`;return this._get(n,"Failed to get entities by access")}))}static getEntitiesWithAccess(e){return Mr(this,void 0,void 0,(function*(){const t=`/api/access-control/entities/with-access?conceptId=${e}`;return this._get(t,"Failed to get entities with access")}))}static getAccessGroupByEntity(e){return Mr(this,void 0,void 0,(function*(){const t="/api/access-control/access-group/by-entity"+(void 0!==e?`?entityId=${e}`:"");return this._get(t,"Failed to get access group by entity")}))}static getAccessGroupByUser(e){return Mr(this,void 0,void 0,(function*(){const t="/api/access-control/access-group/by-user"+(void 0!==e?`?userId=${e}`:"");return this._get(t,"Failed to get access group by user")}))}static getPublicAccessByAccessIds(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/by-access-ids",e,"Failed to get public access by access ids")}))}static getFullAccessMappingForPublic(){return Mr(this,void 0,void 0,(function*(){return this._get("/api/access-control/concepts/by-public-access","Failed to get full access mapping for public")}))}static assignPublicAccessForAllUser(){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/assign-for-all-users",void 0,"Failed to assign public access for all user")}))}static assignAccessByConncetionTypeOfUser(){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access/by-connection-type",void 0,"Failed to assign access by connection type of user")}))}static setAccessInheritance(e){return Mr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access-inheritance",e,"Failed to set access inheritance")}))}static getAccessInheritanceStatus(e){return Mr(this,arguments,void 0,(function*(e,t=999){const n=`/api/access-control/access-inheritance/status?mainConceptId=${e}&connectionTypeId=${t}`;return this._get(n,"Failed to get access inheritance status")}))}static _get(e,t){return Mr(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}${e}`,{method:"GET"});if(!n.ok)throw new Error(t);return n.json()}))}static _post(e,t,n){return Mr(this,void 0,void 0,(function*(){const o=yield fetch(`${this.baseUrl}${e}`,Object.assign({method:"POST",headers:{"Content-Type":"application/json"}},void 0!==t?{body:JSON.stringify(t)}:{}));if(!o.ok)throw new Error(n||"Request failed");return o.json()}))}static _delete(e,t,n){return Mr(this,void 0,void 0,(function*(){const o=yield fetch(`${this.baseUrl}${e}`,Object.assign({method:"DELETE",headers:t?{"Content-Type":"application/json"}:void 0},t?{body:JSON.stringify(t)}:{}));if(!o.ok)throw new Error(n||"Request failed");return o.json()}))}}Hr.accessCache=new class{constructor(){if(this.userAccessCache=new Map,this.publicAccessCache=new Map,this.baseUrl=process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("ACCESS_CONTROL_BASE_URL is not defined in environment");console.log("AccessControlCacheService initialized.")}loadCacheFromApi(e){return jr(this,void 0,void 0,(function*(){try{let t=`${this.baseUrl}/access-group/by-entity`;void 0!==e&&(t+=`?entityId=${e}`);const n=yield fetch(t);if(!n.ok)throw new Error(`Failed to fetch data: ${n.statusText}`);const o=yield n.json();this.loadCacheFromJson(o)}catch(e){console.error("[ERROR] loadCacheFromApi failed:",e)}}))}loadCacheFromJson(e){const t=null==e?void 0:e.data;if(!t||"object"!=typeof t)return;const n=t;for(const[e,t]of Object.entries(n)){const n=parseInt(e);this.userAccessCache.has(n)||this.userAccessCache.set(n,new Map);for(const[e,o]of Object.entries(t)){const t=parseInt(e),r=Vr(o);this.userAccessCache.get(n).set(t,r)}}}hasAccess(e,t,n){return jr(this,void 0,void 0,(function*(){if(yield this.hasPublicAccess(t,n))return!0;console.log("length of userAccessCache:",this.userAccessCache.size),this.userAccessCache.has(e)||(yield this.loadCacheFromApi(e));const o=this.userAccessCache.get(e),r=null==o?void 0:o.get(t);return void 0!==r&&(r&n)===n}))}getAccessibleConcepts(e,t,n){return jr(this,void 0,void 0,(function*(){const o=[],r=[];for(const e of t)(yield this.hasPublicAccess(e,n))?o.push(e):r.push(e);console.log("length of userAccessCache:",this.userAccessCache.size),r.length>0&&!this.userAccessCache.has(e)&&(yield this.loadCacheFromApi(e));const i=this.userAccessCache.get(e);for(const e of r){const t=null==i?void 0:i.get(e);void 0!==t&&(t&n)===n&&o.push(e)}return o}))}getAccessByUser(e){return jr(this,void 0,void 0,(function*(){var t;return this.userAccessCache.has(e)||(yield this.loadCacheFromApi(e)),new Map(null!==(t=this.userAccessCache.get(e))&&void 0!==t?t:[])}))}getAccessByConcept(e){return jr(this,void 0,void 0,(function*(){const t=new Map;0===this.userAccessCache.size&&(yield this.loadCacheFromApi());for(const[n,o]of this.userAccessCache){const r=o.get(e);void 0!==r&&t.set(n,r)}return t}))}deleteRecordByUserId(e){this.userAccessCache.delete(e)}deletePublicAccessRecordById(e){console.log(`Deleting public access for concept ${e}`),this.publicAccessCache.delete(e)}clearCache(){console.log("Clearing access control cache..."),this.userAccessCache.clear(),this.publicAccessCache.clear()}getConceptsByPublicAccess(){return jr(this,void 0,void 0,(function*(){const e={};try{const t=yield fetch(`${this.baseUrl}/concepts/by-public-access`);if(!t.ok)throw new Error(`Failed to fetch public access: ${t.statusText}`);const n=yield t.json(),o=null==n?void 0:n.data;if(!o||"object"!=typeof o)return e;for(const[t,n]of Object.entries(o)){const o=parseInt(t),r=Vr(n);this.publicAccessCache.set(o,r),e[o]=n}}catch(e){console.error("[ERROR] Failed to fetch public access data:",e)}return e}))}hasPublicAccess(e,t){return jr(this,void 0,void 0,(function*(){console.log("length of publicAccessCache:",this.publicAccessCache.size),this.publicAccessCache.has(e)||(yield this.getConceptsByPublicAccess());const n=this.publicAccessCache.get(e);return void 0!==n&&(n&t)===t}))}getConceptsWithPublicAccess(e,t){return jr(this,void 0,void 0,(function*(){const n=[],o=[];for(const r of e){const e=this.publicAccessCache.get(r);void 0!==e?(e&t)===t&&n.push(r):o.push(r)}if(o.length>0){yield this.getConceptsByPublicAccess();for(const e of o){const o=this.publicAccessCache.get(e);void 0!==o&&(o&t)===t&&n.push(e)}}return n}))}},Hr.initialize();var Wr=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(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 Kr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.transactionId=Math.random().toString().substring(5)}initialize(){return Wr(this,void 0,void 0,(function*(){yield Ke.initializeTransaction(this.transactionId)}))}markAction(){return Wr(this,void 0,void 0,(function*(){yield Ke.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Wr(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},yield Ke.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Wr(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield Ke.SyncDataOnline(this.transactionId),this.actions={concepts:[],connections:[]},this.success=!1}))}MakeTheInstanceConcept(e,t){return Wr(this,arguments,void 0,(function*(e,t,n=!1,o,r,i=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield yt(e,t,n,o,r,i,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return Wr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield _t(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 Wr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const r=yield cn(e,t,n,o,this.actions);return yield this.markAction(),r}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,o,r,i,c){return Wr(this,arguments,void 0,(function*(e,t,n,o,r,i,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const u=yield Ot(e,t,n,o,r,i,c,s,a,l,this.actions);return yield this.markAction(),u}catch(e){throw console.log(e),this.success=!1,e}}))}}function Jr(e=""){A.BearerAccessToken=e}function Xr(t="",n="",o="",r=""){I.BASE_URL=t,I.AI_URL=n,console.log("This ist he base url",I.BASE_URL),A.BearerAccessToken=o,A.JwtSecret=r,function(){return dr(this,void 0,void 0,(function*(){return yield new e(!0),yield function(){return lr(this,void 0,void 0,(function*(){}))}(),!0}))}().then((()=>{const e=(new Date).getTime();(function(){return w(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];T.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{a.isDataLoaded=!0,a.isCharacterLoaded=!0,a.isTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare concept data is ",t)})),function(){return ar(this,void 0,void 0,(function*(){var e=yield s();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Le.AddConceptToMemory(n)}}))}().then((()=>{a.isLocalDataLoaded=!0,a.isLocalTypeLoaded=!0,a.isLocalCharacterLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare local concept ",t)})),function(){return sr(this,void 0,void 0,(function*(){!function(){sr(this,void 0,void 0,(function*(){var e=yield s();if(Array.isArray(e))for(var t=0;t<e.length;t++)_e.AddConnection(e[t])}))}()}))}().then((()=>{a.isLocalConnectionLoaded=!0})),function(){return sr(this,void 0,void 0,(function*(){!function(){sr(this,void 0,void 0,(function*(){var e=yield c();if(Array.isArray(e))for(var t=0;t<e.length;t++)V.AddConnectionToMemory(e[t])}))}()}))}().then((()=>{a.isConnectionLoaded=!0,a.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare connections ",t)}))}))}})();var r=exports;for(var i in o)r[i]=o[i];o.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALLID:()=>Ui,AccessControlService:()=>or,AddGhostConcept:()=>Qo,AddGhostConnection:()=>Ko,BaseUrl:()=>n,BinaryTree:()=>R,CCSConfig:()=>Ti,Composition:()=>To,CompositionBinaryTree:()=>po,CompositionNode:()=>fo,Concept:()=>S,ConceptsData:()=>P,Connection:()=>J,ConnectionData:()=>Z,CreateComposition:()=>St,CreateConnection:()=>Wt,CreateConnectionBetweenTwoConcepts:()=>tn,CreateConnectionBetweenTwoConceptsGeneral:()=>on,CreateDefaultConcept:()=>L,CreateDefaultLConcept:()=>je,CreateSession:()=>Fo,CreateSessionVisit:()=>Go,CreateTheCompositionLocal:()=>Dt,CreateTheCompositionWithCache:()=>No,CreateTheConnection:()=>rt,CreateTheConnectionGeneral:()=>$t,CreateTheConnectionLocal:()=>Ut,DATAID:()=>_i,DATAIDDATE:()=>Si,DATAV2:()=>Ei,DeleteConceptById:()=>Bn,DeleteConnectionById:()=>Yt,DeleteConnectionByTypeBulk:()=>fi,FilterSearch:()=>gi,FormatFromConnections:()=>ei,FreeSchemaResponse:()=>j,FreeschemaQuery:()=>Ki,GetAllConnectionsOfComposition:()=>fe,GetAllConnectionsOfCompositionBulk:()=>ae,GetAllTheConnectionsByTypeAndOfTheConcept:()=>Xi,GetComposition:()=>ve,GetCompositionBulk:()=>Jn,GetCompositionBulkWithDataId:()=>zn,GetCompositionFromConnectionsWithDataId:()=>Qn,GetCompositionFromConnectionsWithDataIdInObject:()=>qn,GetCompositionList:()=>Ue,GetCompositionListLocal:()=>Ze,GetCompositionListLocalWithId:()=>et,GetCompositionListWithId:()=>be,GetCompositionLocal:()=>ze,GetCompositionLocalWithId:()=>Qe,GetCompositionWithAllIds:()=>ge,GetCompositionWithCache:()=>So,GetCompositionWithDataIdBulk:()=>bo,GetCompositionWithDataIdWithCache:()=>Uo,GetCompositionWithId:()=>Ie,GetCompositionWithIdFromMemory:()=>Te,GetCompositionWithIdFromMemoryFromConnections:()=>Ne,GetConceptBulk:()=>te,GetConceptByCharacter:()=>Se,GetConceptByCharacterAndCategoryDirectApi:()=>Nn,GetConceptByCharacterAndType:()=>lt,GetConceptByTypeBulk:()=>dt,GetConnectionBulk:()=>$n,GetConnectionById:()=>Kt,GetConnectionByTypeBulk:()=>yi,GetConnectionOfTheConcept:()=>Mt,GetLink:()=>cn,GetLinkRaw:()=>sn,GetLinkerConnectionFromConcepts:()=>bn,GetLinkerConnectionToConcepts:()=>En,GetRelation:()=>Do,GetRelationRaw:()=>jo,GetRequestHeader:()=>V,GetRequestHeaderWithAuthorization:()=>D,GetTheConcept:()=>Zt,GetUserGhostConnectionId:()=>zo,GetUserGhostId:()=>Jo,GiveConnection:()=>Zi,HandleHttpError:()=>M,HttpResponse:()=>l,JUSTDATA:()=>Ri,LConcept:()=>De,LConnection:()=>Lt,LISTNORMAL:()=>bi,LoginToBackend:()=>eo,MakeTheInstanceConcept:()=>_t,MakeTheInstanceConceptLocal:()=>Ot,MakeTheTimestamp:()=>jn,MakeTheTypeConcept:()=>Cn,MakeTheTypeConceptApi:()=>xn,NORMAL:()=>xi,PatcherStructure:()=>pi,PermissionSet:()=>qi,RAW:()=>Li,RecursiveSearchApi:()=>Xn,SchemaQueryListener:()=>Qi,SearchAllConcepts:()=>ko,SearchLinkInternal:()=>ui,SearchLinkMultipleAll:()=>Zo,SearchLinkMultipleApi:()=>Yo,SearchQuery:()=>Mn,SearchStructure:()=>Ci,SearchWithLinker:()=>_o,SessionData:()=>vi,Signin:()=>io,Signup:()=>no,SplitStrings:()=>B,SyncData:()=>it,TokenRefreshError:()=>a,TokenStorage:()=>o,Transaction:()=>rr,TrashTheConcept:()=>Vn,UpdateComposition:()=>Io,UpdateCompositionLocal:()=>ri,UserBinaryTree:()=>$o,ViewInternalData:()=>ai,convertFromLConceptToConcept:()=>ni,deleteWithRetry:()=>p,getFromDatabaseWithType:()=>m,getFromDatabaseWithTypeOld:()=>N,getOAuthToken:()=>r,getWithRetry:()=>f,init:()=>sr,patchWithRetry:()=>v,postWithRetry:()=>h,putWithRetry:()=>y,recursiveFetch:()=>Ae,recursiveFetchNew:()=>go,refreshOAuthToken:()=>c,requestWithRetry:()=>u,storeToDatabase:()=>T,updateAccessToken:()=>cr});class n{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}n.BASE_URL="https://localhost:7053/",n.AI_URL="https://ai.freeschema.com",n.MQTT_URL="192.168.1.249",n.NODE_URL="http://localhost:5001/";class o{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(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());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(console.log("Received 401 Unauthorized, attempting token refresh..."),yield d()){console.log("Token refreshed successfully, retrying request..."),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)throw e;console.error(`Request failed (attempt ${n+1}/${r+1}):`,e)}throw new Error("Request failed after all retry attempts")}))}function h(e,t,n){return s(this,void 0,void 0,(function*(){return u("POST",e,t,n)}))}function f(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 y(e,t,n){return s(this,void 0,void 0,(function*(){return u("PUT",e,t,n)}))}function p(e,t){return s(this,void 0,void 0,(function*(){return u("DELETE",e,t)}))}function v(e,t,n){return s(this,void 0,void 0,(function*(){return u("PATCH",e,t,n)}))}class g{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}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 T(e,t){}function m(e,t,n){return C(this,void 0,void 0,(function*(){}))}function N(e){return C(this,void 0,void 0,(function*(){}))}function w(e){return C(this,void 0,void 0,(function*(){}))}class I{}I.isTypeLoaded=!1,I.isCharacterLoaded=!1,I.isDataLoaded=!1,I.isLocalDataLoaded=!1,I.isLocalCharacterLoaded=!1,I.isLocalTypeLoaded=!1,I.isConnectionLoaded=!1,I.isConnectionTypeLoaded=!1,I.isLocalConnectionLoaded=!1;class A{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var k=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 x{static waitForDataToLoad(){return k(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isCharacterLoaded)return e("done");setTimeout(x.checkFlag,1e3,e)}static addNodeToTree(e){return k(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 k(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 A(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 k(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return k(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))}}x.characterRoot=null;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 R{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 _(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isDataLoaded)return e("done");setTimeout(R.checkFlag,1e3,e)}static addConceptToTree(e){var t=new A(e.id,e,null,null),n=new A(e.characterValue,e,null,null);x.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return _(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return _(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}}R.root=null;class S{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 L(){let e=U(new Date),t=U(new Date);return new S(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function U(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 b=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 E{static addNodeToTree(e){return b(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 A(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 b(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isTypeLoaded)return e("done");setTimeout(E.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return b(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 b(this,void 0,void 0,(function*(){let n=L();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}}E.typeRoot=null;var F=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 P{constructor(){this.name="conceptsArray"}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){this.NPC.includes(e)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(e))}static GetNpc(e){return!!this.NPC.includes(e)}static AddConceptToStorage(e){e.id}static AddConcept(e){e.id>0&&(R.addConceptToTree(e),E.addConceptToTree(e),x.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(R.addConceptToTree(e),E.addConceptToTree(e),x.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);R.removeNodeFromTree(e.id),e.id}static GetConcept(e){return F(this,void 0,void 0,(function*(){var t=L(),n=yield R.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return F(this,void 0,void 0,(function*(){var t=L(),n=x.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return F(this,void 0,void 0,(function*(){var t=L(),n=x.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return F(this,void 0,void 0,(function*(){return L(),yield E.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return F(this,void 0,void 0,(function*(){var n=L(),o=yield x.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 F(this,void 0,void 0,(function*(){let n=[];return n=yield E.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return x.characterRoot}getName(){return this.name}}P.conceptsArray=[],P.NPC=[],P.conceptDictionary=[];var G=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 B(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}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 V(){return O(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(o.isTokenExpiredOrNearExpiry()&&o.hasOAuthCredentials()){console.log("Token expired or near expiry, refreshing...");const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success?console.log("Token refreshed successfully"):console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:t}}))}function D(){return O(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()){console.log("Token expired or near expiry, refreshing...");const e=yield r(o.CLIENT_ID,o.CLIENT_SECRET,o.APPLICATION_NAME,!0);e.success?console.log("Token refreshed successfully"):console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+o.BearerAccessToken,Accept:n}}))}class j{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 M(e){if(e.status>=400){let t=new j(e.statusText,!1,e.status,"");throw t.setUrl(e.url),t}}function H(e){if(401==e.status){let t=new j(e.body,!1,e.status,"");throw t.setUrl(e.headers.url),t}}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())}))};function W(e,t){return $(this,void 0,void 0,(function*(){try{var o=new URLSearchParams;o.append("type",e),o.append("user_id",t.toString());var i=yield V("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:o});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++)P.AddConcept(e[r])}console.log("GetAllConceptsByType error",c.status),M(c)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class J{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=L(),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=U(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class z{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Q=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 K{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 z(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return Q(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isConnectionLoaded)return e("done");setTimeout(K.checkFlag,1e3,e)}static removeNodeFromTree(e){return Q(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return Q(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}K.connectionroot=null;var q=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 Y{static addNodeToTree(e){return q(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 q(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isConnectionTypeLoaded)return e("done");setTimeout(Y.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new z(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 q(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 q(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}))}}Y.connectionTypeRoot=null;var X=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 Z{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){}static AddConnection(e){e.isTemp||(K.addConnectionToTree(e),Y.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(K.addConnectionToTree(e),Y.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(e.id,K.removeNodeFromTree(e.id),Y.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return K.connectionroot}static GetConnectionTypeTree(){return Y.connectionTypeRoot}static GetConnection(e){return X(this,void 0,void 0,(function*(){var t=new J(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield K.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConnectionsOfCompositionLocal(e){return X(this,void 0,void 0,(function*(){var t=[],n=yield Y.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}}Z.connectionArray=[],Z.connectionDictionary=[];var ee=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 te(e){return ee(this,void 0,void 0,(function*(){let t=[];try{var o=[];for(let n=0;n<e.length;n++){let i=yield P.GetConcept(e[n]);0==i.id?o.push(e[n]):t.push(i)}if(0==o.length)return t;{var i=yield V();const e=yield fetch(n.GetConceptBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});if(e.ok){let n=yield e.json();if(n.length>0)for(let e=0;e<n.length;e++){let o=n[e];t.push(o),P.AddConcept(o)}}else console.log("Get Concept Bulk error",e.status),M(e);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var 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 oe(){return ne(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 te(t)}}))}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())}))};function re(){return ie(this,arguments,void 0,(function*(e=[]){var t=[];for(let o=0;o<e.length;o++){var n=yield Z.GetConnectionsOfCompositionLocal(e[o]);t.push(...n)}return t}))}function ce(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||Z.RemoveConnection(t[n]))}var se=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(){return se(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var o=yield re(e),i=yield function(){return se(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=yield V();const r=yield fetch(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++)Z.AddConnection(e[i]),t.push(e[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),M(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 ce(t=i,o),yield oe(t),t}))}var le=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 de=new Map;function ue(e){return le(this,void 0,void 0,(function*(){let t=L();if(de.has(e))return de.get(e)||t;const o=(()=>le(this,void 0,void 0,(function*(){try{var o=yield P.GetConcept(e);let r=P.GetNpc(e);if(0!=o.id||r)return o;{var i=yield V("application/x-www-form-urlencoded");const o=yield fetch(n.GetConceptUrl(),{method:"POST",headers:i,body:`id=${e}`});return o.ok?(t=yield o.json(),t.id>0?P.AddConcept(t):P.AddNpc(e)):(console.log("Get the concept error",o.status,e),M(o)),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{de.delete(e)}})))();return de.set(e,o),o}))}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(e){return he(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield Z.GetConnectionsOfCompositionLocal(e)).length)t=yield ye(e);else{var n=yield ye(e);ce(n,t),t=n}return t}))}function ye(e){return he(this,void 0,void 0,(function*(){var t=[];try{var o=yield V("application/x-www-form-urlencoded");const r=yield fetch(n.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:o,body:`composition_id=${e}`});if(!r.ok)throw M(r),new Error(`Error! status: ${r.status}`);const c=yield r.json();for(var i=0;i<c.length;i++)Z.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 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(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 ge(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield ke(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 Ce(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 Te(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 me(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield Z.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 Ne(e,t){return pe(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 P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 we(e,t){return pe(this,arguments,void 0,(function*(e,t,n=[]){var o,i,r={},c=yield P.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield ue(e));var s=yield Ae(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 Ie(e){return pe(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield fe(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield P.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield ue(e));var a=yield Ae(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 Ae(e,t,n){return pe(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield P.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield ue(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield P.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 P.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield ue(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield P.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(d),y.type=u));var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ae(f,t,n,o);s[p]=e}}else{const e=yield Ae(f,t,n,o);a[p]=e,s=a}}return s}))}function ke(e,t,n){return pe(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[];if(0==e)return null;var l=yield P.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield ue(e)),0!=l.id&&null==l.type){var d=l.typeId,u=yield P.GetConcept(d);l.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 P.GetConcept(f);null!=y&&0!=y.id||null==f||null==f||(y=yield ue(f)),y&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield P.GetConcept(d),y.type=u,null==u&&null!=d&&null!=d&&(u=yield ue(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 ke(f,t,n);s[p]=e}}else{const e=yield ke(f,t,n);a[p]=e,s=a}}return s}))}var xe=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){return xe(this,void 0,void 0,(function*(){let t=L();try{var o=yield V("application/x-www-form-urlencoded");const i=yield fetch(n.GetConceptByCharacterValueUrl(),{method:"POST",headers:o,body:`character_value=${e}`});return i.ok?(t=yield i.json(),t.id>0&&P.AddConcept(t)):(console.log("Error in Getting concept by character value Error",i.status),M(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 Re=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 Se(e){return Re(this,void 0,void 0,(function*(){var t=yield P.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield _e(e),t=yield P.GetConceptByCharacter(e)),t}))}var Le=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(e,t){return Le(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield Se(e),r=[];if(i){yield W(e,t);for(var c=yield P.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ae(a),l=s;l<s+n;l++)if(c[l]){var d=yield Ce(c[l].id);r.push(d)}}return r}))}function be(e,t){return Le(this,arguments,void 0,(function*(e,t,n=10,o=1){var i=yield Se(e),r=[];if(i){yield W(e,t);for(var c=yield P.GetConceptsByTypeIdAndUser(i.id,t),s=n*(o-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield ae(a),l=s;l<s+n;l++)if(c[l]){var d=yield Te(c[l].id);r.push(d)}}return r}))}class Ee{constructor(e,t,n,o){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let o=0;o<t.variants.length;o++)t.variants[o].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,o,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var o=e.variants[0];if(o)return e.value=o.value,e.key=o.key,e.currentNode=o.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var i=this.inOrderSuccessor(e.rightNode);return e.value=i.value,e.key=i.key,e.variants=i.variants,e.currentNode=i.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,i.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var 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())}))};class Pe{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 Ee(e.id,e,null,null);new Ee(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return Fe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalDataLoaded)return e("done");setTimeout(Pe.checkFlag,1e3,e)}static getNodeFromTree(e){return Fe(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 Fe(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Pe.root=null;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())}))};class Be{static waitForDataToLoad(){return Ge(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalCharacterLoaded)return e("done");setTimeout(Be.checkFlag,1e3,e)}static addNodeToTree(e){return Ge(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 Ee(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 Ge(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))}}Be.LocalCharacterRoot=null;var Oe=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 Ve{static addNodeToTree(e){return Oe(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 Ee(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 Oe(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalTypeLoaded)return e("done");setTimeout(Ve.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Oe(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}))}}Ve.LocalTypeRoot=null;class De{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 je(){let e=new Date,t=new Date;return new De(0,0,0,0,0,"0","0",!1,e,t,0)}var Me=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 He{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(Pe.addConceptToTree(e),Be.addConceptToTree(e),Ve.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Pe.addConceptToTree(e),Be.addConceptToTree(e),Ve.addConceptToTree(e))}static GetConcept(e){return Me(this,void 0,void 0,(function*(){var t=je(),n=yield Pe.getNodeFromTree(e);if(null==n?void 0:n.value){var o=n.value;o&&(t=o)}return t}))}static GetConceptByCharacter(e){return Me(this,void 0,void 0,(function*(){var t=je(),n=Be.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Me(this,void 0,void 0,(function*(){var n=je(),o=yield Be.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 Me(this,void 0,void 0,(function*(){let n=[];return n=yield Ve.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}He.localconceptsArray=[];var $e=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 We{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),0!=e.id||e.isTemp,this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return $e(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isLocalConnectionLoaded)return e("done");setTimeout(We.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return $e(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}}We.connectionArray=[],We.connectionDictionary=[];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())}))};function ze(e){return Je(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield We.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield He.GetConcept(e),a=yield Ke(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:"top"]=a,i}))}function Qe(e){return Je(this,void 0,void 0,(function*(){var t,n,o,i={};o=yield We.GetConnectionsOfCompositionLocal(e);for(var r=[],c=0;c<o.length;c++)r.includes(o[c].ofTheConceptId)||r.push(o[c].ofTheConceptId);var s=yield He.GetConcept(e);if(0!=s.id){var a=yield Ke(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:"top"]=a;var l={}}return l.data=i,l.id=e,l}))}function Ke(e,t,n){return Je(this,arguments,void 0,(function*(e,t,n,o=[]){var i,r,c,s={},a=[],l=yield He.GetConcept(e);if(0!=l.id&&null==l.type){var d=l.typeId,u=yield He.GetConcept(d);l.type=u}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,y=yield He.GetConcept(f);0!=y.id&&null==(null==y?void 0:y.type)&&(d=y.typeId,u=yield He.GetConcept(d),y.type=u);var p=(null!==(c=null===(r=null==y?void 0:y.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace("the_","");if(isNaN(Number(p))){if(p){const e=yield Ke(f,t,n);s[p]=e}}else{const e=yield Ke(f,t,n);a[p]=e,s=a}}return s}))}var qe=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 Ye(e){return qe(this,void 0,void 0,(function*(){return yield He.GetConceptByCharacter(e)}))}var Xe=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 Ze(e,t){return Xe(this,void 0,void 0,(function*(){var n=yield Ye(e),o=[];if(n)for(var i=yield He.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield ze(i[r].id);o.push(c)}return o}))}function et(e,t){return Xe(this,void 0,void 0,(function*(){var n=yield Ye(e),o=[];if(n)for(var i=yield He.GetConceptsByTypeIdAndUser(n.id,t),r=0;r<i.length;r++){var c=yield Qe(i[r].id);o.push(c)}return o}))}function tt(e){return t=this,o=void 0,r=function*(){let t=L();try{var o=yield V();const i=yield h(n.CreateTheConceptUrl(),o,JSON.stringify(e));if(!i.ok)throw H(i),new Error(`Error! status: ${i.status}`);return t=yield i.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 nt(e){return t=this,o=void 0,r=function*(){let t=new J(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var o=yield V(),i=JSON.stringify(e);const r=yield h(n.CreateTheConnectionUrl(),o,i);return r.ok?yield r.json():(console.log("Create the connection error message: ",r),H(r)),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 ot=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 it{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 ot(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)),this.transactionCollections=this.transactionCollections.filter((e=>new Date(e.createdDate).getTime()>(new Date).getTime()-6048e5)),!o)return;t=o.data.concepts.slice(),n=o.data.connections.slice(),t.length>0&&(yield tt(t)),n.length>0&&(yield nt(n))}else{for(let e=0;e<this.conceptsSyncArray.length;e++)P.AddConcept(this.conceptsSyncArray[e]);for(let e=0;e<this.connectionSyncArray.length;e++)Z.AddConnection(this.connectionSyncArray[e]);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),this.conceptsSyncArray=[],yield tt(t)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),this.connectionSyncArray=[],yield nt(n))}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return ot(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 ot(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 ot(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 ot(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e];this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e];this.connectionSyncArray=[]}return"done"}))}}function rt(e,t,n,o,i,r,c){var s=new J(0,e,n,t,o,t,i,t,1,t,0,t,4,t,r,c);return e==n?(s.ofTheConceptId=0,s.toTheConceptId=1,s):(s.isTemp=!0,s.id=Math.floor(1e8*Math.random()),it.AddConnection(s),s)}it.conceptsSyncArray=[],it.connectionSyncArray=[],it.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())}))},st=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 at=new Map;function lt(e,t){return st(this,void 0,void 0,(function*(){let o=yield P.GetConceptByCharacterAndTypeLocal(e,t),i=e+t;if(at.has(i))return at.get(i)||o;const r=(()=>st(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 V();const i=yield fetch(n.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:s,body:c});if(i.ok){let e=yield i.json();o=e,P.AddConcept(o)}else console.log("This is the concept by type and character error",i.status),M(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{at.delete(i)}})))();return at.set(i,r),r}))}function dt(e){return st(this,void 0,void 0,(function*(){let t=[],o=JSON.stringify(e);var i=yield V();const r=yield fetch(n.GetConceptConnectionByType(),{method:"POST",headers:i,body:o});if(r.ok){let e=yield r.json();t=yield te(e)}else console.log("This is the concept by type and character error",r.status),M(r);return t}))}class ut{constructor(e,t,n,o,i,r,c,s,a,l){this.id=0,this.userId=e,this.data=t,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=s,this.entryTimestamp=a,this.isNew=l}}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())}))};let ft=!1,yt=[];const pt=()=>{yt.length>0&&!ft&&yt.shift()()};var vt=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 gt=!1,Ct=[];const Tt=()=>{Ct.length>0&&!gt&&Ct.shift()()};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())}))};class Nt{static getId(){return mt(this,void 0,void 0,(function*(){this.ids.length<10&&(yield function(){return vt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{console.log("trying to fetch more concepts"),Ct.push((()=>vt(this,void 0,void 0,(function*(){try{if(gt)return;if(gt=!0,Nt.ids.length>10)return console.log("Enough IDs available, skipping fetch."),gt=!1,Tt(),e();var o=yield V("application/x-www-form-urlencoded");const t=yield fetch(n.GetReservedIdUrl(),{method:"GET",headers:o});if(!t.ok)throw M(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)Nt.AddId(r[i]);console.log("Ids Fetch Success"),e()}catch(e){e instanceof Error?console.log("get reserved ids error message: ",e.message,n.GetReservedConnectionIdUrl()):console.log("get reserved ids unexpected error: ",e),t(e)}finally{gt=!1,Tt()}})))),Tt()}))}))}());var e=this.ids[0];return this.ids.shift(),e}))}static AddId(e){this.ids.includes(e)||this.ids.push(e)}}Nt.ids=[];class wt{static getId(){return mt(this,void 0,void 0,(function*(){this.connectionIds.length<10&&(yield function(){return ht(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{yt.push((()=>ht(this,void 0,void 0,(function*(){try{if(ft)return;if(ft=!0,wt.connectionIds.length>10)return ft=!1,pt(),e();var o=yield V("application/x-www-form-urlencoded");const t=yield fetch(n.GetReservedConnectionIdUrl(),{method:"GET",headers:o});if(!t.ok)throw M(t),new Error(`Error! status: ${t.status}`);const r=yield t.json();for(var i=0;i<r.length;i++)wt.AddId(r[i]);e()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),t(e)}finally{ft=!1,pt()}})))),pt()}))}))}());var e=this.connectionIds[0];return this.connectionIds.shift(),e}))}static AddId(e){this.connectionIds.includes(e)||this.connectionIds.push(e)}}wt.connectionIds=[];var It=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 At(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return It(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 Nt.getId();let v=new Date,g=new Date;var C=new S(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!0,v,g);return C.isTemp=!1,it.AddConcept(C),y.concepts.push(C),C}))}function kt(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return It(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 Nt.getId();let v=new Date,g=new Date;var C=new S(p,t,i,r,n,o,c,s,e,a,l,d,u,h,f,!1,v,g);return P.AddConcept(C),C.updateRecursion=!0,it.AddConcept(C),y.concepts.push(C),C}))}var xt=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 _t(e,t){return xt(this,arguments,void 0,(function*(e,t,o=!1,i,r,c=999,s=0,a={concepts:[],connections:[]}){let l,d=c,u=(i=o?i:999,999),h=i,f=i,y=r,p=i,v="",g=t.length,C=L();v=e.startsWith("the_")?e:"the_"+e;(new Date).getTime();if(o)C=yield xn(e),l=yield At(t,i,4,i,C.id,C.userId,s,999,u,h,y,p,d,f,a),(new Date).getTime();else if(g>255)C=yield xn(v),l=yield At(t,i,4,i,C.id,C.userId,s,999,u,h,y,p,d,f,a),function(e){ct(this,void 0,void 0,(function*(){try{var t=yield V();const o=yield fetch(n.CreateTheTextDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!o.ok)throw M(o),new Error(`Error! status: ${o.status}`);return yield o.json()}catch(e){throw e instanceof Error?console.log("Create the text error message: ",e.message):console.log("Create the text unexpected error: ",e),e}}))}(new ut(i,t,u,h,y,p,d,f,Date.now().toString(),!0)),(new Date).getTime();else{C=yield xn(v);let e=yield lt(t,C.id);l=e,0==e.id&&0==e.userId&&(l=yield kt(t,i,4,i,C.id,C.userId,12,12,u,h,y,p,d,f,a)),(new Date).getTime()}return l.type=C,l}))}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 St(e){return Rt(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=L();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 _t(o,"",!0,s,a,l),h=p.id,d=p.id,yield St(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 _t(o,"",!0,s,a,l),yield rt(f,y,p.id,p.userId,h,l,p.userId),yield St(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 _t(o,e[o].toString(),!1,s,a,l);yield rt(f,y,p.id,p.userId,h,l,p.userId)}return u}))}class Lt{constructor(e=0,t,n,o,i,r,c=999){this.isTemp=!1,this.applicationId=999,this.type=je(),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=U(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}function Ut(e,t,n,o=1){Math.floor(1e8*Math.random());let i=0,r=0,c=0;i=e,r=t,c=n;let s=new Lt(0,0,0,0,0,0);return e!=t&&(s=new Lt(0,e,t,n,o,4),s.isTemp=!0,s.id=Math.floor(1e8*Math.random()),We.AddConnection(s)),s}var 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 Et(e,t,n,o,i,r){return bt(this,arguments,void 0,(function*(e,t,n,o,i,r,c=0){var s=Math.floor(1e8*Math.random());let a=new Date,l=new Date;var d=new De(s,n,i,o,r,e,t,!0,a,l,c);return d.isTemp=!0,He.AddConcept(d),d}))}var 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())}))},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())}))};function Gt(e,t,n,o){return Pt(this,void 0,void 0,(function*(){var i=yield Ye(e);if(i&&(0==i.id||0==i.userId)){var r=B(e);if(r[0]==e){var c=yield function(e,t,n){return Ft(this,void 0,void 0,(function*(){var t=yield He.GetConceptByCharacterAndTypeLocal(e,51),o=t;return 0==o.id&&(o=t=yield Et(e,"the",n,4,51,4)),o}))}(e,0,o);i=c}else{var s=yield Gt(r[0],t,n,o),a=yield Gt(r[1],t,n,o);a&&(i=c=yield Et(e,r[1],o,s.id,a.id,4))}}return i}))}var 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 Ot(e,t){return Bt(this,arguments,void 0,(function*(e,t,n=!1,o,i,r=999,c=0){var s,a,l,d=o=n?o:999,u=t.length;if(l=e.startsWith("the_")?e:"the_"+e,n)s=yield Gt(e,999,o,o),a=yield Et(t,e,o,4,s.id,4,c);else if(u>255)s=yield Gt(l,999,d,o),a=yield Et(t,l,o,4,s.id,4);else{s=yield Gt(l,999,d,o);var h=yield He.GetConceptByCharacterAndTypeLocal(t,s.id);a=h,0==h.id&&0==h.userId&&(a=yield Et(t,l,o,4,s.id,4))}return a.type=s,a}))}var Vt=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 Vt(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:999,l=null!=c?c:4,d=null!=o?o:0,u=je();for(const o in e)if("string"!=typeof e[o]&&"number"!=typeof e[o])if(null==t&&null==n){var h=d;u=y=yield Ot(o,"",!0,s,a,l),h=y.id,d=y.id,yield Dt(e[o],y.id,y.userId,h,i,r,c)}else{var f=null!=t?t:999,y=(h=d,yield Ot(o,"",!0,s,a,l));yield Ut(f,y.id,h),yield Dt(e[o],y.id,y.userId,h,i,r,c)}else f=null!=t?t:999,h=d,y=yield Ot(o,e[o].toString(),!1,s,a,l),yield Ut(f,y.id,h);return u}))}var jt=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,o){return jt(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 V("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),M(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 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 $t(e,t,n,o,i,r,c){return Ht(this,arguments,void 0,(function*(e,t,n,o,i,r,c,s=1,a=4,l=999,d={concepts:[],connections:[]}){let u=t,h=t,f=t;999!=l&&(f=l);let y=t,p=t,v=yield wt.getId(),g=new J(v,e,n,t,o,f,i,h,s,u,0,y,a,p,r,c);return e==n?(g.ofTheConceptId=0,g.toTheConceptId=1,g):(g.toUpdate=!0,g.isTemp=!1,it.AddConnection(g),d.connections.push(g),g)}))}function Wt(e,t,n){return Ht(this,arguments,void 0,(function*(e,t,n,o={concepts:[],connections:[]}){let i=yield xn(n),r=e.userId;return yield $t(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,r,o)}))}var Jt=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())}))},zt=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())}))},Qt=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 Kt(e){return Qt(this,void 0,void 0,(function*(){var t=yield Z.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var o=yield function(e){return zt(this,void 0,void 0,(function*(){var t=yield Z.GetConnection(e);try{if(0!=t.id)return t;{var o=yield V("application/x-www-form-urlencoded");const i=yield fetch(n.GetConnectionUrl(),{method:"POST",headers:o,body:`id=${e}`});return i.ok?(t=yield i.json(),Z.AddConnection(t)):(console.log("Get Connection Error",i.status),M(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 qt=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 Yt(e){return qt(this,arguments,void 0,(function*(e,t=""){let o=!1;var i=yield Kt(e);return o=yield function(e){return Jt(this,arguments,void 0,(function*(e,t=""){let o=!1;try{const i=new FormData;let r=yield V("application/x-www-form-urlencoded");""!=t&&(r=yield D("application/x-www-form-urlencoded",t)),i.append("id",e.toString()),i.append("apiKey","nodeserver");const c=yield fetch(n.DeleteTheConnectionUrl(),{method:"POST",body:i,redirect:"follow"});c.ok?o=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),M(c))}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),K.removeNodeFromTree(e),Y.removeTypeConcept(i.typeId,e),o}))}var Xt=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 Zt(e){return Xt(this,arguments,void 0,(function*(e,t=999){var n=L();if(e<0)return ni(yield Jo(t,e));if(null!=(n=yield P.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield ue(e)),0!=n.id&&null==n.type&&null==(yield P.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){var o=yield ue(n.typeId);n.type=o}return n}))}var en=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){return en(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,s=e.userId,a=s,l=s;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield nn(o,t,s));var d=yield _t("connection",c,!1,999,999,999);let u=new J(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,s,999,a,4,l,999,999);it.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield nn(u,e,s));var f=yield _t("connection",h,!1,999,999,999);let y=new J(0,e.id,t.id,e.userId,t.userId,e.userId,f.id,f.userId,1e3,s,999,a,4,l,999,999);return it.AddConnection(y),y}))}function nn(e,t){return en(this,arguments,void 0,(function*(e,t,n=null){for(var o,i=t,r=null!=n?n:t.userId,c=r,s=r,a=999,l=e+"_count",d=(null===(o=t.type)||void 0===o?void 0:o.characterValue)+"_s_"+l,u=yield _t("connection",d,!1,r,4,a),h=yield Mt(u.id,t.id,r,10,1),f=[],y=L(),p=0;p<h.length;p++){let e=yield Zt(h[p].toTheConceptId);f.push(e)}if(f.length<1)y=yield _t("count","1",!1,r,4,a);else{var v=f[0];let e=0;try{e=Number(v.characterValue)}catch(t){e=0}e+=1,y=yield _t("count",e.toString(),!1,r,4,a);for(let e=0;e<h.length;e++)Yt(h[e].id)}let g=new J(0,i.id,y.id,i.userId,y.userId,i.userId,u.id,u.userId,1e3,r,999,c,4,s,a,999);yield it.AddConnection(g)}))}function on(e,t,n){return en(this,arguments,void 0,(function*(e,t,n,o=!1,i=!1){var r,c,s=e.userId,a=s,l=s;if(o){let o=n+"_by",c=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield nn(o,t,s));var d=yield _t("connection",c,!1,999,999,999);let u=new J(0,t.id,e.id,t.userId,e.userId,t.userId,d.id,d.userId,1e3,s,999,a,4,l,999,999);it.AddConnection(u)}let u=n+"_s",h=(null===(c=e.type)||void 0===c?void 0:c.characterValue)+"_s_"+u;i&&(yield nn(u,e,s));var f=yield _t("connection",h,!1,999,999,999);return yield $t(e.id,e.userId,t.id,t.userId,f.id,999,999,1e3,4)}))}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,t){return rn(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Zt(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield lt(s,16);if(a.id>0){for(var l=yield Mt(a.id,c.id,c.userId,n,o),d=[],u=0;u<l.length;u++)d.push(l[u].toTheConceptId);for(yield ae(d),u=0;u<l.length;u++){let e=l[u].toTheConceptId,t=yield Zt(e),n=yield me(t.id);r.push(n)}}return r}))}function sn(e,t){return rn(this,arguments,void 0,(function*(e,t,n=10,o=1){var i,r=[],c=yield Zt(e),s=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+t,a=yield lt(s,16);if(a.id>0){for(var l=yield Mt(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 Zt(e);r.push(t)}}return r}))}class an{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 ln{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new an(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}}ln.characterData=[];class dn{constructor(e,t,n,o){this.id=e,this.userId=t,this.referentId=n,this.isNew=o}}var un=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())}))},hn=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,o,i,r){return hn(this,void 0,void 0,(function*(){return new an(t,e,o,t,i,t,r,t,"",!1),yield function(){return un(this,void 0,void 0,(function*(){var e;try{if(0==(e=ln.GetCharacter(e.data)).id){var t=yield V();const i=yield fetch(n.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!i.ok)throw M(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var o=new an(r.userId,e.data,0,0,4,4,999,999,"",!1);return o.id=r.id,ln.AddCharacter(o),r}return new dn(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 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 pn(e,t,n,o,i,r,c,s,a,l,d,u,h,f){return yn(this,void 0,void 0,(function*(){var y=yield lt(e,i),p=y;return 0==p.id&&(p=y=yield At(e,t,n,o,i,r,c,s,a,l,d,u,h,f)),p}))}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,n,o){return gn(this,arguments,void 0,(function*(e,t,n,o,i={concepts:[],connections:[]}){var r=yield Se(e);if(r&&(0==r.id||0==r.userId)){var c=B(e);if(c.length>0)if(console.log(c),c[0]==e){var s=yield function(e,t,n,o,i,r){return vn(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 fn(e,t,n,o,r),a=pn(e,t,4,c,h,u,49,l,n,s,o,i,r,d)}else{var f=yield fn(e,t,n,o,r);f.isNew,a=yield pn(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 Cn(c[0],t,n,o,i),l=yield Cn(c[1],t,n,o,i);l&&(r=yield kt(e,o,a.id,o,l.id,o,999,o,999,o,999,o,t,o,i))}}return r}))}var Tn=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 mn=new Map;function Nn(e,t){return Tn(this,void 0,void 0,(function*(){let o=L();if(mn.has(e+t))return mn.get(e+t)||o;const i=(()=>Tn(this,void 0,void 0,(function*(){try{var i=yield V("application/x-www-form-urlencoded");const r=yield fetch(n.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${e}&category_id=${t}`});if(r.ok){let e=yield r.json();o=e,P.AddConcept(o)}else console.log("This is the concept by category and character direct api error",r.status),M(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{mn.delete(e+t)}})))();return mn.set(e+t,i),i}))}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())}))};function In(e){return wn(this,void 0,void 0,(function*(){let t=L();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var o=B(e);if(o.length>1){let n=1,i=yield In(o[0]);0!=i.id&&(n=i.id),t=yield function(e,t){return wn(this,void 0,void 0,(function*(){let n=yield P.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield Nn(e,t)),n}))}(e,n)}else o[0]==e&&1==n?t=yield function(e){return wn(this,void 0,void 0,(function*(){console.log("inside the character length function",e);var t=yield P.GetConceptByCharacterAndTypeLocal(e,49);return console.log("inside the character length function after",t),0==t.id&&(t=yield _e(e)),t}))}(e):o[0]==e&&(t=yield function(e){return wn(this,void 0,void 0,(function*(){var t=yield P.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield _e(e)),t}))}(e));return t}))}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())}))};const kn=new Map;function xn(e,t){return An(this,void 0,void 0,(function*(){let t=L();if(kn.has(e))return kn.get(e)||t;const o=(()=>An(this,void 0,void 0,(function*(){try{if(t=yield In(e),0==t.id||4==t.typeId){var o=yield V("application/x-www-form-urlencoded");const i=yield fetch(n.MakeTheTypeConceptUrl(),{method:"POST",headers:o,body:`type=${e}`});if(!i.ok)throw M(i),new Error(`Error! status: ${i.status}`);let r=yield i.json();t=r,t.id>0&&P.AddConcept(t)}return t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{kn.delete(e)}})))();return kn.set(e,o),o}))}var _n=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 Rn(e){return _n(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield V("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:o});if(c.ok){const e=yield c.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"),M(c);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 Ln(e){return Sn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var o=yield V("application/x-www-form-urlencoded");const c=yield fetch(n.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${e}`,{method:"GET",headers:o});if(c.ok){const e=yield c.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"),M(c);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var Un=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{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 bn(e){return Un(this,void 0,void 0,(function*(){for(var t=yield Rn(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Zt(o);e.type=i}return t}))}function En(e){return Un(this,void 0,void 0,(function*(){for(var t=yield Ln(e),n=0;n<t.length;n++){let e=t[n];var o=e.typeId;let i=yield Zt(o);e.type=i}return t}))}var Fn=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{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())}))},Pn=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},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 Bn(e){return Gn(this,arguments,void 0,(function*(e,t=""){var o=yield Zt(e);yield R.removeNodeFromTree(e);var i=o.typeId,r=o.characterValue;yield E.removeTypeConcept(i,e),yield x.removeNodeByCharacter(r,e);let c=yield function(e){return Fn(this,arguments,void 0,(function*(e,t=""){let o=!1;try{let i=yield D("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=Pn(i,["Content-Type"]),a=yield fetch(n.DeleteConceptUrl(),{method:"POST",headers:s,body:r});if(!a.ok)throw M(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 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(e,t){return On(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 fetch(n.DeleteConceptUrl(),{method:"POST",body:i,headers:o});if(!r.ok)throw M(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 Dn=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(e,t,n,o){return Dn(this,arguments,void 0,(function*(e,t,n,o,i=999){var r,c=n,s=n,a=n,l=e.startsWith("the_"),d=L();return r=l?e:"the_"+e,d=yield xn(r),yield pn(t,n,4,n,d.id,d.userId,0,999,999,c,4,a,999,s)}))}class Mn{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 Hn=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 $n(){return Hn(this,arguments,void 0,(function*(e=[]){var t=[];try{var o=[];for(let n=0;n<e.length;n++){let i=yield Z.GetConnection(e[n]);0==i.id?o.push(e[n]):t.push(i)}if(0==o.length)return t;{var i=yield V();const e=yield fetch(n.GetConnectionBulkUrl(),{method:"POST",headers:i,body:JSON.stringify(o)});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),Z.AddConnection(o)}yield oe(t)}}else console.log("Get Connection Bulk error",e.status),M(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 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())}))};function Jn(){return Wn(this,arguments,void 0,(function*(e=[]){yield ae(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Ce(e[o]);t.push(n)}return t}))}function zn(){return Wn(this,arguments,void 0,(function*(e=[]){yield ae(e);var t=[];for(let o=0;o<e.length;o++){var n=yield Te(e[o]);t.push(n)}return t}))}function Qn(){return Wn(this,arguments,void 0,(function*(e=[],t=[]){yield $n(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||Z.RemoveConnection(t[n])}(t,yield re(e));var n=[];for(let t=0;t<e.length;t++){var o=yield Te(e[t]);n.push(o)}return n}))}function Kn(){return Wn(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 Z.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 $n(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 te(i),n}))}function qn(){return Wn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],o=[];for(let e=0;e<t.length;e++){let i=yield Z.GetConnection(t[e]);0==i.id?n.push(t[e]):o.push(i)}let i=yield $n(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 we(e[t],o,c);r[e[t]]=n}return r}))}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 Xn(){return Yn(this,arguments,void 0,(function*(e=0,t=[],o=""){var i=[];try{var r=new Mn;r.composition=e,r.listLinkers=t,r.textSearch=o;var c=JSON.stringify(r),s=yield V();const d=yield fetch(n.RecursiveSearchUrl(),{method:"POST",headers:s,body:c});if(d.ok){const e=yield d.json();var a=e.compositionIds,l=e.internalConnections;e.externalConnections,i=yield Qn(a,l)}else console.log("recursive search error ",d.status),M(d);return i}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}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 eo(e,t){return Zn(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 fetch(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),M(s)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var to=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 no(e){return to(this,void 0,void 0,(function*(){const t=yield function(){return to(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:M(o),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(n.SignupUrl(),e);return t}))}var oo=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 oo(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 fetch(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}:M(e),o}catch(e){throw console.log("Sign in api error",e),e}}))}function ro(e,t){return-1===e.indexOf(t)&&e.push(t),e}function co(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 so(e=[],t){let n=[],o=t.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(e))for(let i=0;i<e.length;i++){let r=e[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),t.typeId!=e[i].typeId&&o!=r||n.push(e[i])}return n}function ao(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 lo(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 uo(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function ho(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class fo{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&&(po.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var 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())}))};class po{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 fo(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return yo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return yo(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}}po.root=null;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 go(e,t,n,o){return vo(this,arguments,void 0,(function*(e,t,n,o,i=[]){var r,c;let s={};const a=[];if(0==e)return"";let l=Co(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Zt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=Co(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Zt(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=Co(n,d);if(null!=e&&0!=e.id||null==d||null==d||(e=yield Zt(d)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield P.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Zt(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 go(d,t,n,o,i);s[u]=e}}else{const e=yield go(d,t,n,o,i);a[u]=e,s=a}}}return s}))}function Co(e,t){let n=L();for(let o=0;o<e.length;o++)if(t==e[o].id)return n=e[o],n;return n}class To{constructor(){this.id=0,this.mainConcept=L(),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 go(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 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 No(e){return mo(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=L();null==s&&(s=new To);for(const o in e)if("object"==typeof e[o]||Array.isArray(e[o])){const f=yield _t(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 No(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 rt(a,l,f.id,f.userId,y,d,f.userId);s.connections.push(p),yield No(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 _t(o,e[o],!1,a,l,d);s.concepts.push(h);const f=yield rt(i,r,h.id,h.userId,c,d,h.userId);s.connections.push(f)}return h}))}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,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=L(),s=L();const a=[];let l=e.compositionId;const d=e.ofTheCompositionId;let u=[];if(l<0){let e=yield Zt(l,t);if(!(e.id>0))return null;l=e.id}i=yield fe(l);const h=[],f=new To,y=[];f.id=l,f.isUpdating();let p=[];for(let e=0;e<i.length;e++)ro(y,i[e].ofTheConceptId),ro(h,i[e].ofTheConceptId),ro(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 Zt(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=L();const l=v[e];let d=c;if(s.id>0&&(d=s),Array.isArray(l)||"object"==typeof l){i=yield _t(e,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const t=co(r,i);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=ao(f.connections,t[e].id);u=u.concat(n),a.push(t[e])}yield No(v[e],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield _t(e,l,!1,t,o,n);const c=co(r,i);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=ao(f.connections,c[e].id);u=u.concat(t),a.push(c[e])}}const h=yield rt(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++)ho(f.connections,u[e]),Yt(u[e].id);for(let e=0;e<a.length;e++)uo(r,a[e]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),po.addCompositionToTree(f),yield it.SyncDataOnline(),f.GetDataCache()}))}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())}))};function ko(e,t,o,i){return Ao(this,arguments,void 0,(function*(e,t,o,i,r=10,c=1){var s=yield D("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 fetch(l,{method:"GET",headers:s});return e.ok?yield e.json():(M(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}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())}))};function _o(e){return xo(this,arguments,void 0,(function*(e,t=""){var o=yield D("application/json",t);const i=n.SearchLinkMultipleAll(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(console.log("This is the searching error",e.status),M(e),[])}catch(e){throw console.log("This is the searching error",e),e}}))}var Ro=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{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 So(e){return Ro(this,arguments,void 0,(function*(e,t=[]){var n,o;let i=[];const r=[];let c={},s={};const a=[];let l=yield P.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield ue(e));let d=[];d=t.length>0?Lo(e,t):yield fe(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 Ae(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 Lo(e,t){const n=[];for(let o=0;o<t.length;o++)t[o].typeId==e&&n.push(t[o]);return n}function Uo(e){return Ro(this,arguments,void 0,(function*(e,t=[]){var n,o;let i={},r=[];const c=[];let s;const a={},l=[];let d=yield P.GetConcept(e);0==d.id&&null!=e&&null!=e&&(d=yield ue(e));let u=[];u=t.length>0?Lo(e,t):yield fe(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 Ae(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 bo(e,t){return Ro(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield $n(t);for(let t=0;t<e.length;t++){const i=yield Uo(e[t],n);i&&o.push(i)}return o}))}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 Fo(e){return Eo(this,void 0,void 0,(function*(){try{var t=yield V();const o=JSON.stringify(e),i=yield fetch(n.CreateSessionId(),{method:"POST",headers:t,body:o});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),M(i),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Po=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{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,void 0,void 0,(function*(){try{var o=yield V("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",e.toString()),i.append("url",t);const r=yield fetch(n.CreateSessionVisitUrl(),{method:"POST",headers:o,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),M(r),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Bo=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 Oo(e,t,o){return Bo(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 V("application/x-www-form-urlencoded");const l=yield fetch(n.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:s});return l.ok?c=yield l.json():(console.log("Get connection of concept error",l.status),M(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 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 Do(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Zt(e),s=yield In(t);if(s.id>0){let e=[],t=[];if(i){t=yield Oo(s.id,c.id,c.userId,n,o);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield ae(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,o=yield Zt(n),i=yield me(o.id);r.push(i)}}else{t=yield Mt(s.id,c.id,c.userId,n,o);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield ae(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield Zt(n),i=yield me(o.id);r.push(i)}}}return r}))}function jo(e,t){return Vo(this,arguments,void 0,(function*(e,t,n=10,o=1,i=!1){let r=[],c=yield Zt(e),s=yield In(t),a=[],l=[];if(s.id>0){if(i){a=yield Oo(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield Mt(s.id,c.id,c.userId,n,o);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}r=yield te(l)}return r}))}class Mo{constructor(e,t,n,o,i){this.connectionValue=[],this.value=[],this.height=1,this.key=e,t.id>0&&this.value.push(t),n.id>0&&this.connectionValue.push(n),this.leftNode=o,this.rightNode=i}addNode(e,t,n){if(null==t)return e;var o=t.leftNode,i=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,o,n);else{if(!(t.key<e.key))return t.value.push(...e.value),t.connectionValue.push(...e.connectionValue),t;t.rightNode=this.addNode(e,i,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let r=this.getBalanceFactor(t);if(r>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(r<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(e.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.rightNode=this.removeNode(e.rightNode,n.key),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Ho=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 compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return Ho(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(I.isDataLoaded)return e("done");setTimeout($o.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=new Lt(0,0,0,0,0,0);var r=new Mo(o,e,i,null,null);this.addNodeToTree(r)}static addConnectionToTree(e,t,n=999){let o=this.compositeKey(t,n,e.applicationId),i=je();var r=new Mo(o,i,e,null,null);this.addNodeToTree(r)}static getNodeFromTree(e,t){return Ho(this,arguments,void 0,(function*(e,t,n=999){let o=this.compositeKey(e,t,n);return this.root?this.root.getFromNode(o,this.root):null}))}static removeNodeFromTree(e){return Ho(this,arguments,void 0,(function*(e,t=999,n=999){if(this.root){let o=this.compositeKey(e,t,n);this.root=this.root.removeNode(this.root,o)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}$o.root=null;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 Jo(e,t){return Wo(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield $o.getNodeFromTree(e,n,o),r=je();if(i)for(let e=0;e<i.value.length;e++){let n=i.value[e];n.ghostId==t&&(r=n)}return r}))}function zo(e,t){return Wo(this,arguments,void 0,(function*(e,t,n=999,o=999){let i=yield $o.getNodeFromTree(e,n,o),r=new Lt(0,0,0,0,0,0);if(i)for(let e=0;e<i.connectionValue.length;e++){let n=i.connectionValue[e];n.ghostId==t&&(r=n)}return r}))}function Qo(e,t){return Wo(this,arguments,void 0,(function*(e,t,n=999){$o.addConceptToTree(e,t,n)}))}function Ko(e,t){return Wo(this,arguments,void 0,(function*(e,t,n=999){$o.addConnectionToTree(e,t,n)}))}var qo=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 Yo(e){return qo(this,arguments,void 0,(function*(e,t=""){var o=yield D("application/json",t);const i=n.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(console.log("This is the searching multiple error",e.status),M(e),[])}catch(e){throw console.log("This is the searching multiple error",e),e}}))}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())}))};function Zo(e){return Xo(this,arguments,void 0,(function*(e,t=""){let n=[],o=yield Yo(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 ei(a,n,i,l)}))}function ei(e,t,n){return Xo(this,arguments,void 0,(function*(e,t,n,o=[]){let i={},r=yield $n(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 Zt(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(t[r[e].ofTheConceptId])}catch(e){console.log("this is error",e)}}}else if(t[r[e].ofTheConceptId]&&t[r[e].toTheConceptId]){let n=t[r[e].ofTheConceptId],o=yield Zt(r[e].typeId),i=null==n?void 0:n.data,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(t[r[e].toTheConceptId])}catch(e){console.log("this is error",e)}}}return i=t[n],i}))}function ti(e){var t,n;const o=je();return o.id=e.id,o.ghostId=e.ghostId,o.userId=e.userId,o.accessId=e.accessId,o.categoryId=e.categoryId,o.characterValue=e.characterValue,o.entryTimeStamp=e.entryTimeStamp,o.typeId=e.typeId,o.type=e.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:"",o}function ni(e){const t=L();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}function oi(e){const t=new Lt(0,0,0,0,0,0);return t.id=e.id,t.ghostId=e.ghostId,t.accessId=e.accessId,t.ofTheConceptId=e.ofTheConceptId,t.toTheConceptId=e.toTheConceptId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.isTemp=!1,t}var 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){return ii(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,o=e.accessId;let i=[];const r=[];let c=je(),s=je();const a=[],l=e.compositionId,d=e.ofTheCompositionId;let u=[],h=yield fe(l);for(let e=0;e<h.length;e++)i.push(oi(h[e]));const f=[],y=[];let p=[];for(let e=0;e<i.length;e++)ro(y,i[e].ofTheConceptId),ro(f,i[e].ofTheConceptId),ro(f,i[e].toTheConceptId),p.push(i[e].ofTheConceptId);for(let e=0;e<f.length;e++){const t=yield Zt(f[e]);l==f[e]&&(c=ti(t)),d==f[e]&&(s=ti(t)),r.push(ti(t))}const v=e.patchObject;for(const e in v){let l=je();const d=v[e];let h=c;s.id>0&&(h=s),Array.isArray(d)||"object"==typeof d?(l=yield Ot(e,"",!0,c.userId,4,999),yield Dt(v[e],l.id,l.userId,c.id,c.userId,4,999)):l=yield Ot(e,d,!1,t,o,n);const f=so(r,l);for(let e=0;e<f.length;e++)if(f[e].id>0){const t=lo(i,f[e].id);u=u.concat(t),a.push(f[e])}yield Ut(h.id,l.id,c.id,2),r.push(l)}for(let e=0;e<u.length;e++)Yt(u[e].id);it.SyncDataOnline()}))}var ci=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())}))},si=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 ai(e){return si(this,void 0,void 0,(function*(){var t;let o=yield function(e){return ci(this,void 0,void 0,(function*(){let t=[];try{var o=yield V();const i=yield fetch(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;te(i),n[r]=t}return n}return console.log("View Internal Data error",i.status),M(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 Ae(r,c,e);t.data=n,t.id=r,i.push(t)}else{let e={};e.id=r;let n=yield Zt(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}))}var li=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())}))},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())}))};function ui(e){return di(this,arguments,void 0,(function*(e,t=""){var o=yield function(e){return li(this,arguments,void 0,(function*(e,t=""){var o=yield D("application/json",t);let i=n.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+e.composition+"&search="+e.search+"&internalComposition="+e.internalComposition+"&type="+e.type+"&inpage="+e.inpage+"&page="+e.page;try{const e=yield fetch(i,{method:"GET",headers:o});return e.ok?yield e.json():(console.log("This is the searching internal error",e.status),M(e),[])}catch(e){throw console.log("This is the searching internal error",e),e}}))}(e,t);return yield ai(o)}))}var hi=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 fi(e,t){return hi(this,void 0,void 0,(function*(){let n=!0,o=yield Rn(e),i=yield dt(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 Yt(r[e]);n=n&&t}return n}))}function yi(e,t){return hi(this,void 0,void 0,(function*(){let n=yield Rn(e),o=yield dt(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 pi{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class vi{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 gi{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Ci{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}class Ti{constructor(e){this.aiUrl="https://ai.freeschema.com",this.accessToken="",this.enableAi=!0,e&&Object.assign(this,e)}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 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())}))};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())}))},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{}Ii.isUpdated=!1,Ii.isOnlineSync=!1;var Ai=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 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())}))};const xi=1,_i=2,Ri=3,Si=4,Li=5,Ui=6,bi=7,Ei=8;class Fi{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}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 Gi(e){return Pi(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let o=yield ue(e[n].connectionTypeId);e[n].connectionType=o.characterValue,t[e[n].conceptId]=e[n]}return t}))}function Bi(e){const t=e.split("_");if(3===t.length){let e=new Fi;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 Oi(e){return e.startsWith("the_")?e.slice(4):e}var Vi=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())}))},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())}))};function ji(e,t,n){return Di(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 Zt(e[u].ofTheConceptId),y=yield Zt(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 Zt(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){console.log("this is error",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 Zt(e[u].typeId);try{let e=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in t||(t[y.id]={}),t[y.id][e]=n),t[f.id]={}}catch(e){console.log("this is error",e)}}}return t}))}var 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())}))};function Hi(e,t,n){if(e in t){let o=t[e];console.log("this is the count info",o),o&&(n[o.connectionType+"_count"]=o.count,console.log("this is the data updated",n))}}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 Wi(e,t="DESC"){return console.log("this is the order",t),"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var Ji=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 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,t){return zi(this,void 0,void 0,(function*(){let t=e.outputFormat;e.outputFormat=Ui;let o,i=yield function(e){return ki(this,arguments,void 0,(function*(e,t=""){var o=yield D("application/json",t);const i=n.FreeschemaQueryUrl(),r=JSON.stringify(e);try{const e=yield fetch(i,{method:"POST",headers:o,body:r});return e.ok?yield e.json():(M(e),console.log("This is the freeschema query error",e.status),[])}catch(e){console.log("This is the freeschema query error others",e),function(e,t=""){if(e.status){let n=new j(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new j(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=Bi(e[n]);t.push(o)}return t}(l);return o=t==_i?yield function(e,t,n,o,i){return Ji(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Kn(e),s=yield Gi(i);c=Wi(c,r);let a=[];a=yield function(e,t){return Vi(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 Zt(e[u].ofTheConceptId),y=yield Zt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Zt(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){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Zt(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){console.log("this is error",e)}}}return t}))}(c,a,o),a=yield function(e,t){return Vi(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 Zt(e[u].ofTheConceptId),y=yield Zt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Zt(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=Oi(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){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Zt(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=Oi(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){console.log("this is error",e)}}}return t}))}(c,a,o);let l=yield function(e,t,n,o){return Vi(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,r=yield Zt(e[n].ofTheConceptId),f=yield Zt(e[n].toTheConceptId);if(i.includes(e[n].id)&&(o=!0),1==o){if(0!=r.id&&0!=f.id&&f.id in t){let o,i=yield Zt(e[n].typeId),a=null!==(s=null===(c=f.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);try{if(t[e[n].ofTheConceptId]){let c={id:r.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},s=i.characterValue+"_reverse";Array.isArray(o[a][s])?o[a][s].push(c):s.includes("_s_")?(o[a][s]=[],o[a][s].push(c)):o[a][s]=c}}catch(e){console.log("this is error",e)}}}else if(0!=r.id&&0!=f.id&&r.id in t){let o,i=yield Zt(e[n].typeId),c=null!==(l=null===(a=r.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);let y=!0,p=i.characterValue;""==p&&(p=f.characterValue,y=!0),""==p&&(p=null!==(u=null===(d=null==f?void 0:f.type)||void 0===d?void 0:d.characterValue)&&void 0!==u?u:"");try{null===(h=null==f?void 0:f.type)||void 0===h||h.characterValue;let r=t[e[n].toTheConceptId];if(r){let s={id:f.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(o[c])?o[c].push(r):Array.isArray(o[c][p])?o[c][i.characterValue].push(s):p.includes("_s_")?(o[c][p]=[],o[c][p].push(s)):o[c][p]=s}}catch(e){console.log("this is error",e)}}}for(let e=0;e<o.length;e++){let n={};n.id=o[e],n.data=t[o[e]],f.push(n)}return f}))}(c,a,[],n,o,s);return l}))}(c,r,a,s,u,d):t==Ri?yield function(e,t,n,o,i){return Ji(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Kn(e),s=yield Gi(i);c=Wi(c,r);let a=[];a=yield ji(c,a,o),a=yield function(e,t){return Mi(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 Zt(e[u].ofTheConceptId),y=yield Zt(e[u].toTheConceptId);if(n.includes(e[u].id)&&(h=!0),1==h){if(0!=f.id&&0!=y.id){let n,s=yield Zt(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=Oi(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){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=yield Zt(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=Oi(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){console.log("this is error",e)}}}return t}))}(c,a,o);let l=yield function(e,t,n){return Mi(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 Zt(e[n].ofTheConceptId),p=yield Zt(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 Zt(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){console.log("this is error",e)}}}else if(0!=y.id&&0!=p.id&&y.id in t){let o,r=yield Zt(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),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",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,Hi(p.id,i,t)}}catch(e){console.log("this is error",e)}}}console.log("this is the main compositions",n);for(let e=0;e<n.length;e++){let o={};console.log("this is the main compositions DATA",t[n[e]]),o=t[n[e]],o&&(o.id=n[e]),f.push(o)}return f}))}(c,a,n,o,s);return l}))}(c,r,a,s,u,d):t==Ei?yield function(e,t,n,o,i){return Ji(this,arguments,void 0,(function*(e,t,n,o,i,r="DESC"){let c=yield Kn(e),s=yield Gi(i);c=Wi(c,r);let a={};a=yield function(e){return $i(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 Zt(a.ofTheConceptId),d=yield Zt(a.toTheConceptId),u=yield Zt(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;null===(s=u.characterValue)||void 0===s||s.includes("_s_"),t[h.id]||(t[h.id]={}),t[h.id][y]||(t[h.id][y]={}),t[f.id]||(t[f.id]={}),t[f.id][p]=v}return t}))}(c,a,o),a=yield function(e){return $i(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 Zt(a.ofTheConceptId),d=yield Zt(a.toTheConceptId),u=yield Zt(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?Oi(p):g;const T=C.includes("_s_"),m=!isNaN(Number(C)),N={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]=m?[]:{});try{if(T)continue;m?t[h.id][y].push(N):t[h.id][y][e?`${C}_reverse`:C]=N}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,o);let l=yield function(e,t,n){return $i(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 Zt(n.ofTheConceptId),l=yield Zt(n.toTheConceptId),d=yield Zt(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};Hi(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],Hi(y,i,c)}catch(e){console.error("Error processing connection:",e)}}else console.log("This is the error in the source")}for(const e of n){const n=yield Zt(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 Ji(this,void 0,void 0,(function*(){let t=yield Kn(e);t=Wi(t);let i=[];i=yield ji(t,i,o),i=yield function(e,t,n){return Di(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 Zt(e[u].ofTheConceptId),y=yield Zt(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 Zt(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=Oi(o));let i={[e]:t},l=o+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=i)}catch(e){console.log("this is error",e)}}}else if(0!=f.id&&0!=y.id){let n,o=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 Zt(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=Oi(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){console.log("this is error",e)}}}return t}))}(t,i,o);let r=yield function(){return Di(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 Zt(e[n].ofTheConceptId),h=yield Zt(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 Zt(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){console.log("this is error",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 Zt(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){console.log("this is error",e)}}}for(let e=0;e<n.length;e++){let o=t[n[e]];o&&(o.id=n[e],u.push(o))}return u}))}(t,i,n,[],o);return r}))}(c,0,a,s),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=xi,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1}}var qi,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 Xi(e,t){return Yi(this,arguments,void 0,(function*(e,t,n=!1){let o=[];if(n){let n=yield Ln(e),i=yield xn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}else{let n=yield Rn(e);for(let e=0;e<n.length;e++)Z.AddConnection(n[e]);let i=yield xn(t);for(let e=0;e<n.length;e++)n[e].typeId==i.id&&o.push(n[e])}return o}))}function Zi(e,t,n){return Yi(this,arguments,void 0,(function*(e,t,n,o=!1){let i=[],r=[];if(i=o?yield Xi(t,n,o):yield Xi(e,n,o),o)for(let t=0;t<i.length;t++)i[t].ofTheConceptId==e&&r.push(i[t]);else for(let e=0;e<i.length;e++)i[e].toTheConceptId==t&&r.push(i[e]);return r}))}function er(e){let t=qi.None;for(const n of e)switch(n){case"read":t|=qi.Read;break;case"write":t|=qi.Write;break;case"execute":t|=qi.Execute;break;case"delete":t|=qi.Delete}return 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"}(qi||(qi={}));var 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())}))},nr=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 or{static initialize(){if(this.baseUrl=process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("ACCESS_CONTROL_BASE_URL is not defined in environment");console.log("AccessControlService initialized.")}static checkAccessOfConcept(e,t,n,o){return nr(this,void 0,void 0,(function*(){var i;const r=yield Zt(n);if(999===r.userId||r.userId===e)return!0;const c=null!==(i=r.accessId)&&void 0!==i?i:0;return o=o||this.getEntityIdConceptByUserId(e),yield this.accessCache.hasAccess(o,c,t)}))}static checkAccessOfConceptList(e,t,n,o){return nr(this,void 0,void 0,(function*(){const i=yield te(n),r=Array.from(i.values()).filter((t=>t.userId!==e&&999!==t.userId)).map((e=>{var t;return null!==(t=e.accessId)&&void 0!==t?t:0})).filter(((e,t,n)=>n.indexOf(e)===t));return o=o||this.getEntityIdConceptByUserId(e),(yield this.accessCache.getAccessibleConcepts(o,r,t)).length===n.length}))}static filterConceptListByAccess(e,t,n,o){return nr(this,void 0,void 0,(function*(){var i;const r=yield te(n),c=Array.from(r.values()).filter((t=>t.userId!==e&&999!==t.userId)).map((e=>{var t;return null!==(t=e.accessId)&&void 0!==t?t:0})).filter(((e,t,n)=>n.indexOf(e)===t));o=o||this.getEntityIdConceptByUserId(e);const s=new Set(yield this.accessCache.getAccessibleConcepts(o,c,t)),a=[];for(const t of r.values())(t.userId===e||999===t.userId||s.has(null!==(i=t.accessId)&&void 0!==i?i:0))&&a.push(t.id);return a}))}static getEntityIdConceptByUserId(e){return e}static assignAccessToEntity(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access",e,"Failed to assign access to entity")}))}static assignPublicAccess(e){return nr(this,void 0,void 0,(function*(){var t,n;return this._post("/api/access-control/public-access",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0,conceptIdList:null!==(n=e.conceptIdList)&&void 0!==n?n:[]}),"Failed to assign public access")}))}static assignPublicAccessBlukConcept(e){return nr(this,void 0,void 0,(function*(){var t,n;return this._post("/api/access-control/public-access",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0,conceptId:null!==(n=e.conceptId)&&void 0!==n?n:0}),"Failed to assign public access")}))}static assignAccessToEntityBulk(e){return nr(this,void 0,void 0,(function*(){var t;return this._post("/api/access-control/access/bulk",Object.assign(Object.assign({},e),{nestedAccessLevel:null!==(t=e.nestedAccessLevel)&&void 0!==t?t:0}),"Failed to assign access in bulk")}))}static assignAccessByUser(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/user-access",e,"Failed to assign access by user")}))}static revokeAccess(e){return nr(this,void 0,void 0,(function*(){const{conceptId:t,access:n,entityId:o}=e,i=`/api/access-control/access?conceptId=${t}&access=${encodeURIComponent(n)}&entityId=${o}`;return this._delete(i,void 0,"Failed to revoke access")}))}static revokeAccessBulk(e){return nr(this,void 0,void 0,(function*(){return this._delete("/api/access-control/access/bulk",e,"Failed to revoke access in bulk")}))}static getAccessList(e,t){return nr(this,void 0,void 0,(function*(){const n=`/api/access-control/access-list?conceptId=${e}&userId=${t}`;return this._get(n,"Failed to get access list")}))}static getPublicAccessList(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/by-concept-ids",e,"Failed to get public access list")}))}static revokePublicAccess(e){return nr(this,void 0,void 0,(function*(){return this._delete("/api/access-control/public-access",e,"Failed to revoke public access")}))}static checkAccess(e){return nr(this,void 0,void 0,(function*(){const t=`/api/access-control/access/check?conceptId=${e.conceptId}&permission=${encodeURIComponent(e.permission)}&entityId=${e.entityId}`;return this._get(t,"Failed to check access")}))}static checkAccessByUser(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/user-access/check",e,"Failed to check access by user")}))}static filterConceptsByAccess(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/concepts/filter-by-access",e,"Failed to filter concepts by access")}))}static checkAccessOfConceptBulk(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/concepts/check-access-bulk",e,"Failed to check access of concept bulk")}))}static getEntitiesByAccess(e,t){return nr(this,void 0,void 0,(function*(){const n=`/api/access-control/entities/by-access?conceptId=${e}&access=${encodeURIComponent(t)}`;return this._get(n,"Failed to get entities by access")}))}static getEntitiesWithAccess(e){return nr(this,void 0,void 0,(function*(){const t=`/api/access-control/entities/with-access?conceptId=${e}`;return this._get(t,"Failed to get entities with access")}))}static getAccessGroupByEntity(e){return nr(this,void 0,void 0,(function*(){const t="/api/access-control/access-group/by-entity"+(void 0!==e?`?entityId=${e}`:"");return this._get(t,"Failed to get access group by entity")}))}static getAccessGroupByUser(e){return nr(this,void 0,void 0,(function*(){const t="/api/access-control/access-group/by-user"+(void 0!==e?`?userId=${e}`:"");return this._get(t,"Failed to get access group by user")}))}static getPublicAccessByAccessIds(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/by-access-ids",e,"Failed to get public access by access ids")}))}static getFullAccessMappingForPublic(){return nr(this,void 0,void 0,(function*(){return this._get("/api/access-control/concepts/by-public-access","Failed to get full access mapping for public")}))}static assignPublicAccessForAllUser(){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/public-access/assign-for-all-users",void 0,"Failed to assign public access for all user")}))}static assignAccessByConncetionTypeOfUser(){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access/by-connection-type",void 0,"Failed to assign access by connection type of user")}))}static setAccessInheritance(e){return nr(this,void 0,void 0,(function*(){return this._post("/api/access-control/access-inheritance",e,"Failed to set access inheritance")}))}static getAccessInheritanceStatus(e){return nr(this,arguments,void 0,(function*(e,t=999){const n=`/api/access-control/access-inheritance/status?mainConceptId=${e}&connectionTypeId=${t}`;return this._get(n,"Failed to get access inheritance status")}))}static _get(e,t){return nr(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}${e}`,{method:"GET"});if(!n.ok)throw new Error(t);return n.json()}))}static _post(e,t,n){return nr(this,void 0,void 0,(function*(){const o=yield fetch(`${this.baseUrl}${e}`,Object.assign({method:"POST",headers:{"Content-Type":"application/json"}},void 0!==t?{body:JSON.stringify(t)}:{}));if(!o.ok)throw new Error(n||"Request failed");return o.json()}))}static _delete(e,t,n){return nr(this,void 0,void 0,(function*(){const o=yield fetch(`${this.baseUrl}${e}`,Object.assign({method:"DELETE",headers:t?{"Content-Type":"application/json"}:void 0},t?{body:JSON.stringify(t)}:{}));if(!o.ok)throw new Error(n||"Request failed");return o.json()}))}}or.accessCache=new class{constructor(){if(this.userAccessCache=new Map,this.publicAccessCache=new Map,this.baseUrl=process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("ACCESS_CONTROL_BASE_URL is not defined in environment");console.log("AccessControlCacheService initialized.")}loadCacheFromApi(e){return tr(this,void 0,void 0,(function*(){try{let t=`${this.baseUrl}/access-group/by-entity`;void 0!==e&&(t+=`?entityId=${e}`);const n=yield fetch(t);if(!n.ok)throw new Error(`Failed to fetch data: ${n.statusText}`);const o=yield n.json();this.loadCacheFromJson(o)}catch(e){console.error("[ERROR] loadCacheFromApi failed:",e)}}))}loadCacheFromJson(e){const t=null==e?void 0:e.data;if(!t||"object"!=typeof t)return;const n=t;for(const[e,t]of Object.entries(n)){const n=parseInt(e);this.userAccessCache.has(n)||this.userAccessCache.set(n,new Map);for(const[e,o]of Object.entries(t)){const t=parseInt(e),i=er(o);this.userAccessCache.get(n).set(t,i)}}}hasAccess(e,t,n){return tr(this,void 0,void 0,(function*(){if(yield this.hasPublicAccess(t,n))return!0;console.log("length of userAccessCache:",this.userAccessCache.size),this.userAccessCache.has(e)||(yield this.loadCacheFromApi(e));const o=this.userAccessCache.get(e),i=null==o?void 0:o.get(t);return void 0!==i&&(i&n)===n}))}getAccessibleConcepts(e,t,n){return tr(this,void 0,void 0,(function*(){const o=[],i=[];for(const e of t)(yield this.hasPublicAccess(e,n))?o.push(e):i.push(e);console.log("length of userAccessCache:",this.userAccessCache.size),i.length>0&&!this.userAccessCache.has(e)&&(yield this.loadCacheFromApi(e));const r=this.userAccessCache.get(e);for(const e of i){const t=null==r?void 0:r.get(e);void 0!==t&&(t&n)===n&&o.push(e)}return o}))}getAccessByUser(e){return tr(this,void 0,void 0,(function*(){var t;return this.userAccessCache.has(e)||(yield this.loadCacheFromApi(e)),new Map(null!==(t=this.userAccessCache.get(e))&&void 0!==t?t:[])}))}getAccessByConcept(e){return tr(this,void 0,void 0,(function*(){const t=new Map;0===this.userAccessCache.size&&(yield this.loadCacheFromApi());for(const[n,o]of this.userAccessCache){const i=o.get(e);void 0!==i&&t.set(n,i)}return t}))}deleteRecordByUserId(e){this.userAccessCache.delete(e)}deletePublicAccessRecordById(e){console.log(`Deleting public access for concept ${e}`),this.publicAccessCache.delete(e)}clearCache(){console.log("Clearing access control cache..."),this.userAccessCache.clear(),this.publicAccessCache.clear()}getConceptsByPublicAccess(){return tr(this,void 0,void 0,(function*(){const e={};try{const t=yield fetch(`${this.baseUrl}/concepts/by-public-access`);if(!t.ok)throw new Error(`Failed to fetch public access: ${t.statusText}`);const n=yield t.json(),o=null==n?void 0:n.data;if(!o||"object"!=typeof o)return e;for(const[t,n]of Object.entries(o)){const o=parseInt(t),i=er(n);this.publicAccessCache.set(o,i),e[o]=n}}catch(e){console.error("[ERROR] Failed to fetch public access data:",e)}return e}))}hasPublicAccess(e,t){return tr(this,void 0,void 0,(function*(){console.log("length of publicAccessCache:",this.publicAccessCache.size),this.publicAccessCache.has(e)||(yield this.getConceptsByPublicAccess());const n=this.publicAccessCache.get(e);return void 0!==n&&(n&t)===t}))}getConceptsWithPublicAccess(e,t){return tr(this,void 0,void 0,(function*(){const n=[],o=[];for(const i of e){const e=this.publicAccessCache.get(i);void 0!==e?(e&t)===t&&n.push(i):o.push(i)}if(o.length>0){yield this.getConceptsByPublicAccess();for(const e of o){const o=this.publicAccessCache.get(e);void 0!==o&&(o&t)===t&&n.push(e)}}return n}))}},or.initialize();var ir=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 rr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.transactionId=Math.random().toString().substring(5)}initialize(){return ir(this,void 0,void 0,(function*(){yield it.initializeTransaction(this.transactionId)}))}markAction(){return ir(this,void 0,void 0,(function*(){yield it.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return ir(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},yield it.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return ir(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield it.SyncDataOnline(this.transactionId),this.actions={concepts:[],connections:[]},this.success=!1}))}MakeTheInstanceConcept(e,t){return ir(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 _t(e,t,n,o,i,r,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return ir(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Wt(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 ir(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const i=yield Cn(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 ir(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 $t(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}}))}}function cr(e=""){o.BearerAccessToken=e}function sr(e="",t="",i="CCSApp",c){const s=c||new Ti;if(n.BASE_URL=e,n.AI_URL=s.aiUrl,t&&(n.NODE_URL=t),console.log("This is the base url",n.BASE_URL),s.hasOAuthCredentials()){const e=s.applicationName||i;o.setOAuthCredentials(s.clientId,s.clientSecret,e),r(s.clientId,s.clientSecret,e,!0)}else s.hasAccessToken()&&(o.BearerAccessToken=s.accessToken);(function(){return Ai(this,void 0,void 0,(function*(){return yield new g(!0),yield function(){return wi(this,void 0,void 0,(function*(){}))}(),!0}))})().then((()=>{const e=(new Date).getTime();(function(){return G(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield N();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];P.AddConceptToMemory(n)}(new Date).getTime()}))})().then((()=>{I.isDataLoaded=!0,I.isCharacterLoaded=!0,I.isTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare concept data is ",t)})),function(){return Ni(this,void 0,void 0,(function*(){var e=yield w();if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];He.AddConceptToMemory(n)}}))}().then((()=>{I.isLocalDataLoaded=!0,I.isLocalTypeLoaded=!0,I.isLocalCharacterLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare local concept ",t)})),function(){return mi(this,void 0,void 0,(function*(){!function(){mi(this,void 0,void 0,(function*(){var e=yield w();if(Array.isArray(e))for(var t=0;t<e.length;t++)We.AddConnection(e[t])}))}()}))}().then((()=>{I.isLocalConnectionLoaded=!0})),function(){return mi(this,void 0,void 0,(function*(){!function(){mi(this,void 0,void 0,(function*(){var e=yield N();if(Array.isArray(e))for(var t=0;t<e.length;t++)Z.AddConnectionToMemory(e[t])}))}()}))}().then((()=>{I.isConnectionLoaded=!0,I.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-e;console.log("The time taken to prepare connections ",t)}))}))}var ar=exports;for(var lr in t)ar[lr]=t[lr];t.__esModule&&Object.defineProperty(ar,"__esModule",{value:!0})})();
|