@finsemble/finsemble-core 9.9.0 → 9.9.1

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.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see fsbl-polyfill.umd.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolyfillPreload=t():e.PolyfillPreload=t()}(this,()=>(()=>{var e={2:(e,t,n)=>{var r=n(2199),o=n(4664),i=n(5950);e.exports=function(e){return r(e,i,o)}},79:(e,t,n)=>{var r=n(3702),o=n(80),i=n(4739),s=n(8655),a=n(1175);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},80:(e,t,n)=>{var r=n(6025),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():o.call(t,n,1),--this.size,0))}},104:(e,t,n)=>{var r=n(3661);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},124:(e,t,n)=>{var r=n(9325);e.exports=function(){return r.Date.now()}},181:e=>{e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},270:(e,t,n)=>{var r=n(7068),o=n(346);e.exports=function e(t,n,i,s,a){return t===n||(null==t||null==n||!o(t)&&!o(n)?t!=t&&n!=n:r(t,n,i,s,e,a))}},289:(e,t,n)=>{var r=n(2651);e.exports=function(e){return r(this,e).get(e)}},294:e=>{e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},317:e=>{e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},346:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},361:e=>{var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},392:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},575:()=>{},631:(e,t,n)=>{var r=n(8077),o=n(9326);e.exports=function(e,t){return null!=e&&o(e,t,r)}},659:(e,t,n)=>{var r=n(1873),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},689:(e,t,n)=>{var r=n(2),o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,i,s,a){var l=1&n,u=r(e),c=u.length;if(c!=r(t).length&&!l)return!1;for(var d=c;d--;){var h=u[d];if(!(l?h in t:o.call(t,h)))return!1}var p=a.get(e),g=a.get(t);if(p&&g)return p==t&&g==e;var f=!0;a.set(e,t),a.set(t,e);for(var m=l;++d<c;){var y=e[h=u[d]],w=t[h];if(i)var v=l?i(w,y,h,t,e,a):i(y,w,h,e,t,a);if(!(void 0===v?y===w||s(y,w,n,i,a):v)){f=!1;break}m||(m="constructor"==h)}if(f&&!m){var b=e.constructor,C=t.constructor;b==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof C&&C instanceof C||(f=!1)}return a.delete(e),a.delete(t),f}},695:(e,t,n)=>{var r=n(8096),o=n(2428),i=n(6449),s=n(3656),a=n(361),l=n(7167),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),c=!n&&o(e),d=!n&&!c&&s(e),h=!n&&!c&&!d&&l(e),p=n||c||d||h,g=p?r(e.length,String):[],f=g.length;for(var m in e)!t&&!u.call(e,m)||p&&("length"==m||d&&("offset"==m||"parent"==m)||h&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||a(m,f))||g.push(m);return g}},938:e=>{e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},945:(e,t,n)=>{var r=n(79),o=n(8223),i=n(3661);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},1033:e=>{e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},1042:(e,t,n)=>{var r=n(6110)(Object,"create");e.exports=r},1175:(e,t,n)=>{var r=n(6025);e.exports=function(e,t){var n=this.__data__,o=r(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}},1380:e=>{e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},1420:(e,t,n)=>{var r=n(79);e.exports=function(){this.__data__=new r,this.size=0}},1459:e=>{e.exports=function(e){return this.__data__.has(e)}},1549:(e,t,n)=>{var r=n(2032),o=n(3862),i=n(6721),s=n(2749),a=n(5749);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},1769:(e,t,n)=>{var r=n(6449),o=n(8586),i=n(1802),s=n(3222);e.exports=function(e,t){return r(e)?e:o(e,t)?[e]:i(s(e))}},1791:(e,t,n)=>{var r=n(6547),o=n(3360);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var a=-1,l=t.length;++a<l;){var u=t[a],c=i?i(n[u],e[u],u,n,e):void 0;void 0===c&&(c=e[u]),s?o(n,u,c):r(n,u,c)}return n}},1800:e=>{var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},1802:(e,t,n)=>{var r=n(2224),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,function(e,n,r,o){t.push(r?o.replace(i,"$1"):n||e)}),t});e.exports=s},1811:e=>{var t=Date.now;e.exports=function(e){var n=0,r=0;return function(){var o=t(),i=16-(o-r);if(r=o,i>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}},1873:(e,t,n)=>{var r=n(9325).Symbol;e.exports=r},1882:(e,t,n)=>{var r=n(2552),o=n(3805);e.exports=function(e){if(!o(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1961:(e,t,n)=>{var r=n(9653);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},1986:(e,t,n)=>{var r=n(1873),o=n(7828),i=n(5288),s=n(5911),a=n(317),l=n(4247),u=r?r.prototype:void 0,c=u?u.valueOf:void 0;e.exports=function(e,t,n,r,u,d,h){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!d(new o(e),new o(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return i(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var p=a;case"[object Set]":var g=1&r;if(p||(p=l),e.size!=t.size&&!g)return!1;var f=h.get(e);if(f)return f==t;r|=2,h.set(e,t);var m=s(p(e),p(t),r,u,d,h);return h.delete(e),m;case"[object Symbol]":if(c)return c.call(e)==c.call(t)}return!1}},2032:(e,t,n)=>{var r=n(1042);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},2199:(e,t,n)=>{var r=n(4528),o=n(6449);e.exports=function(e,t,n){var i=t(e);return o(e)?i:r(i,n(e))}},2224:(e,t,n)=>{var r=n(104);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},2271:(e,t,n)=>{var r=n(1791),o=n(4664);e.exports=function(e,t){return r(e,o(e),t)}},2404:(e,t,n)=>{var r=n(270);e.exports=function(e,t){return r(e,t)}},2428:(e,t,n)=>{var r=n(7534),o=n(346),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,l=r(function(){return arguments}())?r:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=l},2543:function(e,t,n){var r;e=n.nmd(e),function(){var o,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,u=128,c=1/0,d=9007199254740991,h=NaN,p=4294967295,g=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],f="[object Arguments]",m="[object Array]",y="[object Boolean]",w="[object Date]",v="[object Error]",b="[object Function]",C="[object GeneratorFunction]",S="[object Map]",I="[object Number]",k="[object Object]",T="[object Promise]",x="[object RegExp]",A="[object Set]",E="[object String]",W="[object Symbol]",O="[object WeakMap]",D="[object ArrayBuffer]",_="[object DataView]",P="[object Float32Array]",R="[object Float64Array]",L="[object Int8Array]",F="[object Int16Array]",M="[object Int32Array]",$="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",B="[object Uint32Array]",q=/\b__p \+= '';/g,U=/\b(__p \+=) '' \+/g,z=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,V=RegExp(G.source),Q=RegExp(H.source),J=/<%-([\s\S]+?)%>/g,K=/<%([\s\S]+?)%>/g,Y=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,X=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,oe=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,pe=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,fe=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ye=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ce="\\ud800-\\udfff",Se="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ie="\\u2700-\\u27bf",ke="a-z\\xdf-\\xf6\\xf8-\\xff",Te="A-Z\\xc0-\\xd6\\xd8-\\xde",xe="\\ufe0e\\ufe0f",Ae="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ee="["+Ce+"]",We="["+Ae+"]",Oe="["+Se+"]",De="\\d+",_e="["+Ie+"]",Pe="["+ke+"]",Re="[^"+Ce+Ae+De+Ie+ke+Te+"]",Le="\\ud83c[\\udffb-\\udfff]",Fe="[^"+Ce+"]",Me="(?:\\ud83c[\\udde6-\\uddff]){2}",$e="[\\ud800-\\udbff][\\udc00-\\udfff]",Ne="["+Te+"]",je="\\u200d",Be="(?:"+Pe+"|"+Re+")",qe="(?:"+Ne+"|"+Re+")",Ue="(?:['’](?:d|ll|m|re|s|t|ve))?",ze="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ge="(?:"+Oe+"|"+Le+")?",He="["+xe+"]?",Ve=He+Ge+"(?:"+je+"(?:"+[Fe,Me,$e].join("|")+")"+He+Ge+")*",Qe="(?:"+[_e,Me,$e].join("|")+")"+Ve,Je="(?:"+[Fe+Oe+"?",Oe,Me,$e,Ee].join("|")+")",Ke=RegExp("['’]","g"),Ye=RegExp(Oe,"g"),Ze=RegExp(Le+"(?="+Le+")|"+Je+Ve,"g"),Xe=RegExp([Ne+"?"+Pe+"+"+Ue+"(?="+[We,Ne,"$"].join("|")+")",qe+"+"+ze+"(?="+[We,Ne+Be,"$"].join("|")+")",Ne+"?"+Be+"+"+Ue,Ne+"+"+ze,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",De,Qe].join("|"),"g"),et=RegExp("["+je+Ce+Se+xe+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rt=-1,ot={};ot[P]=ot[R]=ot[L]=ot[F]=ot[M]=ot[$]=ot[N]=ot[j]=ot[B]=!0,ot[f]=ot[m]=ot[D]=ot[y]=ot[_]=ot[w]=ot[v]=ot[b]=ot[S]=ot[I]=ot[k]=ot[x]=ot[A]=ot[E]=ot[O]=!1;var it={};it[f]=it[m]=it[D]=it[_]=it[y]=it[w]=it[P]=it[R]=it[L]=it[F]=it[M]=it[S]=it[I]=it[k]=it[x]=it[A]=it[E]=it[W]=it[$]=it[N]=it[j]=it[B]=!0,it[v]=it[b]=it[O]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,lt=parseInt,ut="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ct="object"==typeof self&&self&&self.Object===Object&&self,dt=ut||ct||Function("return this")(),ht=t&&!t.nodeType&&t,pt=ht&&e&&!e.nodeType&&e,gt=pt&&pt.exports===ht,ft=gt&&ut.process,mt=function(){try{return pt&&pt.require&&pt.require("util").types||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),yt=mt&&mt.isArrayBuffer,wt=mt&&mt.isDate,vt=mt&&mt.isMap,bt=mt&&mt.isRegExp,Ct=mt&&mt.isSet,St=mt&&mt.isTypedArray;function It(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function kt(e,t,n,r){for(var o=-1,i=null==e?0:e.length;++o<i;){var s=e[o];t(r,s,n(s),e)}return r}function Tt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function xt(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function At(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Et(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}function Wt(e,t){return!(null==e||!e.length)&&Nt(e,t,0)>-1}function Ot(e,t,n){for(var r=-1,o=null==e?0:e.length;++r<o;)if(n(t,e[r]))return!0;return!1}function Dt(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}function _t(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}function Pt(e,t,n,r){var o=-1,i=null==e?0:e.length;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function Rt(e,t,n,r){var o=null==e?0:e.length;for(r&&o&&(n=e[--o]);o--;)n=t(n,e[o],o,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Ft=Ut("length");function Mt(e,t,n){var r;return n(e,function(e,n,o){if(t(e,n,o))return r=n,!1}),r}function $t(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i<o;)if(t(e[i],i,e))return i;return-1}function Nt(e,t,n){return t==t?function(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}(e,t,n):$t(e,Bt,n)}function jt(e,t,n,r){for(var o=n-1,i=e.length;++o<i;)if(r(e[o],t))return o;return-1}function Bt(e){return e!=e}function qt(e,t){var n=null==e?0:e.length;return n?Ht(e,t)/n:h}function Ut(e){return function(t){return null==t?o:t[e]}}function zt(e){return function(t){return null==e?o:e[t]}}function Gt(e,t,n,r,o){return o(e,function(e,o,i){n=r?(r=!1,e):t(n,e,o,i)}),n}function Ht(e,t){for(var n,r=-1,i=e.length;++r<i;){var s=t(e[r]);s!==o&&(n=n===o?s:n+s)}return n}function Vt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Qt(e){return e?e.slice(0,hn(e)+1).replace(re,""):e}function Jt(e){return function(t){return e(t)}}function Kt(e,t){return Dt(t,function(t){return e[t]})}function Yt(e,t){return e.has(t)}function Zt(e,t){for(var n=-1,r=e.length;++n<r&&Nt(t,e[n],0)>-1;);return n}function Xt(e,t){for(var n=e.length;n--&&Nt(t,e[n],0)>-1;);return n}var en=zt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tn=zt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function nn(e){return"\\"+st[e]}function rn(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function sn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,r=e.length,o=0,i=[];++n<r;){var s=e[n];s!==t&&s!==a||(e[n]=a,i[o++]=n)}return i}function ln(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function un(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function cn(e){return rn(e)?function(e){for(var t=Ze.lastIndex=0;Ze.test(e);)++t;return t}(e):Ft(e)}function dn(e){return rn(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var pn=zt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),gn=function e(t){var n,r=(t=null==t?dt:gn.defaults(dt.Object(),t,gn.pick(dt,nt))).Array,oe=t.Date,Ce=t.Error,Se=t.Function,Ie=t.Math,ke=t.Object,Te=t.RegExp,xe=t.String,Ae=t.TypeError,Ee=r.prototype,We=Se.prototype,Oe=ke.prototype,De=t["__core-js_shared__"],_e=We.toString,Pe=Oe.hasOwnProperty,Re=0,Le=(n=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Fe=Oe.toString,Me=_e.call(ke),$e=dt._,Ne=Te("^"+_e.call(Pe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),je=gt?t.Buffer:o,Be=t.Symbol,qe=t.Uint8Array,Ue=je?je.allocUnsafe:o,ze=sn(ke.getPrototypeOf,ke),Ge=ke.create,He=Oe.propertyIsEnumerable,Ve=Ee.splice,Qe=Be?Be.isConcatSpreadable:o,Je=Be?Be.iterator:o,Ze=Be?Be.toStringTag:o,et=function(){try{var e=ui(ke,"defineProperty");return e({},"",{}),e}catch(e){}}(),st=t.clearTimeout!==dt.clearTimeout&&t.clearTimeout,ut=oe&&oe.now!==dt.Date.now&&oe.now,ct=t.setTimeout!==dt.setTimeout&&t.setTimeout,ht=Ie.ceil,pt=Ie.floor,ft=ke.getOwnPropertySymbols,mt=je?je.isBuffer:o,Ft=t.isFinite,zt=Ee.join,fn=sn(ke.keys,ke),mn=Ie.max,yn=Ie.min,wn=oe.now,vn=t.parseInt,bn=Ie.random,Cn=Ee.reverse,Sn=ui(t,"DataView"),In=ui(t,"Map"),kn=ui(t,"Promise"),Tn=ui(t,"Set"),xn=ui(t,"WeakMap"),An=ui(ke,"create"),En=xn&&new xn,Wn={},On=Mi(Sn),Dn=Mi(In),_n=Mi(kn),Pn=Mi(Tn),Rn=Mi(xn),Ln=Be?Be.prototype:o,Fn=Ln?Ln.valueOf:o,Mn=Ln?Ln.toString:o;function $n(e){if(ea(e)&&!Us(e)&&!(e instanceof qn)){if(e instanceof Bn)return e;if(Pe.call(e,"__wrapped__"))return $i(e)}return new Bn(e)}var Nn=function(){function e(){}return function(t){if(!Xs(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=o,n}}();function jn(){}function Bn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=o}function qn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Un(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function zn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Gn;++t<n;)this.add(e[t])}function Vn(e){var t=this.__data__=new zn(e);this.size=t.size}function Qn(e,t){var n=Us(e),r=!n&&qs(e),o=!n&&!r&&Vs(e),i=!n&&!r&&!o&&la(e),s=n||r||o||i,a=s?Vt(e.length,xe):[],l=a.length;for(var u in e)!t&&!Pe.call(e,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||mi(u,l))||a.push(u);return a}function Jn(e){var t=e.length;return t?e[Gr(0,t-1)]:o}function Kn(e,t){return _i(Ao(e),ir(t,0,e.length))}function Yn(e){return _i(Ao(e))}function Zn(e,t,n){(n!==o&&!Ns(e[t],n)||n===o&&!(t in e))&&rr(e,t,n)}function Xn(e,t,n){var r=e[t];Pe.call(e,t)&&Ns(r,n)&&(n!==o||t in e)||rr(e,t,n)}function er(e,t){for(var n=e.length;n--;)if(Ns(e[n][0],t))return n;return-1}function tr(e,t,n,r){return cr(e,function(e,o,i){t(r,e,n(e),i)}),r}function nr(e,t){return e&&Eo(t,Oa(t),e)}function rr(e,t,n){"__proto__"==t&&et?et(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function or(e,t){for(var n=-1,i=t.length,s=r(i),a=null==e;++n<i;)s[n]=a?o:Ta(e,t[n]);return s}function ir(e,t,n){return e==e&&(n!==o&&(e=e<=n?e:n),t!==o&&(e=e>=t?e:t)),e}function sr(e,t,n,r,i,s){var a,l=1&t,u=2&t,c=4&t;if(n&&(a=i?n(e,r,i,s):n(e)),a!==o)return a;if(!Xs(e))return e;var d=Us(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Pe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ao(e,a)}else{var h=hi(e),p=h==b||h==C;if(Vs(e))return Co(e,l);if(h==k||h==f||p&&!i){if(a=u||p?{}:gi(e),!l)return u?function(e,t){return Eo(e,di(e),t)}(e,function(e,t){return e&&Eo(t,Da(t),e)}(a,e)):function(e,t){return Eo(e,ci(e),t)}(e,nr(a,e))}else{if(!it[h])return i?e:{};a=function(e,t,n){var r,o=e.constructor;switch(t){case D:return So(e);case y:case w:return new o(+e);case _:return function(e,t){var n=t?So(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case P:case R:case L:case F:case M:case $:case N:case j:case B:return Io(e,n);case S:return new o;case I:case E:return new o(e);case x:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new o;case W:return r=e,Fn?ke(Fn.call(r)):{}}}(e,h,l)}}s||(s=new Vn);var g=s.get(e);if(g)return g;s.set(e,a),ia(e)?e.forEach(function(r){a.add(sr(r,t,n,r,e,s))}):ta(e)&&e.forEach(function(r,o){a.set(o,sr(r,t,n,o,e,s))});var m=d?o:(c?u?ni:ti:u?Da:Oa)(e);return Tt(m||e,function(r,o){m&&(r=e[o=r]),Xn(a,o,sr(r,t,n,o,e,s))}),a}function ar(e,t,n){var r=n.length;if(null==e)return!r;for(e=ke(e);r--;){var i=n[r],s=t[i],a=e[i];if(a===o&&!(i in e)||!s(a))return!1}return!0}function lr(e,t,n){if("function"!=typeof e)throw new Ae(i);return Ei(function(){e.apply(o,n)},t)}function ur(e,t,n,r){var o=-1,i=Wt,s=!0,a=e.length,l=[],u=t.length;if(!a)return l;n&&(t=Dt(t,Jt(n))),r?(i=Ot,s=!1):t.length>=200&&(i=Yt,s=!1,t=new Hn(t));e:for(;++o<a;){var c=e[o],d=null==n?c:n(c);if(c=r||0!==c?c:0,s&&d==d){for(var h=u;h--;)if(t[h]===d)continue e;l.push(c)}else i(t,d,r)||l.push(c)}return l}$n.templateSettings={escape:J,evaluate:K,interpolate:Y,variable:"",imports:{_:$n}},$n.prototype=jn.prototype,$n.prototype.constructor=$n,Bn.prototype=Nn(jn.prototype),Bn.prototype.constructor=Bn,qn.prototype=Nn(jn.prototype),qn.prototype.constructor=qn,Un.prototype.clear=function(){this.__data__=An?An(null):{},this.size=0},Un.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Un.prototype.get=function(e){var t=this.__data__;if(An){var n=t[e];return n===s?o:n}return Pe.call(t,e)?t[e]:o},Un.prototype.has=function(e){var t=this.__data__;return An?t[e]!==o:Pe.call(t,e)},Un.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=An&&t===o?s:t,this},zn.prototype.clear=function(){this.__data__=[],this.size=0},zn.prototype.delete=function(e){var t=this.__data__,n=er(t,e);return!(n<0||(n==t.length-1?t.pop():Ve.call(t,n,1),--this.size,0))},zn.prototype.get=function(e){var t=this.__data__,n=er(t,e);return n<0?o:t[n][1]},zn.prototype.has=function(e){return er(this.__data__,e)>-1},zn.prototype.set=function(e,t){var n=this.__data__,r=er(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Un,map:new(In||zn),string:new Un}},Gn.prototype.delete=function(e){var t=ai(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return ai(this,e).get(e)},Gn.prototype.has=function(e){return ai(this,e).has(e)},Gn.prototype.set=function(e,t){var n=ai(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Hn.prototype.add=Hn.prototype.push=function(e){return this.__data__.set(e,s),this},Hn.prototype.has=function(e){return this.__data__.has(e)},Vn.prototype.clear=function(){this.__data__=new zn,this.size=0},Vn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Vn.prototype.get=function(e){return this.__data__.get(e)},Vn.prototype.has=function(e){return this.__data__.has(e)},Vn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof zn){var r=n.__data__;if(!In||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(e,t),this.size=n.size,this};var cr=Do(wr),dr=Do(vr,!0);function hr(e,t){var n=!0;return cr(e,function(e,r,o){return n=!!t(e,r,o)}),n}function pr(e,t,n){for(var r=-1,i=e.length;++r<i;){var s=e[r],a=t(s);if(null!=a&&(l===o?a==a&&!aa(a):n(a,l)))var l=a,u=s}return u}function gr(e,t){var n=[];return cr(e,function(e,r,o){t(e,r,o)&&n.push(e)}),n}function fr(e,t,n,r,o){var i=-1,s=e.length;for(n||(n=fi),o||(o=[]);++i<s;){var a=e[i];t>0&&n(a)?t>1?fr(a,t-1,n,r,o):_t(o,a):r||(o[o.length]=a)}return o}var mr=_o(),yr=_o(!0);function wr(e,t){return e&&mr(e,t,Oa)}function vr(e,t){return e&&yr(e,t,Oa)}function br(e,t){return Et(t,function(t){return Ks(e[t])})}function Cr(e,t){for(var n=0,r=(t=yo(t,e)).length;null!=e&&n<r;)e=e[Fi(t[n++])];return n&&n==r?e:o}function Sr(e,t,n){var r=t(e);return Us(e)?r:_t(r,n(e))}function Ir(e){return null==e?e===o?"[object Undefined]":"[object Null]":Ze&&Ze in ke(e)?function(e){var t=Pe.call(e,Ze),n=e[Ze];try{e[Ze]=o;var r=!0}catch(e){}var i=Fe.call(e);return r&&(t?e[Ze]=n:delete e[Ze]),i}(e):function(e){return Fe.call(e)}(e)}function kr(e,t){return e>t}function Tr(e,t){return null!=e&&Pe.call(e,t)}function xr(e,t){return null!=e&&t in ke(e)}function Ar(e,t,n){for(var i=n?Ot:Wt,s=e[0].length,a=e.length,l=a,u=r(a),c=1/0,d=[];l--;){var h=e[l];l&&t&&(h=Dt(h,Jt(t))),c=yn(h.length,c),u[l]=!n&&(t||s>=120&&h.length>=120)?new Hn(l&&h):o}h=e[0];var p=-1,g=u[0];e:for(;++p<s&&d.length<c;){var f=h[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(g?Yt(g,m):i(d,m,n))){for(l=a;--l;){var y=u[l];if(!(y?Yt(y,m):i(e[l],m,n)))continue e}g&&g.push(m),d.push(f)}}return d}function Er(e,t,n){var r=null==(e=Ti(e,t=yo(t,e)))?e:e[Fi(Ji(t))];return null==r?o:It(r,e,n)}function Wr(e){return ea(e)&&Ir(e)==f}function Or(e,t,n,r,i){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,r,i,s){var a=Us(e),l=Us(t),u=a?m:hi(e),c=l?m:hi(t),d=(u=u==f?k:u)==k,h=(c=c==f?k:c)==k,p=u==c;if(p&&Vs(e)){if(!Vs(t))return!1;a=!0,d=!1}if(p&&!d)return s||(s=new Vn),a||la(e)?Xo(e,t,n,r,i,s):function(e,t,n,r,o,i,s){switch(n){case _:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case D:return!(e.byteLength!=t.byteLength||!i(new qe(e),new qe(t)));case y:case w:case I:return Ns(+e,+t);case v:return e.name==t.name&&e.message==t.message;case x:case E:return e==t+"";case S:var a=on;case A:var l=1&r;if(a||(a=ln),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var c=Xo(a(e),a(t),r,o,i,s);return s.delete(e),c;case W:if(Fn)return Fn.call(e)==Fn.call(t)}return!1}(e,t,u,n,r,i,s);if(!(1&n)){var g=d&&Pe.call(e,"__wrapped__"),b=h&&Pe.call(t,"__wrapped__");if(g||b){var C=g?e.value():e,T=b?t.value():t;return s||(s=new Vn),i(C,T,n,r,s)}}return!!p&&(s||(s=new Vn),function(e,t,n,r,i,s){var a=1&n,l=ti(e),u=l.length;if(u!=ti(t).length&&!a)return!1;for(var c=u;c--;){var d=l[c];if(!(a?d in t:Pe.call(t,d)))return!1}var h=s.get(e),p=s.get(t);if(h&&p)return h==t&&p==e;var g=!0;s.set(e,t),s.set(t,e);for(var f=a;++c<u;){var m=e[d=l[c]],y=t[d];if(r)var w=a?r(y,m,d,t,e,s):r(m,y,d,e,t,s);if(!(w===o?m===y||i(m,y,n,r,s):w)){g=!1;break}f||(f="constructor"==d)}if(g&&!f){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(g=!1)}return s.delete(e),s.delete(t),g}(e,t,n,r,i,s))}(e,t,n,r,Or,i))}function Dr(e,t,n,r){var i=n.length,s=i,a=!r;if(null==e)return!s;for(e=ke(e);i--;){var l=n[i];if(a&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++i<s;){var u=(l=n[i])[0],c=e[u],d=l[1];if(a&&l[2]){if(c===o&&!(u in e))return!1}else{var h=new Vn;if(r)var p=r(c,d,u,e,t,h);if(!(p===o?Or(d,c,3,r,h):p))return!1}}return!0}function _r(e){return!(!Xs(e)||(t=e,Le&&Le in t))&&(Ks(e)?Ne:fe).test(Mi(e));var t}function Pr(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Us(e)?$r(e[0],e[1]):Mr(e):dl(e)}function Rr(e){if(!Ci(e))return fn(e);var t=[];for(var n in ke(e))Pe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Lr(e,t){return e<t}function Fr(e,t){var n=-1,o=Gs(e)?r(e.length):[];return cr(e,function(e,r,i){o[++n]=t(e,r,i)}),o}function Mr(e){var t=li(e);return 1==t.length&&t[0][2]?Ii(t[0][0],t[0][1]):function(n){return n===e||Dr(n,e,t)}}function $r(e,t){return wi(e)&&Si(t)?Ii(Fi(e),t):function(n){var r=Ta(n,e);return r===o&&r===t?xa(n,e):Or(t,r,3)}}function Nr(e,t,n,r,i){e!==t&&mr(t,function(s,a){if(i||(i=new Vn),Xs(s))!function(e,t,n,r,i,s,a){var l=xi(e,n),u=xi(t,n),c=a.get(u);if(c)Zn(e,n,c);else{var d=s?s(l,u,n+"",e,t,a):o,h=d===o;if(h){var p=Us(u),g=!p&&Vs(u),f=!p&&!g&&la(u);d=u,p||g||f?Us(l)?d=l:Hs(l)?d=Ao(l):g?(h=!1,d=Co(u,!0)):f?(h=!1,d=Io(u,!0)):d=[]:ra(u)||qs(u)?(d=l,qs(l)?d=ma(l):Xs(l)&&!Ks(l)||(d=gi(u))):h=!1}h&&(a.set(u,d),i(d,u,r,s,a),a.delete(u)),Zn(e,n,d)}}(e,t,a,n,Nr,r,i);else{var l=r?r(xi(e,a),s,a+"",e,t,i):o;l===o&&(l=s),Zn(e,a,l)}},Da)}function jr(e,t){var n=e.length;if(n)return mi(t+=t<0?n:0,n)?e[t]:o}function Br(e,t,n){t=t.length?Dt(t,function(e){return Us(e)?function(t){return Cr(t,1===e.length?e[0]:e)}:e}):[nl];var r=-1;t=Dt(t,Jt(si()));var o=Fr(e,function(e,n,o){var i=Dt(t,function(t){return t(e)});return{criteria:i,index:++r,value:e}});return function(e){var t=e.length;for(e.sort(function(e,t){return function(e,t,n){for(var r=-1,o=e.criteria,i=t.criteria,s=o.length,a=n.length;++r<s;){var l=ko(o[r],i[r]);if(l)return r>=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)});t--;)e[t]=e[t].value;return e}(o)}function qr(e,t,n){for(var r=-1,o=t.length,i={};++r<o;){var s=t[r],a=Cr(e,s);n(a,s)&&Kr(i,yo(s,e),a)}return i}function Ur(e,t,n,r){var o=r?jt:Nt,i=-1,s=t.length,a=e;for(e===t&&(t=Ao(t)),n&&(a=Dt(e,Jt(n)));++i<s;)for(var l=0,u=t[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==e&&Ve.call(a,l,1),Ve.call(e,l,1);return e}function zr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var o=t[n];if(n==r||o!==i){var i=o;mi(o)?Ve.call(e,o,1):lo(e,o)}}return e}function Gr(e,t){return e+pt(bn()*(t-e+1))}function Hr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Vr(e,t){return Wi(ki(e,t,nl),e+"")}function Qr(e){return Jn(Na(e))}function Jr(e,t){var n=Na(e);return _i(n,ir(t,0,n.length))}function Kr(e,t,n,r){if(!Xs(e))return e;for(var i=-1,s=(t=yo(t,e)).length,a=s-1,l=e;null!=l&&++i<s;){var u=Fi(t[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return e;if(i!=a){var d=l[u];(c=r?r(d,u,l):o)===o&&(c=Xs(d)?d:mi(t[i+1])?[]:{})}Xn(l,u,c),l=l[u]}return e}var Yr=En?function(e,t){return En.set(e,t),e}:nl,Zr=et?function(e,t){return et(e,"toString",{configurable:!0,enumerable:!1,value:Xa(t),writable:!0})}:nl;function Xr(e){return _i(Na(e))}function eo(e,t,n){var o=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=r(i);++o<i;)s[o]=e[o+t];return s}function to(e,t){var n;return cr(e,function(e,r,o){return!(n=t(e,r,o))}),!!n}function no(e,t,n){var r=0,o=null==e?r:e.length;if("number"==typeof t&&t==t&&o<=2147483647){for(;r<o;){var i=r+o>>>1,s=e[i];null!==s&&!aa(s)&&(n?s<=t:s<t)?r=i+1:o=i}return o}return ro(e,t,nl,n)}function ro(e,t,n,r){var i=0,s=null==e?0:e.length;if(0===s)return 0;for(var a=(t=n(t))!=t,l=null===t,u=aa(t),c=t===o;i<s;){var d=pt((i+s)/2),h=n(e[d]),p=h!==o,g=null===h,f=h==h,m=aa(h);if(a)var y=r||f;else y=c?f&&(r||p):l?f&&p&&(r||!g):u?f&&p&&!g&&(r||!m):!g&&!m&&(r?h<=t:h<t);y?i=d+1:s=d}return yn(s,4294967294)}function oo(e,t){for(var n=-1,r=e.length,o=0,i=[];++n<r;){var s=e[n],a=t?t(s):s;if(!n||!Ns(a,l)){var l=a;i[o++]=0===s?0:s}}return i}function io(e){return"number"==typeof e?e:aa(e)?h:+e}function so(e){if("string"==typeof e)return e;if(Us(e))return Dt(e,so)+"";if(aa(e))return Mn?Mn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ao(e,t,n){var r=-1,o=Wt,i=e.length,s=!0,a=[],l=a;if(n)s=!1,o=Ot;else if(i>=200){var u=t?null:Vo(e);if(u)return ln(u);s=!1,o=Yt,l=new Hn}else l=t?[]:a;e:for(;++r<i;){var c=e[r],d=t?t(c):c;if(c=n||0!==c?c:0,s&&d==d){for(var h=l.length;h--;)if(l[h]===d)continue e;t&&l.push(d),a.push(c)}else o(l,d,n)||(l!==a&&l.push(d),a.push(c))}return a}function lo(e,t){return null==(e=Ti(e,t=yo(t,e)))||delete e[Fi(Ji(t))]}function uo(e,t,n,r){return Kr(e,t,n(Cr(e,t)),r)}function co(e,t,n,r){for(var o=e.length,i=r?o:-1;(r?i--:++i<o)&&t(e[i],i,e););return n?eo(e,r?0:i,r?i+1:o):eo(e,r?i+1:0,r?o:i)}function ho(e,t){var n=e;return n instanceof qn&&(n=n.value()),Pt(t,function(e,t){return t.func.apply(t.thisArg,_t([e],t.args))},n)}function po(e,t,n){var o=e.length;if(o<2)return o?ao(e[0]):[];for(var i=-1,s=r(o);++i<o;)for(var a=e[i],l=-1;++l<o;)l!=i&&(s[i]=ur(s[i]||a,e[l],t,n));return ao(fr(s,1),t,n)}function go(e,t,n){for(var r=-1,i=e.length,s=t.length,a={};++r<i;){var l=r<s?t[r]:o;n(a,e[r],l)}return a}function fo(e){return Hs(e)?e:[]}function mo(e){return"function"==typeof e?e:nl}function yo(e,t){return Us(e)?e:wi(e,t)?[e]:Li(ya(e))}var wo=Vr;function vo(e,t,n){var r=e.length;return n=n===o?r:n,!t&&n>=r?e:eo(e,t,n)}var bo=st||function(e){return dt.clearTimeout(e)};function Co(e,t){if(t)return e.slice();var n=e.length,r=Ue?Ue(n):new e.constructor(n);return e.copy(r),r}function So(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function Io(e,t){var n=t?So(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ko(e,t){if(e!==t){var n=e!==o,r=null===e,i=e==e,s=aa(e),a=t!==o,l=null===t,u=t==t,c=aa(t);if(!l&&!c&&!s&&e>t||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&e<t||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(e,t,n,o){for(var i=-1,s=e.length,a=n.length,l=-1,u=t.length,c=mn(s-a,0),d=r(u+c),h=!o;++l<u;)d[l]=t[l];for(;++i<a;)(h||i<s)&&(d[n[i]]=e[i]);for(;c--;)d[l++]=e[i++];return d}function xo(e,t,n,o){for(var i=-1,s=e.length,a=-1,l=n.length,u=-1,c=t.length,d=mn(s-l,0),h=r(d+c),p=!o;++i<d;)h[i]=e[i];for(var g=i;++u<c;)h[g+u]=t[u];for(;++a<l;)(p||i<s)&&(h[g+n[a]]=e[i++]);return h}function Ao(e,t){var n=-1,o=e.length;for(t||(t=r(o));++n<o;)t[n]=e[n];return t}function Eo(e,t,n,r){var i=!n;n||(n={});for(var s=-1,a=t.length;++s<a;){var l=t[s],u=r?r(n[l],e[l],l,n,e):o;u===o&&(u=e[l]),i?rr(n,l,u):Xn(n,l,u)}return n}function Wo(e,t){return function(n,r){var o=Us(n)?kt:tr,i=t?t():{};return o(n,e,si(r,2),i)}}function Oo(e){return Vr(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:o,a=i>2?n[2]:o;for(s=e.length>3&&"function"==typeof s?(i--,s):o,a&&yi(n[0],n[1],a)&&(s=i<3?o:s,i=1),t=ke(t);++r<i;){var l=n[r];l&&e(t,l,r,s)}return t})}function Do(e,t){return function(n,r){if(null==n)return n;if(!Gs(n))return e(n,r);for(var o=n.length,i=t?o:-1,s=ke(n);(t?i--:++i<o)&&!1!==r(s[i],i,s););return n}}function _o(e){return function(t,n,r){for(var o=-1,i=ke(t),s=r(t),a=s.length;a--;){var l=s[e?a:++o];if(!1===n(i[l],l,i))break}return t}}function Po(e){return function(t){var n=rn(t=ya(t))?dn(t):o,r=n?n[0]:t.charAt(0),i=n?vo(n,1).join(""):t.slice(1);return r[e]()+i}}function Ro(e){return function(t){return Pt(Ka(qa(t).replace(Ke,"")),e,"")}}function Lo(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Nn(e.prototype),r=e.apply(n,t);return Xs(r)?r:n}}function Fo(e){return function(t,n,r){var i=ke(t);if(!Gs(t)){var s=si(n,3);t=Oa(t),n=function(e){return s(i[e],e,i)}}var a=e(t,n,r);return a>-1?i[s?t[a]:a]:o}}function Mo(e){return ei(function(t){var n=t.length,r=n,s=Bn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(i);if(s&&!l&&"wrapper"==oi(a))var l=new Bn([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=t[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var e=arguments,r=e[0];if(l&&1==e.length&&Us(r))return l.plant(r).value();for(var o=0,i=n?t[o].apply(this,e):r;++o<n;)i=t[o].call(this,i);return i}})}function $o(e,t,n,i,s,a,l,c,d,h){var p=t&u,g=1&t,f=2&t,m=24&t,y=512&t,w=f?o:Lo(e);return function u(){for(var v=arguments.length,b=r(v),C=v;C--;)b[C]=arguments[C];if(m)var S=ii(u),I=function(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}(b,S);if(i&&(b=To(b,i,s,m)),a&&(b=xo(b,a,l,m)),v-=I,m&&v<h){var k=an(b,S);return Go(e,t,$o,u.placeholder,n,b,k,c,d,h-v)}var T=g?n:this,x=f?T[e]:e;return v=b.length,c?b=function(e,t){for(var n=e.length,r=yn(t.length,n),i=Ao(e);r--;){var s=t[r];e[r]=mi(s,n)?i[s]:o}return e}(b,c):y&&v>1&&b.reverse(),p&&d<v&&(b.length=d),this&&this!==dt&&this instanceof u&&(x=w||Lo(x)),x.apply(T,b)}}function No(e,t){return function(n,r){return function(e,t,n,r){return wr(e,function(e,o,i){t(r,n(e),o,i)}),r}(n,e,t(r),{})}}function jo(e,t){return function(n,r){var i;if(n===o&&r===o)return t;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=so(n),r=so(r)):(n=io(n),r=io(r)),i=e(n,r)}return i}}function Bo(e){return ei(function(t){return t=Dt(t,Jt(si())),Vr(function(n){var r=this;return e(t,function(e){return It(e,r,n)})})})}function qo(e,t){var n=(t=t===o?" ":so(t)).length;if(n<2)return n?Hr(t,e):t;var r=Hr(t,ht(e/cn(t)));return rn(t)?vo(dn(r),0,e).join(""):r.slice(0,e)}function Uo(e){return function(t,n,i){return i&&"number"!=typeof i&&yi(t,n,i)&&(n=i=o),t=ha(t),n===o?(n=t,t=0):n=ha(n),function(e,t,n,o){for(var i=-1,s=mn(ht((t-e)/(n||1)),0),a=r(s);s--;)a[o?s:++i]=e,e+=n;return a}(t,n,i=i===o?t<n?1:-1:ha(i),e)}}function zo(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=fa(t),n=fa(n)),e(t,n)}}function Go(e,t,n,r,i,s,a,u,c,d){var h=8&t;t|=h?l:64,4&(t&=~(h?64:l))||(t&=-4);var p=[e,t,i,h?s:o,h?a:o,h?o:s,h?o:a,u,c,d],g=n.apply(o,p);return vi(e)&&Ai(g,p),g.placeholder=r,Oi(g,e,t)}function Ho(e){var t=Ie[e];return function(e,n){if(e=fa(e),(n=null==n?0:yn(pa(n),292))&&Ft(e)){var r=(ya(e)+"e").split("e");return+((r=(ya(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Vo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(e){return new Tn(e)}:al;function Qo(e){return function(t){var n=hi(t);return n==S?on(t):n==A?un(t):function(e,t){return Dt(t,function(t){return[t,e[t]]})}(t,e(t))}}function Jo(e,t,n,s,c,d,h,p){var g=2&t;if(!g&&"function"!=typeof e)throw new Ae(i);var f=s?s.length:0;if(f||(t&=-97,s=c=o),h=h===o?h:mn(pa(h),0),p=p===o?p:pa(p),f-=c?c.length:0,64&t){var m=s,y=c;s=c=o}var w=g?o:ri(e),v=[e,t,n,s,c,m,y,d,h,p];if(w&&function(e,t){var n=e[1],r=t[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&256==n&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!i&&!s)return e;1&r&&(e[2]=t[2],o|=1&n?0:4);var l=t[3];if(l){var c=e[3];e[3]=c?To(c,l,t[4]):l,e[4]=c?an(e[3],a):t[4]}(l=t[5])&&(c=e[5],e[5]=c?xo(c,l,t[6]):l,e[6]=c?an(e[5],a):t[6]),(l=t[7])&&(e[7]=l),r&u&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=o}(v,w),e=v[0],t=v[1],n=v[2],s=v[3],c=v[4],!(p=v[9]=v[9]===o?g?0:e.length:mn(v[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)b=8==t||16==t?function(e,t,n){var i=Lo(e);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var d=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=d.length)<n?Go(e,t,$o,s.placeholder,o,l,d,o,o,n-a):It(this&&this!==dt&&this instanceof s?i:e,this,l)}}(e,t,p):t!=l&&33!=t||c.length?$o.apply(o,v):function(e,t,n,o){var i=1&t,s=Lo(e);return function t(){for(var a=-1,l=arguments.length,u=-1,c=o.length,d=r(c+l),h=this&&this!==dt&&this instanceof t?s:e;++u<c;)d[u]=o[u];for(;l--;)d[u++]=arguments[++a];return It(h,i?n:this,d)}}(e,t,n,s);else var b=function(e,t,n){var r=1&t,o=Lo(e);return function t(){return(this&&this!==dt&&this instanceof t?o:e).apply(r?n:this,arguments)}}(e,t,n);return Oi((w?Yr:Ai)(b,v),e,t)}function Ko(e,t,n,r){return e===o||Ns(e,Oe[n])&&!Pe.call(r,n)?t:e}function Yo(e,t,n,r,i,s){return Xs(e)&&Xs(t)&&(s.set(t,e),Nr(e,t,o,Yo,s),s.delete(t)),e}function Zo(e){return ra(e)?o:e}function Xo(e,t,n,r,i,s){var a=1&n,l=e.length,u=t.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(e),d=s.get(t);if(c&&d)return c==t&&d==e;var h=-1,p=!0,g=2&n?new Hn:o;for(s.set(e,t),s.set(t,e);++h<l;){var f=e[h],m=t[h];if(r)var y=a?r(m,f,h,t,e,s):r(f,m,h,e,t,s);if(y!==o){if(y)continue;p=!1;break}if(g){if(!Lt(t,function(e,t){if(!Yt(g,t)&&(f===e||i(f,e,n,r,s)))return g.push(t)})){p=!1;break}}else if(f!==m&&!i(f,m,n,r,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function ei(e){return Wi(ki(e,o,zi),e+"")}function ti(e){return Sr(e,Oa,ci)}function ni(e){return Sr(e,Da,di)}var ri=En?function(e){return En.get(e)}:al;function oi(e){for(var t=e.name+"",n=Wn[t],r=Pe.call(Wn,t)?n.length:0;r--;){var o=n[r],i=o.func;if(null==i||i==e)return o.name}return t}function ii(e){return(Pe.call($n,"placeholder")?$n:e).placeholder}function si(){var e=$n.iteratee||rl;return e=e===rl?Pr:e,arguments.length?e(arguments[0],arguments[1]):e}function ai(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function li(e){for(var t=Oa(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,Si(o)]}return t}function ui(e,t){var n=function(e,t){return null==e?o:e[t]}(e,t);return _r(n)?n:o}var ci=ft?function(e){return null==e?[]:(e=ke(e),Et(ft(e),function(t){return He.call(e,t)}))}:gl,di=ft?function(e){for(var t=[];e;)_t(t,ci(e)),e=ze(e);return t}:gl,hi=Ir;function pi(e,t,n){for(var r=-1,o=(t=yo(t,e)).length,i=!1;++r<o;){var s=Fi(t[r]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++r!=o?i:!!(o=null==e?0:e.length)&&Zs(o)&&mi(s,o)&&(Us(e)||qs(e))}function gi(e){return"function"!=typeof e.constructor||Ci(e)?{}:Nn(ze(e))}function fi(e){return Us(e)||qs(e)||!!(Qe&&e&&e[Qe])}function mi(e,t){var n=typeof e;return!!(t=null==t?d:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function yi(e,t,n){if(!Xs(n))return!1;var r=typeof t;return!!("number"==r?Gs(n)&&mi(t,n.length):"string"==r&&t in n)&&Ns(n[t],e)}function wi(e,t){if(Us(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!aa(e))||X.test(e)||!Z.test(e)||null!=t&&e in ke(t)}function vi(e){var t=oi(e),n=$n[t];if("function"!=typeof n||!(t in qn.prototype))return!1;if(e===n)return!0;var r=ri(n);return!!r&&e===r[0]}(Sn&&hi(new Sn(new ArrayBuffer(1)))!=_||In&&hi(new In)!=S||kn&&hi(kn.resolve())!=T||Tn&&hi(new Tn)!=A||xn&&hi(new xn)!=O)&&(hi=function(e){var t=Ir(e),n=t==k?e.constructor:o,r=n?Mi(n):"";if(r)switch(r){case On:return _;case Dn:return S;case _n:return T;case Pn:return A;case Rn:return O}return t});var bi=De?Ks:fl;function Ci(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function Si(e){return e==e&&!Xs(e)}function Ii(e,t){return function(n){return null!=n&&n[e]===t&&(t!==o||e in ke(n))}}function ki(e,t,n){return t=mn(t===o?e.length-1:t,0),function(){for(var o=arguments,i=-1,s=mn(o.length-t,0),a=r(s);++i<s;)a[i]=o[t+i];i=-1;for(var l=r(t+1);++i<t;)l[i]=o[i];return l[t]=n(a),It(e,this,l)}}function Ti(e,t){return t.length<2?e:Cr(e,eo(t,0,-1))}function xi(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ai=Di(Yr),Ei=ct||function(e,t){return dt.setTimeout(e,t)},Wi=Di(Zr);function Oi(e,t,n){var r=t+"";return Wi(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return Tt(g,function(n){var r="_."+n[0];t&n[1]&&!Wt(e,r)&&e.push(r)}),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Di(e){var t=0,n=0;return function(){var r=wn(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(o,arguments)}}function _i(e,t){var n=-1,r=e.length,i=r-1;for(t=t===o?r:t;++n<t;){var s=Gr(n,i),a=e[s];e[s]=e[n],e[n]=a}return e.length=t,e}var Pi,Ri,Li=(Pi=Ps(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,function(e,n,r,o){t.push(r?o.replace(ce,"$1"):n||e)}),t},function(e){return 500===Ri.size&&Ri.clear(),e}),Ri=Pi.cache,Pi);function Fi(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Mi(e){if(null!=e){try{return _e.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $i(e){if(e instanceof qn)return e.clone();var t=new Bn(e.__wrapped__,e.__chain__);return t.__actions__=Ao(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ni=Vr(function(e,t){return Hs(e)?ur(e,fr(t,1,Hs,!0)):[]}),ji=Vr(function(e,t){var n=Ji(t);return Hs(n)&&(n=o),Hs(e)?ur(e,fr(t,1,Hs,!0),si(n,2)):[]}),Bi=Vr(function(e,t){var n=Ji(t);return Hs(n)&&(n=o),Hs(e)?ur(e,fr(t,1,Hs,!0),o,n):[]});function qi(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=mn(r+o,0)),$t(e,si(t,3),o)}function Ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r-1;return n!==o&&(i=pa(n),i=n<0?mn(r+i,0):yn(i,r-1)),$t(e,si(t,3),i,!0)}function zi(e){return null!=e&&e.length?fr(e,1):[]}function Gi(e){return e&&e.length?e[0]:o}var Hi=Vr(function(e){var t=Dt(e,fo);return t.length&&t[0]===e[0]?Ar(t):[]}),Vi=Vr(function(e){var t=Ji(e),n=Dt(e,fo);return t===Ji(n)?t=o:n.pop(),n.length&&n[0]===e[0]?Ar(n,si(t,2)):[]}),Qi=Vr(function(e){var t=Ji(e),n=Dt(e,fo);return(t="function"==typeof t?t:o)&&n.pop(),n.length&&n[0]===e[0]?Ar(n,o,t):[]});function Ji(e){var t=null==e?0:e.length;return t?e[t-1]:o}var Ki=Vr(Yi);function Yi(e,t){return e&&e.length&&t&&t.length?Ur(e,t):e}var Zi=ei(function(e,t){var n=null==e?0:e.length,r=or(e,t);return zr(e,Dt(t,function(e){return mi(e,n)?+e:e}).sort(ko)),r});function Xi(e){return null==e?e:Cn.call(e)}var es=Vr(function(e){return ao(fr(e,1,Hs,!0))}),ts=Vr(function(e){var t=Ji(e);return Hs(t)&&(t=o),ao(fr(e,1,Hs,!0),si(t,2))}),ns=Vr(function(e){var t=Ji(e);return t="function"==typeof t?t:o,ao(fr(e,1,Hs,!0),o,t)});function rs(e){if(!e||!e.length)return[];var t=0;return e=Et(e,function(e){if(Hs(e))return t=mn(e.length,t),!0}),Vt(t,function(t){return Dt(e,Ut(t))})}function os(e,t){if(!e||!e.length)return[];var n=rs(e);return null==t?n:Dt(n,function(e){return It(t,o,e)})}var is=Vr(function(e,t){return Hs(e)?ur(e,t):[]}),ss=Vr(function(e){return po(Et(e,Hs))}),as=Vr(function(e){var t=Ji(e);return Hs(t)&&(t=o),po(Et(e,Hs),si(t,2))}),ls=Vr(function(e){var t=Ji(e);return t="function"==typeof t?t:o,po(Et(e,Hs),o,t)}),us=Vr(rs),cs=Vr(function(e){var t=e.length,n=t>1?e[t-1]:o;return n="function"==typeof n?(e.pop(),n):o,os(e,n)});function ds(e){var t=$n(e);return t.__chain__=!0,t}function hs(e,t){return t(e)}var ps=ei(function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof qn&&mi(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:hs,args:[i],thisArg:o}),new Bn(r,this.__chain__).thru(function(e){return t&&!e.length&&e.push(o),e})):this.thru(i)}),gs=Wo(function(e,t,n){Pe.call(e,n)?++e[n]:rr(e,n,1)}),fs=Fo(qi),ms=Fo(Ui);function ys(e,t){return(Us(e)?Tt:cr)(e,si(t,3))}function ws(e,t){return(Us(e)?xt:dr)(e,si(t,3))}var vs=Wo(function(e,t,n){Pe.call(e,n)?e[n].push(t):rr(e,n,[t])}),bs=Vr(function(e,t,n){var o=-1,i="function"==typeof t,s=Gs(e)?r(e.length):[];return cr(e,function(e){s[++o]=i?It(t,e,n):Er(e,t,n)}),s}),Cs=Wo(function(e,t,n){rr(e,n,t)});function Ss(e,t){return(Us(e)?Dt:Fr)(e,si(t,3))}var Is=Wo(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),ks=Vr(function(e,t){if(null==e)return[];var n=t.length;return n>1&&yi(e,t[0],t[1])?t=[]:n>2&&yi(t[0],t[1],t[2])&&(t=[t[0]]),Br(e,fr(t,1),[])}),Ts=ut||function(){return dt.Date.now()};function xs(e,t,n){return t=n?o:t,t=e&&null==t?e.length:t,Jo(e,u,o,o,o,o,t)}function As(e,t){var n;if("function"!=typeof t)throw new Ae(i);return e=pa(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=o),n}}var Es=Vr(function(e,t,n){var r=1;if(n.length){var o=an(n,ii(Es));r|=l}return Jo(e,r,t,n,o)}),Ws=Vr(function(e,t,n){var r=3;if(n.length){var o=an(n,ii(Ws));r|=l}return Jo(t,r,e,n,o)});function Os(e,t,n){var r,s,a,l,u,c,d=0,h=!1,p=!1,g=!0;if("function"!=typeof e)throw new Ae(i);function f(t){var n=r,i=s;return r=s=o,d=t,l=e.apply(i,n)}function m(e){var n=e-c;return c===o||n>=t||n<0||p&&e-d>=a}function y(){var e=Ts();if(m(e))return w(e);u=Ei(y,function(e){var n=t-(e-c);return p?yn(n,a-(e-d)):n}(e))}function w(e){return u=o,g&&r?f(e):(r=s=o,l)}function v(){var e=Ts(),n=m(e);if(r=arguments,s=this,c=e,n){if(u===o)return function(e){return d=e,u=Ei(y,t),h?f(e):l}(c);if(p)return bo(u),u=Ei(y,t),f(c)}return u===o&&(u=Ei(y,t)),l}return t=fa(t)||0,Xs(n)&&(h=!!n.leading,a=(p="maxWait"in n)?mn(fa(n.maxWait)||0,t):a,g="trailing"in n?!!n.trailing:g),v.cancel=function(){u!==o&&bo(u),d=0,r=c=s=u=o},v.flush=function(){return u===o?l:w(Ts())},v}var Ds=Vr(function(e,t){return lr(e,1,t)}),_s=Vr(function(e,t,n){return lr(e,fa(t)||0,n)});function Ps(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(i);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Ps.Cache||Gn),n}function Rs(e){if("function"!=typeof e)throw new Ae(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ps.Cache=Gn;var Ls=wo(function(e,t){var n=(t=1==t.length&&Us(t[0])?Dt(t[0],Jt(si())):Dt(fr(t,1),Jt(si()))).length;return Vr(function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=t[o].call(this,r[o]);return It(e,this,r)})}),Fs=Vr(function(e,t){var n=an(t,ii(Fs));return Jo(e,l,o,t,n)}),Ms=Vr(function(e,t){var n=an(t,ii(Ms));return Jo(e,64,o,t,n)}),$s=ei(function(e,t){return Jo(e,256,o,o,o,t)});function Ns(e,t){return e===t||e!=e&&t!=t}var js=zo(kr),Bs=zo(function(e,t){return e>=t}),qs=Wr(function(){return arguments}())?Wr:function(e){return ea(e)&&Pe.call(e,"callee")&&!He.call(e,"callee")},Us=r.isArray,zs=yt?Jt(yt):function(e){return ea(e)&&Ir(e)==D};function Gs(e){return null!=e&&Zs(e.length)&&!Ks(e)}function Hs(e){return ea(e)&&Gs(e)}var Vs=mt||fl,Qs=wt?Jt(wt):function(e){return ea(e)&&Ir(e)==w};function Js(e){if(!ea(e))return!1;var t=Ir(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!ra(e)}function Ks(e){if(!Xs(e))return!1;var t=Ir(e);return t==b||t==C||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==pa(e)}function Zs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function Xs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=vt?Jt(vt):function(e){return ea(e)&&hi(e)==S};function na(e){return"number"==typeof e||ea(e)&&Ir(e)==I}function ra(e){if(!ea(e)||Ir(e)!=k)return!1;var t=ze(e);if(null===t)return!0;var n=Pe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&_e.call(n)==Me}var oa=bt?Jt(bt):function(e){return ea(e)&&Ir(e)==x},ia=Ct?Jt(Ct):function(e){return ea(e)&&hi(e)==A};function sa(e){return"string"==typeof e||!Us(e)&&ea(e)&&Ir(e)==E}function aa(e){return"symbol"==typeof e||ea(e)&&Ir(e)==W}var la=St?Jt(St):function(e){return ea(e)&&Zs(e.length)&&!!ot[Ir(e)]},ua=zo(Lr),ca=zo(function(e,t){return e<=t});function da(e){if(!e)return[];if(Gs(e))return sa(e)?dn(e):Ao(e);if(Je&&e[Je])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Je]());var t=hi(e);return(t==S?on:t==A?ln:Na)(e)}function ha(e){return e?(e=fa(e))===c||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=ha(e),n=t%1;return t==t?n?t-n:t:0}function ga(e){return e?ir(pa(e),0,p):0}function fa(e){if("number"==typeof e)return e;if(aa(e))return h;if(Xs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Xs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var n=ge.test(e);return n||me.test(e)?lt(e.slice(2),n?2:8):pe.test(e)?h:+e}function ma(e){return Eo(e,Da(e))}function ya(e){return null==e?"":so(e)}var wa=Oo(function(e,t){if(Ci(t)||Gs(t))Eo(t,Oa(t),e);else for(var n in t)Pe.call(t,n)&&Xn(e,n,t[n])}),va=Oo(function(e,t){Eo(t,Da(t),e)}),ba=Oo(function(e,t,n,r){Eo(t,Da(t),e,r)}),Ca=Oo(function(e,t,n,r){Eo(t,Oa(t),e,r)}),Sa=ei(or),Ia=Vr(function(e,t){e=ke(e);var n=-1,r=t.length,i=r>2?t[2]:o;for(i&&yi(t[0],t[1],i)&&(r=1);++n<r;)for(var s=t[n],a=Da(s),l=-1,u=a.length;++l<u;){var c=a[l],d=e[c];(d===o||Ns(d,Oe[c])&&!Pe.call(e,c))&&(e[c]=s[c])}return e}),ka=Vr(function(e){return e.push(o,Yo),It(Pa,o,e)});function Ta(e,t,n){var r=null==e?o:Cr(e,t);return r===o?n:r}function xa(e,t){return null!=e&&pi(e,t,xr)}var Aa=No(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Fe.call(t)),e[t]=n},Xa(nl)),Ea=No(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Fe.call(t)),Pe.call(e,t)?e[t].push(n):e[t]=[n]},si),Wa=Vr(Er);function Oa(e){return Gs(e)?Qn(e):Rr(e)}function Da(e){return Gs(e)?Qn(e,!0):function(e){if(!Xs(e))return function(e){var t=[];if(null!=e)for(var n in ke(e))t.push(n);return t}(e);var t=Ci(e),n=[];for(var r in e)("constructor"!=r||!t&&Pe.call(e,r))&&n.push(r);return n}(e)}var _a=Oo(function(e,t,n){Nr(e,t,n)}),Pa=Oo(function(e,t,n,r){Nr(e,t,n,r)}),Ra=ei(function(e,t){var n={};if(null==e)return n;var r=!1;t=Dt(t,function(t){return t=yo(t,e),r||(r=t.length>1),t}),Eo(e,ni(e),n),r&&(n=sr(n,7,Zo));for(var o=t.length;o--;)lo(n,t[o]);return n}),La=ei(function(e,t){return null==e?{}:function(e,t){return qr(e,t,function(t,n){return xa(e,n)})}(e,t)});function Fa(e,t){if(null==e)return{};var n=Dt(ni(e),function(e){return[e]});return t=si(t),qr(e,n,function(e,n){return t(e,n[0])})}var Ma=Qo(Oa),$a=Qo(Da);function Na(e){return null==e?[]:Kt(e,Oa(e))}var ja=Ro(function(e,t,n){return t=t.toLowerCase(),e+(n?Ba(t):t)});function Ba(e){return Ja(ya(e).toLowerCase())}function qa(e){return(e=ya(e))&&e.replace(we,en).replace(Ye,"")}var Ua=Ro(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),za=Ro(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),Ga=Po("toLowerCase"),Ha=Ro(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),Va=Ro(function(e,t,n){return e+(n?" ":"")+Ja(t)}),Qa=Ro(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ja=Po("toUpperCase");function Ka(e,t,n){return e=ya(e),(t=n?o:t)===o?function(e){return tt.test(e)}(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ya=Vr(function(e,t){try{return It(e,o,t)}catch(e){return Js(e)?e:new Ce(e)}}),Za=ei(function(e,t){return Tt(t,function(t){t=Fi(t),rr(e,t,Es(e[t],e))}),e});function Xa(e){return function(){return e}}var el=Mo(),tl=Mo(!0);function nl(e){return e}function rl(e){return Pr("function"==typeof e?e:sr(e,1))}var ol=Vr(function(e,t){return function(n){return Er(n,e,t)}}),il=Vr(function(e,t){return function(n){return Er(e,n,t)}});function sl(e,t,n){var r=Oa(t),o=br(t,r);null!=n||Xs(t)&&(o.length||!r.length)||(n=t,t=e,e=this,o=br(t,Oa(t)));var i=!(Xs(n)&&"chain"in n&&!n.chain),s=Ks(e);return Tt(o,function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(i||t){var n=e(this.__wrapped__);return(n.__actions__=Ao(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_t([this.value()],arguments))})}),e}function al(){}var ll=Bo(Dt),ul=Bo(At),cl=Bo(Lt);function dl(e){return wi(e)?Ut(Fi(e)):function(e){return function(t){return Cr(t,e)}}(e)}var hl=Uo(),pl=Uo(!0);function gl(){return[]}function fl(){return!1}var ml,yl=jo(function(e,t){return e+t},0),wl=Ho("ceil"),vl=jo(function(e,t){return e/t},1),bl=Ho("floor"),Cl=jo(function(e,t){return e*t},1),Sl=Ho("round"),Il=jo(function(e,t){return e-t},0);return $n.after=function(e,t){if("function"!=typeof t)throw new Ae(i);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},$n.ary=xs,$n.assign=wa,$n.assignIn=va,$n.assignInWith=ba,$n.assignWith=Ca,$n.at=Sa,$n.before=As,$n.bind=Es,$n.bindAll=Za,$n.bindKey=Ws,$n.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Us(e)?e:[e]},$n.chain=ds,$n.chunk=function(e,t,n){t=(n?yi(e,t,n):t===o)?1:mn(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,l=r(ht(i/t));s<i;)l[a++]=eo(e,s,s+=t);return l},$n.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,o=[];++t<n;){var i=e[t];i&&(o[r++]=i)}return o},$n.concat=function(){var e=arguments.length;if(!e)return[];for(var t=r(e-1),n=arguments[0],o=e;o--;)t[o-1]=arguments[o];return _t(Us(n)?Ao(n):[n],fr(t,1))},$n.cond=function(e){var t=null==e?0:e.length,n=si();return e=t?Dt(e,function(e){if("function"!=typeof e[1])throw new Ae(i);return[n(e[0]),e[1]]}):[],Vr(function(n){for(var r=-1;++r<t;){var o=e[r];if(It(o[0],this,n))return It(o[1],this,n)}})},$n.conforms=function(e){return function(e){var t=Oa(e);return function(n){return ar(n,e,t)}}(sr(e,1))},$n.constant=Xa,$n.countBy=gs,$n.create=function(e,t){var n=Nn(e);return null==t?n:nr(n,t)},$n.curry=function e(t,n,r){var i=Jo(t,8,o,o,o,o,o,n=r?o:n);return i.placeholder=e.placeholder,i},$n.curryRight=function e(t,n,r){var i=Jo(t,16,o,o,o,o,o,n=r?o:n);return i.placeholder=e.placeholder,i},$n.debounce=Os,$n.defaults=Ia,$n.defaultsDeep=ka,$n.defer=Ds,$n.delay=_s,$n.difference=Ni,$n.differenceBy=ji,$n.differenceWith=Bi,$n.drop=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,(t=n||t===o?1:pa(t))<0?0:t,r):[]},$n.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,0,(t=r-(t=n||t===o?1:pa(t)))<0?0:t):[]},$n.dropRightWhile=function(e,t){return e&&e.length?co(e,si(t,3),!0,!0):[]},$n.dropWhile=function(e,t){return e&&e.length?co(e,si(t,3),!0):[]},$n.fill=function(e,t,n,r){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&yi(e,t,n)&&(n=0,r=i),function(e,t,n,r){var i=e.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:pa(r))<0&&(r+=i),r=n>r?0:ga(r);n<r;)e[n++]=t;return e}(e,t,n,r)):[]},$n.filter=function(e,t){return(Us(e)?Et:gr)(e,si(t,3))},$n.flatMap=function(e,t){return fr(Ss(e,t),1)},$n.flatMapDeep=function(e,t){return fr(Ss(e,t),c)},$n.flatMapDepth=function(e,t,n){return n=n===o?1:pa(n),fr(Ss(e,t),n)},$n.flatten=zi,$n.flattenDeep=function(e){return null!=e&&e.length?fr(e,c):[]},$n.flattenDepth=function(e,t){return null!=e&&e.length?fr(e,t=t===o?1:pa(t)):[]},$n.flip=function(e){return Jo(e,512)},$n.flow=el,$n.flowRight=tl,$n.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var o=e[t];r[o[0]]=o[1]}return r},$n.functions=function(e){return null==e?[]:br(e,Oa(e))},$n.functionsIn=function(e){return null==e?[]:br(e,Da(e))},$n.groupBy=vs,$n.initial=function(e){return null!=e&&e.length?eo(e,0,-1):[]},$n.intersection=Hi,$n.intersectionBy=Vi,$n.intersectionWith=Qi,$n.invert=Aa,$n.invertBy=Ea,$n.invokeMap=bs,$n.iteratee=rl,$n.keyBy=Cs,$n.keys=Oa,$n.keysIn=Da,$n.map=Ss,$n.mapKeys=function(e,t){var n={};return t=si(t,3),wr(e,function(e,r,o){rr(n,t(e,r,o),e)}),n},$n.mapValues=function(e,t){var n={};return t=si(t,3),wr(e,function(e,r,o){rr(n,r,t(e,r,o))}),n},$n.matches=function(e){return Mr(sr(e,1))},$n.matchesProperty=function(e,t){return $r(e,sr(t,1))},$n.memoize=Ps,$n.merge=_a,$n.mergeWith=Pa,$n.method=ol,$n.methodOf=il,$n.mixin=sl,$n.negate=Rs,$n.nthArg=function(e){return e=pa(e),Vr(function(t){return jr(t,e)})},$n.omit=Ra,$n.omitBy=function(e,t){return Fa(e,Rs(si(t)))},$n.once=function(e){return As(2,e)},$n.orderBy=function(e,t,n,r){return null==e?[]:(Us(t)||(t=null==t?[]:[t]),Us(n=r?o:n)||(n=null==n?[]:[n]),Br(e,t,n))},$n.over=ll,$n.overArgs=Ls,$n.overEvery=ul,$n.overSome=cl,$n.partial=Fs,$n.partialRight=Ms,$n.partition=Is,$n.pick=La,$n.pickBy=Fa,$n.property=dl,$n.propertyOf=function(e){return function(t){return null==e?o:Cr(e,t)}},$n.pull=Ki,$n.pullAll=Yi,$n.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Ur(e,t,si(n,2)):e},$n.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Ur(e,t,o,n):e},$n.pullAt=Zi,$n.range=hl,$n.rangeRight=pl,$n.rearg=$s,$n.reject=function(e,t){return(Us(e)?Et:gr)(e,Rs(si(t,3)))},$n.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,o=[],i=e.length;for(t=si(t,3);++r<i;){var s=e[r];t(s,r,e)&&(n.push(s),o.push(r))}return zr(e,o),n},$n.rest=function(e,t){if("function"!=typeof e)throw new Ae(i);return Vr(e,t=t===o?t:pa(t))},$n.reverse=Xi,$n.sampleSize=function(e,t,n){return t=(n?yi(e,t,n):t===o)?1:pa(t),(Us(e)?Kn:Jr)(e,t)},$n.set=function(e,t,n){return null==e?e:Kr(e,t,n)},$n.setWith=function(e,t,n,r){return r="function"==typeof r?r:o,null==e?e:Kr(e,t,n,r)},$n.shuffle=function(e){return(Us(e)?Yn:Xr)(e)},$n.slice=function(e,t,n){var r=null==e?0:e.length;return r?(n&&"number"!=typeof n&&yi(e,t,n)?(t=0,n=r):(t=null==t?0:pa(t),n=n===o?r:pa(n)),eo(e,t,n)):[]},$n.sortBy=ks,$n.sortedUniq=function(e){return e&&e.length?oo(e):[]},$n.sortedUniqBy=function(e,t){return e&&e.length?oo(e,si(t,2)):[]},$n.split=function(e,t,n){return n&&"number"!=typeof n&&yi(e,t,n)&&(t=n=o),(n=n===o?p:n>>>0)?(e=ya(e))&&("string"==typeof t||null!=t&&!oa(t))&&!(t=so(t))&&rn(e)?vo(dn(e),0,n):e.split(t,n):[]},$n.spread=function(e,t){if("function"!=typeof e)throw new Ae(i);return t=null==t?0:mn(pa(t),0),Vr(function(n){var r=n[t],o=vo(n,0,t);return r&&_t(o,r),It(e,this,o)})},$n.tail=function(e){var t=null==e?0:e.length;return t?eo(e,1,t):[]},$n.take=function(e,t,n){return e&&e.length?eo(e,0,(t=n||t===o?1:pa(t))<0?0:t):[]},$n.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,(t=r-(t=n||t===o?1:pa(t)))<0?0:t,r):[]},$n.takeRightWhile=function(e,t){return e&&e.length?co(e,si(t,3),!1,!0):[]},$n.takeWhile=function(e,t){return e&&e.length?co(e,si(t,3)):[]},$n.tap=function(e,t){return t(e),e},$n.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new Ae(i);return Xs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Os(e,t,{leading:r,maxWait:t,trailing:o})},$n.thru=hs,$n.toArray=da,$n.toPairs=Ma,$n.toPairsIn=$a,$n.toPath=function(e){return Us(e)?Dt(e,Fi):aa(e)?[e]:Ao(Li(ya(e)))},$n.toPlainObject=ma,$n.transform=function(e,t,n){var r=Us(e),o=r||Vs(e)||la(e);if(t=si(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Xs(e)&&Ks(i)?Nn(ze(e)):{}}return(o?Tt:wr)(e,function(e,r,o){return t(n,e,r,o)}),n},$n.unary=function(e){return xs(e,1)},$n.union=es,$n.unionBy=ts,$n.unionWith=ns,$n.uniq=function(e){return e&&e.length?ao(e):[]},$n.uniqBy=function(e,t){return e&&e.length?ao(e,si(t,2)):[]},$n.uniqWith=function(e,t){return t="function"==typeof t?t:o,e&&e.length?ao(e,o,t):[]},$n.unset=function(e,t){return null==e||lo(e,t)},$n.unzip=rs,$n.unzipWith=os,$n.update=function(e,t,n){return null==e?e:uo(e,t,mo(n))},$n.updateWith=function(e,t,n,r){return r="function"==typeof r?r:o,null==e?e:uo(e,t,mo(n),r)},$n.values=Na,$n.valuesIn=function(e){return null==e?[]:Kt(e,Da(e))},$n.without=is,$n.words=Ka,$n.wrap=function(e,t){return Fs(mo(t),e)},$n.xor=ss,$n.xorBy=as,$n.xorWith=ls,$n.zip=us,$n.zipObject=function(e,t){return go(e||[],t||[],Xn)},$n.zipObjectDeep=function(e,t){return go(e||[],t||[],Kr)},$n.zipWith=cs,$n.entries=Ma,$n.entriesIn=$a,$n.extend=va,$n.extendWith=ba,sl($n,$n),$n.add=yl,$n.attempt=Ya,$n.camelCase=ja,$n.capitalize=Ba,$n.ceil=wl,$n.clamp=function(e,t,n){return n===o&&(n=t,t=o),n!==o&&(n=(n=fa(n))==n?n:0),t!==o&&(t=(t=fa(t))==t?t:0),ir(fa(e),t,n)},$n.clone=function(e){return sr(e,4)},$n.cloneDeep=function(e){return sr(e,5)},$n.cloneDeepWith=function(e,t){return sr(e,5,t="function"==typeof t?t:o)},$n.cloneWith=function(e,t){return sr(e,4,t="function"==typeof t?t:o)},$n.conformsTo=function(e,t){return null==t||ar(e,t,Oa(t))},$n.deburr=qa,$n.defaultTo=function(e,t){return null==e||e!=e?t:e},$n.divide=vl,$n.endsWith=function(e,t,n){e=ya(e),t=so(t);var r=e.length,i=n=n===o?r:ir(pa(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},$n.eq=Ns,$n.escape=function(e){return(e=ya(e))&&Q.test(e)?e.replace(H,tn):e},$n.escapeRegExp=function(e){return(e=ya(e))&&ne.test(e)?e.replace(te,"\\$&"):e},$n.every=function(e,t,n){var r=Us(e)?At:hr;return n&&yi(e,t,n)&&(t=o),r(e,si(t,3))},$n.find=fs,$n.findIndex=qi,$n.findKey=function(e,t){return Mt(e,si(t,3),wr)},$n.findLast=ms,$n.findLastIndex=Ui,$n.findLastKey=function(e,t){return Mt(e,si(t,3),vr)},$n.floor=bl,$n.forEach=ys,$n.forEachRight=ws,$n.forIn=function(e,t){return null==e?e:mr(e,si(t,3),Da)},$n.forInRight=function(e,t){return null==e?e:yr(e,si(t,3),Da)},$n.forOwn=function(e,t){return e&&wr(e,si(t,3))},$n.forOwnRight=function(e,t){return e&&vr(e,si(t,3))},$n.get=Ta,$n.gt=js,$n.gte=Bs,$n.has=function(e,t){return null!=e&&pi(e,t,Tr)},$n.hasIn=xa,$n.head=Gi,$n.identity=nl,$n.includes=function(e,t,n,r){e=Gs(e)?e:Na(e),n=n&&!r?pa(n):0;var o=e.length;return n<0&&(n=mn(o+n,0)),sa(e)?n<=o&&e.indexOf(t,n)>-1:!!o&&Nt(e,t,n)>-1},$n.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=mn(r+o,0)),Nt(e,t,o)},$n.inRange=function(e,t,n){return t=ha(t),n===o?(n=t,t=0):n=ha(n),function(e,t,n){return e>=yn(t,n)&&e<mn(t,n)}(e=fa(e),t,n)},$n.invoke=Wa,$n.isArguments=qs,$n.isArray=Us,$n.isArrayBuffer=zs,$n.isArrayLike=Gs,$n.isArrayLikeObject=Hs,$n.isBoolean=function(e){return!0===e||!1===e||ea(e)&&Ir(e)==y},$n.isBuffer=Vs,$n.isDate=Qs,$n.isElement=function(e){return ea(e)&&1===e.nodeType&&!ra(e)},$n.isEmpty=function(e){if(null==e)return!0;if(Gs(e)&&(Us(e)||"string"==typeof e||"function"==typeof e.splice||Vs(e)||la(e)||qs(e)))return!e.length;var t=hi(e);if(t==S||t==A)return!e.size;if(Ci(e))return!Rr(e).length;for(var n in e)if(Pe.call(e,n))return!1;return!0},$n.isEqual=function(e,t){return Or(e,t)},$n.isEqualWith=function(e,t,n){var r=(n="function"==typeof n?n:o)?n(e,t):o;return r===o?Or(e,t,o,n):!!r},$n.isError=Js,$n.isFinite=function(e){return"number"==typeof e&&Ft(e)},$n.isFunction=Ks,$n.isInteger=Ys,$n.isLength=Zs,$n.isMap=ta,$n.isMatch=function(e,t){return e===t||Dr(e,t,li(t))},$n.isMatchWith=function(e,t,n){return n="function"==typeof n?n:o,Dr(e,t,li(t),n)},$n.isNaN=function(e){return na(e)&&e!=+e},$n.isNative=function(e){if(bi(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return _r(e)},$n.isNil=function(e){return null==e},$n.isNull=function(e){return null===e},$n.isNumber=na,$n.isObject=Xs,$n.isObjectLike=ea,$n.isPlainObject=ra,$n.isRegExp=oa,$n.isSafeInteger=function(e){return Ys(e)&&e>=-9007199254740991&&e<=d},$n.isSet=ia,$n.isString=sa,$n.isSymbol=aa,$n.isTypedArray=la,$n.isUndefined=function(e){return e===o},$n.isWeakMap=function(e){return ea(e)&&hi(e)==O},$n.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==Ir(e)},$n.join=function(e,t){return null==e?"":zt.call(e,t)},$n.kebabCase=Ua,$n.last=Ji,$n.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=pa(n))<0?mn(r+i,0):yn(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):$t(e,Bt,i,!0)},$n.lowerCase=za,$n.lowerFirst=Ga,$n.lt=ua,$n.lte=ca,$n.max=function(e){return e&&e.length?pr(e,nl,kr):o},$n.maxBy=function(e,t){return e&&e.length?pr(e,si(t,2),kr):o},$n.mean=function(e){return qt(e,nl)},$n.meanBy=function(e,t){return qt(e,si(t,2))},$n.min=function(e){return e&&e.length?pr(e,nl,Lr):o},$n.minBy=function(e,t){return e&&e.length?pr(e,si(t,2),Lr):o},$n.stubArray=gl,$n.stubFalse=fl,$n.stubObject=function(){return{}},$n.stubString=function(){return""},$n.stubTrue=function(){return!0},$n.multiply=Cl,$n.nth=function(e,t){return e&&e.length?jr(e,pa(t)):o},$n.noConflict=function(){return dt._===this&&(dt._=$e),this},$n.noop=al,$n.now=Ts,$n.pad=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return qo(pt(o),n)+e+qo(ht(o),n)},$n.padEnd=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;return t&&r<t?e+qo(t-r,n):e},$n.padStart=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;return t&&r<t?qo(t-r,n)+e:e},$n.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),vn(ya(e).replace(re,""),t||0)},$n.random=function(e,t,n){if(n&&"boolean"!=typeof n&&yi(e,t,n)&&(t=n=o),n===o&&("boolean"==typeof t?(n=t,t=o):"boolean"==typeof e&&(n=e,e=o)),e===o&&t===o?(e=0,t=1):(e=ha(e),t===o?(t=e,e=0):t=ha(t)),e>t){var r=e;e=t,t=r}if(n||e%1||t%1){var i=bn();return yn(e+i*(t-e+at("1e-"+((i+"").length-1))),t)}return Gr(e,t)},$n.reduce=function(e,t,n){var r=Us(e)?Pt:Gt,o=arguments.length<3;return r(e,si(t,4),n,o,cr)},$n.reduceRight=function(e,t,n){var r=Us(e)?Rt:Gt,o=arguments.length<3;return r(e,si(t,4),n,o,dr)},$n.repeat=function(e,t,n){return t=(n?yi(e,t,n):t===o)?1:pa(t),Hr(ya(e),t)},$n.replace=function(){var e=arguments,t=ya(e[0]);return e.length<3?t:t.replace(e[1],e[2])},$n.result=function(e,t,n){var r=-1,i=(t=yo(t,e)).length;for(i||(i=1,e=o);++r<i;){var s=null==e?o:e[Fi(t[r])];s===o&&(r=i,s=n),e=Ks(s)?s.call(e):s}return e},$n.round=Sl,$n.runInContext=e,$n.sample=function(e){return(Us(e)?Jn:Qr)(e)},$n.size=function(e){if(null==e)return 0;if(Gs(e))return sa(e)?cn(e):e.length;var t=hi(e);return t==S||t==A?e.size:Rr(e).length},$n.snakeCase=Ha,$n.some=function(e,t,n){var r=Us(e)?Lt:to;return n&&yi(e,t,n)&&(t=o),r(e,si(t,3))},$n.sortedIndex=function(e,t){return no(e,t)},$n.sortedIndexBy=function(e,t,n){return ro(e,t,si(n,2))},$n.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=no(e,t);if(r<n&&Ns(e[r],t))return r}return-1},$n.sortedLastIndex=function(e,t){return no(e,t,!0)},$n.sortedLastIndexBy=function(e,t,n){return ro(e,t,si(n,2),!0)},$n.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=no(e,t,!0)-1;if(Ns(e[n],t))return n}return-1},$n.startCase=Va,$n.startsWith=function(e,t,n){return e=ya(e),n=null==n?0:ir(pa(n),0,e.length),t=so(t),e.slice(n,n+t.length)==t},$n.subtract=Il,$n.sum=function(e){return e&&e.length?Ht(e,nl):0},$n.sumBy=function(e,t){return e&&e.length?Ht(e,si(t,2)):0},$n.template=function(e,t,n){var r=$n.templateSettings;n&&yi(e,t,n)&&(t=o),e=ya(e),t=ba({},t,r,Ko);var i,s,a=ba({},t.imports,r.imports,Ko),l=Oa(a),u=Kt(a,l),c=0,d=t.interpolate||ve,h="__p += '",p=Te((t.escape||ve).source+"|"+d.source+"|"+(d===Y?de:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),g="//# sourceURL="+(Pe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(p,function(t,n,r,o,a,l){return r||(r=o),h+=e.slice(c,l).replace(be,nn),n&&(i=!0,h+="' +\n__e("+n+") +\n'"),a&&(s=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=l+t.length,t}),h+="';\n";var f=Pe.call(t,"variable")&&t.variable;if(f){if(ue.test(f))throw new Ce("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(s?h.replace(q,""):h).replace(U,"$1").replace(z,"$1;"),h="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=Ya(function(){return Se(l,g+"return "+h).apply(o,u)});if(m.source=h,Js(m))throw m;return m},$n.times=function(e,t){if((e=pa(e))<1||e>d)return[];var n=p,r=yn(e,p);t=si(t),e-=p;for(var o=Vt(r,t);++n<e;)t(n);return o},$n.toFinite=ha,$n.toInteger=pa,$n.toLength=ga,$n.toLower=function(e){return ya(e).toLowerCase()},$n.toNumber=fa,$n.toSafeInteger=function(e){return e?ir(pa(e),-9007199254740991,d):0===e?e:0},$n.toString=ya,$n.toUpper=function(e){return ya(e).toUpperCase()},$n.trim=function(e,t,n){if((e=ya(e))&&(n||t===o))return Qt(e);if(!e||!(t=so(t)))return e;var r=dn(e),i=dn(t);return vo(r,Zt(r,i),Xt(r,i)+1).join("")},$n.trimEnd=function(e,t,n){if((e=ya(e))&&(n||t===o))return e.slice(0,hn(e)+1);if(!e||!(t=so(t)))return e;var r=dn(e);return vo(r,0,Xt(r,dn(t))+1).join("")},$n.trimStart=function(e,t,n){if((e=ya(e))&&(n||t===o))return e.replace(re,"");if(!e||!(t=so(t)))return e;var r=dn(e);return vo(r,Zt(r,dn(t))).join("")},$n.truncate=function(e,t){var n=30,r="...";if(Xs(t)){var i="separator"in t?t.separator:i;n="length"in t?pa(t.length):n,r="omission"in t?so(t.omission):r}var s=(e=ya(e)).length;if(rn(e)){var a=dn(e);s=a.length}if(n>=s)return e;var l=n-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):e.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(e.slice(l).search(i)){var c,d=u;for(i.global||(i=Te(i.source,ya(he.exec(i))+"g")),i.lastIndex=0;c=i.exec(d);)var h=c.index;u=u.slice(0,h===o?l:h)}}else if(e.indexOf(so(i),l)!=l){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+r},$n.unescape=function(e){return(e=ya(e))&&V.test(e)?e.replace(G,pn):e},$n.uniqueId=function(e){var t=++Re;return ya(e)+t},$n.upperCase=Qa,$n.upperFirst=Ja,$n.each=ys,$n.eachRight=ws,$n.first=Gi,sl($n,(ml={},wr($n,function(e,t){Pe.call($n.prototype,t)||(ml[t]=e)}),ml),{chain:!1}),$n.VERSION="4.17.21",Tt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){$n[e].placeholder=$n}),Tt(["drop","take"],function(e,t){qn.prototype[e]=function(n){n=n===o?1:mn(pa(n),0);var r=this.__filtered__&&!t?new qn(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,p),type:e+(r.__dir__<0?"Right":"")}),r},qn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Tt(["filter","map","takeWhile"],function(e,t){var n=t+1,r=1==n||3==n;qn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:si(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),Tt(["head","last"],function(e,t){var n="take"+(t?"Right":"");qn.prototype[e]=function(){return this[n](1).value()[0]}}),Tt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");qn.prototype[e]=function(){return this.__filtered__?new qn(this):this[n](1)}}),qn.prototype.compact=function(){return this.filter(nl)},qn.prototype.find=function(e){return this.filter(e).head()},qn.prototype.findLast=function(e){return this.reverse().find(e)},qn.prototype.invokeMap=Vr(function(e,t){return"function"==typeof e?new qn(this):this.map(function(n){return Er(n,e,t)})}),qn.prototype.reject=function(e){return this.filter(Rs(si(e)))},qn.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new qn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==o&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},qn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},qn.prototype.toArray=function(){return this.take(p)},wr(qn.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=$n[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);i&&($n.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof qn,u=a[0],c=l||Us(t),d=function(e){var t=i.apply($n,_t([e],a));return r&&h?t[0]:t};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var h=this.__chain__,p=!!this.__actions__.length,g=s&&!h,f=l&&!p;if(!s&&c){t=f?t:new qn(this);var m=e.apply(t,a);return m.__actions__.push({func:hs,args:[d],thisArg:o}),new Bn(m,h)}return g&&f?e.apply(this,a):(m=this.thru(d),g?r?m.value()[0]:m.value():m)})}),Tt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Ee[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);$n.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(Us(o)?o:[],e)}return this[n](function(n){return t.apply(Us(n)?n:[],e)})}}),wr(qn.prototype,function(e,t){var n=$n[t];if(n){var r=n.name+"";Pe.call(Wn,r)||(Wn[r]=[]),Wn[r].push({name:t,func:n})}}),Wn[$o(o,2).name]=[{name:"wrapper",func:o}],qn.prototype.clone=function(){var e=new qn(this.__wrapped__);return e.__actions__=Ao(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ao(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ao(this.__views__),e},qn.prototype.reverse=function(){if(this.__filtered__){var e=new qn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},qn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Us(e),r=t<0,o=n?e.length:0,i=function(e,t,n){for(var r=-1,o=n.length;++r<o;){var i=n[r],s=i.size;switch(i.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=yn(t,e+s);break;case"takeRight":e=mn(e,t-s)}}return{start:e,end:t}}(0,o,this.__views__),s=i.start,a=i.end,l=a-s,u=r?a:s-1,c=this.__iteratees__,d=c.length,h=0,p=yn(l,this.__takeCount__);if(!n||!r&&o==l&&p==l)return ho(e,this.__actions__);var g=[];e:for(;l--&&h<p;){for(var f=-1,m=e[u+=t];++f<d;){var y=c[f],w=y.iteratee,v=y.type,b=w(m);if(2==v)m=b;else if(!b){if(1==v)continue e;break e}}g[h++]=m}return g},$n.prototype.at=ps,$n.prototype.chain=function(){return ds(this)},$n.prototype.commit=function(){return new Bn(this.value(),this.__chain__)},$n.prototype.next=function(){this.__values__===o&&(this.__values__=da(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?o:this.__values__[this.__index__++]}},$n.prototype.plant=function(e){for(var t,n=this;n instanceof jn;){var r=$i(n);r.__index__=0,r.__values__=o,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},$n.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof qn){var t=e;return this.__actions__.length&&(t=new qn(this)),(t=t.reverse()).__actions__.push({func:hs,args:[Xi],thisArg:o}),new Bn(t,this.__chain__)}return this.thru(Xi)},$n.prototype.toJSON=$n.prototype.valueOf=$n.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},$n.prototype.first=$n.prototype.head,Je&&($n.prototype[Je]=function(){return this}),$n}();dt._=gn,(r=function(){return gn}.call(t,n,t,e))===o||(e.exports=r)}.call(this)},2552:(e,t,n)=>{var r=n(1873),o=n(659),i=n(9350),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},2651:(e,t,n)=>{var r=n(4218);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},2749:(e,t,n)=>{var r=n(1042),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:o.call(t,e)}},2804:(e,t,n)=>{var r=n(6110)(n(9325),"Promise");e.exports=r},2865:(e,t,n)=>{var r=n(9570),o=n(1811)(r);e.exports=o},2903:(e,t,n)=>{var r=n(3805),o=n(5527),i=n(181),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=o(e),n=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&n.push(a);return n}},2949:(e,t,n)=>{var r=n(2651);e.exports=function(e,t){var n=r(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this}},3007:e=>{e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},3040:(e,t,n)=>{var r=n(1549),o=n(79),i=n(8223);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},3120:(e,t,n)=>{var r=n(4528),o=n(5891);e.exports=function e(t,n,i,s,a){var l=-1,u=t.length;for(i||(i=o),a||(a=[]);++l<u;){var c=t[l];n>0&&i(c)?n>1?e(c,n-1,i,s,a):r(a,c):s||(a[a.length]=c)}return a}},3170:(e,t,n)=>{var r=n(6547),o=n(1769),i=n(361),s=n(3805),a=n(7797);e.exports=function(e,t,n,l){if(!s(e))return e;for(var u=-1,c=(t=o(t,e)).length,d=c-1,h=e;null!=h&&++u<c;){var p=a(t[u]),g=n;if("__proto__"===p||"constructor"===p||"prototype"===p)return e;if(u!=d){var f=h[p];void 0===(g=l?l(f,p,h):void 0)&&(g=s(f)?f:i(t[u+1])?[]:{})}r(h,p,g),h=h[p]}return e}},3201:e=>{var t=/\w*$/;e.exports=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}},3222:(e,t,n)=>{var r=n(7556);e.exports=function(e){return null==e?"":r(e)}},3243:(e,t,n)=>{var r=n(6110),o=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},3290:(e,t,n)=>{e=n.nmd(e);var r=n(9325),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=a?a(n):new e.constructor(n);return e.copy(r),r}},3345:e=>{e.exports=function(){return[]}},3349:(e,t,n)=>{var r=n(2199),o=n(6375),i=n(7241);e.exports=function(e){return r(e,i,o)}},3360:(e,t,n)=>{var r=n(3243);e.exports=function(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},3488:e=>{e.exports=function(e){return e}},3605:e=>{e.exports=function(e){return this.__data__.get(e)}},3650:(e,t,n)=>{var r=n(4335)(Object.keys,Object);e.exports=r},3656:(e,t,n)=>{e=n.nmd(e);var r=n(9325),o=n(9935),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?r.Buffer:void 0,l=(a?a.isBuffer:void 0)||o;e.exports=l},3661:(e,t,n)=>{var r=n(3040),o=n(7670),i=n(289),s=n(4509),a=n(2949);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},3702:e=>{e.exports=function(){this.__data__=[],this.size=0}},3729:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},3736:(e,t,n)=>{var r=n(1873),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},3805:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},3838:(e,t,n)=>{var r=n(1791),o=n(7241);e.exports=function(e,t){return e&&r(t,o(t),e)}},3862:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},4128:(e,t,n)=>{var r=n(1800),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},4218:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4247:e=>{e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4248:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},4335:e=>{e.exports=function(e,t){return function(n){return e(t(n))}}},4342:(e,t,n)=>{"use strict";!function(){var t,r,o,i=0,s=[];for(r=0;r<256;r++)s[r]=(r+256).toString(16).substr(1);function a(){var e=((!t||i+16>l.BUFFER_SIZE)&&(i=0,t=l.randomBytes(l.BUFFER_SIZE)),t.slice(i,i+=16));return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function l(){var e=a();return s[e[0]]+s[e[1]]+s[e[2]]+s[e[3]]+"-"+s[e[4]]+s[e[5]]+"-"+s[e[6]]+s[e[7]]+"-"+s[e[8]]+s[e[9]]+"-"+s[e[10]]+s[e[11]]+s[e[12]]+s[e[13]]+s[e[14]]+s[e[15]]}l.BUFFER_SIZE=4096,l.bin=a,l.clearBuffer=function(){t=null,i=0},l.test=function(e){return"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},"undefined"!=typeof crypto?o=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(o=window.msCrypto),o=o||n(575),e.exports=l,l.randomBytes=function(){if(o){if(o.randomBytes)return o.randomBytes;if(o.getRandomValues)return"function"!=typeof Uint8Array.prototype.slice?function(e){var t=new Uint8Array(e);return o.getRandomValues(t),Array.from(t)}:function(e){var t=new Uint8Array(e);return o.getRandomValues(t),t}}return function(e){var t,n=[];for(t=0;t<e;t++)n.push(Math.floor(256*Math.random()));return n}}()}()},4383:(e,t,n)=>{var r=n(6001),o=n(8816)(function(e,t){return null==e?{}:r(e,t)});e.exports=o},4394:(e,t,n)=>{var r=n(2552),o=n(346);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},4509:(e,t,n)=>{var r=n(2651);e.exports=function(e){return r(this,e).has(e)}},4528:e=>{e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},4664:(e,t,n)=>{var r=n(9770),o=n(3345),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:o;e.exports=a},4733:(e,t,n)=>{var r=n(1791),o=n(5950);e.exports=function(e,t){return e&&r(t,o(t),e)}},4739:(e,t,n)=>{var r=n(6025);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},4744:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map(function(e){return r(e,n)})}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function a(e,n,l){(l=l||{}).arrayMerge=l.arrayMerge||o,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=r;var u=Array.isArray(n);return u===Array.isArray(e)?u?l.arrayMerge(e,n,l):function(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach(function(t){o[t]=r(e[t],n)}),i(t).forEach(function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return a;var n=t.customMerge(e);return"function"==typeof n?n:a}(i,n)(e[i],t[i],n):o[i]=r(t[i],n))}),o}(e,n,l):r(n,l)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return a(e,n,t)},{})};var l=a;e.exports=l},4840:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},4894:(e,t,n)=>{var r=n(1882),o=n(294);e.exports=function(e){return null!=e&&o(e.length)&&!r(e)}},4901:(e,t,n)=>{var r=n(2552),o=n(294),i=n(346),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!s[r(e)]}},4932:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},5083:(e,t,n)=>{var r=n(1882),o=n(7296),i=n(3805),s=n(7473),a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,c=l.toString,d=u.hasOwnProperty,h=RegExp("^"+c.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(r(e)?h:a).test(s(e))}},5288:e=>{e.exports=function(e,t){return e===t||e!=e&&t!=t}},5481:(e,t,n)=>{var r=n(9325)["__core-js_shared__"];e.exports=r},5527:e=>{var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},5529:(e,t,n)=>{var r=n(9344),o=n(8879),i=n(5527);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:r(o(e))}},5580:(e,t,n)=>{var r=n(6110)(n(9325),"DataView");e.exports=r},5749:(e,t,n)=>{var r=n(1042);e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},5861:(e,t,n)=>{var r=n(5580),o=n(8223),i=n(2804),s=n(6545),a=n(8303),l=n(2552),u=n(7473),c="[object Map]",d="[object Promise]",h="[object Set]",p="[object WeakMap]",g="[object DataView]",f=u(r),m=u(o),y=u(i),w=u(s),v=u(a),b=l;(r&&b(new r(new ArrayBuffer(1)))!=g||o&&b(new o)!=c||i&&b(i.resolve())!=d||s&&b(new s)!=h||a&&b(new a)!=p)&&(b=function(e){var t=l(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case f:return g;case m:return c;case y:return d;case w:return h;case v:return p}return t}),e.exports=b},5891:(e,t,n)=>{var r=n(1873),o=n(2428),i=n(6449),s=r?r.isConcatSpreadable:void 0;e.exports=function(e){return i(e)||o(e)||!!(s&&e&&e[s])}},5911:(e,t,n)=>{var r=n(8859),o=n(4248),i=n(9219);e.exports=function(e,t,n,s,a,l){var u=1&n,c=e.length,d=t.length;if(c!=d&&!(u&&d>c))return!1;var h=l.get(e),p=l.get(t);if(h&&p)return h==t&&p==e;var g=-1,f=!0,m=2&n?new r:void 0;for(l.set(e,t),l.set(t,e);++g<c;){var y=e[g],w=t[g];if(s)var v=u?s(w,y,g,t,e,l):s(y,w,g,e,t,l);if(void 0!==v){if(v)continue;f=!1;break}if(m){if(!o(t,function(e,t){if(!i(m,t)&&(y===e||a(y,e,n,s,l)))return m.push(t)})){f=!1;break}}else if(y!==w&&!a(y,w,n,s,l)){f=!1;break}}return l.delete(e),l.delete(t),f}},5950:(e,t,n)=>{var r=n(695),o=n(8984),i=n(4894);e.exports=function(e){return i(e)?r(e):o(e)}},5970:(e,t,n)=>{var r=n(3120);e.exports=function(e){return null!=e&&e.length?r(e,1):[]}},6001:(e,t,n)=>{var r=n(7420),o=n(631);e.exports=function(e,t){return r(e,t,function(t,n){return o(e,n)})}},6009:(e,t,n)=>{e=n.nmd(e);var r=n(4840),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o&&r.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a},6025:(e,t,n)=>{var r=n(5288);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},6038:(e,t,n)=>{var r=n(5861),o=n(346);e.exports=function(e){return o(e)&&"[object Set]"==r(e)}},6110:(e,t,n)=>{var r=n(5083),o=n(392);e.exports=function(e,t){var n=o(e,t);return r(n)?n:void 0}},6169:(e,t,n)=>{var r=n(9653);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}},6189:e=>{var t=Object.prototype.hasOwnProperty;e.exports=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r}},6375:(e,t,n)=>{var r=n(4528),o=n(8879),i=n(4664),s=n(3345),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)r(t,i(e)),e=o(e);return t}:s;e.exports=a},6449:e=>{var t=Array.isArray;e.exports=t},6545:(e,t,n)=>{var r=n(6110)(n(9325),"Set");e.exports=r},6547:(e,t,n)=>{var r=n(3360),o=n(5288),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&o(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},6721:(e,t,n)=>{var r=n(1042),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(t,e)?t[e]:void 0}},6757:(e,t,n)=>{var r=n(1033),o=Math.max;e.exports=function(e,t,n){return t=o(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,a=o(i.length-t,0),l=Array(a);++s<a;)l[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(l),r(e,this,u)}}},7068:(e,t,n)=>{var r=n(7217),o=n(5911),i=n(1986),s=n(689),a=n(5861),l=n(6449),u=n(3656),c=n(7167),d="[object Arguments]",h="[object Array]",p="[object Object]",g=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,f,m,y){var w=l(e),v=l(t),b=w?h:a(e),C=v?h:a(t),S=(b=b==d?p:b)==p,I=(C=C==d?p:C)==p,k=b==C;if(k&&u(e)){if(!u(t))return!1;w=!0,S=!1}if(k&&!S)return y||(y=new r),w||c(e)?o(e,t,n,f,m,y):i(e,t,b,n,f,m,y);if(!(1&n)){var T=S&&g.call(e,"__wrapped__"),x=I&&g.call(t,"__wrapped__");if(T||x){var A=T?e.value():e,E=x?t.value():t;return y||(y=new r),m(A,E,n,f,y)}}return!!k&&(y||(y=new r),s(e,t,n,f,m,y))}},7167:(e,t,n)=>{var r=n(4901),o=n(7301),i=n(6009),s=i&&i.isTypedArray,a=s?o(s):r;e.exports=a},7199:(e,t,n)=>{var r=n(9653),o=n(6169),i=n(3201),s=n(3736),a=n(1961);e.exports=function(e,t,n){var l=e.constructor;switch(t){case"[object ArrayBuffer]":return r(e);case"[object Boolean]":case"[object Date]":return new l(+e);case"[object DataView]":return o(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(e,n);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},7217:(e,t,n)=>{var r=n(79),o=n(1420),i=n(938),s=n(3605),a=n(9817),l=n(945);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=l,e.exports=u},7241:(e,t,n)=>{var r=n(695),o=n(2903),i=n(4894);e.exports=function(e){return i(e)?r(e,!0):o(e)}},7296:(e,t,n)=>{var r,o=n(5481),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!i&&i in e}},7301:e=>{e.exports=function(e){return function(t){return e(t)}}},7334:e=>{e.exports=function(e){return function(){return e}}},7350:(e,t,n)=>{var r=n(8221),o=n(3805);e.exports=function(e,t,n){var i=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return o(n)&&(i="leading"in n?!!n.leading:i,s="trailing"in n?!!n.trailing:s),r(e,t,{leading:i,maxWait:t,trailing:s})}},7420:(e,t,n)=>{var r=n(7422),o=n(3170),i=n(1769);e.exports=function(e,t,n){for(var s=-1,a=t.length,l={};++s<a;){var u=t[s],c=r(e,u);n(c,u)&&o(l,i(u,e),c)}return l}},7422:(e,t,n)=>{var r=n(1769),o=n(7797);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[o(t[n++])];return n&&n==i?e:void 0}},7473:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},7534:(e,t,n)=>{var r=n(2552),o=n(346);e.exports=function(e){return o(e)&&"[object Arguments]"==r(e)}},7556:(e,t,n)=>{var r=n(1873),o=n(4932),i=n(6449),s=n(4394),a=r?r.prototype:void 0,l=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return l?l.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}},7670:(e,t,n)=>{var r=n(2651);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},7730:(e,t,n)=>{var r=n(9172),o=n(7301),i=n(6009),s=i&&i.isMap,a=s?o(s):r;e.exports=a},7797:(e,t,n)=>{var r=n(4394);e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7828:(e,t,n)=>{var r=n(9325).Uint8Array;e.exports=r},8055:(e,t,n)=>{var r=n(9999);e.exports=function(e){return r(e,5)}},8077:e=>{e.exports=function(e,t){return null!=e&&t in Object(e)}},8096:e=>{e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},8221:(e,t,n)=>{var r=n(3805),o=n(124),i=n(9374),s=Math.max,a=Math.min;e.exports=function(e,t,n){var l,u,c,d,h,p,g=0,f=!1,m=!1,y=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=l,r=u;return l=u=void 0,g=t,d=e.apply(r,n)}function v(e){var n=e-p;return void 0===p||n>=t||n<0||m&&e-g>=c}function b(){var e=o();if(v(e))return C(e);h=setTimeout(b,function(e){var n=t-(e-p);return m?a(n,c-(e-g)):n}(e))}function C(e){return h=void 0,y&&l?w(e):(l=u=void 0,d)}function S(){var e=o(),n=v(e);if(l=arguments,u=this,p=e,n){if(void 0===h)return function(e){return g=e,h=setTimeout(b,t),f?w(e):d}(p);if(m)return clearTimeout(h),h=setTimeout(b,t),w(p)}return void 0===h&&(h=setTimeout(b,t)),d}return t=i(t)||0,r(n)&&(f=!!n.leading,c=(m="maxWait"in n)?s(i(n.maxWait)||0,t):c,y="trailing"in n?!!n.trailing:y),S.cancel=function(){void 0!==h&&clearTimeout(h),g=0,l=p=u=h=void 0},S.flush=function(){return void 0===h?d:C(o())},S}},8223:(e,t,n)=>{var r=n(6110)(n(9325),"Map");e.exports=r},8303:(e,t,n)=>{var r=n(6110)(n(9325),"WeakMap");e.exports=r},8440:(e,t,n)=>{var r=n(6038),o=n(7301),i=n(6009),s=i&&i.isSet,a=s?o(s):r;e.exports=a},8586:(e,t,n)=>{var r=n(6449),o=n(4394),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8655:(e,t,n)=>{var r=n(6025);e.exports=function(e){return r(this.__data__,e)>-1}},8816:(e,t,n)=>{var r=n(5970),o=n(6757),i=n(2865);e.exports=function(e){return i(o(e,void 0,r),e+"")}},8859:(e,t,n)=>{var r=n(3661),o=n(1380),i=n(1459);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=o,s.prototype.has=i,e.exports=s},8879:(e,t,n)=>{var r=n(4335)(Object.getPrototypeOf,Object);e.exports=r},8948:(e,t,n)=>{var r=n(1791),o=n(6375);e.exports=function(e,t){return r(e,o(e),t)}},8984:(e,t,n)=>{var r=n(5527),o=n(3650),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))i.call(e,n)&&"constructor"!=n&&t.push(n);return t}},9031:e=>{"use strict";function t(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,r){r||(r={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof r.unknown&&(o.unknownFn=r.unknown),"boolean"==typeof r.boolean&&r.boolean?o.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach(function(e){o.bools[e]=!0});var i={};function s(e){return i[e].some(function(e){return o.bools[e]})}Object.keys(r.alias||{}).forEach(function(e){i[e]=[].concat(r.alias[e]),i[e].forEach(function(t){i[t]=[e].concat(i[e].filter(function(e){return t!==e}))})}),[].concat(r.string).filter(Boolean).forEach(function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach(function(e){o.strings[e]=!0})});var a=r.default||{},l={_:[]};function u(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var l=t[t.length-1];n(i,l)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[l]||o.bools[l]||"boolean"==typeof i[l]?i[l]=r:Array.isArray(i[l])?i[l].push(r):i[l]=[i[l],r])}function c(e,n,r){if(!r||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,r)||!1!==o.unknownFn(r)){var s=!o.strings[e]&&t(n)?Number(n):n;u(l,e.split("."),s),(i[e]||[]).forEach(function(e){u(l,e.split("."),s)})}}Object.keys(o.bools).forEach(function(e){c(e,void 0!==a[e]&&a[e])});var d=[];-1!==e.indexOf("--")&&(d=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var h=0;h<e.length;h++){var p,g,f=e[h];if(/^--.+=/.test(f)){var m=f.match(/^--([^=]+)=([\s\S]*)$/);p=m[1];var y=m[2];o.bools[p]&&(y="false"!==y),c(p,y,f)}else if(/^--no-.+/.test(f))c(p=f.match(/^--no-(.+)/)[1],!1,f);else if(/^--.+/.test(f))p=f.match(/^--(.+)/)[1],void 0===(g=e[h+1])||/^(-|--)[^-]/.test(g)||o.bools[p]||o.allBools||i[p]&&s(p)?/^(true|false)$/.test(g)?(c(p,"true"===g,f),h+=1):c(p,!o.strings[p]||"",f):(c(p,g,f),h+=1);else if(/^-[^-]+/.test(f)){for(var w=f.slice(1,-1).split(""),v=!1,b=0;b<w.length;b++)if("-"!==(g=f.slice(b+2))){if(/[A-Za-z]/.test(w[b])&&"="===g[0]){c(w[b],g.slice(1),f),v=!0;break}if(/[A-Za-z]/.test(w[b])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(g)){c(w[b],g,f),v=!0;break}if(w[b+1]&&w[b+1].match(/\W/)){c(w[b],f.slice(b+2),f),v=!0;break}c(w[b],!o.strings[w[b]]||"",f)}else c(w[b],g,f);p=f.slice(-1)[0],v||"-"===p||(!e[h+1]||/^(-|--)[^-]/.test(e[h+1])||o.bools[p]||i[p]&&s(p)?e[h+1]&&/^(true|false)$/.test(e[h+1])?(c(p,"true"===e[h+1],f),h+=1):c(p,!o.strings[p]||"",f):(c(p,e[h+1],f),h+=1))}else if(o.unknownFn&&!1===o.unknownFn(f)||l._.push(o.strings._||!t(f)?f:Number(f)),r.stopEarly){l._.push.apply(l._,e.slice(h+1));break}}return Object.keys(a).forEach(function(e){var t,n,r;t=l,n=e.split("."),r=t,n.slice(0,-1).forEach(function(e){r=r[e]||{}}),n[n.length-1]in r||(u(l,e.split("."),a[e]),(i[e]||[]).forEach(function(t){u(l,t.split("."),a[e])}))}),r["--"]?l["--"]=d.slice():d.forEach(function(e){l._.push(e)}),l}},9132:(e,t,n)=>{var r=n(270);e.exports=function(e,t,n){var o=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===o?r(e,t,void 0,n):!!o}},9172:(e,t,n)=>{var r=n(5861),o=n(346);e.exports=function(e){return o(e)&&"[object Map]"==r(e)}},9219:e=>{e.exports=function(e,t){return e.has(t)}},9325:(e,t,n)=>{var r=n(4840),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},9326:(e,t,n)=>{var r=n(1769),o=n(2428),i=n(6449),s=n(361),a=n(294),l=n(7797);e.exports=function(e,t,n){for(var u=-1,c=(t=r(t,e)).length,d=!1;++u<c;){var h=l(t[u]);if(!(d=null!=e&&n(e,h)))break;e=e[h]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&a(c)&&s(h,c)&&(i(e)||o(e))}},9344:(e,t,n)=>{var r=n(3805),o=Object.create,i=function(){function e(){}return function(t){if(!r(t))return{};if(o)return o(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();e.exports=i},9350:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},9374:(e,t,n)=>{var r=n(4128),o=n(3805),i=n(4394),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||l.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},9570:(e,t,n)=>{var r=n(7334),o=n(3243),i=n(3488),s=o?function(e,t){return o(e,"toString",{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},9653:(e,t,n)=>{var r=n(7828);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},9770:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}},9817:e=>{e.exports=function(e){return this.__data__.has(e)}},9935:e=>{e.exports=function(){return!1}},9999:(e,t,n)=>{var r=n(7217),o=n(3729),i=n(6547),s=n(4733),a=n(3838),l=n(3290),u=n(3007),c=n(2271),d=n(8948),h=n(2),p=n(3349),g=n(5861),f=n(6189),m=n(7199),y=n(5529),w=n(6449),v=n(3656),b=n(7730),C=n(3805),S=n(8440),I=n(5950),k=n(7241),T="[object Arguments]",x="[object Function]",A="[object Object]",E={};E[T]=E["[object Array]"]=E["[object ArrayBuffer]"]=E["[object DataView]"]=E["[object Boolean]"]=E["[object Date]"]=E["[object Float32Array]"]=E["[object Float64Array]"]=E["[object Int8Array]"]=E["[object Int16Array]"]=E["[object Int32Array]"]=E["[object Map]"]=E["[object Number]"]=E[A]=E["[object RegExp]"]=E["[object Set]"]=E["[object String]"]=E["[object Symbol]"]=E["[object Uint8Array]"]=E["[object Uint8ClampedArray]"]=E["[object Uint16Array]"]=E["[object Uint32Array]"]=!0,E["[object Error]"]=E[x]=E["[object WeakMap]"]=!1,e.exports=function e(t,n,W,O,D,_){var P,R=1&n,L=2&n,F=4&n;if(W&&(P=D?W(t,O,D,_):W(t)),void 0!==P)return P;if(!C(t))return t;var M=w(t);if(M){if(P=f(t),!R)return u(t,P)}else{var $=g(t),N=$==x||"[object GeneratorFunction]"==$;if(v(t))return l(t,R);if($==A||$==T||N&&!D){if(P=L||N?{}:y(t),!R)return L?d(t,a(P,t)):c(t,s(P,t))}else{if(!E[$])return D?t:{};P=m(t,$,R)}}_||(_=new r);var j=_.get(t);if(j)return j;_.set(t,P),S(t)?t.forEach(function(r){P.add(e(r,n,W,r,t,_))}):b(t)&&t.forEach(function(r,o){P.set(o,e(r,n,W,o,t,_))});var B=M?void 0:(F?L?p:h:L?k:I)(t);return o(B||t,function(r,o){B&&(r=t[o=r]),i(P,o,e(r,n,W,o,t,_))}),P}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e={};n.r(e),n.d(e,{APPLICATION_STATE_CHANNEL:()=>gy,CLIENT_SERVER_MAPPING:()=>by,COMPONENT_STATE_STORAGE_TOPIC:()=>Oy,EVENT_INTERRUPT_CHANNEL:()=>Ty,HEARTBEAT_TIMEOUT_CHANNEL:()=>Dy,INTERRUPTIBLE_EVENTS:()=>xy,LAUNCHER_SERVICE:()=>_y,MOVE_REASON:()=>Py,SERVICES_STATE_CHANNEL:()=>Cy,SERVICE_CLOSED_CHANNEL:()=>wy,SERVICE_CLOSING_CHANNEL:()=>yy,SERVICE_INITIALIZING_CHANNEL:()=>fy,SERVICE_QUERY_READY_CHANNEL:()=>vy,SERVICE_READY_CHANNEL:()=>my,SERVICE_START_CHANNEL:()=>Iy,SERVICE_STOP_CHANNEL:()=>ky,WINDOW:()=>Ay,WINDOWSTATE:()=>Sy,WINDOW_SERVICE_REQUESTS:()=>Wy,WORKSPACE:()=>Ey,WRAPPERS:()=>py});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var i,s,a=Object.prototype.toString,l=function(e){var t=a.call(e),n="[object Arguments]"===t;return n||(n="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===a.call(e.callee)),n},u=Array.prototype.slice,c=l,d=Object.keys,h=d?function(e){return d(e)}:function(){if(s)return i;var e;if(s=1,!Object.keys){var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=l,o=Object.prototype.propertyIsEnumerable,a=!o.call({toString:null},"toString"),u=o.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=function(e){var t=e.constructor;return t&&t.prototype===e},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!h["$"+e]&&t.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{d(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();e=function(e){var o=null!==e&&"object"==typeof e,i="[object Function]"===n.call(e),s=r(e),l=o&&"[object String]"===n.call(e),h=[];if(!o&&!i&&!s)throw new TypeError("Object.keys called on a non-object");var g=u&&i;if(l&&e.length>0&&!t.call(e,0))for(var f=0;f<e.length;++f)h.push(String(f));if(s&&e.length>0)for(var m=0;m<e.length;++m)h.push(String(m));else for(var y in e)g&&"prototype"===y||!t.call(e,y)||h.push(String(y));if(a)for(var w=function(e){if("undefined"==typeof window||!p)return d(e);try{return d(e)}catch(e){return!1}}(e),v=0;v<c.length;++v)w&&"constructor"===c[v]||!t.call(e,c[v])||h.push(c[v]);return h}}return i=e}(),p=Object.keys;h.shim=function(){if(Object.keys){var e=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);e||(Object.keys=function(e){return c(e)?p(u.call(e)):p(e)})}else Object.keys=h;return Object.keys||h};var g,f,m=h,y=Error,w=EvalError,v=RangeError,b=ReferenceError,C=SyntaxError,S=TypeError,I=URIError;function k(){return f?g:(f=1,g=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0})}var T,x="undefined"!=typeof Symbol&&Symbol,A=k(),E=function(){return"function"==typeof x&&"function"==typeof Symbol&&"symbol"==typeof x("foo")&&"symbol"==typeof Symbol("bar")&&A()},W={__proto__:null,foo:{}},O=Object,D=Object.prototype.toString,_=Math.max,P=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var o=0;o<t.length;o+=1)n[o+e.length]=t[o];return n},R=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==D.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var n,r=function(e){for(var t=[],n=1,r=0;n<e.length;n+=1,r+=1)t[r]=e[n];return t}(arguments),o=_(0,t.length-r.length),i=[],s=0;s<o;s++)i[s]="$"+s;if(n=Function("binder","return function ("+function(e){for(var t="",n=0;n<e.length;n+=1)t+=e[n],n+1<e.length&&(t+=",");return t}(i)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var o=t.apply(this,P(r,arguments));return Object(o)===o?o:this}return t.apply(e,P(r,arguments))}),t.prototype){var a=function(){};a.prototype=t.prototype,n.prototype=new a,a.prototype=null}return n},L=Function.prototype.call,F=Object.prototype.hasOwnProperty,M=R.call(L,F),$=y,N=w,j=v,B=b,q=C,U=S,z=I,G=Function,H=function(e){try{return G('"use strict"; return ('+e+").constructor;")()}catch(e){}},V=Object.getOwnPropertyDescriptor;if(V)try{V({},"")}catch(Ny){V=null}var Q=function(){throw new U},J=V?function(){try{return Q}catch(e){try{return V(arguments,"callee").get}catch(e){return Q}}}():Q,K=E(),Y={__proto__:W}.foo===W.foo&&!(W instanceof O),Z=Object.getPrototypeOf||(Y?function(e){return e.__proto__}:null),X={},ee="undefined"!=typeof Uint8Array&&Z?Z(Uint8Array):T,te={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?T:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?T:ArrayBuffer,"%ArrayIteratorPrototype%":K&&Z?Z([][Symbol.iterator]()):T,"%AsyncFromSyncIteratorPrototype%":T,"%AsyncFunction%":X,"%AsyncGenerator%":X,"%AsyncGeneratorFunction%":X,"%AsyncIteratorPrototype%":X,"%Atomics%":"undefined"==typeof Atomics?T:Atomics,"%BigInt%":"undefined"==typeof BigInt?T:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?T:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?T:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?T:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":$,"%eval%":eval,"%EvalError%":N,"%Float32Array%":"undefined"==typeof Float32Array?T:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?T:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?T:FinalizationRegistry,"%Function%":G,"%GeneratorFunction%":X,"%Int8Array%":"undefined"==typeof Int8Array?T:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?T:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?T:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":K&&Z?Z(Z([][Symbol.iterator]())):T,"%JSON%":"object"==typeof JSON?JSON:T,"%Map%":"undefined"==typeof Map?T:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&K&&Z?Z((new Map)[Symbol.iterator]()):T,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?T:Promise,"%Proxy%":"undefined"==typeof Proxy?T:Proxy,"%RangeError%":j,"%ReferenceError%":B,"%Reflect%":"undefined"==typeof Reflect?T:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?T:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&K&&Z?Z((new Set)[Symbol.iterator]()):T,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?T:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":K&&Z?Z(""[Symbol.iterator]()):T,"%Symbol%":K?Symbol:T,"%SyntaxError%":q,"%ThrowTypeError%":J,"%TypedArray%":ee,"%TypeError%":U,"%Uint8Array%":"undefined"==typeof Uint8Array?T:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?T:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?T:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?T:Uint32Array,"%URIError%":z,"%WeakMap%":"undefined"==typeof WeakMap?T:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?T:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?T:WeakSet};if(Z)try{null.error}catch(Ny){var ne=Z(Z(Ny));te["%Error.prototype%"]=ne}var re,oe,ie=function e(t){var n;if("%AsyncFunction%"===t)n=H("async function () {}");else if("%GeneratorFunction%"===t)n=H("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=H("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&Z&&(n=Z(o.prototype))}return te[t]=n,n},se={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=R,le=M,ue=ae.call(Function.call,Array.prototype.concat),ce=ae.call(Function.apply,Array.prototype.splice),de=ae.call(Function.call,String.prototype.replace),he=ae.call(Function.call,String.prototype.slice),pe=ae.call(Function.call,RegExp.prototype.exec),ge=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,fe=/\\(\\)?/g,me=function(e,t){var n,r=e;if(le(se,r)&&(r="%"+(n=se[r])[0]+"%"),le(te,r)){var o=te[r];if(o===X&&(o=ie(r)),void 0===o&&!t)throw new U("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:o}}throw new q("intrinsic "+e+" does not exist!")},ye=function(e,t){if("string"!=typeof e||0===e.length)throw new U("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new U('"allowMissing" argument must be a boolean');if(null===pe(/^%?[^%]*%?$/,e))throw new q("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=he(e,0,1),n=he(e,-1);if("%"===t&&"%"!==n)throw new q("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new q("invalid intrinsic syntax, expected opening `%`");var r=[];return de(e,ge,function(e,t,n,o){r[r.length]=n?de(o,fe,"$1"):t||e}),r}(e),r=n.length>0?n[0]:"",o=me("%"+r+"%",t),i=o.name,s=o.value,a=!1,l=o.alias;l&&(r=l[0],ce(n,ue([0,1],l)));for(var u=1,c=!0;u<n.length;u+=1){var d=n[u],h=he(d,0,1),p=he(d,-1);if(('"'===h||"'"===h||"`"===h||'"'===p||"'"===p||"`"===p)&&h!==p)throw new q("property names with quotes must have matching quotes");if("constructor"!==d&&c||(a=!0),le(te,i="%"+(r+="."+d)+"%"))s=te[i];else if(null!=s){if(!(d in s)){if(!t)throw new U("base intrinsic for "+e+" exists, but the property is not available.");return}if(V&&u+1>=n.length){var g=V(s,d);s=(c=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:s[d]}else c=le(s,d),s=s[d];c&&!a&&(te[i]=s)}}return s};function we(){if(oe)return re;oe=1;var e=ye("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return re=e}var ve=ye("%Object.getOwnPropertyDescriptor%",!0);if(ve)try{ve([],"length")}catch(Ny){ve=null}var be=ve,Ce=we(),Se=C,Ie=S,ke=be,Te=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new Ie("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new Ie("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new Ie("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new Ie("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new Ie("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new Ie("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ke&&ke(e,t);if(Ce)Ce(e,t,{configurable:null===i&&a?a.configurable:!i,enumerable:null===r&&a?a.enumerable:!r,value:n,writable:null===o&&a?a.writable:!o});else{if(!s&&(r||o||i))throw new Se("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}},xe=we(),Ae=function(){return!!xe};Ae.hasArrayLengthDefineBug=function(){if(!xe)return null;try{return 1!==xe([],"length",{value:1}).length}catch(e){return!0}};var Ee=Ae,We=m,Oe="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),De=Object.prototype.toString,_e=Array.prototype.concat,Pe=Te,Re=Ee(),Le=function(e,t,n,r){if(t in e)if(!0===r){if(e[t]===n)return}else if("function"!=typeof(o=r)||"[object Function]"!==De.call(o)||!r())return;var o;Re?Pe(e,t,n,!0):Pe(e,t,n)},Fe=function(e,t){var n=arguments.length>2?arguments[2]:{},r=We(t);Oe&&(r=_e.call(r,Object.getOwnPropertySymbols(t)));for(var o=0;o<r.length;o+=1)Le(e,r[o],t[r[o]],n[r[o]])};Fe.supportsDescriptors=!!Re;var Me=Fe,$e={exports:{}},Ne=ye,je=Te,Be=Ee(),qe=be,Ue=S,ze=Ne("%Math.floor%"),Ge=function(e,t){if("function"!=typeof e)throw new Ue("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||ze(t)!==t)throw new Ue("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,o=!0;if("length"in e&&qe){var i=qe(e,"length");i&&!i.configurable&&(r=!1),i&&!i.writable&&(o=!1)}return(r||o||!n)&&(Be?je(e,"length",t,!0,!0):je(e,"length",t)),e};!function(e){var t=R,n=ye,r=Ge,o=S,i=n("%Function.prototype.apply%"),s=n("%Function.prototype.call%"),a=n("%Reflect.apply%",!0)||t.call(s,i),l=we(),u=n("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var n=a(t,s,arguments);return r(n,1+u(0,e.length-(arguments.length-1)),!0)};var c=function(){return a(t,i,arguments)};l?l(e.exports,"apply",{value:c}):e.exports.apply=c}($e);var He=$e.exports,Ve=ye,Qe=He,Je=Qe(Ve("String.prototype.indexOf")),Ke=function(e,t){var n=Ve(e,!!t);return"function"==typeof n&&Je(e,".prototype.")>-1?Qe(n):n},Ye=m,Ze=k()(),Xe=Ke,et=Object,tt=Xe("Array.prototype.push"),nt=Xe("Object.prototype.propertyIsEnumerable"),rt=Ze?Object.getOwnPropertySymbols:null,ot=function(e,t){if(null==e)throw new TypeError("target must be an object");var n=et(e);if(1===arguments.length)return n;for(var r=1;r<arguments.length;++r){var o=et(arguments[r]),i=Ye(o),s=Ze&&(Object.getOwnPropertySymbols||rt);if(s)for(var a=s(o),l=0;l<a.length;++l){var u=a[l];nt(o,u)&&tt(i,u)}for(var c=0;c<i.length;++c){var d=i[c];if(nt(o,d)){var h=o[d];n[d]=h}}}return n},it=ot,st=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),n={},r=0;r<t.length;++r)n[t[r]]=t[r];var o=Object.assign({},n),i="";for(var s in o)i+=s;return e!==i}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}return!1}()?it:Object.assign:it},at=Me,lt=st,ut=Me,ct=ot,dt=st,ht=He.apply(dt()),pt=function(e,t){return ht(Object,arguments)};ut(pt,{getPolyfill:dt,implementation:ct,shim:function(){var e=lt();return at(Object,{assign:e},{assign:function(){return Object.assign!==e}}),e}});var gt=pt,ft=function(){return"string"==typeof function(){}.name},mt=Object.getOwnPropertyDescriptor;if(mt)try{mt([],"length")}catch(Ny){mt=null}ft.functionsHaveConfigurableNames=function(){if(!ft()||!mt)return!1;var e=mt(function(){},"name");return!!e&&!!e.configurable};var yt=Function.prototype.bind;ft.boundFunctionsHaveNames=function(){return ft()&&"function"==typeof yt&&""!==function(){}.bind().name};var wt=ft,vt=Te,bt=Ee(),Ct=wt.functionsHaveConfigurableNames(),St=S,It=S,kt=Object,Tt=function(e,t){if("function"!=typeof e)throw new St("`fn` is not a function");return arguments.length>2&&!!arguments[2]&&!Ct||(bt?vt(e,"name",t,!0,!0):vt(e,"name",t)),e}(function(){if(null==this||this!==kt(this))throw new It("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),xt=Tt,At=Me.supportsDescriptors,Et=Object.getOwnPropertyDescriptor,Wt=function(){if(At&&"gim"===/a/gim.flags){var e=Et(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"boolean"==typeof RegExp.prototype.dotAll&&"boolean"==typeof RegExp.prototype.hasIndices){var t="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(n,"sticky",{get:function(){t+="y"}}),"dy"===t)return e.get}}return xt},Ot=Me.supportsDescriptors,Dt=Wt,_t=Object.getOwnPropertyDescriptor,Pt=Object.defineProperty,Rt=TypeError,Lt=Object.getPrototypeOf,Ft=/a/,Mt=Me,$t=Tt,Nt=Wt,jt=He(Nt());Mt(jt,{getPolyfill:Nt,implementation:$t,shim:function(){if(!Ot||!Lt)throw new Rt("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=Dt(),t=Lt(Ft),n=_t(t,"flags");return n&&n.get===e||Pt(t,"flags",{configurable:!0,enumerable:!1,get:e}),e}});var Bt=jt,qt={exports:{}},Ut=k(),zt=function(){return Ut()&&!!Symbol.toStringTag},Gt=zt(),Ht=Ke("Object.prototype.toString"),Vt=function(e){return!(Gt&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===Ht(e)},Qt=function(e){return!!Vt(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==Ht(e)&&"[object Function]"===Ht(e.callee)},Jt=function(){return Vt(arguments)}();Vt.isLegacyArguments=Qt;var Kt=Jt?Vt:Qt,Yt=o(Object.freeze({__proto__:null,default:{}})),Zt="function"==typeof Map&&Map.prototype,Xt=Object.getOwnPropertyDescriptor&&Zt?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,en=Zt&&Xt&&"function"==typeof Xt.get?Xt.get:null,tn=Zt&&Map.prototype.forEach,nn="function"==typeof Set&&Set.prototype,rn=Object.getOwnPropertyDescriptor&&nn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,on=nn&&rn&&"function"==typeof rn.get?rn.get:null,sn=nn&&Set.prototype.forEach,an="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,ln="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,un="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,cn=Boolean.prototype.valueOf,dn=Object.prototype.toString,hn=Function.prototype.toString,pn=String.prototype.match,gn=String.prototype.slice,fn=String.prototype.replace,mn=String.prototype.toUpperCase,yn=String.prototype.toLowerCase,wn=RegExp.prototype.test,vn=Array.prototype.concat,bn=Array.prototype.join,Cn=Array.prototype.slice,Sn=Math.floor,In="function"==typeof BigInt?BigInt.prototype.valueOf:null,kn=Object.getOwnPropertySymbols,Tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,xn="function"==typeof Symbol&&"object"==typeof Symbol.iterator,An="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,En=Object.prototype.propertyIsEnumerable,Wn=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function On(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||wn.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Sn(-e):Sn(e);if(r!==e){var o=String(r),i=gn.call(t,o.length+1);return fn.call(o,n,"$&_")+"."+fn.call(fn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fn.call(t,n,"$&_")}var Dn=Yt,_n=Dn.custom,Pn=$n(_n)?_n:null;function Rn(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Ln(e){return fn.call(String(e),/"/g,"&quot;")}function Fn(e){return!("[object Array]"!==Bn(e)||An&&"object"==typeof e&&An in e)}function Mn(e){return!("[object RegExp]"!==Bn(e)||An&&"object"==typeof e&&An in e)}function $n(e){if(xn)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Tn)return!1;try{return Tn.call(e),!0}catch(e){}return!1}var Nn=Object.prototype.hasOwnProperty||function(e){return e in this};function jn(e,t){return Nn.call(e,t)}function Bn(e){return dn.call(e)}function qn(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function Un(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Un(gn.call(e,0,t.maxStringLength),t)+r}return Rn(fn.call(fn.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,zn),"single",t)}function zn(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+mn.call(t.toString(16))}function Gn(e){return"Object("+e+")"}function Hn(e){return e+" { ? }"}function Vn(e,t,n,r){return e+" ("+t+") {"+(r?Qn(n,r):bn.call(n,", "))+"}"}function Qn(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+bn.call(e,","+n)+"\n"+t.prev}function Jn(e,t){var n=Fn(e),r=[];if(n){r.length=e.length;for(var o=0;o<e.length;o++)r[o]=jn(e,o)?t(e[o],e):""}var i,s="function"==typeof kn?kn(e):[];if(xn){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var l in e)jn(e,l)&&(n&&String(Number(l))===l&&l<e.length||xn&&i["$"+l]instanceof Symbol||(wn.call(/[^\w$]/,l)?r.push(t(l,e)+": "+t(e[l],e)):r.push(l+": "+t(e[l],e))));if("function"==typeof kn)for(var u=0;u<s.length;u++)En.call(e,s[u])&&r.push("["+t(s[u])+"]: "+t(e[s[u]],e));return r}var Kn=ye,Yn=Ke,Zn=function e(n,r,o,i){var s=r||{};if(jn(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(jn(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!jn(s,"customInspect")||s.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(jn(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(jn(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var l=s.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return Un(n,s);if("number"==typeof n){if(0===n)return 1/0/n>0?"0":"-0";var u=String(n);return l?On(n,u):u}if("bigint"==typeof n){var c=String(n)+"n";return l?On(n,c):c}var d=void 0===s.depth?5:s.depth;if(void 0===o&&(o=0),o>=d&&d>0&&"object"==typeof n)return Fn(n)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=bn.call(Array(e.indent+1)," ")}return{base:n,prev:bn.call(Array(t+1),n)}}(s,o);if(void 0===i)i=[];else if(qn(i,n)>=0)return"[Circular]";function p(t,n,r){if(n&&(i=Cn.call(i)).push(n),r){var a={depth:s.depth};return jn(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,o+1,i)}return e(t,s,o+1,i)}if("function"==typeof n&&!Mn(n)){var g=function(e){if(e.name)return e.name;var t=pn.call(hn.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(n),f=Jn(n,p);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(f.length>0?" { "+bn.call(f,", ")+" }":"")}if($n(n)){var m=xn?fn.call(String(n),/^(Symbol\(.*\))_[^)]*$/,"$1"):Tn.call(n);return"object"!=typeof n||xn?m:Gn(m)}if(function(e){return!(!e||"object"!=typeof e)&&("undefined"!=typeof HTMLElement&&e instanceof HTMLElement||"string"==typeof e.nodeName&&"function"==typeof e.getAttribute)}(n)){for(var y="<"+yn.call(String(n.nodeName)),w=n.attributes||[],v=0;v<w.length;v++)y+=" "+w[v].name+"="+Rn(Ln(w[v].value),"double",s);return y+=">",n.childNodes&&n.childNodes.length&&(y+="..."),y+"</"+yn.call(String(n.nodeName))+">"}if(Fn(n)){if(0===n.length)return"[]";var b=Jn(n,p);return h&&!function(e){for(var t=0;t<e.length;t++)if(qn(e[t],"\n")>=0)return!1;return!0}(b)?"["+Qn(b,h)+"]":"[ "+bn.call(b,", ")+" ]"}if(function(e){return!("[object Error]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n)){var C=Jn(n,p);return"cause"in Error.prototype||!("cause"in n)||En.call(n,"cause")?0===C.length?"["+String(n)+"]":"{ ["+String(n)+"] "+bn.call(C,", ")+" }":"{ ["+String(n)+"] "+bn.call(vn.call("[cause]: "+p(n.cause),C),", ")+" }"}if("object"==typeof n&&a){if(Pn&&"function"==typeof n[Pn]&&Dn)return Dn(n,{depth:d-o});if("symbol"!==a&&"function"==typeof n.inspect)return n.inspect()}if(function(e){if(!en||!e||"object"!=typeof e)return!1;try{en.call(e);try{on.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(n)){var S=[];return tn&&tn.call(n,function(e,t){S.push(p(t,n,!0)+" => "+p(e,n))}),Vn("Map",en.call(n),S,h)}if(function(e){if(!on||!e||"object"!=typeof e)return!1;try{on.call(e);try{en.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(n)){var I=[];return sn&&sn.call(n,function(e){I.push(p(e,n))}),Vn("Set",on.call(n),I,h)}if(function(e){if(!an||!e||"object"!=typeof e)return!1;try{an.call(e,an);try{ln.call(e,ln)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(n))return Hn("WeakMap");if(function(e){if(!ln||!e||"object"!=typeof e)return!1;try{ln.call(e,ln);try{an.call(e,an)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(n))return Hn("WeakSet");if(function(e){if(!un||!e||"object"!=typeof e)return!1;try{return un.call(e),!0}catch(e){}return!1}(n))return Hn("WeakRef");if(function(e){return!("[object Number]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(p(Number(n)));if(function(e){if(!e||"object"!=typeof e||!In)return!1;try{return In.call(e),!0}catch(e){}return!1}(n))return Gn(p(In.call(n)));if(function(e){return!("[object Boolean]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(cn.call(n));if(function(e){return!("[object String]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(p(String(n)));if("undefined"!=typeof window&&n===window)return"{ [object Window] }";if(n===t)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n)&&!Mn(n)){var k=Jn(n,p),T=Wn?Wn(n)===Object.prototype:n instanceof Object||n.constructor===Object,x=n instanceof Object?"":"null prototype",A=!T&&An&&Object(n)===n&&An in n?gn.call(Bn(n),8,-1):x?"Object":"",E=(T||"function"!=typeof n.constructor?"":n.constructor.name?n.constructor.name+" ":"")+(A||x?"["+bn.call(vn.call([],A||[],x||[]),": ")+"] ":"");return 0===k.length?E+"{}":h?E+"{"+Qn(k,h)+"}":E+"{ "+bn.call(k,", ")+" }"}return String(n)},Xn=S,er=Kn("%WeakMap%",!0),tr=Kn("%Map%",!0),nr=Yn("WeakMap.prototype.get",!0),rr=Yn("WeakMap.prototype.set",!0),or=Yn("WeakMap.prototype.has",!0),ir=Yn("Map.prototype.get",!0),sr=Yn("Map.prototype.set",!0),ar=Yn("Map.prototype.has",!0),lr=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ur=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new Xn("Side channel does not contain "+Zn(e))},get:function(r){if(er&&r&&("object"==typeof r||"function"==typeof r)){if(e)return nr(e,r)}else if(tr){if(t)return ir(t,r)}else if(n)return function(e,t){var n=lr(e,t);return n&&n.value}(n,r)},has:function(r){if(er&&r&&("object"==typeof r||"function"==typeof r)){if(e)return or(e,r)}else if(tr){if(t)return ar(t,r)}else if(n)return function(e,t){return!!lr(e,t)}(n,r);return!1},set:function(r,o){er&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new er),rr(e,r,o)):tr?(t||(t=new tr),sr(t,r,o)):(n||(n={key:{},next:null}),function(e,t,n){var r=lr(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,o))}};return r},cr=M,dr=ur(),hr=S,pr={assert:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");if(dr.assert(e),!pr.has(e,t))throw new hr("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var n=dr.get(e);return n&&n["$"+t]},has:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var n=dr.get(e);return!!n&&cr(n,"$"+t)},set:function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var r=dr.get(e);r||(r={},dr.set(e,r)),r["$"+t]=n}};Object.freeze&&Object.freeze(pr);var gr,fr=pr,mr=SyntaxError,yr="object"==typeof StopIteration?StopIteration:null,wr={}.toString,vr=Array.isArray||function(e){return"[object Array]"==wr.call(e)},br=String.prototype.valueOf,Cr=Object.prototype.toString,Sr=zt(),Ir=function(e){return"string"==typeof e||"object"==typeof e&&(Sr?function(e){try{return br.call(e),!0}catch(e){return!1}}(e):"[object String]"===Cr.call(e))},kr="function"==typeof Map&&Map.prototype?Map:null,Tr="function"==typeof Set&&Set.prototype?Set:null;kr||(gr=function(e){return!1});var xr=kr?Map.prototype.has:null,Ar=Tr?Set.prototype.has:null;gr||xr||(gr=function(e){return!1});var Er,Wr=gr||function(e){if(!e||"object"!=typeof e)return!1;try{if(xr.call(e),Ar)try{Ar.call(e)}catch(e){return!0}return e instanceof kr}catch(e){}return!1},Or="function"==typeof Map&&Map.prototype?Map:null,Dr="function"==typeof Set&&Set.prototype?Set:null;Dr||(Er=function(e){return!1});var _r=Or?Map.prototype.has:null,Pr=Dr?Set.prototype.has:null;Er||Pr||(Er=function(e){return!1});var Rr=Er||function(e){if(!e||"object"!=typeof e)return!1;try{if(Pr.call(e),_r)try{_r.call(e)}catch(e){return!0}return e instanceof Dr}catch(e){}return!1},Lr=Kt,Fr=function(e){if(!yr)throw new mr("this environment lacks StopIteration");fr.set(e,"[[Done]]",!1);var t={next:function(){var e=fr.get(this,"[[Iterator]]"),t=fr.get(e,"[[Done]]");try{return{done:t,value:t?void 0:e.next()}}catch(t){if(fr.set(e,"[[Done]]",!0),t!==yr)throw t;return{done:!0,value:void 0}}}};return fr.set(t,"[[Iterator]]",e),t};if(E()||k()()){var Mr=Symbol.iterator;qt.exports=function(e){return null!=e&&void 0!==e[Mr]?e[Mr]():Lr(e)?Array.prototype[Mr].call(e):void 0}}else{var $r=vr,Nr=Ir,jr=ye,Br=jr("%Map%",!0),qr=jr("%Set%",!0),Ur=Ke,zr=Ur("Array.prototype.push"),Gr=Ur("String.prototype.charCodeAt"),Hr=Ur("String.prototype.slice"),Vr=function(e){var t=0;return{next:function(){var n,r=t>=e.length;return r||(n=e[t],t+=1),{done:r,value:n}}}},Qr=function(e,t){if($r(e)||Lr(e))return Vr(e);if(Nr(e)){var n=0;return{next:function(){var t=function(e,t){if(t+1>=e.length)return t+1;var n=Gr(e,t);if(n<55296||n>56319)return t+1;var r=Gr(e,t+1);return r<56320||r>57343?t+1:t+2}(e,n),r=Hr(e,n,t);return n=t,{done:t>e.length,value:r}}}}return t&&void 0!==e["_es6-shim iterator_"]?e["_es6-shim iterator_"]():void 0};if(Br||qr){var Jr=Wr,Kr=Rr,Yr=Ur("Map.prototype.forEach",!0),Zr=Ur("Set.prototype.forEach",!0);if("undefined"==typeof process||!process.versions||!process.versions.node)var Xr=Ur("Map.prototype.iterator",!0),eo=Ur("Set.prototype.iterator",!0);var to=Ur("Map.prototype.@@iterator",!0)||Ur("Map.prototype._es6-shim iterator_",!0),no=Ur("Set.prototype.@@iterator",!0)||Ur("Set.prototype._es6-shim iterator_",!0);qt.exports=function(e){return function(e){if(Jr(e)){if(Xr)return Fr(Xr(e));if(to)return to(e);if(Yr){var t=[];return Yr(e,function(e,n){zr(t,[n,e])}),Vr(t)}}if(Kr(e)){if(eo)return Fr(eo(e));if(no)return no(e);if(Zr){var n=[];return Zr(e,function(e){zr(n,e)}),Vr(n)}}}(e)||Qr(e)}}else qt.exports=function(e){if(null!=e)return Qr(e,!0)}}var ro=qt.exports,oo=function(e){return e!=e},io=function(e,t){return 0===e&&0===t?1/e==1/t:e===t||!(!oo(e)||!oo(t))},so=io,ao=function(){return"function"==typeof Object.is?Object.is:so},lo=ao,uo=Me,co=Me,ho=io,po=ao,go=He(po(),Object);co(go,{getPolyfill:po,implementation:ho,shim:function(){var e=lo();return uo(Object,{is:e},{is:function(){return Object.is!==e}}),e}});var fo,mo,yo,wo,vo=go,bo=He,Co=Ke,So=ye("%ArrayBuffer%",!0),Io=Co("ArrayBuffer.prototype.byteLength",!0),ko=Co("Object.prototype.toString"),To=!!So&&!Io&&new So(0).slice,xo=!!To&&bo(To),Ao=Io||xo?function(e){if(!e||"object"!=typeof e)return!1;try{return Io?Io(e):xo(e,0),!0}catch(e){return!1}}:So?function(e){return"[object ArrayBuffer]"===ko(e)}:function(e){return!1},Eo=Date.prototype.getDay,Wo=Object.prototype.toString,Oo=zt(),Do=Ke,_o=zt();if(_o){fo=Do("Object.prototype.hasOwnProperty"),mo=Do("RegExp.prototype.exec"),yo={};var Po=function(){throw yo};wo={toString:Po,valueOf:Po},"symbol"==typeof Symbol.toPrimitive&&(wo[Symbol.toPrimitive]=Po)}var Ro=Do("Object.prototype.toString"),Lo=Object.getOwnPropertyDescriptor,Fo=_o?function(e){if(!e||"object"!=typeof e)return!1;var t=Lo(e,"lastIndex");if(!t||!fo(t,"value"))return!1;try{mo(e,wo)}catch(e){return e===yo}}:function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Ro(e)},Mo=Ke("SharedArrayBuffer.prototype.byteLength",!0),$o=Mo?function(e){if(!e||"object"!=typeof e)return!1;try{return Mo(e),!0}catch(e){return!1}}:function(e){return!1},No=Number.prototype.toString,jo=Object.prototype.toString,Bo=zt(),qo=Ke,Uo=qo("Boolean.prototype.toString"),zo=qo("Object.prototype.toString"),Go=zt(),Ho={exports:{}},Vo=Object.prototype.toString;if(E()){var Qo=Symbol.prototype.toString,Jo=/^Symbol\(.*\)$/;Ho.exports=function(e){if("symbol"==typeof e)return!0;if("[object Symbol]"!==Vo.call(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&Jo.test(Qo.call(e))}(e)}catch(e){return!1}}}else Ho.exports=function(e){return!1};var Ko=Ho.exports,Yo={exports:{}},Zo="undefined"!=typeof BigInt&&BigInt;if("function"==typeof Zo&&"function"==typeof BigInt&&"bigint"==typeof Zo(42)&&"bigint"==typeof BigInt(42)){var Xo=BigInt.prototype.valueOf;Yo.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return Xo.call(e),!0}catch(e){}return!1}(e))}}else Yo.exports=function(e){return!1};var ei,ti=Yo.exports,ni=Ir,ri=Ko,oi=ti,ii="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,si="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;ii||(ei=function(e){return!1});var ai=ii?ii.prototype.has:null,li=si?si.prototype.has:null;ei||ai||(ei=function(e){return!1});var ui=ei||function(e){if(!e||"object"!=typeof e)return!1;try{if(ai.call(e,ai),li)try{li.call(e,li)}catch(e){return!0}return e instanceof ii}catch(e){}return!1},ci={exports:{}},di=Ke,hi=ye("%WeakSet%",!0),pi=di("WeakSet.prototype.has",!0);if(pi){var gi=di("WeakMap.prototype.has",!0);ci.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(pi(e,pi),gi)try{gi(e,gi)}catch(e){return!0}return e instanceof hi}catch(e){}return!1}}else ci.exports=function(e){return!1};var fi,mi,yi=ci.exports,wi=Wr,vi=Rr,bi=ui,Ci=yi,Si=Function.prototype.toString,Ii="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Ii&&"function"==typeof Object.defineProperty)try{fi=Object.defineProperty({},"length",{get:function(){throw mi}}),mi={},Ii(function(){throw 42},null,fi)}catch(Xy){Xy!==mi&&(Ii=null)}else Ii=null;var ki=/^\s*class\b/,Ti=function(e){try{var t=Si.call(e);return ki.test(t)}catch(e){return!1}},xi=function(e){try{return!Ti(e)&&(Si.call(e),!0)}catch(e){return!1}},Ai=Object.prototype.toString,Ei="function"==typeof Symbol&&!!Symbol.toStringTag,Wi=!(0 in[,]),Oi=function(){return!1};if("object"==typeof document){var Di=document.all;Ai.call(Di)===Ai.call(document.all)&&(Oi=function(e){if((Wi||!e)&&(void 0===e||"object"==typeof e))try{var t=Ai.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var _i=Ii?function(e){if(Oi(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Ii(e,null,fi)}catch(e){if(e!==mi)return!1}return!Ti(e)&&xi(e)}:function(e){if(Oi(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Ei)return xi(e);if(Ti(e))return!1;var t=Ai.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&xi(e)},Pi=_i,Ri=Object.prototype.toString,Li=Object.prototype.hasOwnProperty,Fi=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],Mi="undefined"==typeof globalThis?t:globalThis,$i=function(e,t,n){if(!Pi(t))throw new TypeError("iterator must be a function");var r;arguments.length>=3&&(r=n),"[object Array]"===Ri.call(e)?function(e,t,n){for(var r=0,o=e.length;r<o;r++)Li.call(e,r)&&(null==n?t(e[r],r,e):t.call(n,e[r],r,e))}(e,t,r):"string"==typeof e?function(e,t,n){for(var r=0,o=e.length;r<o;r++)null==n?t(e.charAt(r),r,e):t.call(n,e.charAt(r),r,e)}(e,t,r):function(e,t,n){for(var r in e)Li.call(e,r)&&(null==n?t(e[r],r,e):t.call(n,e[r],r,e))}(e,t,r)},Ni=He,ji=Ke,Bi=be,qi=ji("Object.prototype.toString"),Ui=zt(),zi="undefined"==typeof globalThis?t:globalThis,Gi=function(){for(var e=[],t=0;t<Fi.length;t++)"function"==typeof Mi[Fi[t]]&&(e[e.length]=Fi[t]);return e}(),Hi=ji("String.prototype.slice"),Vi=Object.getPrototypeOf,Qi=ji("Array.prototype.indexOf",!0)||function(e,t){for(var n=0;n<e.length;n+=1)if(e[n]===t)return n;return-1},Ji={__proto__:null};$i(Gi,Ui&&Bi&&Vi?function(e){var t=new zi[e];if(Symbol.toStringTag in t){var n=Vi(t),r=Bi(n,Symbol.toStringTag);if(!r){var o=Vi(n);r=Bi(o,Symbol.toStringTag)}Ji["$"+e]=Ni(r.get)}}:function(e){var t=new zi[e],n=t.slice||t.set;n&&(Ji["$"+e]=Ni(n))});var Ki=Ke("ArrayBuffer.prototype.byteLength",!0),Yi=Ao,Zi=gt,Xi=Ke,es=Bt,ts=ye,ns=ro,rs=ur,os=vo,is=Kt,ss=vr,as=Ao,ls=function(e){return"object"==typeof e&&null!==e&&(Oo?function(e){try{return Eo.call(e),!0}catch(e){return!1}}(e):"[object Date]"===Wo.call(e))},us=Fo,cs=$o,ds=m,hs=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:ni(e)?"String":function(e){return"number"==typeof e||"object"==typeof e&&(Bo?function(e){try{return No.call(e),!0}catch(e){return!1}}(e):"[object Number]"===jo.call(e))}(e)?"Number":function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(Go&&Symbol.toStringTag in e?function(e){try{return Uo(e),!0}catch(e){return!1}}(e):"[object Boolean]"===zo(e))}(e)?"Boolean":ri(e)?"Symbol":oi(e)?"BigInt":void 0},ps=function(e){if(e&&"object"==typeof e){if(wi(e))return"Map";if(vi(e))return"Set";if(bi(e))return"WeakMap";if(Ci(e))return"WeakSet"}return!1},gs=function(e){if(!e||"object"!=typeof e)return!1;if(!Ui){var t=Hi(qi(e),8,-1);return Qi(Gi,t)>-1?t:"Object"===t&&function(e){var t=!1;return $i(Ji,function(n,r){if(!t)try{n(e),t=Hi(r,1)}catch(e){}}),t}(e)}return Bi?function(e){var t=!1;return $i(Ji,function(n,r){if(!t)try{"$"+n(e)===r&&(t=Hi(r,1))}catch(e){}}),t}(e):null},fs=function(e){return Yi(e)?Ki?Ki(e):e.byteLength:NaN},ms=Xi("SharedArrayBuffer.prototype.byteLength",!0),ys=Xi("Date.prototype.getTime"),ws=Object.getPrototypeOf,vs=Xi("Object.prototype.toString"),bs=ts("%Set%",!0),Cs=Xi("Map.prototype.has",!0),Ss=Xi("Map.prototype.get",!0),Is=Xi("Map.prototype.size",!0),ks=Xi("Set.prototype.add",!0),Ts=Xi("Set.prototype.delete",!0),xs=Xi("Set.prototype.has",!0),As=Xi("Set.prototype.size",!0);function Es(e,t,n,r){for(var o,i=ns(e);(o=i.next())&&!o.done;)if(Ps(t,o.value,n,r))return Ts(e,o.value),!0;return!1}function Ws(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Os(e,t,n,r,o,i){var s=Ws(n);if(null!=s)return s;var a=Ss(t,s),l=Zi({},o,{strict:!1});return!(void 0===a&&!Cs(t,s)||!Ps(r,a,l,i))&&!Cs(e,s)&&Ps(r,a,l,i)}function Ds(e,t,n){var r=Ws(n);return null!=r?r:xs(t,r)&&!xs(e,r)}function _s(e,t,n,r,o,i){for(var s,a,l=ns(e);(s=l.next())&&!s.done;)if(Ps(n,a=s.value,o,i)&&Ps(r,Ss(t,a),o,i))return Ts(e,a),!0;return!1}function Ps(e,t,n,r){var o=n||{};if(o.strict?os(e,t):e===t)return!0;if(hs(e)!==hs(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return o.strict?os(e,t):e==t;var i,s=r.has(e),a=r.has(t);if(s&&a){if(r.get(e)===r.get(t))return!0}else i={};return s||r.set(e,i),a||r.set(t,i),function(e,t,n,r){var o,i;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(vs(e)!==vs(t))return!1;if(is(e)!==is(t))return!1;if(ss(e)!==ss(t))return!1;var s=e instanceof Error,a=t instanceof Error;if(s!==a)return!1;if((s||a)&&(e.name!==t.name||e.message!==t.message))return!1;var l=us(e),u=us(t);if(l!==u)return!1;if((l||u)&&(e.source!==t.source||es(e)!==es(t)))return!1;var c=ls(e),d=ls(t);if(c!==d)return!1;if((c||d)&&ys(e)!==ys(t))return!1;if(n.strict&&ws&&ws(e)!==ws(t))return!1;var h=gs(e),p=gs(t);if(h!==p)return!1;if(h||p){if(e.length!==t.length)return!1;for(o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var g=Rs(e),f=Rs(t);if(g!==f)return!1;if(g||f){if(e.length!==t.length)return!1;for(o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var m=as(e),y=as(t);if(m!==y)return!1;if(m||y)return fs(e)===fs(t)&&"function"==typeof Uint8Array&&Ps(new Uint8Array(e),new Uint8Array(t),n,r);var w=cs(e),v=cs(t);if(w!==v)return!1;if(w||v)return ms(e)===ms(t)&&"function"==typeof Uint8Array&&Ps(new Uint8Array(e),new Uint8Array(t),n,r);if(typeof e!=typeof t)return!1;var b=ds(e),C=ds(t);if(b.length!==C.length)return!1;for(b.sort(),C.sort(),o=b.length-1;o>=0;o--)if(b[o]!=C[o])return!1;for(o=b.length-1;o>=0;o--)if(!Ps(e[i=b[o]],t[i],n,r))return!1;var S=ps(e),I=ps(t);return S===I&&("Set"===S||"Set"===I?function(e,t,n,r){if(As(e)!==As(t))return!1;for(var o,i,s,a=ns(e),l=ns(t);(o=a.next())&&!o.done;)if(o.value&&"object"==typeof o.value)s||(s=new bs),ks(s,o.value);else if(!xs(t,o.value)){if(n.strict)return!1;if(!Ds(e,t,o.value))return!1;s||(s=new bs),ks(s,o.value)}if(s){for(;(i=l.next())&&!i.done;)if(i.value&&"object"==typeof i.value){if(!Es(s,i.value,n.strict,r))return!1}else if(!n.strict&&!xs(e,i.value)&&!Es(s,i.value,n.strict,r))return!1;return 0===As(s)}return!0}(e,t,n,r):"Map"!==S||function(e,t,n,r){if(Is(e)!==Is(t))return!1;for(var o,i,s,a,l,u,c=ns(e),d=ns(t);(o=c.next())&&!o.done;)if(a=o.value[0],l=o.value[1],a&&"object"==typeof a)s||(s=new bs),ks(s,a);else if(void 0===(u=Ss(t,a))&&!Cs(t,a)||!Ps(l,u,n,r)){if(n.strict)return!1;if(!Os(e,t,a,l,n,r))return!1;s||(s=new bs),ks(s,a)}if(s){for(;(i=d.next())&&!i.done;)if(a=i.value[0],u=i.value[1],a&&"object"==typeof a){if(!_s(s,e,a,u,n,r))return!1}else if(!(n.strict||e.has(a)&&Ps(Ss(e,a),u,n,r)||_s(s,e,a,u,Zi({},n,{strict:!1}),r)))return!1;return 0===As(s)}return!0}(e,t,n,r))}(e,t,o,r)}function Rs(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length||"function"!=typeof e.copy||"function"!=typeof e.slice||e.length>0&&"number"!=typeof e[0]||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}var Ls=function(e,t,n){return Ps(e,t,n,rs())},Fs=r(Ls);let Ms=(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t};const $s=e=>"object"==typeof e&&!Array.isArray(e)&&0!==Object.keys(e).length,Ns=e=>({unsubscribe(){e?"function"==typeof e?e():e.then(e=>e()).catch(console.error):console.error("Failed to unsubscribe!")}}),js=(e,t,n)=>new Promise((r,o)=>{const i=setTimeout(()=>{o(n||`Promise timeout hit: ${t}`)},t);e().then(e=>{clearTimeout(i),r(e)}).catch(e=>{clearTimeout(i),o(e)})}),Bs=()=>Ms(),qs=["name","title","version","customProperties","icon","caption","type"],Us=["appId","name","type","details","version","title","tooltip","lang","description","categories","icons","screenshots","contactEmail","moreInfo","publisher","customConfig","hostManifests","interop","localizedVersions"];var zs=function(e){return{ok:!0,result:e}},Gs=function(e){return{ok:!1,error:e}},Hs=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:zs(e(t.result,n.result))},Vs=function(e,t){return!0===t.ok?t:Gs(e(t.error))},Qs=function(){return Qs=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Qs.apply(this,arguments)};function Js(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Js(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Js(e[r[n]],t[r[n]]))return!1}return!0}}var Ks=function(e){return Array.isArray(e)},Ys=function(e){return"object"==typeof e&&null!==e&&!Ks(e)},Zs=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},Xs=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},ea=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Qs({at:e+(n||"")},r)},ta=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return Vs(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?zs(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?zs(e):Gs({message:Zs("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?zs(e):Gs({message:Zs("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?zs(e):Gs({message:Zs("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Js(e,t)?zs(t):Gs({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Ys(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?Gs({message:"the key '"+r+"' is required but was not present"}):Gs(ea("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return zs(n)}return Ys(e)?zs(e):Gs({message:Zs("an object",e)})})},e.array=function(t){return new e(function(e){return Ks(e)&&t?e.reduce(function(e,n,r){return Hs(function(e,t){return e.concat([t])},e,function(e,n){return Vs(function(e){return ea("["+n+"]",e)},t.decode(e))}(n,r))},zs([])):Ks(e)?zs(e):Gs({message:Zs("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ks(e)){if(e.length!==t.length)return Gs({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return Gs(ea("["+r+"]",o.error));n[r]=o.result}return zs(n)}return Gs({message:Zs("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return Hs(Object.assign,t,n.decode(e))},zs({}))})},e.anyJson=function(){return new e(function(e){return zs(e)})},e.unknownJson=function(){return new e(function(e){return zs(e)})},e.dict=function(t){return new e(function(e){if(Ys(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return Gs(ea("."+r,o.error));n[r]=o.result}return zs(n)}return Gs({message:Zs("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?zs(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return Gs({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return zs(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return Gs({at:Xs(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Ys(r))return Gs({at:Xs(t.slice(0,o+1)),message:Zs("an object",r)});if("number"==typeof t[o]&&!Ks(r))return Gs({at:Xs(t.slice(0,o+1)),message:Zs("an array",r)});r=r[t[o]]}return Vs(function(e){return void 0===r?{at:Xs(t),message:"path does not exist"}:ea(Xs(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return zs(t)})},e.fail=function(t){return new e(function(e){return Gs({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),na=ta.string,ra=ta.number,oa=ta.boolean,ia=ta.anyJson;ta.unknownJson;var sa=ta.constant,aa=ta.object,la=ta.array;ta.tuple;var ua=ta.dict,ca=ta.optional,da=ta.oneOf;ta.union,ta.intersection,ta.withDefault,ta.valueAt,ta.succeed,ta.fail,ta.lazy;const ha=na().where(e=>e.length>0,"Expected a non-empty string"),pa=ra().where(e=>e>=0,"Expected a non-negative number"),ga=aa({name:ha,displayName:ca(na()),contexts:ca(la(na())),customConfig:ca(aa())}),fa=da(sa("web"),sa("native"),sa("citrix"),sa("onlineNative"),sa("other")),ma=aa({url:ha}),ya=aa({src:ha,size:ca(ha),type:ca(ha)}),wa=aa({src:ha,size:ca(ha),type:ca(ha),label:ca(ha)}),va=aa({contexts:la(ha),displayName:ca(ha),resultType:ca(ha),customConfig:ca(ia())}),ba=aa({listensFor:ca(ua(va)),raises:ca(ua(la(ha)))}),Ca=aa({broadcasts:ca(la(ha)),listensFor:ca(la(ha))}),Sa=aa({name:ha,description:ca(ha),broadcasts:ca(la(ha)),listensFor:ca(la(ha))}),Ia=aa({intents:ca(ba),userChannels:ca(Ca),appChannels:ca(la(Sa))}),ka=aa({url:ca(ha),top:ca(ra()),left:ca(ra()),width:ca(pa),height:ca(pa)}),Ta=aa({name:ca(ha),type:ca(ha.where(e=>"window"===e,"Expected a value of window")),title:ca(ha),version:ca(ha),customProperties:ca(ia()),icon:ca(na()),caption:ca(na()),details:ca(ka),intents:ca(la(ga)),hidden:ca(oa())}),xa=aa({name:ha,appId:ha,title:ca(ha),version:ca(ha),manifest:ha,manifestType:ha,tooltip:ca(ha),description:ca(ha),contactEmail:ca(ha),supportEmail:ca(ha),publisher:ca(ha),images:ca(la(aa({url:ca(ha)}))),icons:ca(la(aa({icon:ca(ha)}))),customConfig:ia(),intents:ca(la(ga))}),Aa=aa({appId:ca(ha),name:ca(ha),details:ca(ma),version:ca(ha),title:ca(ha),tooltip:ca(ha),lang:ca(ha),description:ca(ha),categories:ca(la(ha)),icons:ca(la(ya)),screenshots:ca(la(wa)),contactEmail:ca(ha),supportEmail:ca(ha),moreInfo:ca(ha),publisher:ca(ha),customConfig:ca(la(ia())),hostManifests:ca(ia()),interop:ca(Ia)}),Ea=aa({appId:ha,name:ha,type:fa,details:ma,version:ca(ha),title:ca(ha),tooltip:ca(ha),lang:ca(ha),description:ca(ha),categories:ca(la(ha)),icons:ca(la(ya)),screenshots:ca(la(wa)),contactEmail:ca(ha),supportEmail:ca(ha),moreInfo:ca(ha),publisher:ca(ha),customConfig:ca(la(ia())),hostManifests:ca(ia()),interop:ca(Ia),localizedVersions:ca(ua(Aa))}),Wa=da(xa,Ea),Oa=e=>`${e.kind} at ${e.at}: ${JSON.stringify(e.input)}. Reason - ${e.message}`;class Da{fdc3ToDesktopDefinitionType={web:"window",native:"exe",citrix:"citrix",onlineNative:"clickonce",other:"window"};toApi(){return{isFdc3Definition:this.isFdc3Definition.bind(this),parseToBrowserBaseAppData:this.parseToBrowserBaseAppData.bind(this),parseToDesktopAppConfig:this.parseToDesktopAppConfig.bind(this)}}isFdc3Definition(e){const t=Wa.run(e);return t.ok?e.appId&&e.details?{isFdc3:!0,version:"2.0"}:e.manifest?{isFdc3:!0,version:"1.2"}:{isFdc3:!1,reason:"The passed definition is not FDC3"}:{isFdc3:!1,reason:Oa(t.error)}}parseToBrowserBaseAppData(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const r=Wa.run(e);if(!r.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(r.error)}`);const o=this.getUserPropertiesFromDefinition(e,n),i={url:this.getUrl(e,n)},s={name:e.appId,type:"window",createOptions:i,userProperties:{...o,intents:"1.2"===n?o.intents:this.getIntentsFromV2AppDefinition(e),details:i},title:e.title,version:e.version,icon:this.getIconFromDefinition(e,n),caption:e.description,fdc3:"2.0"===n?{...e,definitionVersion:"2.0"}:void 0},a=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!a)return s;const l=Ta.run(a);if(!l.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(l.error)}`);return Object.keys(l.result).length?this.mergeBaseAppDataWithGlueManifest(s,l.result):s}parseToDesktopAppConfig(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const r=Wa.run(e);if(!r.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(r.error)}`);if("1.2"===n){const t=e;return{name:t.appId,type:"window",details:{url:this.getUrl(e,n)},version:t.version,title:t.title,tooltip:t.tooltip,caption:t.description,icon:t.icons?.[0].icon,intents:t.intents,customProperties:{manifestType:t.manifestType,images:t.images,contactEmail:t.contactEmail,supportEmail:t.supportEmail,publisher:t.publisher,icons:t.icons,customConfig:t.customConfig}}}const o=e,i={name:o.appId,type:this.fdc3ToDesktopDefinitionType[o.type],details:o.details,version:o.version,title:o.title,tooltip:o.tooltip,caption:o.description,icon:this.getIconFromDefinition(o,"2.0"),intents:this.getIntentsFromV2AppDefinition(o),fdc3:{...o,definitionVersion:"2.0"}},s=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!s)return i;if("object"!=typeof s||Array.isArray(s))throw new Error(`Invalid '${e.hostManifests.ioConnect?"hostManifests.ioConnect":"hostManifests['Glue42']"}' key`);return this.mergeDesktopConfigWithGlueManifest(i,s)}getUserPropertiesFromDefinition(e,t){return"1.2"===t?Object.fromEntries(Object.entries(e).filter(([e])=>!qs.includes(e))):Object.fromEntries(Object.entries(e).filter(([e])=>!qs.includes(e)&&!Us.includes(e)))}getUrl(e,t){let n;if("1.2"===t){const t=JSON.parse(e.manifest);n=t.details?.url||t.url}else n=e.details?.url;if(!n||"string"!=typeof n)throw new Error(`Invalid FDC3 ${t} definition. Provide valid 'url' under '${"1.2"===t?"manifest":"details"}' key`);return n}getIntentsFromV2AppDefinition(e){const t=e.interop?.intents?.listensFor;if(t)return Object.entries(t).map(e=>{const[t,n]=e;return{name:t,...n}})}getIconFromDefinition(e,t){return"1.2"===t?e.icons?.find(e=>e.icon)?.icon||void 0:e.icons?.find(e=>e.src)?.src||void 0}mergeBaseAppDataWithGlueManifest(e,t){let n=e;if(t.details){const r={...e.createOptions,...t.details};n.createOptions=r,n.userProperties.details=r}return Array.isArray(t.intents)&&(n.userProperties.intents=(n.userProperties.intents||[]).concat(t.intents)),n={...n,...t},delete n.details,delete n.intents,n}mergeDesktopConfigWithGlueManifest(e,t){const n=Object.assign({},e,t,{details:{...e.details,...t.details}});return Array.isArray(t.intents)&&(n.intents=(e.intents||[]).concat(t.intents)),n}}const _a={common:{nonEmptyStringDecoder:ha,nonNegativeNumberDecoder:pa},fdc3:{allDefinitionsDecoder:Wa,v1DefinitionDecoder:xa,v2DefinitionDecoder:Ea}};var Pa;!function(e){e.USER_CANCELLED="User Closed Intents Resolver UI without choosing a handler",e.CALLER_NOT_DEFINED="Caller Id is not defined",e.TIMEOUT_HIT="Timeout hit",e.INTENT_NOT_FOUND="Cannot find Intent",e.HANDLER_NOT_FOUND="Cannot find Intent Handler",e.TARGET_INSTANCE_UNAVAILABLE="Cannot start Target Instance",e.INTENT_DELIVERY_FAILED="Target Instance did not add a listener",e.RESOLVER_UNAVAILABLE="Intents Resolver UI unavailable",e.RESOLVER_TIMEOUT="User did not choose a handler",e.INVALID_RESOLVER_RESPONSE="Intents Resolver UI returned invalid response",e.INTENT_HANDLER_REJECTION="Intent Handler function processing the raised intent threw an error or rejected the promise it returned"}(Pa||(Pa={}));const Ra=new class{_fdc3;_decoders=_a;_errors={intents:Pa};get fdc3(){return this._fdc3||(this._fdc3=(new Da).toApi()),this._fdc3}get decoders(){return this._decoders}get errors(){return this._errors}};Ra.fdc3,Ra.decoders;const La=Ra.errors;var Fa,Ma;!function(e){e.Context="Context",e.Channel="Channel"}(Fa||(Fa={})),function(e){e.User="user",e.App="app",e.Private="private"}(Ma||(Ma={}));const $a=["id","type","broadcast","addContextListener","getCurrentContext"],Na=["type"],ja=["contexts","channels","interop","intents","appManager","windows"],Ba=La.intents,qa="FDC3.Collaborate",Ua="___privateFDC3Channel___";var za;!function(e){e.ListenerAdded="listenerAdded",e.OnAddContextListener="onAddContextListener",e.OnUnsubscribe="onUnsubscribe",e.OnDisconnect="onDisconnect"}(za||(za={}));var Ga=function(e){return{ok:!0,result:e}},Ha=function(e){return{ok:!1,error:e}},Va=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:Ga(e(t.result,n.result))},Qa=function(e,t){return!0===t.ok?t:Ha(e(t.error))},Ja=function(){return Ja=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ja.apply(this,arguments)};function Ka(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Ka(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Ka(e[r[n]],t[r[n]]))return!1}return!0}}var Ya=function(e){return Array.isArray(e)},Za=function(e){return"object"==typeof e&&null!==e&&!Ya(e)},Xa=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},el=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},tl=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Ja({at:e+(n||"")},r)},nl=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return Qa(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?Ga(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?Ga(e):Ha({message:Xa("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?Ga(e):Ha({message:Xa("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?Ga(e):Ha({message:Xa("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Ka(e,t)?Ga(t):Ha({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Za(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?Ha({message:"the key '"+r+"' is required but was not present"}):Ha(tl("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return Ga(n)}return Za(e)?Ga(e):Ha({message:Xa("an object",e)})})},e.array=function(t){return new e(function(e){return Ya(e)&&t?e.reduce(function(e,n,r){return Va(function(e,t){return e.concat([t])},e,function(e,n){return Qa(function(e){return tl("["+n+"]",e)},t.decode(e))}(n,r))},Ga([])):Ya(e)?Ga(e):Ha({message:Xa("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ya(e)){if(e.length!==t.length)return Ha({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return Ha(tl("["+r+"]",o.error));n[r]=o.result}return Ga(n)}return Ha({message:Xa("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return Va(Object.assign,t,n.decode(e))},Ga({}))})},e.anyJson=function(){return new e(function(e){return Ga(e)})},e.unknownJson=function(){return new e(function(e){return Ga(e)})},e.dict=function(t){return new e(function(e){if(Za(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return Ha(tl("."+r,o.error));n[r]=o.result}return Ga(n)}return Ha({message:Xa("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?Ga(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return Ha({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return Ga(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return Ha({at:el(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Za(r))return Ha({at:el(t.slice(0,o+1)),message:Xa("an object",r)});if("number"==typeof t[o]&&!Ya(r))return Ha({at:el(t.slice(0,o+1)),message:Xa("an array",r)});r=r[t[o]]}return Qa(function(e){return void 0===r?{at:el(t),message:"path does not exist"}:tl(el(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return Ga(t)})},e.fail=function(t){return new e(function(e){return Ha({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),rl=nl.string,ol=nl.number;nl.boolean;var il=nl.anyJson;nl.unknownJson;var sl=nl.constant,al=nl.object,ll=nl.array;nl.tuple,nl.dict;var ul=nl.optional,cl=nl.oneOf;nl.union,nl.intersection,nl.withDefault,nl.valueAt,nl.succeed,nl.fail,nl.lazy;const dl=rl().where(e=>e.length>0,"Expected a non-empty string");ol().where(e=>e>=0,"Expected a non-negative number");const hl=al({src:dl,size:ul(rl()),type:ul(rl())}),pl=al({src:dl,size:ul(rl()),type:ul(rl()),label:ul(rl())});al({appId:dl,instanceId:ul(rl()),name:ul(rl()),version:ul(rl()),title:ul(rl()),tooltip:ul(rl()),description:ul(rl()),icons:ul(ll(hl)),images:ul(ll(pl))});const gl=al({appId:dl,instanceId:ul(rl())}),fl=cl(dl,gl),ml=al({type:dl,name:ul(dl),id:ul(il())}),yl=ul(ml),wl=ul(gl),vl=ul(fl),bl=ul(dl),Cl=cl(sl("joinPrivateChannel"),sl("publishOnPrivateChannel"),sl("addedContextListenerOnPrivateChannel"),sl("removedContextListenerOnPrivateChannel"),sl("disconnectedFromPrivateChannel"),sl("startupContextOpened")),Sl=al({channelId:ul(dl),contextType:ul(dl),payload:ul(ml)}),Il=al({action:Cl,correlationId:dl,collaborationObject:ul(Sl)}),kl=al({fdc3:al({collaborationId:dl,openApp:al({appId:dl,instanceId:dl}),context:al({contextType:ul(rl()),payload:ml})})});al({channelId:ul(dl)});class Tl{channelsParser;channelsStateStore;glue;_logger;glueInitPromise;resolveGluePromise;rejectGluePromise;defaultGluePromiseTimeout=12e4;constructor(e,t){this.channelsParser=e,this.channelsStateStore=t}get gluePromise(){return this.glueInitPromise.then(this.initializeLogger.bind(this))}initialize(e){this.glue=e,this.resolveGluePromise()}initializeFailed(e){this.rejectGluePromise(e)}createGluePromise(){this.glueInitPromise=js(()=>new Promise((e,t)=>{this.resolveGluePromise=e,this.rejectGluePromise=t}),this.defaultGluePromiseTimeout,`Timeout of ${this.defaultGluePromiseTimeout}ms waiting for Glue to initialize`)}get logger(){return this._logger}validateGlue(e){if("object"!=typeof e||Array.isArray(e))return{isValid:!1,error:{message:"Glue is not a valid object"}};const t=Object.keys(e),n=ja.filter(e=>!t.includes(e));return n.length?{isValid:!1,error:{message:`Fdc3 cannot initialize correctly - Glue is missing the following ${n.length>1?"properties":"property"}: ${n.join(", ")}`}}:{isValid:!0}}interopInstance(){return this.glue.interop.instance}getApplication(e){return this.glue.appManager.application(e)}getApplicationInstances(e){return this.glue.appManager.instances().filter(t=>t.application.name===e)}getAppInstanceById(e){return this.glue.appManager.instances().find(t=>t.id===e)}async findIntents(e){return this.glue.intents.find(e)}async raiseIntent(e){return this.glue.intents.raise(e)}doesFilterHandlersExist(){return!!this.glue.intents.filterHandlers}async filterHandlers(e){if(!this.glue.intents.filterHandlers)throw new Error("Intents method 'filterHandlers' does not exist");return this.glue.intents.filterHandlers(e)}doesGetIntentsExist(){return!!this.glue.intents.getIntents}getIntents(e){if(!this.glue.intents.getIntents)throw new Error("Intents method 'getIntents' does not exist");return this.glue.intents.getIntents(e)}async getMyWindowContext(){const e=this.getMyWindow();if(e)return e.getContext()}addIntentListener(e,t){return this.glue.intents.register?this.glue.intents.register(e,t):this.glue.intents.addIntentListener(e,t)}getAllContexts(){return this.glue.contexts.all()}async getContext(e){return this.glue.contexts.get(e)}async updateContext(e,t){return this.glue.contexts.update(e,t)}async updateContextWithLatestFdc3Type(e,t){const{path:n,value:r}=this.channelsParser.parseFDC3ContextToGlueContexts(t),o={path:"latest_fdc3_type",value:this.channelsParser.mapFDC3TypeToChannelsDelimiter(t.type)};await this.contextsSetPaths(e,[{path:`data.${n}`,value:r},o])}async channelsUpdate(e,t){return this.glue.channels.publish(e,t)}getChannelsMode(){return this.glue.channels.mode}async getMyChannels(){return this.glue.channels.getMyChannels?this.glue.channels.getMyChannels():[await this.glue.channels.getMy()]}async joinChannel(e){return this.glue.channels.join(e)}async leaveChannel(e){return this.glue.channels.leave(e)}getCurrentChannel(){if(!this.glue.channels.myChannels)return this.glue.channels.my();const e=this.glue.channels.myChannels();return e[e.length-1]}async getIoChannelNameByFDC3ChannelId(e){const t=await this.listAllChannels();return t.find(t=>t.meta.fdc3?.id===e)?.name}async getFDC3ChannelIdByIoChannelName(e){const t=(await this.listAllChannels()).filter(e=>e.meta.fdc3),n=t.find(t=>t.name===e);return n?.meta.fdc3.id}getMyChannel(){return this.glue.channels.getMy()}setOnChannelChanged(e){return this.glue.channels.onChannelsChanged?this.glue.channels.onChannelsChanged(t=>{const n=t[t.length-1];e(n)}):this.glue.channels.changed(e)}async getAllChannels(){return this.glue.channels.all()}async listAllChannels(){return this.glue.channels.list()}async getChannel(e){return this.glue.channels.get(e)}getMyWindow(){const e=this.glue.windows.my();return $s(e)?e:void 0}getMyInteropInstance(){return this.glue.interop.instance}getGlueVersion(){return this.glue?.version}registerOnInstanceStopped(e){return this.glue.appManager.onInstanceStopped(e)}async unregisterMethod(e){return this.glue.interop.unregister(e)}invokeSystemMethod(e,t){return Il.runWithException(e),this.glue.interop.invoke(qa,e,{instance:t})}registerMethod(e,t){return this.glue.interop.register(e,t)}getInteropMethods(e){return this.glue.interop.methods(e)}legacyChannelsSubscribe(e,t){const n={replayed:!1};return this.glue.channels.subscribe(async(r,o,i)=>{if(this.isUpdateFromMe(i)||!o||!o.latest_fdc3_type)return;const s=await this.getFDC3ChannelIdByIoChannelName(o.name);if(n.replayed)return this.parseDataAndInvokeSubscribeCallback({callback:e,contextData:o,metadata:this.getContextMetadata(i),contextType:t,channelId:s});this.invokePreviouslyBroadcastedData({callback:e,contextData:o,metadata:this.getContextMetadata(i),contextType:t,channelId:s}),n.replayed=!0})}channelsSubscribe(e,t){const n={replayed:!1};let r;return this.glue.channels.subscribe(async(o,i,s)=>{if(this.isUpdateFromMe(s)||!i||!o.fdc3)return;const a=await this.getFDC3ChannelIdByIoChannelName(i.name);if(t&&o.fdc3.type!==t&&!n.replayed)return this.invokePreviouslyBroadcastedData({callback:e,contextData:i,metadata:this.getContextMetadata(s),contextType:t,channelId:a}),n.replayed=!0,void(r=o.fdc3);r&&Fs(r,o.fdc3,{strict:!0})||(e(o.fdc3,this.getContextMetadata(s),a),n.replayed=!0,r=o.fdc3)})}contextsSubscribe(e,t){const n={replayed:!1};return this.glue.contexts.subscribe(e,(e,r,o,i,s)=>{this.isUpdateFromMe(s?.updaterId)||this.checkIfShouldInvokeInitialReplay(n,e)&&this.parseDataAndInvokeSubscribeCallback({callback:t,contextData:e,metadata:this.getContextMetadata(s?.updaterId)})})}getInteropServers(e){return this.glue.interop.servers(e)}initSubLogger(e){return this.logger?.subLogger(e)}getPrefs(e){return this.glue.prefs.get(e)}async checkIsFdc3DataWrappingSupported(){const e=window.glue42core||window.iobrowser,t=e?"T42.Web.Client.Control":"T42.Channels.Command",n=this.glue.interop.servers().find(e=>e.instance===this.glue.interop.instance.instance);if(!n)return!1;if(!n.getMethods().some(e=>e.name===t))return!1;const r=e?{domain:"system",operation:"isFdc3DataWrappingSupported"}:{command:"isFdc3DataWrappingSupported"};try{return(await this.glue.interop.invoke(t,r,{instance:this.interopInstance().instance})).returned.isSupported}catch(e){return!1}}invokePreviouslyBroadcastedData({callback:e,contextData:t,metadata:n,contextType:r,channelId:o}){const i=r||this.channelsParser.mapChannelsDelimiterToFDC3Type(t.latest_fdc3_type),s=this.getLatestBroadcastedDataByContextType(t,i);s&&e(s,n,o)}isUpdateFromMe(e){return this.glue.interop.instance.peerId===e}getContextMetadata(e){const t=this.glue.interop.servers().find(t=>t.peerId===e);if(t)return{source:{appId:t.applicationName,instanceId:t.instance}}}initializeLogger(){this._logger=this.glue.logger}parseDataAndInvokeSubscribeCallback({callback:e,contextData:t,metadata:n,contextType:r,channelId:o}){if(!r)return void e(this.channelsParser.parseContextsDataToInitialFDC3Data({data:t.data,latest_fdc3_type:t.latest_fdc3_type}),n,o);if(this.channelsParser.mapChannelsDelimiterToFDC3Type(t.latest_fdc3_type)!==r)return;const i=this.getLatestBroadcastedDataByContextType(t,r);i&&e(i,n,o)}getLatestBroadcastedDataByContextType(e,t){let n;return Object.entries(e.data).forEach(([e,r])=>{if(!this.channelsParser.isFdc3DataKey(e))return;const o=this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(e);o===t&&(n={type:o,...r})}),n}checkIfShouldInvokeInitialReplay(e,t){return e.replayed?!!t.latest_fdc3_type:(e.replayed=!0,!1)}async contextsSetPaths(e,t){await this.glue.contexts.setPaths(e,t)}}const xl="Glue42";class Al{fireFdc3Ready(){const e=new Event("fdc3Ready");window.dispatchEvent(e)}fireNotifyStarted(){this.send("notifyStarted")}fireRequestGlue(){this.send("requestGlue")}send(e,t){const n=new CustomEvent(xl,{detail:{glue42:{event:e,message:t}}});window.dispatchEvent(n)}}var El,Wl,Ol,Dl,_l;!function(e){e.AppNotFound="AppNotFound",e.ErrorOnLaunch="ErrorOnLaunch",e.AppTimeout="AppTimeout",e.ResolverUnavailable="ResolverUnavailable",e.MalformedContext="MalformedContext",e.DesktopAgentNotFound="DesktopAgentNotFound"}(El||(El={})),function(e){e.NoAppsFound="NoAppsFound",e.ResolverUnavailable="ResolverUnavailable",e.UserCancelled="UserCancelledResolution",e.ResolverTimeout="ResolverTimeout",e.TargetAppUnavailable="TargetAppUnavailable",e.TargetInstanceUnavailable="TargetInstanceUnavailable",e.IntentDeliveryFailed="IntentDeliveryFailed",e.MalformedContext="MalformedContext",e.DesktopAgentNotFound="DesktopAgentNotFound"}(Wl||(Wl={})),function(e){e.NoResultReturned="NoResultReturned",e.IntentHandlerRejected="IntentHandlerRejected"}(Ol||(Ol={})),function(e){e.NoChannelFound="NoChannelFound",e.AccessDenied="AccessDenied",e.CreationFailed="CreationFailed",e.MalformedContext="MalformedContext"}(Dl||(Dl={})),function(e){e.ResponseTimedOut="ResponseToBridgeTimedOut",e.AgentDisconnected="AgentDisconnected",e.NotConnectedToBridge="NotConnectedToBridge",e.MalformedMessage="MalformedMessage"}(_l||(_l={})),"function"==typeof SuppressedError&&SuppressedError;var Pl=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}("fdc3.action","fdc3.chart","fdc3.chat.initSettings","fdc3.chat.message","fdc3.chat.room","fdc3.chat.searchCriteria","fdc3.contact","fdc3.contactList","fdc3.country","fdc3.currency","fdc3.email","fdc3.instrument","fdc3.instrumentList","fdc3.interaction","fdc3.message","fdc3.organization","fdc3.portfolio","fdc3.position","fdc3.nothing","fdc3.timeRange","fdc3.transactionResult","fdc3.valuation");new Set(Pl);var Rl,Ll,Fl=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}("CreateInteraction","SendChatMessage","StartCall","StartChat","StartEmail","ViewAnalysis","ViewChat","ViewChart","ViewContact","ViewHoldings","ViewInstrument","ViewInteractions","ViewMessages","ViewNews","ViewOrders","ViewProfile","ViewQuote","ViewResearch");new Set(Fl),function(e){e.Chart="fdc3.chart",e.ChatInitSettings="fdc3.chat.initSettings",e.ChatRoom="fdc3.chat.room",e.Contact="fdc3.contact",e.ContactList="fdc3.contactList",e.Country="fdc3.country",e.Currency="fdc3.currency",e.Email="fdc3.email",e.Instrument="fdc3.instrument",e.InstrumentList="fdc3.instrumentList",e.Interaction="fdc3.interaction",e.Nothing="fdc3.nothing",e.Organization="fdc3.organization",e.Portfolio="fdc3.portfolio",e.Position="fdc3.position",e.ChatSearchCriteria="fdc3.chat.searchCriteria",e.TimeRange="fdc3.timeRange",e.TransactionResult="fdc3.transactionResult",e.Valuation="fdc3.valuation"}(Rl||(Rl={})),function(e){e.CreateInteraction="CreateInteraction",e.SendChatMessage="SendChatMessage",e.StartCall="StartCall",e.StartChat="StartChat",e.StartEmail="StartEmail",e.ViewAnalysis="ViewAnalysis",e.ViewChat="ViewChat",e.ViewChart="ViewChart",e.ViewContact="ViewContact",e.ViewHoldings="ViewHoldings",e.ViewInstrument="ViewInstrument",e.ViewInteractions="ViewInteractions",e.ViewMessages="ViewMessages",e.ViewNews="ViewNews",e.ViewOrders="ViewOrders",e.ViewProfile="ViewProfile",e.ViewQuote="ViewQuote",e.ViewResearch="ViewResearch"}(Ll||(Ll={}));class Ml{intentsController;applicationController;channelsController;constructor(e,t,n){this.intentsController=e,this.applicationController=t,this.channelsController=n}toApi(){return{getStartupContext:this.getStartupContext.bind(this),addContextListener:this.addContextListener.bind(this),addIntentListener:this.addIntentListener.bind(this),broadcast:this.broadcast.bind(this),createPrivateChannel:this.createPrivateChannel.bind(this),findInstances:this.findInstances.bind(this),findIntent:this.findIntent.bind(this),findIntentsByContext:this.findIntentsByContext.bind(this),getAppMetadata:this.getAppMetadata.bind(this),getCurrentChannel:this.getCurrentChannel.bind(this),getInfo:this.getInfo.bind(this),getOrCreateChannel:this.getOrCreateChannel.bind(this),getSystemChannels:this.getSystemChannels.bind(this),getUserChannels:this.getSystemChannels.bind(this),joinChannel:this.joinChannel.bind(this),joinUserChannel:this.joinUserChannel.bind(this),leaveCurrentChannel:this.leaveCurrentChannel.bind(this),open:this.open.bind(this),raiseIntent:this.raiseIntent.bind(this),raiseIntentForContext:this.raiseIntentForContext.bind(this),getCurrentChannels:this.getCurrentChannels.bind(this),leaveChannel:this.leaveChannel.bind(this),leaveCurrentChannels:this.leaveCurrentChannels.bind(this)}}async open(e,t){if(fl.runWithException(e),!yl.run(t).ok)throw new Error(El.MalformedContext);return this.applicationController.open({commandId:Bs(),target:e,context:t})}async findInstances(e){return gl.runWithException(e),this.applicationController.findInstances({commandId:Bs(),appIdentifier:e})}async getAppMetadata(e){return gl.runWithException(e),this.applicationController.getAppMetadata({commandId:Bs(),appIdentifier:e})}async getInfo(){return this.applicationController.getInfo({commandId:Bs()})}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e)}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:e})}const n=bl.runWithException(e);if("function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n})}async findIntent(e,t,n){dl.runWithException(e);const r=yl.run(t);if(!r.ok)throw new Error(Wl.MalformedContext);return bl.runWithException(n),this.intentsController.findIntent({commandId:Bs(),intent:e,context:r.result,resultType:n})}async findIntentsByContext(e,t){const n=ml.run(e);if(!n.ok)throw new Error(Wl.MalformedContext);return bl.runWithException(t),this.intentsController.findIntentsByContext({commandId:Bs(),context:n.result,resultType:t})}async raiseIntent(e,t,n){if(dl.runWithException(e),!ml.run(t).ok)throw new Error(Wl.MalformedContext);return vl.runWithException(n),this.intentsController.raiseIntent({commandId:Bs(),intent:e,context:t,target:n})}async raiseIntentForContext(e,t){if(!ml.run(e).ok)throw new Error(Wl.MalformedContext);return wl.runWithException(t),this.intentsController.raiseIntentForContext({commandId:Bs(),context:e,target:t})}async addIntentListener(e,t){if(dl.runWithException(e),"function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.intentsController.addIntentListener({commandId:Bs(),intent:e,handler:t})}async getStartupContext(){return this.channelsController.getStartupContext()}async getOrCreateChannel(e){return dl.runWithException(e),this.channelsController.getOrCreateChannel({commandId:Bs(),channelId:e})}async getSystemChannels(){return this.channelsController.getUserChannels(Bs())}async joinChannel(e){return dl.runWithException(e),this.channelsController.joinUserChannel({commandId:Bs(),channelId:e})}async joinUserChannel(e){return dl.runWithException(e),this.channelsController.joinUserChannel({commandId:Bs(),channelId:e})}async getCurrentChannel(){return this.channelsController.getCurrentChannel(Bs())}async leaveCurrentChannel(){return this.channelsController.leaveCurrentChannel(Bs())}async createPrivateChannel(){return this.channelsController.createPrivateChannel(Bs())}async getCurrentChannels(){return this.channelsController.getCurrentChannels(Bs())}async leaveChannel(e){return dl.runWithException(e),this.channelsController.leave(Bs(),{channelId:e})}async leaveCurrentChannels(){return this.channelsController.leave(Bs())}}class $l{channelsController;id;type=Ma.App;constructor(e,t){this.channelsController=e,this.id=t}toApi(){return{id:this.id,type:this.type,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this)}}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e,this.id)}async getCurrentContext(e){return bl.runWithException(e),this.channelsController.getContextForChannel({commandId:Bs(),channelId:this.id,contextType:e})}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:e,channelId:this.id})}const n=bl.runWithException(e);if("function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n,channelId:this.id})}}class Nl{fdc3Delimiter="&";channelsFdc3DataPrefix="fdc3_";mapChannelNameToContextName(e){return`___channel___${e}`}parseContextsDataToInitialFDC3Data(e){const{data:t,latest_fdc3_type:n}=e;return{type:this.mapChannelsDelimiterToFDC3Type(n),...t[`${this.channelsFdc3DataPrefix}${n}`]}}revertGlueParsedTypeToInitialFDC3Type(e){const t=e.replace(this.channelsFdc3DataPrefix,"");return this.mapChannelsDelimiterToFDC3Type(t)}parseFDC3ContextToGlueContexts(e){const{type:t,...n}=e,r=this.mapFDC3TypeToChannelsDelimiter(t);return{path:`${this.channelsFdc3DataPrefix}${r}`,value:n}}mapFDC3TypeToChannelsDelimiter(e){return e.split(".").join(this.fdc3Delimiter)}isFdc3DataKey(e){return!!e.startsWith(this.channelsFdc3DataPrefix)}mapChannelsDelimiterToFDC3Type(e){return e.split(this.fdc3Delimiter).join(".")}}class jl{channelsController;id;type=Ma.User;displayMetadata;constructor(e,t){this.channelsController=e,this.id=t.meta.fdc3?t.meta.fdc3.id:t.name,this.displayMetadata={name:t.name,color:t.meta.color}}toApi(){return{id:this.id,type:this.type,displayMetadata:this.displayMetadata,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this)}}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e,this.id)}async getCurrentContext(e){return bl.run(e),this.channelsController.getContextForChannel({commandId:Bs(),channelId:this.id,contextType:e})}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};return this.channelsController.addContextListener({commandId:Bs(),handler:e,channelId:this.id})}const n=bl.runWithException(e);if("function"!=typeof t)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof t};return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n,channelId:this.id})}}const Bl=e=>({id:e.id,type:e.type,displayMetadata:e.displayMetadata}),ql=(e,t)=>(n,r,o)=>{t?n.type===t&&e(n,r,o):e(n,r,o)};class Ul{glueController;channelsController;channelsFactory;glueEventsController;_logger;ioToFDC3ErrorsDict={[Ba.USER_CANCELLED]:Wl.UserCancelled,[Ba.TIMEOUT_HIT]:Wl.IntentDeliveryFailed,[Ba.TARGET_INSTANCE_UNAVAILABLE]:Wl.TargetInstanceUnavailable,[Ba.RESOLVER_UNAVAILABLE]:Wl.ResolverUnavailable,[Ba.RESOLVER_TIMEOUT]:Wl.ResolverTimeout,[Ba.INVALID_RESOLVER_RESPONSE]:Wl.IntentDeliveryFailed,[Ba.INTENT_NOT_FOUND]:Wl.NoAppsFound,[Ba.INTENT_DELIVERY_FAILED]:Wl.IntentDeliveryFailed,[Ba.HANDLER_NOT_FOUND]:Wl.NoAppsFound,[Ba.CALLER_NOT_DEFINED]:Wl.IntentDeliveryFailed,[Ba.INTENT_HANDLER_REJECTION]:Ol.IntentHandlerRejected};constructor(e,t,n,r){this.glueController=e,this.channelsController=t,this.channelsFactory=n,this.glueEventsController=r}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.intents.controller")),this._logger}async findIntent({commandId:e,intent:t,context:n,resultType:r}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findIntent() invoked for intent ${t} with contextType ${n?.type} and resultType ${r}`);const o=await this.glueController.findIntents({name:t});if(!o.length)throw{message:Wl.NoAppsFound,reason:`There are no apps handling the passed intent ${t}`};const i=o.find(e=>e.name===t);if(!i)throw{message:Wl.NoAppsFound,reason:`There are no apps handling the passed intent ${t}`};if(!n&&!r)return this.convertGlue42IntentToFDC3Intent(i);const s=n&&"fdc3.nothing"===n.type?void 0:n?.type,a=this.getGlueIntentWithFilteredHandlers(i,{contextType:s,resultType:r});if(!a.handlers.length)throw{message:Wl.NoAppsFound,reason:`No apps handling intent ${t} with contextType ${n?.type} and resultType ${r}`};return this.convertGlue42IntentToFDC3Intent(a)}async findIntentsByContext({commandId:e,context:t,resultType:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findIntentsByContext() invoked for context type ${t.type} and resultType ${n}`);const r=await this.glueController.findIntents({contextType:t.type,resultType:n});if(!r.length)throw{message:Wl.NoAppsFound,reason:`No apps registering intent with contextType ${t.type} ${n?`and resultType ${n}`:""}`};return this.logger?.info(`[${e}] - parsing glue intents to fdc3 intents and returning`),r.map(e=>{const r=this.getGlueIntentWithFilteredHandlers(e,{contextType:t.type,resultType:n});return this.convertGlue42IntentToFDC3Intent(r)})}async raiseIntent({commandId:e,intent:t,context:n,target:r}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - raiseIntent() invoked for intent ${t} with contextType: ${n.type} and target: ${r}`);const o={type:n.type,data:{...n}},i=(await this.glueController.findIntents({name:t})).find(e=>e.name===t);if(!i)throw{message:Wl.NoAppsFound,reason:`There's no app registering an intent '${t}'`};if(!r){const s=this.filterGlueIntentHandlers({commandId:e,intent:i,context:n,target:r});return this.logger?.info(`[${e}] - raising intent ${t} with contextType ${n.type} and handlers ${s.handlers.map(e=>e.applicationName&&e.instanceId)}`),this.invokeRaiseIntent(e,{intent:t,context:o,handlers:s.handlers})}if(r?.instanceId)return this.logger?.info(`[${e}] - raising intent ${t} with contextType ${n.type} to target instance of app ${r.appId} and id ${r.instanceId}`),this.invokeRaiseIntent(e,{intent:t,context:o,target:{instance:r.instanceId}});const s="string"==typeof r?r:r.appId;return this.invokeRaiseIntent(e,{intent:t,context:o,target:{app:s}})}async raiseIntentForContext({commandId:e,context:t,target:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - raiseIntentForContext() invoked with contextType ${t.type} and target ${n}`);const r=this.glueController.doesFilterHandlersExist(),o=this.glueController.doesGetIntentsExist(),i=await this.checkForRememberedIntentHandlerForContext(t.type),s={type:t.type,data:{...t}};if(i)return this.invokeRaiseIntent(e,{context:s,intent:i.intent});if(!r||!o||n)return this.legacyRaiseIntentForContext({commandId:e,context:t,target:n});const a=this.glueController.filterHandlers({contextTypes:[t.type]}).catch(e=>{throw this.parseIoToFdc3Error(e)}),{handlers:l}=await a;if(!l.length){const n=`${Wl.NoAppsFound} - Cannot find Intent Handlers for intents with context type ${t.type}`;throw this._logger?.warn(`[${e}] - ${n}`),new Error(Wl.NoAppsFound)}if(l.length>1)return this.legacyRaiseIntentForContext({commandId:e,context:t,target:n});const u=l[0],{intents:c}=await this.glueController.getIntents(u),d=c.find(e=>e.contextTypes?.includes(t.type));if(!d)throw this.logger?.warn(`[${e}] - ${Wl.IntentDeliveryFailed} - There's no valid intent for handler ${JSON.stringify(u)} and context type ${t.type}`),new Error(Wl.IntentDeliveryFailed);return this.invokeRaiseIntent(e,{intent:d.intent,context:s,target:{app:u.applicationName,instance:u.instanceId}})}async addIntentListener({commandId:e,intent:t,handler:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - addIntentListener() invoked for intent ${t}`);const r=this.getWrappedIntentHandler(n);return this.glueController.addIntentListener(t,r)}async checkForRememberedIntentHandlerForContext(e){let t;try{t=await this.glueController.getPrefs()}catch(e){return void this._logger?.warn(`Cannot get prefs due to the following error: ${e}`)}const n=t.data?.intents;if(!n)return;const r=Object.entries(n).find(([t,n])=>n.filter?.contextTypes?.includes(e));if(!r)return;const[o,i]=r;return{intent:o,handler:i.handler}}filterGlueIntentHandlers({commandId:e,intent:t,context:n,target:r}){let o;return o=this.filterIntentHandlersByContext(t,n),r?(this.logger?.log(`[${e}] - filtering handlers by target (${JSON.stringify(r)}) for intent ${t.name}`),o=this.filterIntentHandlersByTarget({intent:t,target:r,commandId:e}),o):(this.logger?.info(`[${e}] - There's no passed target, intent handlers are filtered only by context type`),o)}filterIntentHandlersByTarget({intent:e,target:t,commandId:n}){const r="string"==typeof t?t:t.appId,o="string"==typeof t?void 0:t.instanceId;this.logger?.info(`[${n}] - Checking if application with name ${r} exists`);const i=this.glueController.getApplication(r),s=this.serverInstanceAsIntentHandler(e.name);if(!(i||"string"!=typeof t&&t.instanceId&&s.length))throw{message:Wl.TargetAppUnavailable,reason:`There's no app with appId ${r}`};this.logger?.info(`[${n}] - target app ${r} found. Filtering handlers by applicationName: ${r}`);const a=e.handlers.filter(e=>e.applicationName===r);if(!a.length)throw{message:Wl.NoAppsFound,reason:`Intent ${e.name} exists but there's no app with appId ${r} registering it`};if(!o)return this.logger?.log(`[${n}] - returning all handlers for intent ${e.name} and target: ${JSON.stringify(t)}`),{name:e.name,handlers:a};if(!(i?i.instances.find(e=>e.id===o):s.find(e=>e.instance===o)))throw{message:Wl.TargetInstanceUnavailable,reason:`There's no instance with id ${o} of the passed app ${r}`};this.logger?.info(`[${n}] - Filtering handlers by instanceId: ${o}`);const l=a.filter(e=>e.instanceId===o);if(!l.length)throw{message:Wl.IntentDeliveryFailed,reason:`There's no instance with id ${o} of app ${r} registering intent ${e.name}`};return{name:e.name,handlers:l}}serverInstanceAsIntentHandler(e){const t=`Tick42.FDC3.Intents.${e}`;return this.glueController.getInteropServers({name:t})}filterIntentHandlersByContext(e,t){const n=this.getGlueIntentWithFilteredHandlers(e,{contextType:t.type});if(!n.handlers.length)throw{message:Wl.NoAppsFound,reason:`There's no app registering an intent with the passed context type ${t.type}`};return n}async getResult(e,t){this.logger?.info(`[${e}] - getResult() of IntentResolution invoked`);const{result:n}=t;if(n.fdc3error)throw n.fdc3error;if(!n||"object"!=typeof n||Array.isArray(n)||$s(n)&&!n.fdc3intentContext&&!n.fdc3intentChannel&&!n.fdc3error)throw this.logger?.warn(`[${e}] - ${Ol.NoResultReturned} - The intent handler exited without returning a valid result - a promise resolving to a Context, Channel object or void`),new Error(Ol.NoResultReturned);if(!$s(n))return;if(!n.fdc3intentChannel&&!n.fdc3intentContext)return n;if(n.fdc3intentContext)return n.fdc3intentContext.payload;const{fdc3intentChannel:r}=n;if(r.type===Ma.User){const e=(await this.glueController.listAllChannels()).find(e=>e.name===r.displayMetadata.name);return this.channelsFactory.buildModel({type:Ma.User,...r,displayMetadata:{...r.displayMetadata,glueChannel:e}})}if(r.type===Ma.App)return this.channelsFactory.buildModel(r);await this.glueEventsController.initializeCollaborateMethod();const o=this.channelsController.buildPrivateChannel(r.id,e,!1);o.setCollaborator({appId:t.handler.applicationName,instanceId:t.handler.instanceId},e);const i={action:"joinPrivateChannel",correlationId:o.id,collaborationObject:{channelId:o.id}};return await this.glueController.invokeSystemMethod(i,t.handler.instanceId),this.logger?.info(`[${e}] - returning private channel`),o.toApi()}convertGlue42IntentToFDC3Intent(e){const{name:t,handlers:n}=e;return{intent:{name:t,displayName:n[0].displayName||""},apps:n.map(e=>{const t=e.applicationName,n=this.glueController.getApplication(t);return{appId:t,instanceId:e.instanceId,name:t,title:e.applicationTitle||e.instanceTitle||t,tooltip:n?.userProperties.tooltip||`${t} (${e.type})`,description:e.applicationDescription,icons:e.applicationIcon?[e.applicationIcon,...n?.userProperties.icons||[]]:n?.userProperties.icons,images:n?.userProperties.images,resultType:e.resultType}})}}getResultType(e){return(e=>$a.every(t=>Object.keys(e).includes(t)))(e)?Fa.Channel:(e=>Na.every(t=>Object.keys(e).includes(t)))(e)?Fa.Context:void 0}getWrappedIntentHandler(e){return async(t,n)=>{const r=n?{source:{appId:n.application||n.applicationName||"",instanceId:n.instance}}:void 0;let o;try{o=await e({...t.data,type:t.type||""},r)}catch(e){throw this.logger?.warn("string"==typeof e?e:e.message||JSON.stringify(e)),new Error(Ol.IntentHandlerRejected)}if(!o)return;const i=this.getResultType(o);return i?i===Fa.Channel?{fdc3intentChannel:Bl(o)}:{fdc3intentContext:{contextType:o.type,payload:o}}:{fdc3error:{message:Ol.NoResultReturned,reason:"The intent handler exited without returning a valid result - a promise resolving to a Context, Channel object or void"}}}}getGlueIntentWithFilteredHandlers(e,t){const{name:n,handlers:r}=e;let o=r;const i=t.contextType;i&&(o=r.filter(e=>!!e.instanceId||e.contextTypes?.includes(i)));const s=t.resultType;return s&&(o=r.filter(e=>!!e.instanceId||e.resultType?.includes(s))),{name:n,handlers:o}}async invokeRaiseIntent(e,t){try{const n=await this.glueController.raiseIntent({...t,timeout:75e3});return{source:{appId:n.handler.applicationName,instanceId:n.handler.instanceId},intent:t.intent,getResult:(()=>this.getResult(e,n)).bind(this)}}catch(e){throw this.parseIoToFdc3Error(e)}}parseIoToFdc3Error(e){const t=Object.keys(this.ioToFDC3ErrorsDict).find(t=>e?.message?.includes(t)),n=t?this.ioToFDC3ErrorsDict[t]:Wl.IntentDeliveryFailed,r="string"==typeof e?e:JSON.stringify(e);return{message:n,reason:e instanceof Error?e.message:r}}async legacyRaiseIntentForContext({commandId:e,context:t,target:n}){this.logger?.info(`[${e}] - raiseIntentForContext() invoked with contextType ${t.type} and target ${n}`);const r=await this.findIntentsByContext({commandId:e,context:t});if(!r||0===r.length)throw{message:Wl.NoAppsFound,reason:`No apps registering intent with contextType ${t.type} ${n?`and target ${JSON.stringify(n)}`:""}`};return this.raiseIntent({commandId:e,intent:r[0].intent.name,context:t,target:n})}}class zl{glueController;appsStateStore;glueEventsController;_logger;defaultContextListenerInvokedPromiseTimeout=12e4;constructor(e,t,n){this.glueController=e,this.appsStateStore=t,this.glueEventsController=n}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.application.controller")),this._logger}async open({commandId:e,target:t,context:n}){await this.glueController.gluePromise,this.logger?.log(`[${e}] - open() invoked with target ${t} ${n?`and contextType ${n.type}`:""}`);const r="object"==typeof t?t.appId:t,o=this.glueController.getApplication(r);if(!o)throw{message:El.AppNotFound,reason:`Cannot find targeted ${r} application`};if(n)return await this.glueEventsController.initializeCollaborateMethod(),this.logger?.info(`[${e}] - opening app ${o} with startup context`),this.openAppWithContext(o,n);try{this.logger?.info(`[${e}] - opening app ${o}`);const t=await o.start();return this.logger?.info(`[${e}] - instance with id ${t.id} started`),this.parseGlueInstToAppIdentifier(t)}catch(e){throw{message:El.ErrorOnLaunch,reason:"string"==typeof e?e:JSON.stringify(e)}}}async findInstances({commandId:e,appIdentifier:t}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findInstances() invoked with appIdentifier ${t}`);const{appId:n}=t;if(!this.glueController.getApplication(n))throw{message:Wl.NoAppsFound,reason:`App with appId: ${n} does not exist`};const r=this.glueController.getApplicationInstances(n).map(e=>this.parseGlueInstToAppIdentifier(e));return this.logger?.info(`[${e}] - ids of opened instances for appIdentifier ${t}: ${JSON.stringify(r.map(e=>e.instanceId))}`),r}async getAppMetadata({commandId:e,appIdentifier:t}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - getAppMetadata() invoked with appIdentifier ${t}`);const{appId:n,instanceId:r}=t,o=this.glueController.getApplication(n);if(!o)throw{message:El.AppNotFound,reason:`Cannot find application with appId: ${n}`};if(!r)return this.logger?.info(`[${e}] - no opened instances found. Parsing app ${o}`),this.parseGlueAppToAppMetadata(o);const i=this.glueController.getAppInstanceById(r),s=this.parseGlueAppToAppMetadata(o,i);return this.logger?.info(`[${e}] - found app metadata: ${s}`),s}async getInfo({commandId:e}){await this.glueController.gluePromise,this.logger?.info(`${e} - getInfo() invoked`);const t=await this.getCurrentAppMetadata(),{provider:n,providerVersion:r,standardVersion:o}=window.fdc3Info;return{provider:n,providerVersion:r,fdc3Version:o,optionalFeatures:{OriginatingAppMetadata:!0,UserChannelMembershipAPIs:!0,DesktopAgentBridging:!1},appMetadata:t}}getCurrentAppMetadata(){const e=this.glueController.interopInstance();return Promise.resolve({appId:e.applicationName,instanceId:e.instance})}parseGlueInstToAppIdentifier(e){return{appId:e.application.name,instanceId:e.id}}async parseGlueAppToAppMetadata(e,t){const n=await this.getBaseGlueAppToAppMetadata(e);return t?this.addInstanceMetadataToAppMetadata(n,t):n}async getBaseGlueAppToAppMetadata(e){const t=window.glue42gd||window.iodesktop,n=t?await e.getConfiguration():e.userProperties,r=t?(await e.getConfiguration()).icon:e.icon;return{appId:e.name,name:e.name,version:e.version,description:n.description,title:e.title,icons:r?[{src:r}]:[],tooltip:n.tooltip,screenshots:t?n.customProperties.screenshots:n.screenshots}}addInstanceMetadataToAppMetadata(e,t){return{...e,instanceId:t.id,instanceMetadata:t.agm}}async openAppWithContext(e,t){const n=Ms(),r=this.buildStartContext(t,n),o=this.createContextListenerWrappedPromise(e);this.appsStateStore.addOpenAppPromise(n,o);try{const t=await e.start(r);return await o.promise,this.appsStateStore.removeOpenAppPromise(n),this.parseGlueInstToAppIdentifier(t)}catch(e){throw this.appsStateStore.removeOpenAppPromise(n),{message:El.AppTimeout,reason:"string"==typeof e?e:JSON.stringify(e)}}}buildStartContext(e,t){const n=this.glueController.getMyInteropInstance();return{fdc3:{collaborationId:t,openApp:{appId:n.application||n.applicationName||"",instanceId:n.instance},context:{contextType:e.type,payload:e}}}}createContextListenerWrappedPromise(e){let t=()=>{},n=()=>{};return{promise:js(()=>new Promise((e,r)=>{t=e,n=r}),this.defaultContextListenerInvokedPromiseTimeout,`Timeout of ${this.defaultContextListenerInvokedPromiseTimeout}ms hit waiting for application with appId: ${e.name} to register context listener`),resolve:t,reject:n}}}class Gl{glueController;eventDispatcher;glueResponseReceived=!1;glueInitialized=!1;_glueReceiverHandler;events={start:{name:"start",handle:this.handleStart.bind(this)},requestGlueResponse:{name:"requestGlueResponse",handle:this.handleRequestGlueResponse.bind(this)}};constructor(e,t){this.glueController=e,this.eventDispatcher=t}start(){this.wireCustomEventListener(),this.eventDispatcher.fireNotifyStarted()}wireCustomEventListener(){this._glueReceiverHandler=this.glueReceiverHandler.bind(this),window.addEventListener(xl,this._glueReceiverHandler)}handleStart(){this.eventDispatcher.fireRequestGlue()}glueReceiverHandler(e){const t=e.detail;if(!t||!t.glue42)return;const n=t.glue42.event,r=this.events[n];r&&r.handle(t.glue42.message)}async handleRequestGlueResponse(e){if(this.glueResponseReceived&&this.glueInitialized)return;this.glueResponseReceived=!0;const{glue:t}=e,n=this.glueController.validateGlue(t);if(!n.isValid)return this.glueController.initializeFailed(n.error),void window.removeEventListener(xl,this._glueReceiverHandler);window.removeEventListener(xl,this._glueReceiverHandler),this.glueController.initialize(t),this.eventDispatcher.fireFdc3Ready(),this.glueInitialized=!0}}class Hl{_privateChannels={};addPrivateChannel(e){this._privateChannels[e.id]=e}getPrivateChannelById(e){return this._privateChannels[e]}removePrivateChannelById(e){delete this._privateChannels[e]}}function Vl(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}Vl.default=Vl;var Ql=r(Vl);class Jl{channelsController;logger;isCreator;id;type=Ma.Private;displayMetadata;myAppMetadata;unsubFromInstanceStopped;collaborator;disconnected=!1;lastBroadcastedContextType;broadcastedContexts={};collaboratorListenerTypes=[];myListenerTypesBeforeBound=[];registry=Ql();constructor(e,t,n,r){this.channelsController=e,this.logger=t,this.isCreator=r,this.id=n;const o=this.channelsController.getMyServerInstance();this.myAppMetadata={source:{appId:o.applicationName,instanceId:o.instance}}}toApi(){return{id:this.id,type:this.type,displayMetadata:this.displayMetadata,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this),onAddContextListener:this.onAddContextListener.bind(this),onUnsubscribe:this.onUnsubscribe.bind(this),onDisconnect:this.onDisconnect.bind(this),disconnect:this.disconnect.bind(this)}}getCollaborator(){return this.collaborator}setCollaborator(e,t){if(this.collaborator&&this.collaborator.instanceId!==e.instanceId)throw new Error(`There's already a collaborator for private channel with id ${this.id}`);this.collaborator=e,this.subscribeForCollaboratorInstanceStop(t)}async handleCollaboratorJoin(e,t){this.setCollaborator(e,t),await Promise.all(this.myListenerTypesBeforeBound.map(e=>{const n={action:"addedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e||void 0}};return this.logger?.trace(`[${t}] - announcing addedContextListenerOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),this.channelsController.invokeSystemMethod(n,this.collaborator?.instanceId)})).catch(e=>this.logger?.error(e))}handleCollaboratorBroadcast(e,t,n){this.logger?.trace(`[${n}] - heard context with type ${e.type} broadcasted on the channel`),this.lastBroadcastedContextType=e.type,this.broadcastedContexts[e.type]={context:e,metadata:t},this.logger?.trace(`[${n}] - invoking all context listeners`),this.registry.execute(za.ListenerAdded,e,t)}handleCollaboratorAddContextListener(e,t){this.logger?.trace(`[${t}] - heard collaborator added context listener for type ${e}`),this.collaboratorListenerTypes.push(e),this.registry.execute(za.OnAddContextListener,e)}handleCollaboratorRemovedListener(e,t){this.logger?.trace(`[${t}] - heard collaborator removed context listener with type ${e}`);const n=this.collaboratorListenerTypes.indexOf(e);this.collaboratorListenerTypes.splice(n,1),this.registry.execute(za.OnUnsubscribe,e)}handleCollaboratorDisconnect(){this.disconnected=!0,this.collaboratorListenerTypes.forEach(e=>this.registry.execute(za.OnUnsubscribe,e)),this.registry.execute(za.OnDisconnect)}async announceJoin(e,t){const n={action:"joinPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id}};this.logger?.trace(`[${t}] - announcing joinPrivateChannel to target instance with id ${JSON.stringify(e)}`),await this.channelsController.invokeSystemMethod(n,e),this.logger?.trace(`[${t}] - collaborator received joinPrivateChannel action`)}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);const t=Bs();this.ensureAlive(t),this.ensureBound(t,"broadcast"),this.lastBroadcastedContextType=e.type,this.broadcastedContexts[e.type]={context:e,metadata:this.myAppMetadata};const n={action:"publishOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e.type,payload:e}};this.logger?.trace(`[${t}] - announcing publishOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),await this.channelsController.invokeSystemMethod(n,this.collaborator?.instanceId),this.logger?.trace(`[${t}] - collaborator received context for action publishOnPrivateChannel`)}async getCurrentContext(e){const t=Bs();this.ensureAlive(t);const n=e?` with contextType ${e}`:"";if(this.logger?.trace(`[${t}] - getCurrentContext invoked ${n}`),bl.runWithException(e),!e&&!this.lastBroadcastedContextType)return null;const r=e||this.lastBroadcastedContextType;return this.logger?.trace(`[${t}] - Returning context with type ${r}`),this.broadcastedContexts[r].context}async addContextListener(e,t){const n=Bs();if(this.ensureAlive(n),bl.runWithException(e),"function"!=typeof t)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};this.logger?.trace(`[${n}] - adding subscription for broadcasted contexts with type: ${e}`);const r=this.retrieveLatestBroadcastedContextPerType(e),o=r?[[r.context,r.metadata]]:void 0,i=this.registry.add(za.ListenerAdded,(n,r)=>{e?n.type===e&&t(n,r):t(n,r)},o);if(!this.collaborator){this.myListenerTypesBeforeBound.push(e);const t=this.getAddContextListenerUnsub(i,e,n);return Ns(t)}const s={action:"addedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e||void 0}};this.logger?.trace(`[${n}] - announcing addedContextListenerOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),await this.channelsController.invokeSystemMethod(s,this.collaborator?.instanceId),this.logger?.trace(`[${n}] - collaborator received action addedContextListenerOnPrivateChannel`);const a=this.getAddContextListenerUnsub(i,e,n);return Ns(a)}retrieveLatestBroadcastedContextPerType(e){if(e||this.lastBroadcastedContextType)return!e&&this.lastBroadcastedContextType?{context:this.broadcastedContexts[this.lastBroadcastedContextType].context,metadata:this.broadcastedContexts[this.lastBroadcastedContextType].metadata}:this.broadcastedContexts[e]}getAddContextListenerUnsub(e,t,n){return async()=>{if(e(),!this.collaborator){const e=this.myListenerTypesBeforeBound.indexOf(t);return void this.myListenerTypesBeforeBound.splice(e,1)}const r={action:"removedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:t||void 0}};this.logger?.trace(`[${n}] - announcing unsubscribe from context listener for type ${t}`),await this.channelsController.invokeSystemMethod(r,this.collaborator?.instanceId),this.logger?.trace(`[${n}] - collaborator heard removedContextListenerOnPrivateChannel`)}}onAddContextListener(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnAddContextListener,e,this.collaboratorListenerTypes);return Ns(n)}onUnsubscribe(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnUnsubscribe,e);return Ns(n)}onDisconnect(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnDisconnect,e);return Ns(n)}async disconnect(){const e=Bs();if(this.isCreator&&!this.collaborator)return void(this.disconnected=!0);this.ensureAlive(e),this.ensureBound(e,"disconnect"),this.logger?.trace(`[${e}] - disconnect invoked`),this.disconnected=!0,this.logger?.trace(`[${e}] - announcing disconnectedFromPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`);const t={action:"disconnectedFromPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id}};this.channelsController.removePrivateChannelFromStoreById(this.id),await this.channelsController.invokeSystemMethod(t,this.collaborator?.instanceId),this.logger?.trace(`[${e}] - collaborator received action disconnectedFromPrivateChannel`),this.unsubFromInstanceStopped&&this.unsubFromInstanceStopped()}ensureAlive(e){if(!this.disconnected)return;const t="Channel is disconnected - operation is no longer available";throw this.logger?.error(`[${e}] - ${t}`),{message:Dl.AccessDenied,reason:t}}ensureBound(e,t){if(this.collaborator)return;const n=`There's no collaborator on the other side of the channel - operation ${t} is unavailable`;throw this.logger?.error(`[${e}] - ${n}`),{message:Dl.AccessDenied,reason:n}}subscribeForCollaboratorInstanceStop(e){this.unsubFromInstanceStopped=this.channelsController.subscribeOnInstanceStop(this.id,(e=>{e.id===this.collaborator?.instanceId&&this.handleCollaboratorDisconnect()}).bind(this),e)}}class Kl{createUserChannelFn;createAppChannel;createPrivateChannel;constructor(e,t,n){this.createUserChannelFn=e,this.createAppChannel=t,this.createPrivateChannel=n}buildPrivateChannel(e){return this.createPrivateChannel(e.logger,e.id,e.isCreator)}buildModel(e){if(e.type===Ma.User)return this.createUserChannelFn(e.displayMetadata.glueChannel);if(e.type===Ma.App)return this.createAppChannel(e.id);throw new Error("Pass one of the supported channel types: user, app, private")}}class Yl{glueController;channelsStateStore;appsStateStore;_logger;actionDictionary={joinPrivateChannel:this.handleJoin.bind(this),publishOnPrivateChannel:this.handlePublish.bind(this),addedContextListenerOnPrivateChannel:this.handleContextListenerAdded.bind(this),removedContextListenerOnPrivateChannel:this.handleContextListenerRemoved.bind(this),disconnectedFromPrivateChannel:this.handleDisconnect.bind(this),startupContextOpened:this.handleStartupContextOpened.bind(this)};constructor(e,t,n){this.glueController=e,this.channelsStateStore=t,this.appsStateStore=n}async initializeCollaborateMethod(){this.checkSystemMethodRegistered()||await this.glueController.registerMethod(qa,this.handleReceivedAction.bind(this))}checkSystemMethodRegistered(){const e=this.glueController.getInteropMethods(qa),t=this.glueController.getMyInteropInstance().instance;return!!e.filter(e=>e.getServers().find(e=>e.instance===t)?e:void 0).length}async handleReceivedAction(e,t){const n=Il.run(e);if(!n.ok)throw new Error(`Interop Method ${qa} invoked with invalid argument object - ${n.error}`);const r=Bs();this.logger?.log(`${r} - received system method from instance with id ${t.instance} for action ${e.action} with arguments: ${JSON.stringify(e)}`);const o=this.actionDictionary[e.action];if(!o){const t=`Unsupported private channel action: ${e.action}`;throw this.logger?.error(`[${r}] - ${t}`),new Error(t)}await o(e,t,r)}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.private.channels.controller")),this._logger}validateAndRetrieveChannel({action:e,correlationId:t},n,r){const o=this.channelsStateStore.getPrivateChannelById(t);if(!o){const e=`There's no private channel with id ${t}`;throw this.logger?.error(`[${r}] - ${e}`),new Error(e)}const i=o.getCollaborator();if("joinPrivateChannel"===e)return o;if(i&&i.instanceId===n.instance)return this.logger?.log(`[${r}] - request sent from correct collaborator with id ${n.instance}. Returning channel`),o;const s=`Cannot proceed with action ${e} - ${i?`private channel ${t} established communication with collaborator with id ${i}`:`no collaborator joined private channel with id ${t}`}`;throw this.logger?.error(s),new Error(s)}async handleJoin(e,t,n){const r={appId:t.application||t.applicationName,instanceId:t.instance},o=this.validateAndRetrieveChannel(e,t,n);await o.handleCollaboratorJoin(r,n),this.logger?.log(`[${n}] - collaborator ${JSON.stringify(r)} set for private channel with id ${e.correlationId}`)}handlePublish(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, adding context with type ${e.collaborationObject?.contextType} to the private channel broadcasted contexts`);const r=this.validateAndRetrieveChannel(e,t,n),o={source:{appId:t.application||t.applicationName||"",instanceId:t.instance}};r.handleCollaboratorBroadcast(e.collaborationObject?.payload,o,n)}handleContextListenerAdded(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onAddContextListener' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorAddContextListener(e.collaborationObject?.contextType||null,n)}handleContextListenerRemoved(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onUnsubscribe' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorRemovedListener(e.collaborationObject?.contextType||null,n)}handleDisconnect(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onDisconnect' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorDisconnect()}handleStartupContextOpened(e,t,n){this.logger?.log(`[${n}] - received ${e.action} with correlationId: ${e.correlationId} from instance with id ${t.instance}`);const r=this.appsStateStore.getOpenAppPromise(e.correlationId);r?(this.logger?.log(`[${n}] - resolving open app promise related to guid ${e.correlationId} from instance with id ${t.instance}`),r.resolve()):this.logger?.log(`[${n}] - there's no open app promise related to guid ${e.correlationId}`)}}class Zl{openAppPromises={};addOpenAppPromise(e,t){this.openAppPromises[e]=t}getOpenAppPromise(e){return this.openAppPromises[e]}removeOpenAppPromise(e){delete this.openAppPromises[e]}}class Xl{glueController;stateStore;parser;channelsFactory;glueEventsController;legacyController;ioFdc3SupportedController;_logger;initDonePromise;invokeContextHandlerWithStartupContext=!0;isFdc3DataWrappingSupported;constructor(e,t,n,r,o,i,s){this.glueController=e,this.stateStore=t,this.parser=n,this.channelsFactory=r,this.glueEventsController=o,this.legacyController=i,this.ioFdc3SupportedController=s,this.initDonePromise=this.initialize(),this.initDonePromise.catch(e=>{this.logger?.error(e)})}async getStartupContext(){await this.initDonePromise;const e=await this.glueController.getMyWindowContext();return e?.fdc3?.context?.payload||null}async addContextListener({commandId:e,handler:t,contextType:n,channelId:r}){await this.initDonePromise,this.logger?.info(`[${e}] - addContextListener() invoked for contextType ${n} and channelId ${r}`),this.invokeContextHandlerWithStartupContext&&!r&&(this.logger?.info(`[${e}] - trying to invoke context handler with window context`),this.handleWindowContextOnOpening(e,t,n).catch(t=>this.logger?.warn(`[${e}] - ${t}`)));const o=r||(await this.getCurrentChannel(e))?.id,i="multi"===this.glueController.getChannelsMode()&&(await this.glueController.getMyChannels()).length>1,s=ql(t,n);return!o||i?{unsubscribe:this.glueController.channelsSubscribe(s,n)}:this.addContextListenerByChannelId({commandId:e,handler:s,invokedOnChannelModel:!!r,channelId:o,contextType:n})}async broadcast(e,t,n){if(await this.initDonePromise,this.logger?.info(`[${e}] - broadcast() invoked with contextType ${t.type} and channelId ${n}`),!await this.isBroadcastPermitted(e,n))return;const r=n||(await this.getCurrentChannel(e))?.id;if(!r)return;const o="multi"===this.glueController.getChannelsMode()&&(await this.glueController.getMyChannels()).length>1;return!r||o?this.glueController.channelsUpdate(t,{fdc3:!0}):this.broadcastByChannelId(e,r,t)}async getUserChannels(e){await this.initDonePromise,this.logger?.info(`[${e}] - getUserChannels() invoked`);const t=await this.glueController.listAllChannels();return this.mapIoToFDC3Channels(t)}async getOrCreateChannel({commandId:e,channelId:t}){await this.initDonePromise,this.logger?.info(`[${e}] - getOrCreateChannel() invoked for channel with id ${t}`);const n=(await this.getUserChannels(e)).find(e=>e.id===t);if(n)return n;if(this.stateStore.getPrivateChannelById(t))throw this.logger?.error("Cannot retrieve a private channel"),new Error(Dl.AccessDenied);return this.getOrCreateAppChannel(e,t)}async joinUserChannel({commandId:e,channelId:t}){if(await this.initDonePromise,this.logger?.info(`[${e}] - joinUserChannel() invoked for channel with id ${t}`),this.doesAppChannelExist(t))throw this.logger?.error("Cannot join an app channel"),new Error(Dl.AccessDenied);if(!(await this.getUserChannels(e)).find(e=>e.id===t))throw this.logger?.error(`Cannot find user channel with id ${t}`),new Error(Dl.NoChannelFound);const n=(await this.getOrCreateChannel({commandId:e,channelId:t}))?.displayMetadata?.name;if(!n)throw this.logger?.error(`[${e}] - Cannot find io channel name for fdc3 channel with id ${t}`),new Error(Dl.NoChannelFound);this.logger?.info(`[${e}] - joining fdc3 user channel with id ${t} (underlying io channel: ${n})`),await this.glueController.joinChannel(n)}async getCurrentChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - getCurrentChannel() invoked`);const t=await this.glueController.getMyChannel();return t?.meta.fdc3?this.channelsFactory.buildModel({type:Ma.User,displayMetadata:{glueChannel:t}}):null}async leaveCurrentChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - leaveCurrentChannel() invoked`),await this.getCurrentChannel(e)?(await this.glueController.leaveChannel(),this.logger?.info(`[${e}] - current channel is left. unsubscribing from all listeners`)):this.logger?.info(`[${e}] - no channel to leave`)}async getContextForChannel({commandId:e,channelId:t,contextType:n}){if(await this.initDonePromise,this.logger?.info(`[${e}] - getContextForChannel() invoked for channel with id ${t}`),await this.isUserChannel(e,t))return this.userChannelsSupportController.getContext({commandId:e,channelId:t,contextType:n});if(!n){const e=await this.glueController.getContext(t);return e.latest_fdc3_type?this.parser.parseContextsDataToInitialFDC3Data(e):null}const r=this.parser.mapFDC3TypeToChannelsDelimiter(n),{data:o}=await this.glueController.getContext(t);return o?.[`fdc3_${r}`]?this.parser.parseContextsDataToInitialFDC3Data({data:o,latest_fdc3_type:r}):null}async createPrivateChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - createPrivateChannel() invoked`);const t=`${Ua}${Ms()}`;return await this.glueEventsController.initializeCollaborateMethod(),this.buildPrivateChannel(t,e,!0).toApi()}async removePrivateChannelFromStoreById(e){this.stateStore.removePrivateChannelById(e)}async invokeSystemMethod(e,t){if(t)return this.glueController.invokeSystemMethod(e,t)}getMyServerInstance(){return this.glueController.getMyInteropInstance()}async addClientToPrivateChannel(e,t,n){this.logger?.info(`[${e}] - client with id ${n} added to private channel with id ${t}`),await this.glueController.updateContext(t,{clientId:n})}async isPrivateChannelDisconnected({commandId:e,channelId:t}){return this.logger?.info(`[${e}] - checking if private channel with id ${t} is disconnected`),!!(await this.glueController.getContext(t)).disconnected}subscribeOnInstanceStop(e,t,n){return this.logger?.info(`[${n}] - subscribing onInstanceStopped callback for channel with id ${e}`),this.glueController.registerOnInstanceStopped(t.bind(this))}buildPrivateChannel(e,t,n){const r=this.glueController.initSubLogger(e),o=this.channelsFactory.buildPrivateChannel({id:e,logger:r,isCreator:n});return this.logger?.info(`[${t}] - private channel with id ${e} created. Adding it to the store`),this.stateStore.addPrivateChannel(o),o}buildChannel(e,t){return this.channelsFactory.buildModel({type:e,...t})}async publish(e,t){return(await this.glueController.getMyChannels()).length?this.glueController.channelsUpdate(t,{fdc3:!0}):(this.logger?.info(`[${e}] - invocation of publish ignored - no channel to publish to`),void console.warn("You need to join a user channel to broadcast data"))}async getCurrentChannels(e){await this.initDonePromise,this.logger?.info(`[${e}] - getCurrentChannels() invoked`);const t=await this.glueController.getMyChannels();return this.mapIoToFDC3Channels(t)}async leave(e,t){if(await this.initDonePromise,this.logger?.info(`[${e}] - leave() invoked with options: ${JSON.stringify(t)}`),!t?.channelId)return this.logger?.info(`[${e}] - leaving all channels`),this.glueController.leaveChannel();const n=(await this.glueController.listAllChannels()).find(e=>e.meta.fdc3?.id===t.channelId);if(!n)throw new Error(Dl.NoChannelFound);return this.logger?.info(`[${e}] - leaving channel '${n.name}'`),this.glueController.leaveChannel({channel:n.name})}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.channels.controller")),this._logger}get userChannelsSupportController(){return this.isFdc3DataWrappingSupported?this.ioFdc3SupportedController:this.legacyController}async initialize(){await this.glueController.gluePromise,this.isFdc3DataWrappingSupported=await this.glueController.checkIsFdc3DataWrappingSupported()}async isBroadcastPermitted(e,t){if(t)return!0;const n=await this.getCurrentChannel(e);return n?n.type!==Ma.App||(this.logger?.info(`[${e}] - invocation of broadcast ignored - cannot broadcast on app channel directly`),console.error("You can't broadcast to an app channel directly - use channel's broadcast method instead"),!1):(this.logger?.info(`[${e}] - invocation of broadcast ignored - no channel to broadcast to`),console.warn("You need to join a user channel in order to broadcast"),!1)}mapIoToFDC3Channels(e){return e.filter(e=>e.meta.fdc3).map(e=>this.channelsFactory.buildModel({type:Ma.User,displayMetadata:{glueChannel:e}}))}async handleWindowContextOnOpening(e,t,n){const r=this.glueController.getMyWindow();if(!r)return this.logger?.trace(`[${e}] - Cannot get window context because this is not a Glue window, it's probably an iframe`),void(this.invokeContextHandlerWithStartupContext=!1);const o=await r.getContext();if(!o)return this.logger?.trace(`[${e}] - Cannot get window context because this is not a Glue window, it's probably an iframe`),void(this.invokeContextHandlerWithStartupContext=!1);if(!$s(o)||!o.fdc3)return this.logger?.info(`[${e}] - addContextListener handler won't be invoked - startup context is empty`),void(this.invokeContextHandlerWithStartupContext=!1);await this.glueEventsController.initializeCollaborateMethod(),kl.runWithException(o);const{fdc3:i}=o;if(this.logger?.trace(`[${e}] - received FDC3 startup context from ${JSON.stringify(i.openApp)} for contextType ${i.context.contextType}`),n&&i.context.contextType!==n)this.logger?.info(`[${e}] - addContextListener handler won't be invoked for contextType ${n} for startup context with type: ${i.context.contextType}`);else{this.logger?.info(`[${e}] - invoking addContextListener handler with startup context with type ${i.context.contextType}`);try{t(i.context.payload,{source:i.openApp})}catch(e){const t=e.message?JSON.stringify(e.message):JSON.stringify(e);this.logger?.error("string"==typeof e?e:t)}this.invokeContextHandlerWithStartupContext=!1,this.logger?.trace(`[${e}] - invoking response method to with target ${JSON.stringify(i.openApp)}`),await this.invokeSystemMethod({action:"startupContextOpened",correlationId:i.collaborationId},i.openApp.instanceId),this.logger?.trace(`[${e}] - system method invocation success for 'startupContextOpened' heard`)}}async getOrCreateAppChannel(e,t){this.doesAppChannelExist(t)||(this.logger?.info(`[${e}] - app channel with id ${t} does not exist. Creating one`),await this.glueController.updateContext(t,{})),this.logger?.info(`[${e}] - returning app channel with id ${t}`);const n=this.glueController.initSubLogger(`app.channel.${t}`);return this.channelsFactory.buildModel({type:Ma.App,id:t,logger:n})}doesAppChannelExist(e){return!e.includes(Ua)&&this.glueController.getAllContexts().some(t=>t===e)}async isUserChannel(e,t){return!!t&&(await this.getUserChannels(e)).some(e=>e.id===t)}async broadcastByChannelId(e,t,n){if(!await this.isUserChannel(e,t))return this.logger?.info(`[${e}] - broadcasting on app channel with id ${t}`),this.glueController.updateContextWithLatestFdc3Type(t,n);const r=(await this.getOrCreateChannel({commandId:e,channelId:t}))?.displayMetadata?.name;if(!r)throw this.logger?.error(`[${e}] - Cannot find io channel name for fdc3 channel with id ${t}`),new Error(Dl.NoChannelFound);return this.logger?.info(`[${e}] - broadcasting on fdc3 user channel with id ${t} (underlying glue channel: ${r})`),this.userChannelsSupportController.broadcast({ioChannelName:r,context:n})}async addContextListenerByChannelId({commandId:e,channelId:t,handler:n,contextType:r,invokedOnChannelModel:o}){const i=ql(n,r),s=await this.getChannelTypeById(e,t);if(s===Ma.User)return this.userChannelsSupportController.addContextListener({commandId:e,channelId:t,handler:i,contextType:r,invokedOnChannelModel:o});if(s===Ma.App){this.logger?.info(`[${e}] - subscribing for fdc3 app channel with id ${t} (underlying glue context with same name)`);const n=await this.glueController.contextsSubscribe(t,i);return{unsubscribe:()=>{this.logger?.info(`[${e}] - invoking unsubscribe for app channel with id ${t}`),n()}}}throw this.logger?.error("Cannot add a context listener on an invalid channel"),new Error(Dl.AccessDenied)}async getChannelTypeById(e,t){if(await this.isUserChannel(e,t))return Ma.User;if(this.doesAppChannelExist(t))return Ma.App;throw this.logger?.error(`Channel with id: ${t} does not exist`),new Error(Dl.NoChannelFound)}}class eu{parser;glueController;_logger;constructor(e,t){this.parser=e,this.glueController=t}async getContext({commandId:e,channelId:t,contextType:n}){this.logger?.info(`[${e}] - retrieving latest context of type ${n} broadcasted on channel with id ${t}`);const r=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!r)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);if(!n){const n=this.parser.mapChannelNameToContextName(r);this.logger?.info(`[${e}] - getting context for user channel with id ${t} (underlying glue channel ${r})`);const o=await this.glueController.getContext(n);return o.latest_fdc3_type?this.parser.parseContextsDataToInitialFDC3Data(o):null}const o=this.parser.mapFDC3TypeToChannelsDelimiter(n),{data:i}=await this.glueController.getChannel(r);return i?.[`fdc3_${o}`]?this.parser.parseContextsDataToInitialFDC3Data({data:i,latest_fdc3_type:o}):null}async broadcast({ioChannelName:e,context:t}){const{path:n,value:r}=this.parser.parseFDC3ContextToGlueContexts(t);return this.glueController.channelsUpdate({[n]:r},e)}async addContextListener({commandId:e,channelId:t,handler:n,invokedOnChannelModel:r,contextType:o}){if(!r)return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:this.glueController.legacyChannelsSubscribe(n,o)};const i=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!i)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const s=this.parser.mapChannelNameToContextName(i);return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:await this.glueController.contextsSubscribe(s,n)}}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.legacy.channels.controller")),this._logger}}class tu{parser;glueController;_logger;constructor(e,t){this.parser=e,this.glueController=t}async getContext({commandId:e,channelId:t,contextType:n}){this.logger?.info(`[${e}] - retrieving latest context of type ${n} broadcasted on channel with id ${t}`);const r=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!r)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const o=await this.glueController.getChannel(r);if(!n)return o.data.fdc3||null;if(n&&o.data.fdc3?.type===n)return o.data.fdc3;const i=this.parser.mapChannelNameToContextName(r),{data:s}=await this.glueController.getContext(i),a=this.parser.mapFDC3TypeToChannelsDelimiter(n);return s?.[`fdc3_${a}`]?this.parser.parseContextsDataToInitialFDC3Data({data:s,latest_fdc3_type:a}):null}async broadcast({ioChannelName:e,context:t}){return this.glueController.channelsUpdate(t,{name:e,fdc3:!0})}async addContextListener({commandId:e,channelId:t,invokedOnChannelModel:n,handler:r,contextType:o}){if(!n)return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:this.glueController.channelsSubscribe(r,o)};const i=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!i)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const s=this.parser.mapChannelNameToContextName(i);return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:await this.glueController.contextsSubscribe(s,r)}}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.ioSupport.channels.controller")),this._logger}}class nu{_eventDispatcher;_eventReceiver;_desktopAgent;_glueController;_intentsController;_applicationController;_channelsBaseController;_legacyDataWrappingChannelsController;_newDataWrappingChannelsController;_channelsParser;_channelsStateStore;_channelsFactory;_fdc3;_eventsController;_applicationsStateStore;get ioc(){return this}get eventReceiver(){return this._eventReceiver||(this._eventReceiver=new Gl(this.glueController,this.eventDispatcher)),this._eventReceiver}get glueController(){return this._glueController||(this._glueController=new Tl(this.channelsParser,this.channelsStateStore)),this._glueController}get fdc3(){return this._fdc3||(this._fdc3=this.desktopAgent.toApi()),this._fdc3}get eventDispatcher(){return this._eventDispatcher||(this._eventDispatcher=new Al),this._eventDispatcher}get channelsFactory(){return this._channelsFactory||(this._channelsFactory=new Kl(this.createUserChannel.bind(this),this.createAppChannel.bind(this),this.createPrivateChannel.bind(this))),this._channelsFactory}createUserChannel(e){return new jl(this.channelsBaseController,e).toApi()}createAppChannel(e){return new $l(this.channelsBaseController,e).toApi()}createPrivateChannel(e,t,n){return new Jl(this.channelsBaseController,e,t,n)}get desktopAgent(){return this._desktopAgent||(this._desktopAgent=new Ml(this.intentsController,this.applicationController,this.channelsBaseController)),this._desktopAgent}get channelsParser(){return this._channelsParser||(this._channelsParser=new Nl),this._channelsParser}get intentsController(){return this._intentsController||(this._intentsController=new Ul(this.glueController,this.channelsBaseController,this.channelsFactory,this.eventsController)),this._intentsController}get applicationController(){return this._applicationController||(this._applicationController=new zl(this.glueController,this.applicationsStateStore,this.eventsController)),this._applicationController}get channelsBaseController(){return this._channelsBaseController||(this._channelsBaseController=new Xl(this.glueController,this.channelsStateStore,this.channelsParser,this.channelsFactory,this.eventsController,this.legacyDataWrappingChannelsController,this.ioFdc3SupportChannelsController)),this._channelsBaseController}get legacyDataWrappingChannelsController(){return this._legacyDataWrappingChannelsController||(this._legacyDataWrappingChannelsController=new eu(this.channelsParser,this.glueController)),this._legacyDataWrappingChannelsController}get ioFdc3SupportChannelsController(){return this._newDataWrappingChannelsController||(this._newDataWrappingChannelsController=new tu(this.channelsParser,this.glueController)),this._newDataWrappingChannelsController}get channelsStateStore(){return this._channelsStateStore||(this._channelsStateStore=new Hl),this._channelsStateStore}get eventsController(){return this._eventsController||(this._eventsController=new Yl(this.glueController,this.channelsStateStore,this.applicationsStateStore)),this._eventsController}get applicationsStateStore(){return this._applicationsStateStore||(this._applicationsStateStore=new Zl),this._applicationsStateStore}}let ru=window.fdc3;window.fdc3Info={provider:"io.Connect",providerVersion:"2.5.1",standardVersion:"2.1"},void 0===ru?(ru=(()=>{const e=new nu;return e.glueController.createGluePromise(),e.eventReceiver.start(),e.fdc3})(),window.fdc3=ru):console.warn("Defaulting to using the auto-injected fdc3.");let ou=(e=21)=>{let t="",n=0|e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t};function iu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function su(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}su.default=su;var au=iu(su);const lu="done",uu="in-progress",cu="error",du="info",hu="search",pu="cancel";var gu=function(e){return{ok:!0,result:e}},fu=function(e){return{ok:!1,error:e}},mu=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:gu(e(t.result,n.result))},yu=function(e,t){return!0===t.ok?t:fu(e(t.error))},wu=function(){return wu=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wu.apply(this,arguments)};function vu(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!vu(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!vu(e[r[n]],t[r[n]]))return!1}return!0}}var bu=function(e){return Array.isArray(e)},Cu=function(e){return"object"==typeof e&&null!==e&&!bu(e)},Su=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},Iu=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},ku=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return wu({at:e+(n||"")},r)},Tu=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return yu(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?gu(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?gu(e):fu({message:Su("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?gu(e):fu({message:Su("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?gu(e):fu({message:Su("a boolean",e)})})},e.constant=function(t){return new e(function(e){return vu(e,t)?gu(t):fu({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Cu(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?fu({message:"the key '"+r+"' is required but was not present"}):fu(ku("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return gu(n)}return Cu(e)?gu(e):fu({message:Su("an object",e)})})},e.array=function(t){return new e(function(e){return bu(e)&&t?e.reduce(function(e,n,r){return mu(function(e,t){return e.concat([t])},e,function(e,n){return yu(function(e){return ku("["+n+"]",e)},t.decode(e))}(n,r))},gu([])):bu(e)?gu(e):fu({message:Su("an array",e)})})},e.tuple=function(t){return new e(function(e){if(bu(e)){if(e.length!==t.length)return fu({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return fu(ku("["+r+"]",o.error));n[r]=o.result}return gu(n)}return fu({message:Su("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return mu(Object.assign,t,n.decode(e))},gu({}))})},e.anyJson=function(){return new e(function(e){return gu(e)})},e.unknownJson=function(){return new e(function(e){return gu(e)})},e.dict=function(t){return new e(function(e){if(Cu(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return fu(ku("."+r,o.error));n[r]=o.result}return gu(n)}return fu({message:Su("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?gu(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return fu({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return gu(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return fu({at:Iu(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Cu(r))return fu({at:Iu(t.slice(0,o+1)),message:Su("an object",r)});if("number"==typeof t[o]&&!bu(r))return fu({at:Iu(t.slice(0,o+1)),message:Su("an array",r)});r=r[t[o]]}return yu(function(e){return void 0===r?{at:Iu(t),message:"path does not exist"}:ku(Iu(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return gu(t)})},e.fail=function(t){return new e(function(e){return fu({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),xu=Tu.string,Au=Tu.number;Tu.boolean;var Eu=Tu.anyJson;Tu.unknownJson;var Wu=Tu.constant,Ou=Tu.object,Du=Tu.array;Tu.tuple,Tu.dict;var _u=Tu.optional,Pu=Tu.oneOf;Tu.union,Tu.intersection,Tu.withDefault,Tu.valueAt,Tu.succeed,Tu.fail,Tu.lazy;const Ru=xu().where(e=>e.length>0,"Expected a non-empty string"),Lu=Au().where(e=>e>=0,"Expected a non-negative number"),Fu=Ou({name:Ru,displayName:_u(Ru)}),Mu=Ou({id:Ru,interopId:Ru,name:Ru,appName:_u(Ru),types:_u(Du(Fu))}),$u=Ou({maxResults:_u(Lu),maxResultsPerType:_u(Lu)}),Nu=Ou({search:Ru,providers:_u(Du(Mu)),types:_u(Du(Fu)),providerLimits:_u($u)}),ju=Ou({name:Ru,types:_u(Du(Fu))}),Bu=Pu(Wu("cancel"),Wu("info"),Wu("search")),qu=Pu(Wu("done"),Wu("in-progress"),Wu("error")),Uu=Ou({id:Ru}),zu=Ou({method:Ru,target:_u(Pu(Ou({instance:Ru}),Wu("all"))),params:_u(Eu())}),Gu=Ou({name:Ru,method:Ru,target:_u(Pu(Ou({instance:Ru}),Wu("all"))),params:_u(Eu())}),Hu=Ou({type:Fu,id:_u(Ru),displayName:_u(Ru),description:_u(Ru),iconURL:_u(Ru),metadata:_u(Eu()),action:_u(zu),secondaryActions:_u(Du(Gu))}),Vu=Ou({type:xu(),category:_u(xu()),id:_u(xu()),displayName:_u(xu()),description:_u(xu()),iconURL:_u(xu()),action:_u(zu)}),Qu=Ou({items:Du(Pu(Hu,Vu)),provider:_u(Mu),queryId:Ru,status:Wu("in-progress")}),Ju=Ou({items:Du(Pu(Hu,Vu)),queryId:Ru,status:Wu("done")}),Ku=Ou({items:Du(Pu(Hu,Vu)),provider:_u(Mu),queryId:Ru,errorMessage:Ru,status:Wu("error")});class Yu{logger;glueController;modelFactory;registry=au();activeQueryLookup={};queryIdToMasterIdLookup={};pendingDebounce=[];debounceTimer;debounceMS=0;constructor(e,t,n){this.logger=e,this.glueController=t,this.modelFactory=n}setDebounceMS(e){this.logger.info(`[${e.commandId}] Setting the debounceMS to: ${e.milliseconds}`),this.debounceMS=e.milliseconds,this.logger.info(`[${e.commandId}] debounceMS set to: ${e.milliseconds}`)}getDebounceMS(e){return this.logger.info(`[${e.commandId}] Getting the debounceMS`),this.debounceMS}async query(e,t){if(this.debounceMS&&!t)return this.debounceQuery(e);await this.glueController.registerMainClientMethod(this.handleProviderCall.bind(this));const{queryConfig:n,commandId:r}=e;this.logger.info(`[${r}] Initiating a query request`);let o=await this.glueController.getAllProvidersInfo();this.logger.trace(`[${r}] Got all available providers: ${JSON.stringify(o)}`),n.providers&&(this.logger.info(`[${r}] Filtering providers by explicitly allowed providers.`),o=this.filterProvidersByAllowList(o,n.providers)),n.types&&(this.logger.info(`[${r}] Filtering providers by explicitly allowed types.`),o=this.filterProvidersByAllowedTypes(o,n.types)),o.length||this.logger.warn(`[${r}] There are no providers that can handle the query for ${e.queryConfig.search}`),this.logger.info(`[${r}] Sending query request to providers: ${JSON.stringify(o)}`);const i=await this.glueController.sendQueryRequest(n,o);this.logger.info(`[${r}] Received responses from the providers: ${JSON.stringify(i)}`);const s=this.generateMasterQueryId(),a=this.modelFactory.buildClientQueryModel(s,this);return this.logger.info(`[${r}] The query is in progress with master id: ${s}`),this.activeQueryLookup[s]={servers:i,model:a},i.forEach(e=>{this.queryIdToMasterIdLookup[e.queryId]=s}),i.length||setTimeout(()=>{this.registry.execute(`on-query-completed-${s}`),this.cleanUpQuery(s)},0),a.exposeFacade()}async cancelQuery(e,t){const n=this.activeQueryLookup[e];if(!n)throw new Error(`[${t}] Cannot cancel query: ${e}, because this query does not exist`);const r=n.servers;this.logger.info(`[${t}] Sending cancel query requests`),await Promise.all(r.map(e=>(this.logger.trace(`[${t}] Sending cancel query request to ${e.interopId} with queryId: ${e.queryId}`),this.glueController.sendQueryCancelRequest({id:e.queryId},{instance:e.interopId})))),this.logger.info(`[${t}] The query was cancelled`)}processClientOnResults(e){return this.registry.add(`on-query-results-${e.masterQueryId}`,e.callback)}processClientOnCompleted(e){return this.registry.add(`on-query-completed-${e.masterQueryId}`,e.callback)}processClientOnError(e){return this.registry.add(`on-query-error-${e.masterQueryId}`,e.callback)}async handleProviderCall(e){const{status:t}=e,n=qu.runWithException(t),r=ou(10);switch(n){case lu:return this.handleQueryCompleted({completedConfig:e,commandId:r});case uu:return this.handleQueryResults({resultsBatch:e,commandId:r});case cu:return this.handleQueryError({error:e,commandId:r});default:throw new Error(`Unrecognized status: ${t}`)}}handleQueryResults(e){const{resultsBatch:t,commandId:n}=e;this.logger.trace(`[${n}] Processing a results batch from provider: ${t.provider?.name} with id: ${t.provider?.id}`);const r=Qu.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received results for an unknown query. Provider ${JSON.stringify(r.provider)}, items: ${JSON.stringify(r.items)}`);this.logger.trace(`[${n}] The results batch is validated, forwarding to the callbacks`);const i=this.checkTransformLegacyResults(r.items),s={provider:r.provider,results:i};this.registry.execute(`on-query-results-${o}`,s)}handleQueryCompleted(e){const{completedConfig:t,commandId:n}=e;this.logger.trace(`[${n}] Processing a query completed message from query id: ${t.queryId}`);const r=Ju.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received completed message for an unknown query. Provider query id: ${JSON.stringify(r.queryId)}`);if(r.items.length){const e={results:this.checkTransformLegacyResults(r.items)};this.registry.execute(`on-query-results-${o}`,e)}delete this.queryIdToMasterIdLookup[r.queryId];const i=this.activeQueryLookup[o];i.servers=i.servers.filter(e=>e.queryId!==r.queryId),i.servers.length?this.logger.trace(`[${n}] Waiting for more providers to complete`):(this.logger.trace(`[${n}] All providers are done, marking this query as completed`),this.registry.execute(`on-query-completed-${o}`),this.cleanUpQuery(o))}handleQueryError(e){const{error:t,commandId:n}=e;this.logger.trace(`[${n}] Processing an error message from query: ${t.queryId}`);const r=Ku.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received error message for an unknown query. Provider query id: ${JSON.stringify(r.queryId)} and message: ${JSON.stringify(r.errorMessage)}`);const i={error:r.errorMessage,provider:r.provider};this.registry.execute(`on-query-error-${o}`,i)}filterProvidersByAllowList(e,t){const n=t.reduce((e,t)=>(e[t.id]=!0,e),{});return e.filter(e=>e.info.providers.some(e=>n[e.id]))}filterProvidersByAllowedTypes(e,t){const n=t.reduce((e,t)=>(e[t.name]=!0,e),{});return e.filter(e=>{const t=e.info.supportedTypes;return!!t.some(e=>"*"===e)||!t||!t.length||t.some(e=>n[e])})}generateMasterQueryId(){const e=ou(10);return this.activeQueryLookup[e]?this.generateMasterQueryId():e}cleanUpQuery(e){this.registry.clearKey(`on-query-results-${e}`),this.registry.clearKey(`on-query-completed-${e}`),this.registry.clearKey(`on-query-error-${e}`),delete this.activeQueryLookup[e]}debounceQuery(e){return new Promise((t,n)=>{clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{const t=[...this.pendingDebounce];this.pendingDebounce=[],this.query(e,!0).then(e=>t.forEach(({resolve:t})=>t(e))).catch(e=>t.forEach(({reject:t})=>t(e)))},this.debounceMS),this.pendingDebounce.push({resolve:t,reject:n})})}checkTransformLegacyResults(e){if(!e.length)return[];const t=e[0];return t&&"object"!=typeof t.type?e.map(e=>({type:{name:e.type,displayName:e.category},id:e.id,displayName:e.displayName,description:e.description,iconURL:e.iconURL,action:e.action})):e}}const Zu="T42.Search.Provider",Xu="T42.Search.Client";class ec{glue;constructor(e){this.glue=e}get myAppName(){return this.glue.interop.instance.applicationName}get myInteropId(){return this.glue.interop.instance.instance}async registerMainProviderMethod(e){this.checkMyMethodExists(Zu).exists||await this.glue.interop.register(Zu,e)}async registerMainClientMethod(e){this.checkMyMethodExists(Xu).exists||await this.glue.interop.register(Xu,e)}async clearMainProviderMethod(){await this.glue.interop.unregister(Zu)}async sendClientResultsBatch(e,t,n){const r={items:e.results,provider:e.provider,queryId:n,status:uu};await this.glue.interop.invoke(Xu,r,{instance:t})}async sendClientQueueCompleted(e,t){const n={items:[],queryId:t,status:lu};await this.glue.interop.invoke(Xu,n,{instance:e})}async sendClientErrorMessage(e,t,n,r){const o={items:[],provider:r,errorMessage:e,queryId:n,status:cu};await this.glue.interop.invoke(Xu,o,{instance:t})}async sendQueryRequest(e,t){if(!t.length)return[];const n=t.map(e=>({instance:e.interopId})),r={operation:hu,apiVersion:"1",...e};return((await this.glue.interop.invoke(Zu,r,n)).all_return_values||[]).map(e=>({interopId:e.executed_by?.instance,queryId:e.returned.id}))}async sendQueryCancelRequest(e,t){const n={operation:pu,id:e.id};await this.glue.interop.invoke(Zu,n,t)}async getAllProvidersInfo(){if(this.glue.interop.methods().every(e=>e.name!==Zu))return[];const e={operation:du},t=await this.glue.interop.invoke(Zu,e,"all");return(t.all_return_values||[]).map(e=>{const n=void 0===e.returned.apiVersion?{supportedTypes:e.returned.supportedTypes,apiVersion:e.returned.apiVersion,providers:[{interopId:e.executed_by?.instance,id:e.executed_by?.instance,name:e.executed_by?.instance,appName:t.executed_by?.application,types:e.returned.supportedTypes.map(e=>({name:e}))}]}:e.returned;return{interopId:e.executed_by?.instance,info:n}})}checkMyMethodExists(e){return{exists:this.glue.interop.methodsForInstance({instance:this.glue.interop.instance.instance}).some(t=>t.name===e)}}}class tc{logger;glueController;clientController;providerController;constructor(e,t,n,r){this.logger=e,this.glueController=t,this.clientController=n,this.providerController=r}setDebounceMS(e){this.logger.info(`[${e.commandId}] Starting setDebounceMS operation with duration ${e.milliseconds}`),this.clientController.setDebounceMS(e),this.logger.info(`[${e.commandId}] Operation setDebounceMS with duration ${e.milliseconds} completed`)}getDebounceMS(e){return this.logger.info(`[${e.commandId}] Starting getDebounceMS operation.`),this.clientController.getDebounceMS(e)}async query(e){if(this.logger.info(`[${e.commandId}] Starting query operation with config ${JSON.stringify(e.queryConfig)}`),Array.isArray(e.queryConfig.providers)&&!e.queryConfig.providers.length)throw new Error("Cannot sent a query with a defined empty array of providers, because this is an impossible query for complete.");if(Array.isArray(e.queryConfig.types)&&!e.queryConfig.types.length)throw new Error("Cannot sent a query with a defined empty array of types, because this is an impossible query for complete.");const t=await this.clientController.query(e);return this.logger.info(`[${e.commandId}] Operation query with config ${JSON.stringify(e.queryConfig)} completed.`),t}async registerProvider(e){this.logger.info(`[${e.commandId}] Starting registerProvider operation with config ${JSON.stringify(e.config)}`);const t=await this.providerController.processRegisterProvider(e);return this.logger.info(`[${e.commandId}] Operation registerProvider with config ${JSON.stringify(e.config)} completed.`),t}async providers(e){this.logger.info(`[${e.commandId}] Starting providers operation.`);const t=(await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers);return this.logger.info(`[${e.commandId}] Operation providers completed.`),t}async types(e){this.logger.info(`[${e.commandId}] Starting types operation.`);const t=(await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers).filter(e=>!!e.types).flatMap(e=>e.types),n=[...new Set(t)];return this.logger.info(`[${e.commandId}] Operation types completed.`),n}}const nc=e=>"string"==typeof e?e:e.message?JSON.stringify(e.message):JSON.stringify(e);class rc{logger;glueController;sequelizer;limitsTracker;modelsFactory;registry=au();providersModels={};activeQueries={};constructor(e,t,n,r,o){this.logger=e,this.glueController=t,this.sequelizer=n,this.limitsTracker=r,this.modelsFactory=o}async processRegisterProvider(e){const{config:t,commandId:n}=e;this.logger.info(`[${n}] enqueueing the provider registration process with config: ${JSON.stringify(t)}`);const r=await this.sequelizer.enqueue(async()=>{if((await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers).some(e=>e&&e.name===t.name))throw new Error(`Cannot register a new provider with name: ${t.name}, because there already is a provider with this name`);await this.glueController.registerMainProviderMethod(this.handleSearchQueryRequest.bind(this));const e={id:ou(10),name:t.name,interopId:this.glueController.myInteropId,appName:this.glueController.myAppName,types:t.types},n=this.modelsFactory.buildProviderModel(e,this);return this.providersModels[e.id]=n,n.exposeFacade()});return this.logger.info(`[${n}] the provider with name: ${t.name} has been registered.`),r}processProviderOnQuery(e){return this.registry.add(`on-search-query-${e.id}`,e.callback)}processProviderOnQueryCancel(e){return this.registry.add(`on-cancel-query-${e.id}`,e.callback)}async processProviderUnregister(e){this.logger.info(`[${e.commandId}] enqueueing the provider un-registration with id: ${e.id}`),await this.sequelizer.enqueue(async()=>{this.cleanUpProvider(e.id,e.commandId),Object.keys(this.providersModels).length||await this.glueController.clearMainProviderMethod()}),this.logger.info(`[${e.commandId}] the provider un-registration with id: ${e.id} completed`)}async processProviderQueryDone(e){const{commandId:t,identification:n}=e;this.activeQueries[n.queryId]?.publisher.syncSuspendProvider(n.providerId,t),await this.sequelizer.enqueue(async()=>{this.logger.trace(`[${t}] Processing a query done command with identification: ${JSON.stringify(n)}`);const e=this.activeQueries[n.queryId];e?(await this.cleanUpProviderQuery(n.queryId,n.providerId,t),e.providersAtWork.length?this.logger.trace(`[${t}] Query done command completed, but there are more providers still at work.`):(this.cleanUpQuery(n.queryId,t),this.logger.trace(`[${t}] Query is completed, signalling.`))):this.logger.warn(`[${t}] Cannot mark provider: ${n.providerId} done with query ${n.queryId}, because there is no active query with this id`)})}processProviderQueryError(e){const{commandId:t,identification:n,error:r}=e;return this.logger.warn(`[${t}] Processing an error sent by provider: ${n.providerId} for query id: ${n.queryId} -> ${r}`),this.activeQueries[n.queryId]?.publisher.markProviderError(e),this.processProviderQueryDone(e)}processProviderQueryResult(e){const{commandId:t,identification:n}=e,r=this.activeQueries[n.queryId];if(!r){const t=`Will not send this result to the client, because there is no active query with id ${n.queryId}. Most likely this query was cancelled.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}if(r.publisher.checkProviderSuspended(n.providerId)){const t=`Will not send this result to the client, because there is no info about this provider in the active query with id ${n.queryId}. Most likely this query was marked as done by this provider already.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}const o=r.requestedTypes;if(o&&o.every(t=>t.name!==e.result.type.name)){const t=`Will not send this result to the client, because this result has a defined type: ${e.result.type.name} which is not in the explicitly requested list of types by the client.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}const i=this.limitsTracker.testResultLimit(e);if(i?.maxLimitHit){const t=`Will not process this result from provider ${e.identification.providerId}, because this provider has reached the max results limit set by the client. This provider cannot send more result, marking it as done.`;throw this.logger.info(t),setTimeout(()=>this.processProviderQueryDone(e),0),new Error(t)}if(i?.maxLimitPerTypeHit){const t=`Will not process this result from provider ${e.identification.providerId}, because this provider has reached the max results limit per type as set by the client.`;throw this.logger.info(t),new Error(t)}this.logger.trace(`[${t}] An active query for query ${n.queryId} was found and the provider is within limits, queueing the result`),this.limitsTracker.update(e),r.publisher.queueResult(e),this.logger.trace(`[${t}] The query result was queued successfully.`)}async handleSearchQueryRequest(e,t){const{operation:n}=e,r=Bu.runWithException(n),o=ou(10);switch(r){case du:return this.handleInfoOperation({commandId:o});case hu:return this.handleSearchOperation({args:e,commandId:o},t);case pu:return this.handleCancelOperation({args:e,commandId:o});default:throw new Error(`Unrecognized operation: ${n}`)}}async handleInfoOperation(e){this.logger.info(`[${e.commandId}] handling an info operation`);const t=Object.values(this.providersModels).flatMap(e=>e.myProviderData.types||[]),n=[...new Set(t)];Object.values(this.providersModels).some(e=>!e.myProviderData.types)&&n.push({name:"*"});const r=Object.values(this.providersModels).map(e=>e.myProviderData),o={supportedTypes:n.map(e=>e.name),providers:r,apiVersion:"1"};return this.logger.info(`[${e.commandId}] responding to an info operation with: ${JSON.stringify(o)}`),o}async handleSearchOperation(e,t){const n=e.commandId,r=this.generateQueryId();this.logger.info(`[${n}] Processing search operation with queryId: ${r} request details: ${JSON.stringify(e.args)}`);const o=this.checkRequestLegacy(e.args),i=this.prepareRequest(e.args,o,n);return this.logger.info(`[${n}] Search operation with queryId: ${r} is validated. Creating an active query and enqueueing calling the providers.`),this.activeQueries[r]={queryId:r,callerInstanceId:t.instance,providersAtWork:[],requestedTypes:i.types,publisher:this.modelsFactory.buildPublisher(t.instance,r,o),staleTimer:this.setClearStaleQueryTimer(r)},i.providerLimits&&this.limitsTracker.enableTracking(i.providerLimits,r),setTimeout(()=>{this.sequelizer.enqueue(async()=>{try{this.logger.info(`[${n}] Calling the providers.`),this.callProviders(i,r,n)}catch(e){this.logger.error(`[${n}] Error calling the providers: ${nc(e)}`)}})},0),this.logger.info(`[${n}] Search operation with queryID: ${r} processed successfully.`),{id:r}}async handleCancelOperation(e){await this.sequelizer.enqueue(async()=>{const t=Uu.run(e.args);if(!t.ok){const n=`Cannot process a cancel request, because of validation error: ${JSON.stringify(t.error)}`;throw this.logger.warn(`[${e.commandId}] ${n}`),new Error(n)}const n=t.result,r=this.activeQueries[n.id];r&&(clearTimeout(r.staleTimer),r.publisher.cancel(e.commandId),delete this.activeQueries[n.id],r.providersAtWork.forEach(e=>this.registry.execute(`on-cancel-query-${e.myProviderData.id}`,{id:n.id})))})}generateQueryId(){const e=ou(10);return this.activeQueries[e]?this.generateQueryId():e}translateLegacySearchRequest(e){return{search:e.search,types:e.types?.map(e=>({name:e})),providerLimits:{maxResults:e.limit,maxResultsPerType:e.categoryLimit}}}checkRequestLegacy(e){return void 0===e.apiVersion}callProviders(e,t,n){let r=e.providers?this.getFilteredProviderModels(e.providers):Object.values(this.providersModels);this.logger.trace(`[${n}] initial providers filtration yielded: ${JSON.stringify(r.map(e=>e.myProviderData.name).join(", "))}`),r=e.types?this.getFilteredProvidersBySearchTypes(r,e.types):r,this.logger.trace(`[${n}] search type providers filtration yielded: ${JSON.stringify(r.map(e=>e.myProviderData.name).join(", "))}`),this.activeQueries[t].publisher.configureProviders(r),this.activeQueries[t].providersAtWork.push(...r),r.forEach(r=>this.callProvider(r,e,t,n))}callProvider(e,t,n,r){const o=this.modelsFactory.buildProviderQueryModel(t,{queryId:n,providerId:e.myProviderData.id},this).exposeFacade();this.logger.info(`[${r}] The query facade for provider: ${e.myProviderData.id} with name ${e.myProviderData.name} is ready, raising the event for query ID: ${n}.`),this.registry.execute(`on-search-query-${e.myProviderData.id}`,o)}getFilteredProviderModels(e){const t=e.reduce((e,t)=>(this.providersModels[t.id]&&e.push(this.providersModels[t.id]),e),[]);return t}getFilteredProvidersBySearchTypes(e,t){return e.filter(e=>!e.myProviderData.types||!e.myProviderData.types.length||e.myProviderData.types?.some(e=>t.some(t=>t.name===e.name)))}setClearStaleQueryTimer(e){return setTimeout(()=>{const t=ou(10);this.logger.info(`[${t}] Stale query timer is activated for queryId: ${e}`),this.activeQueries[e]?(this.logger.info(`[${t}] force-marking the query as done`),this.cleanUpQuery(e,t),this.logger.info(`[${t}] the stale query was cleared.`)):this.logger.info(`[${t}] No active query was found, this was a false activation.`)},9e5)}prepareRequest(e,t,n){const r=t?this.translateLegacySearchRequest(e):e,o=Nu.run(r);if(!o.ok){const e=`Cannot process a search request, because of validation error: ${JSON.stringify(o.error)}`;throw this.logger.warn(`[${n}] ${e}`),new Error(e)}return o.result}cleanUpQuery(e,t){const n=this.activeQueries[e];clearTimeout(n.staleTimer),n.publisher.cleanPublisher(t),delete this.activeQueries[e],this.limitsTracker.cleanTracking(e)}cleanUpProvider(e,t){this.registry.clearKey(`on-search-query-${e}`),this.registry.clearKey(`on-cancel-query-${e}`),delete this.providersModels[e];Object.values(this.activeQueries).filter(t=>!t.publisher.checkProviderSuspended(e)).forEach(n=>{this.processProviderQueryDone({identification:{queryId:n.queryId,providerId:e},commandId:t})})}async cleanUpProviderQuery(e,t,n){const r=this.activeQueries[e];r?(r.providersAtWork=r.providersAtWork.filter(e=>e.myProviderData.id!==t),await r.publisher.markProviderDone(t,n)):this.logger.warn(`[${n}] Cannot clean up a provider query ${e} for provider ${t} because there is no such active query`)}}class oc{main;constructor(e){this.main=e}exposeApi(){const e={version:"3.0.0",setDebounceMS:this.setDebounceMS.bind(this),getDebounceMS:this.getDebounceMS.bind(this),listProviders:this.providers.bind(this),listTypes:this.types.bind(this),query:this.query.bind(this),registerProvider:this.registerProvider.bind(this)};return Object.freeze(e)}setDebounceMS(e){Lu.runWithException(e);const t=ou(10);return this.main.setDebounceMS({milliseconds:e,commandId:t})}getDebounceMS(){const e=ou(10);return this.main.getDebounceMS({commandId:e})}async providers(){const e=ou(10);return this.main.providers({commandId:e})}async types(){const e=ou(10);return this.main.types({commandId:e})}async query(e){const t=Nu.runWithException(e),n=ou(10);return this.main.query({queryConfig:t,commandId:n})}async registerProvider(e){const t=ju.runWithException(e),n=ou(10);return this.main.registerProvider({config:t,commandId:n})}}class ic{minSequenceInterval;queue=[];isExecutingQueue=!1;constructor(e=0){this.minSequenceInterval=e}enqueue(e){return new Promise((t,n)=>{this.queue.push({action:e,resolve:t,reject:n}),this.executeQueue()})}async executeQueue(){if(!this.isExecutingQueue){for(this.isExecutingQueue=!0;this.queue.length;){const e=this.queue.shift();if(!e)return void(this.isExecutingQueue=!1);try{const t=await e.action();e.resolve(t)}catch(t){e.reject(t)}await this.intervalBreak()}this.isExecutingQueue=!1}}intervalBreak(){return new Promise(e=>setTimeout(e,this.minSequenceInterval))}}class sc{limitsLookup={};limitsData={};enableTracking(e,t){this.limitsLookup[t]={},this.limitsData[t]={maxResults:e.maxResults?e.maxResults:Number.MAX_SAFE_INTEGER,maxResultsPerType:e.maxResultsPerType?e.maxResultsPerType:Number.MAX_SAFE_INTEGER}}testResultLimit(e){const t=this.limitsLookup[e.identification.queryId],n=this.limitsData[e.identification.queryId];if(!t||!n)return;let r=t[e.identification.providerId];if(r||(r={total:0},t[e.identification.providerId]=r),r.total+1>n.maxResults)return{maxLimitHit:!0};const o=e.result.type.name;return o&&(r[o]||0)+1>n.maxResultsPerType?{maxLimitPerTypeHit:!0}:void 0}update(e){const t=this.limitsLookup[e.identification.queryId],n=this.limitsData[e.identification.queryId];if(!t||!n)return;const r=t[e.identification.providerId];r.total+=1;const o=e.result.type.name;o&&(r[o]=r[o]?r[o]+1:1)}cleanTracking(e){delete this.limitsLookup[e],delete this.limitsData[e]}}class ac{controller;logger;masterQueryId;constructor(e,t,n){this.controller=e,this.logger=t,this.masterQueryId=n}exposeFacade(){const e={cancel:this.cancel.bind(this),onResults:this.onResults.bind(this),onCompleted:this.onCompleted.bind(this),onError:this.onError.bind(this)};return Object.freeze(e)}async cancel(){const e=ou(10);this.logger.info(`[${e}] received a valid query cancel request, forwarding to the controller.`),await this.controller.cancelQuery(this.masterQueryId,e),this.logger.info(`[${e}] the cancel request was completed.`)}onResults(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onResults request, forwarding to the controller.`);const n=this.controller.processClientOnResults({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onResults request was completed.`),n}onCompleted(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onCompleted request, forwarding to the controller.`);const n=this.controller.processClientOnCompleted({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onCompleted request was completed.`),n}onError(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onError request, forwarding to the controller.`);const n=this.controller.processClientOnError({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onError request was completed.`),n}}class lc{myData;controller;logger;constructor(e,t,n){this.myData=e,this.controller=t,this.logger=n}get id(){return this.myData.id}get name(){return this.myData.name}get appName(){return this.myData.appName}get types(){return this.myData.types}get myProviderData(){return Object.assign({},this.myData)}exposeFacade(){const e={interopId:this.myData.interopId,id:this.id,name:this.name,appName:this.appName,types:this.types,onQuery:this.onQuery.bind(this),onQueryCancel:this.onQueryCancel.bind(this),unregister:this.unregister.bind(this)};return Object.freeze(e)}onQuery(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid onQuery request, forwarding to the controller.`);const n=this.controller.processProviderOnQuery({callback:e,id:this.id,commandId:t});return this.logger.info(`[${t}] the onQuery request was completed.`),n}onQueryCancel(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid onQueryCancel request, forwarding to the controller.`);const n=this.controller.processProviderOnQueryCancel({callback:e,id:this.id,commandId:t});return this.logger.info(`[${t}] the onQueryCancel request was completed.`),n}async unregister(){const e=ou(10);this.logger.info(`[${e}] received a valid unregister request, forwarding to the controller.`),await this.controller.processProviderUnregister({id:this.id,commandId:e}),this.logger.info(`[${e}] the unregister request was completed.`)}}class uc{myData;controller;logger;identification;constructor(e,t,n,r){this.myData=e,this.controller=t,this.logger=n,this.identification=r}get id(){return this.identification.queryId}get search(){return this.myData.search}get providers(){return this.myData.providers}get types(){return this.myData.types}get providerLimits(){return this.myData.providerLimits}get myQueryData(){return Object.assign({},this.myData)}exposeFacade(){const e={id:this.id,search:this.search,providers:this.providers,types:this.types,providerLimits:this.providerLimits,sendResult:this.sendResult.bind(this),error:this.error.bind(this),done:this.done.bind(this)};return Object.freeze(e)}sendResult(e){Hu.runWithException(e);const t=ou(10);return this.logger.trace(`[${t}] Received a valid result, forwarding to the controller`),this.controller.processProviderQueryResult({identification:this.identification,result:e,commandId:t})}error(e){const t=ou(10);Ru.runWithException(e),this.logger.trace(`[${t}] Received a valid error, forwarding to the controller`),this.controller.processProviderQueryError({identification:this.identification,error:e,commandId:t}).catch(e=>this.logger.warn(`Error processing the error signal for this provider: ${this.id}, error: ${nc(e)}`))}done(){const e=ou(10);this.logger.trace(`[${e}] Received a valid done, forwarding to the controller`),this.controller.processProviderQueryDone({identification:this.identification,commandId:e}).catch(e=>this.logger.warn(`Error processing the done signal for this provider: ${this.identification.providerId}, error: ${nc(e)}`))}}class cc{sequelizer;glueController;logger;clientInstanceId;queryId;isLegacy;queues={};constructor(e,t,n,r,o,i){this.sequelizer=e,this.glueController=t,this.logger=n,this.clientInstanceId=r,this.queryId=o,this.isLegacy=i}checkProviderSuspended(e){return!!this.queues[e]&&!!this.queues[e].suspended}syncSuspendProvider(e,t){const n=this.queues[e];n?n.suspended=!0:this.logger.warn(`[${t}] Cannot suspend provider: ${e}, because there is no provider queue. This happens when the provider queue was already cancelled or completed`)}configureProviders(e){e.forEach(e=>{this.queues[e.myProviderData.id]={providerData:e,pendingResults:[]}})}queueResult(e){const{commandId:t,identification:n}=e;this.logger.trace(`[${t}] Queuing a new result from provider: ${n.providerId}`);const r=this.queues[n.providerId];if(!r)return void this.logger.warn(`[${t}] Cannot queue this result, because there is no provider queue. This happens when the provider queue was already cancelled or completed`);const o=this.isLegacy?this.translateLegacySearchItem(e.result):e.result;if(r.pendingResults.push(o),clearTimeout(r.flushTimer),10===r.pendingResults.length)return this.logger.trace(`[${t}] Reached the limit in the queue buffer, flushing to the client.`),void this.flushProviderQueue(n.providerId,t);this.logger.trace(`[${t}] The limit in the queue buffer is not reached yet, setting a flush timer.`),r.flushTimer=setTimeout(()=>{this.logger.trace(`[${t}] Reached the time limit in the queue buffer, flushing to the client.`),this.flushProviderQueue(n.providerId,t)},100)}cancel(e){this.logger.trace(`[${e}] Cancelling queue ${this.queryId}.`),Object.values(this.queues).forEach(e=>clearTimeout(e.flushTimer)),this.queues={},this.logger.trace(`[${e}] Queue ${this.queryId} publisher cancelled.`)}async markProviderDone(e,t){this.logger.trace(`[${t}] Marking provider ${e} as done.`);const n=this.queues[e];n?(clearTimeout(n.flushTimer),await this.flushProviderQueue(e,t),delete this.queues[e],this.logger.trace(`[${t}] Provider ${e} marked as done.`)):this.logger.info(`[${t}] Cannot mark this queue as done, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent an error`)}markProviderError(e){const t=this.queues[e.identification.providerId];t?this.glueController.sendClientErrorMessage(e.error,this.clientInstanceId,this.queryId,t.providerData.myProviderData).catch(t=>this.logger.warn(`[${e.commandId}] The client errored when handling error message for query: ${this.queryId} -> ${nc(t)}`)):this.logger.warn(`[${e.commandId}] Cannot mark this provider as errored, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent and error`)}cleanPublisher(e){Object.values(this.queues).forEach(e=>clearTimeout(e.flushTimer)),this.queues={},this.glueController.sendClientQueueCompleted(this.clientInstanceId,this.queryId).catch(t=>this.logger.warn(`[${e}] The client errored when handling search end message for query: ${this.queryId} -> ${nc(t)}`))}async flushProviderQueue(e,t){await this.sequelizer.enqueue(async()=>{const n=this.queues[e];if(!n)return void this.logger.warn(`[${t}] Cannot flush this queue, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent and error`);if(!n.pendingResults.length)return void this.logger.info(`[${t}] This provider does not have any pending results to flush.`);const r={results:n.pendingResults,provider:n.providerData.myProviderData};n.pendingResults=[];try{await this.glueController.sendClientResultsBatch(r,this.clientInstanceId,this.queryId)}catch(e){this.logger.warn(`[${t}] The client errored when handling search results for query: ${this.queryId} -> ${nc(e)}`)}})}translateLegacySearchItem(e){return{type:e.type.name,category:e.type.displayName,id:e.id,displayName:e.displayName,description:e.description,iconURL:e.iconURL,action:e.action}}}class dc{glueController;glue;flushSequelizer;constructor(e,t,n){this.glueController=e,this.glue=t,this.flushSequelizer=n}buildProviderModel(e,t){return new lc(e,t,this.glue.logger.subLogger(`search.provider.model.${e.name}`))}buildProviderQueryModel(e,t,n){return new uc(e,n,this.glue.logger.subLogger(`search.provider.${t.providerId}.query.${t.queryId}`),t)}buildPublisher(e,t,n){return new cc(this.flushSequelizer,this.glueController,this.glue.logger.subLogger(`search.results.publisher.${t}`),e,t,n)}buildClientQueryModel(e,t){return new ac(t,this.glue.logger.subLogger(`search.provider.model.${e}`),e)}}class hc{glue;config;_glueController;_facade;_mainController;_providerController;_clientController;_asyncSequelizer;_flushSequelizer;_limitsTracker;_modelFactory;constructor(e,t){this.glue=e,this.config=t}get glueController(){return this._glueController||(this._glueController=new ec(this.glue)),this._glueController}get main(){return this._mainController||(this._mainController=new tc(this.glue.logger.subLogger("search.main.controller"),this.glueController,this.clientController,this.providerController)),this._mainController}get clientController(){return this._clientController||(this._clientController=new Yu(this.glue.logger.subLogger("search.client.controller"),this.glueController,this.modelFactory)),this._clientController}get providerController(){return this._providerController||(this._providerController=new rc(this.glue.logger.subLogger("search.provider.controller"),this.glueController,this.sequelizer,this.limitsTracker,this.modelFactory)),this._providerController}get facade(){return this._facade||(this._facade=new oc(this.main)),this._facade}get sequelizer(){return this._asyncSequelizer||(this._asyncSequelizer=new ic(10)),this._asyncSequelizer}get flushSequelizer(){return this._flushSequelizer||(this._flushSequelizer=new ic(10)),this._flushSequelizer}get limitsTracker(){return this._limitsTracker||(this._limitsTracker=new sc),this._limitsTracker}get modelFactory(){return this._modelFactory||(this._modelFactory=new dc(this.glueController,this.glue,this.flushSequelizer)),this._modelFactory}}const pc=async(e,t)=>{const n=new hc(e,t);e.search=n.facade.exposeApi()};function gc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function fc(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}"undefined"!=typeof window&&(window.IOSearch=pc),fc.default=fc;var mc=gc(fc),yc=function(e){return{ok:!0,result:e}},wc=function(e){return{ok:!1,error:e}},vc=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:yc(e(t.result,n.result))},bc=function(e,t){return!0===t.ok?t:wc(e(t.error))},Cc=function(){return Cc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Cc.apply(this,arguments)};function Sc(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Sc(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Sc(e[r[n]],t[r[n]]))return!1}return!0}}var Ic=function(e){return Array.isArray(e)},kc=function(e){return"object"==typeof e&&null!==e&&!Ic(e)},Tc=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},xc=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},Ac=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Cc({at:e+(n||"")},r)},Ec=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return bc(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?yc(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?yc(e):wc({message:Tc("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?yc(e):wc({message:Tc("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?yc(e):wc({message:Tc("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Sc(e,t)?yc(t):wc({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(kc(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?wc({message:"the key '"+r+"' is required but was not present"}):wc(Ac("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return yc(n)}return kc(e)?yc(e):wc({message:Tc("an object",e)})})},e.array=function(t){return new e(function(e){return Ic(e)&&t?e.reduce(function(e,n,r){return vc(function(e,t){return e.concat([t])},e,function(e,n){return bc(function(e){return Ac("["+n+"]",e)},t.decode(e))}(n,r))},yc([])):Ic(e)?yc(e):wc({message:Tc("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ic(e)){if(e.length!==t.length)return wc({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return wc(Ac("["+r+"]",o.error));n[r]=o.result}return yc(n)}return wc({message:Tc("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return vc(Object.assign,t,n.decode(e))},yc({}))})},e.anyJson=function(){return new e(function(e){return yc(e)})},e.unknownJson=function(){return new e(function(e){return yc(e)})},e.dict=function(t){return new e(function(e){if(kc(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return wc(Ac("."+r,o.error));n[r]=o.result}return yc(n)}return wc({message:Tc("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?yc(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return wc({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return yc(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return wc({at:xc(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!kc(r))return wc({at:xc(t.slice(0,o+1)),message:Tc("an object",r)});if("number"==typeof t[o]&&!Ic(r))return wc({at:xc(t.slice(0,o+1)),message:Tc("an array",r)});r=r[t[o]]}return bc(function(e){return void 0===r?{at:xc(t),message:"path does not exist"}:Ac(xc(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return yc(t)})},e.fail=function(t){return new e(function(e){return wc({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),Wc=Ec.string,Oc=Ec.number,Dc=Ec.boolean,_c=Ec.anyJson;Ec.unknownJson;var Pc=Ec.constant,Rc=Ec.object,Lc=Ec.array;Ec.tuple,Ec.dict;var Fc=Ec.optional,Mc=Ec.oneOf;Ec.union;var $c=Ec.intersection;Ec.withDefault,Ec.valueAt,Ec.succeed,Ec.fail;var Nc=Ec.lazy;const jc=Wc().where(e=>e.length>0,"Expected a non-empty string"),Bc=Oc().where(e=>e>=0,"Expected a non-negative number"),qc=Oc().where(e=>e>0,"Expected a positive number"),Uc=Mc(Pc("keepInside"),Pc("autoEject")),zc=Rc({inWorkspace:Dc()}),Gc=Rc({base64Image:jc}),Hc=Rc({icon:Gc,frameId:jc}),Vc=Mc(Pc("workspace"),Pc("row"),Pc("column"),Pc("group")),Qc=Mc(Pc("row"),Pc("column"),Pc("group")),Jc=Mc(Pc("maximized"),Pc("minimized"),Pc("normal")),Kc=Mc(Pc("workspace")),Yc=(e,t)=>{const n=typeof e;if(t&&"function"!==n&&"undefined"!==n)throw new Error(`Provided argument must be either undefined or of type function, provided: ${n}`);if(!t&&"function"!==n)throw new Error(`Provided argument must be of type function, provided: ${n}`)},Zc=Fc(Rc({saveLayout:Fc(Dc())})),Xc=Rc({name:jc}),ed=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc())}),td=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),allowDrop:Fc(Dc()),allowDropHeader:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropBottom:Fc(Dc()),showMaximizeButton:Fc(Dc()),showEjectButton:Fc(Dc()),showAddWindowButton:Fc(Dc())}),nd=Rc({minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowDrop:Fc(Dc()),allowSplitters:Fc(Dc()),isPinned:Fc(Dc()),maximizationBoundary:Fc(Dc())}),rd=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),allowDrop:Fc(Dc()),allowSplitters:Fc(Dc()),isPinned:Fc(Dc()),maximizationBoundary:Fc(Dc())}),od=Rc({type:Fc(Pc("window")),appName:Fc(jc),windowId:Fc(jc),context:Fc(_c()),config:Fc(ed)}),id=Rc({type:Pc("window"),appName:Fc(jc),windowId:Fc(jc),context:Fc(_c()),config:Fc(ed)}),sd=Fc(Rc({type:Fc(Qc),children:Fc(Nc(()=>Lc(Mc(od,sd)))),config:Fc(_c())})),ad=Rc({type:Pc("column"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(rd)}),ld=Rc({type:Pc("row"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(nd)}),ud=Rc({type:Pc("group"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(td)}),cd=Mc(ud,ad,ld);Mc(Wc().where(e=>"maximized"===e.toLowerCase(),"Expected a case insensitive variation of 'maximized'"),Wc().where(e=>"normal"===e.toLowerCase(),"Expected a case insensitive variation of 'normal'"));const dd=Rc({bounds:Fc(Rc({left:Fc(Oc()),top:Fc(Oc()),width:Fc(Bc),height:Fc(Bc)})),frameId:Fc(jc)}),hd=Mc(Pc("direct"),Pc("delayed"),Pc("lazy")),pd=Fc(Rc({app:Fc(jc),context:Fc(_c()),loadingStrategy:Fc(hd),title:Fc(jc),reuseWorkspaceId:Fc(jc),frameId:Fc(jc),applicationName:Fc(jc),lockdown:Fc(Dc()),activateFrame:Fc(Dc()),newFrame:Fc(Mc(dd,Dc())),noTabHeader:Fc(Dc()),inMemoryLayout:Fc(Dc()),icon:Fc(jc),isPinned:Fc(Dc()),isSelected:Fc(Dc()),positionIndex:Fc(Bc),allowSystemHibernation:Fc(Dc())})),gd=Rc({name:jc,restoreOptions:Fc(pd)}),fd=Rc({children:Fc(Lc(Mc(od,cd))),context:Fc(_c()),config:Fc(Rc({title:Fc(jc),position:Fc(Bc),isFocused:Fc(Dc()),noTabHeader:Fc(Dc()),reuseWorkspaceId:Fc(jc),loadingStrategy:Fc(hd),allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),showCloseButton:Fc(Dc()),allowSplitters:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),showEjectButtons:Fc(Dc()),showAddWindowButtons:Fc(Dc()),icon:Fc(jc),isPinned:Fc(Dc()),isSelected:Fc(Dc()),positionIndex:Fc(Bc),windowDragMode:Fc(Uc)})),frame:Fc(Rc({activate:Fc(Dc()),reuseFrameId:Fc(jc),applicationName:Fc(jc),newFrame:Fc(Mc(Dc(),dd))}))}),md=Rc({workspaceId:jc}),yd=Rc({name:jc,restoreOptions:Fc(pd)}),wd=Fc(Rc({applicationName:Fc(Wc()),frameConfig:Fc(dd),context:Fc(Rc()),layoutComponentId:Fc(jc)})),vd=Rc({workspaces:Lc(Mc(Fc(fd),Fc(yd)))}),bd=Rc({frameId:jc,workspaces:Lc(Mc(fd,yd))}),Cd=Rc({type:Vc,definition:Fc(Mc(fd,sd))}),Sd=$c(fd,Rc({saveConfig:Fc(Rc({saveLayout:Fc(Dc())}))})),Id=Rc({itemId:jc}),kd=Rc({context:Fc(Rc())}),Td=Rc({id:jc,isFocused:Fc(Dc()),isInitialized:Fc(Dc()),initializationContext:Fc(kd)});Rc({type:Qc,id:jc,frameId:jc,workspaceId:jc,positionIndex:Oc()});const xd=Mc(Pc("frame"),Pc("workspace"),Pc("container"),Pc("window")),Ad=Rc({type:xd,branch:jc}),Ed=Mc(Pc("opened"),Pc("closing"),Pc("closed"),Pc("focus"),Pc("added"),Pc("loaded"),Pc("removed"),Pc("childrenUpdate"),Pc("containerChange"),Pc("maximized"),Pc("restored"),Pc("minimized"),Pc("normal"),Pc("selected"),Pc("lock-configuration-changed"),Pc("hibernated"),Pc("resumed")),Wd=Rc({frameId:jc,title:jc,positionIndex:Bc,name:jc,layoutName:Fc(jc),isHibernated:Fc(Dc()),isSelected:Fc(Dc()),allowDrop:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),allowSplitters:Fc(Dc()),showCloseButton:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),showAddWindowButtons:Fc(Dc()),showEjectButtons:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),widthInPx:Fc(Oc()),heightInPx:Fc(Oc()),isPinned:Fc(Dc()),windowDragMode:Fc(Uc),loadingStrategy:Fc(hd)}),Od=Rc({frameId:jc,workspaceId:jc,positionIndex:Oc(),minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc())}),Dd=_c(),_d=$c(Od,Rc({windowId:Fc(jc),isMaximized:Fc(Dc()),isFocused:Dc(),isSelected:Fc(Dc()),title:Fc(Wc()),appName:Fc(jc),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc()),minWidth:Fc(Oc()),minHeight:Fc(Oc()),maxWidth:Fc(Oc()),maxHeight:Fc(Oc()),widthInPx:Fc(Oc()),heightInPx:Fc(Oc()),context:Fc(_c())})),Pd=Rc({id:Fc(jc),config:Dd,children:Fc(Nc(()=>Lc(Ld))),type:Mc(Pc("row"),Pc("column"),Pc("group"))}),Rd=Rc({id:Fc(jc),config:_d,type:Pc("window")}),Ld=Mc(Rd,Pd),Fd=Rc({id:jc,config:Wd,children:Lc(Ld),frameSummary:Td,context:Fc(_c())}),Md=Rc({type:Pc("window"),config:Rc({appName:jc,windowId:Fc(jc),context:Fc(_c()),url:Fc(jc),title:Fc(Wc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc()),minWidth:Fc(Oc()),minHeight:Fc(Oc()),maxWidth:Fc(Oc()),maxHeight:Fc(Oc()),isMaximized:Fc(Dc())})}),$d=Rc({type:Pc("group"),config:_c(),children:Lc(Mc(Md))}),Nd=Rc({type:Pc("column"),config:_c(),children:Lc(Mc($d,Md,Nc(()=>Nd),Nc(()=>jd)))}),jd=Rc({type:Pc("row"),config:_c(),children:Lc(Mc(Nd,$d,Md,Nc(()=>jd)))}),Bd=Rc({name:jc,type:Pc("Workspace"),metadata:Fc(_c()),components:Lc(Rc({type:Pc("Workspace"),application:Fc(Wc()),state:Rc({config:_c(),context:_c(),children:Lc(Mc(jd,Nd,$d,Md))})}))}),qd=Rc({layout:Bd,mode:Mc(Pc("replace"),Pc("merge"))}),Ud=Rc({layouts:Lc(Bd),mode:Mc(Pc("replace"),Pc("merge"))}),zd=Rc({layouts:Lc(Bd)}),Gd=Rc({id:jc,isFocused:Fc(Dc()),isInitialized:Fc(Dc()),initializationContext:Fc(kd)}),Hd=Rc({summaries:Lc(Gd)}),Vd=Rc({id:jc,config:Wd}),Qd=Rc({summaries:Lc(Vd)}),Jd=Rc({id:jc,config:_c(),workspaces:Lc(Fd)}),Kd=Rc({name:jc,applicationName:Fc(Wc())}),Yd=Rc({summaries:Lc(Kd)}),Zd=Rc({windowId:jc}),Xd=_c(),eh=Rc({state:Jc}),th=Rc({top:Oc(),left:Oc(),width:Bc,height:Bc}),nh=Rc({bounds:th}),rh=Rc({icon:Fc(jc)}),oh=Rc({id:Fc(jc)}),ih=Rc({isSupported:Dc()}),sh=Rc({width:Fc(qc),height:Fc(qc),relative:Fc(Dc())}),ah=Rc({top:Fc(Oc()),left:Fc(Oc()),relative:Fc(Dc())}),lh=Rc({itemId:jc}),uh=Rc({allowPrevent:Fc(Dc()),showDialog:Fc(Dc())}),ch=Rc({itemId:jc,closeOptions:Fc(uh)}),dh=Rc({itemId:jc,excludeIds:Fc(Dc())}),hh=Rc({frameId:jc,requestedState:Jc}),ph=Rc({itemId:jc,title:jc}),gh=Rc({itemId:jc,containerId:jc}),fh=$c(lh,sh),mh=Rc({itemId:jc,enabled:Dc()}),yh=$c(lh,ah);Rc({id:jc,type:Qc});const wh=Rc({definition:od,parentId:jc,parentType:Vc}),vh=Rc({definition:cd,parentId:jc,parentType:Vc}),bh=Rc({itemId:jc,windowId:Fc(jc)}),Ch=Rc({live:Dc()}),Sh=Rc({type:Mc(Pc("row"),Pc("column")),workspaceId:jc}),Ih=Rc({type:Mc(Pc("row"),Pc("column")),itemId:jc}),kh=Rc({itemId:jc,config:Dd}),Th=Rc({frameSummary:Td,frameBounds:Fc(th)}),xh=Rc({workspaceSummary:Vd,frameSummary:Td,workspaceSnapshot:Fc(Fd),frameBounds:Fc(th)}),Ah=Rc({containerSummary:kh}),Eh=Rc({windowSummary:Rc({itemId:jc,parentId:jc,config:_d})}),Wh=Rc({name:jc,workspaceId:jc,saveContext:Fc(Dc()),allowMultiple:Fc(Dc()),metadata:Fc(Rc())}),Oh=Rc({allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),allowSplitters:Fc(Dc()),showCloseButton:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),showAddWindowButtons:Fc(Dc()),showEjectButtons:Fc(Dc())}),Dh=Rc({workspaceId:jc,config:Fc(Oh)}),_h=Rc({allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc())}),Ph=Rc({width:Fc(Bc),height:Fc(Bc)}),Rh=Rc({windowPlacementId:jc,config:Fc(_h)}),Lh=Rc({allowDrop:Fc(Dc()),allowSplitters:Fc(Dc())}),Fh=Rc({allowDrop:Fc(Dc()),allowSplitters:Fc(Dc())}),Mh=Rc({allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropBottom:Fc(Dc()),allowDropHeader:Fc(Dc()),showMaximizeButton:Fc(Dc()),showEjectButton:Fc(Dc()),showAddWindowButton:Fc(Dc())}),$h=Rc({itemId:jc,type:Pc("row"),config:Fc(Lh)}),Nh=Rc({itemId:jc,type:Pc("column"),config:Fc(Fh)}),jh=Rc({itemId:jc,type:Pc("group"),config:Fc(Mh)}),Bh=Mc($h,Nh,jh),qh=Rc({workspaceId:jc,icon:Fc(jc)}),Uh=Rc({workspaceId:jc,icon:Fc(jc)}),zh=Fc(Rc({icon:Fc(jc)})),Gh=Rc({shortcut:jc,frameId:jc}),Hh=Rc({shortcut:jc,frameId:jc}),Vh=Rc({frameId:jc}),Qh=Rc({enabled:Dc()}),Jh=Rc({itemId:jc,type:Kc}),Kh=Rc({operation:jc}),Yh=Rc({itemId:jc,dragMode:Uc}),Zh=Rc({itemId:jc,strategy:hd}),Xh=Rc({prevent:Dc()}),ep="T42.Web.Platform.Control",tp="T42.Web.Platform.WSP.Stream",np={control:{name:"T42.Workspaces.Control",isStream:!1},frameStream:{name:"T42.Workspaces.Stream.Frame",isStream:!0},workspaceStream:{name:"T42.Workspaces.Stream.Workspace",isStream:!0},containerStream:{name:"T42.Workspaces.Stream.Container",isStream:!0},windowStream:{name:"T42.Workspaces.Stream.Window",isStream:!0}},rp={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},op={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:Th},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:xh},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:Ah},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:Eh}},ip={shortcutClicked:{name:"shortcutClicked",argsDecoder:Hh,resultDecoder:Xd},frameClosing:{name:"frameClosing",argsDecoder:Vh,resultDecoder:Xh}},sp={ping:{name:"ping",resultDecoder:Ch},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:lh,resultDecoder:zc},createWorkspace:{name:"createWorkspace",resultDecoder:Fd,argsDecoder:Sd},createFrame:{name:"createFrame",resultDecoder:Gd,argsDecoder:wd},initFrame:{name:"initFrame",resultDecoder:Xd,argsDecoder:bd},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Hd},getFrameSummary:{name:"getFrameSummary",resultDecoder:Td,argsDecoder:Id},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Qd},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:Fd,argsDecoder:lh},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Yd},openWorkspace:{name:"openWorkspace",argsDecoder:gd,resultDecoder:Fd},deleteLayout:{name:"deleteLayout",resultDecoder:Xd,argsDecoder:Xc},saveLayout:{name:"saveLayout",resultDecoder:Bd,argsDecoder:Wh},importLayout:{name:"importLayout",resultDecoder:Xd,argsDecoder:qd},importLayouts:{name:"importLayouts",resultDecoder:Xd,argsDecoder:Ud},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:zd},restoreItem:{name:"restoreItem",argsDecoder:lh,resultDecoder:Xd},maximizeItem:{name:"maximizeItem",argsDecoder:lh,resultDecoder:Xd},focusItem:{name:"focusItem",argsDecoder:lh,resultDecoder:Xd},closeItem:{name:"closeItem",argsDecoder:ch,resultDecoder:Xd},resizeItem:{name:"resizeItem",argsDecoder:fh,resultDecoder:Xd},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:mh,resultDecoder:Xd},changeFrameState:{name:"changeFrameState",argsDecoder:hh,resultDecoder:Xd},getFrameState:{name:"getFrameState",argsDecoder:lh,resultDecoder:eh},getFrameBounds:{name:"getFrameBounds",argsDecoder:lh,resultDecoder:nh},moveFrame:{name:"moveFrame",argsDecoder:yh,resultDecoder:Xd},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:dh,resultDecoder:Jd},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:lh,resultDecoder:Zd},ejectWindow:{name:"ejectWindow",argsDecoder:lh,resultDecoder:Zd},setItemTitle:{name:"setItemTitle",argsDecoder:ph,resultDecoder:Xd},moveWindowTo:{name:"moveWindowTo",argsDecoder:gh,resultDecoder:Xd},addWindow:{name:"addWindow",argsDecoder:wh,resultDecoder:bh},addContainer:{name:"addContainer",argsDecoder:vh,resultDecoder:bh},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:Sh,resultDecoder:Xd},bundleItem:{name:"bundleItem",argsDecoder:Ih,resultDecoder:Xd},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:md,resultDecoder:Xd},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:md,resultDecoder:Xd},lockWorkspace:{name:"lockWorkspace",argsDecoder:Dh,resultDecoder:Xd},lockWindow:{name:"lockWindow",argsDecoder:Rh,resultDecoder:Xd},lockContainer:{name:"lockContainer",argsDecoder:Bh,resultDecoder:Xd},pinWorkspace:{name:"pinWorkspace",argsDecoder:qh,resultDecoder:Xd},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:md,resultDecoder:Xd},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:md,resultDecoder:rh},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Uh,resultDecoder:Xd},registerShortcut:{name:"registerShortcut",argsDecoder:Gh,resultDecoder:Xd},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:Gh,resultDecoder:Xd},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Jh,resultDecoder:Xd},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Jh,resultDecoder:Xd},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:oh},operationCheck:{name:"operationCheck",argsDecoder:Kh,resultDecoder:ih},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:Yh,resultDecoder:Xd},setLoadingStrategy:{name:"setLoadingStrategy",argsDecoder:Zh,resultDecoder:Xd},getTaskbarIcon:{name:"getTaskbarIcon",resultDecoder:Gc},setTaskbarIcon:{name:"setTaskbarIcon",argsDecoder:Hc,resultDecoder:Xd},subscribeToFrameClosing:{name:"subscribeToFrameClosing",argsDecoder:lh,resultDecoder:Xd}};class ap{resolve;reject;promise;constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class lp{transport;registry;activeSubscriptions=[];pendingSubScriptions=[];constructor(e,t){this.transport=e,this.registry=t}async createCoreEventSubscription(){await this.transport.coreSubscriptionReady(this.handleCoreEvent.bind(this))}handleCoreSubscription(e){const t=`${e.eventType}-${e.action}`,n=e.scope,r=e.scopeId;return this.registry.add(t,t=>{const o={type:n,id:r},i={frame:t.frameSummary?.id||t.windowSummary?.config.frameId,workspace:t.workspaceSummary?.id||t.windowSummary?.config.workspaceId,container:t.containerSummary?.itemId,window:t.windowSummary?.itemId};this.checkScopeMatch(o,i)&&e.callback(t)})}async send(e,t){const n=Object.values(sp).find(t=>t.name===e);if(!n)throw new Error(`Cannot find definition for operation name: ${e}`);if(n.argsDecoder)try{n.argsDecoder.runWithException(t)}catch(t){throw new Error(`Unexpected internal outgoing validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`)}try{const e=await this.transport.transmitControl(n.name,t);return n.resultDecoder.runWithException(e),e}catch(t){if(t.kind)throw new Error(`Unexpected internal incoming validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`);throw new Error(t.message)}}async subscribe(e){const t=this.getPendingSubscription(e);t&&await t.promise;let n=this.getActiveSubscription(e);const r=this.getRegistryKey(e);if(!n){const t=new ap,r={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(r);try{const r=op[e.eventType],o=await this.transport.subscribe(r.name,this.getBranchKey(e),e.eventType);o.onData(e=>{const t=e.data,n=Ad.run(e.requestArguments),r=Ed.run(t.action);if(!n.ok||!r.ok)return;const o=n.result.type,i=`${o}-${n.result.branch}-${r.result}`,s=op[o].payloadDecoder.run(t.payload);s.ok&&this.registry.execute(i,s.result)}),n={streamType:e.eventType,level:e.scope,levelId:e.scopeId,callbacksCount:0,gdSub:o},this.activeSubscriptions.push(n),t.resolve()}catch(e){throw t.reject(e),e}finally{this.removePendingSubscription(r)}}const o=this.registry.add(r,e.callback);return++n.callbacksCount,()=>{o(),--n.callbacksCount,0===n.callbacksCount&&(n.gdSub.close(),this.activeSubscriptions.splice(this.activeSubscriptions.indexOf(n),1))}}onOperation(e){return this.transport.onInternalMethodInvoked("control",(t,n)=>{const r=t.operation,o=t.data,i=Object.values(ip).find(e=>e.name===r);if(!i)throw new Error(`Cannot find definition for operation name: ${r}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(o)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}e(t,n)})}onOperationWithResponse(e){return this.transport.onInternalMethodInvoked("control",async(t,n)=>{const r=t.operation,o=t.data,i=Object.values(ip).find(e=>e.name===r);if(!i)throw new Error(`Cannot find definition for operation name: ${r}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(o)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}const s=await e(t,n);if(i.resultDecoder)try{i.resultDecoder.runWithException(s)}catch(e){throw new Error(`Unexpected internal outgoing result validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}return s})}checkScopeMatch(e,t){return"global"===e.type||"frame"===e.type&&e.id===t.frame||"workspace"===e.type&&e.id===t.workspace||"container"===e.type&&e.id===t.container||"window"===e.type&&e.id===t.window}handleCoreEvent(e){const t=e.data;try{const e=Ed.runWithException(t.action),n=xd.runWithException(t.type),r=op[n].payloadDecoder.runWithException(t.payload),o=`${n}-${e}`;this.registry.execute(o,r)}catch(e){console.warn(`Cannot handle event with data ${JSON.stringify(t)}, because of validation error: ${e.message}`)}}getBranchKey(e){return"global"===e.scope?e.scope:`${e.scope}_${e.scopeId}`}getRegistryKey(e){return`${e.eventType}-${this.getBranchKey(e)}-${e.action}`}getActiveSubscription(e){return this.activeSubscriptions.find(t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId)}getPendingSubscription(e){return this.pendingSubScriptions.find(t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId)}removePendingSubscription(e){const t=this.pendingSubScriptions.indexOf(e);t>=0&&this.pendingSubScriptions.splice(t,1)}}const up=()=>"undefined"==typeof window||window.glue42gd||window.iodesktop,cp=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class dp{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(up())return await Promise.all(Object.values(np).map(e=>this.verifyMethodLive(e.name))),void await Promise.all(Object.keys(rp).map(e=>this.registerMethod(e)));const t=cp().communicationId;await Promise.all([this.verifyMethodLive(ep,t),this.verifyMethodLive(tp,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=cp().communicationId;this.corePlatformSubPromise=this.agm.subscribe(tp,t?{target:{instance:t}}:void 0),this.corePlatformSubPromise.then(t=>{t.onData(t=>e(t.data))})}async subscribe(e,t,n){const r={branch:t,type:n};let o;try{o=await this.agm.subscribe(e,{arguments:r})}catch(n){const r=`Internal subscription error! Error details: stream - ${e}, branch: ${t}. Internal message: ${n.message}`;throw new Error(r)}return o}async transmitControl(e,t){const n=up()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},r=up()?np.control.name:ep,o=up()?void 0:cp().communicationId;let i;const s=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(n)}. `;try{if(i=await this.agm.invoke(r,n,o?{instance:o}:"best",{methodResponseTimeoutMs:this.defaultTransportTimeout}),!i)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(i.all_return_values)||0===i.all_return_values.length)throw new Error("Received unsupported result from GD - empty values collection")}catch(e){if(e&&e.all_errors&&e.all_errors.length){const t=e.all_errors[0].message;throw new Error(`${s} -> Inner message: ${t}`)}throw new Error(`${s} -> Inner message: ${e.message}`)}return i.all_return_values[0].returned}onInternalMethodInvoked(e,t){return this.registry.add(e,t)}verifyMethodLive(e,t){return(e=>new Promise((t,n)=>{let r=!0;const o=setTimeout(()=>{r&&(r=!1,n("Timeout waiting for the Workspaces communication channels"))},15e3);e().then(e=>{r&&(r=!1,clearTimeout(o),t(e))}).catch(e=>{r&&(r=!1,clearTimeout(o),n(e))})}))(()=>new Promise(n=>{if(this.agm.methods().some(n=>{const r=n.name===e,o=!t||n.getServers().some(e=>e.instance===t);return r&&o}))return void n();const r=this.agm.serverMethodAdded(o=>{const i=o.method,s=o.server,a=!t||s.instance===t;i.name===e&&a&&(r(),n())})}))}registerMethod(e){const t=rp[e];return this.agm.register(t.name,(t,n)=>Promise.all(this.registry.execute(e,t,n)))}}const hp=new WeakMap;class pp{constructor(e,t){const n=t.wrapChildren(e.children);delete e.children,hp.set(this,{base:t,children:n,definition:e})}get type(){return hp.get(this).definition.type}addColumn(e){return hp.get(this).base.add("column",hp.get(this).children,e)}addRow(e){return hp.get(this).base.add("row",hp.get(this).children,e)}addGroup(e){return hp.get(this).base.add("group",hp.get(this).children,e)}addWindow(e){return hp.get(this).base.addWindow(hp.get(this).children,e),this}serialize(){const e=hp.get(this).definition;return e.children=hp.get(this).base.serializeChildren(hp.get(this).children),e}}class gp{getBuilder;constructor(e){this.getBuilder=e}wrapChildren(e){return e.map(e=>"window"===e.type?e:this.getBuilder({type:e.type,definition:e}))}add(e,t,n){const r=sd.runWithException(n),o=this.getBuilder({type:e,definition:r});return t.push(o),o}addWindow(e,t){const n=od.runWithException(t);n.type="window",e.push(n)}serializeChildren(e){return e.map(e=>e instanceof pp?e.serialize():e)}}const fp=new WeakMap;class mp{constructor(e,t,n){const r=t.wrapChildren(e.children);delete e.children,fp.set(this,{base:t,children:r,definition:e,controller:n})}addColumn(e){const t=fp.get(this).children;if(!t.every(e=>e instanceof pp&&"column"===e.type))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return fp.get(this).base.add("column",t,e)}addRow(e){const t=fp.get(this).children;if(!t.every(e=>e instanceof pp&&"row"===e.type))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return fp.get(this).base.add("row",t,e)}addGroup(e){const t=fp.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return fp.get(this).base.add("group",t,e)}addWindow(e){const t=fp.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return fp.get(this).base.addWindow(t,e),this}getChildAt(e){return Bc.runWithException(e),fp.get(this).children[e]}async create(e){const t=Zc.runWithException(e),n=fp.get(this).definition;return n.children=fp.get(this).base.serializeChildren(fp.get(this).children),fp.get(this).controller.createWorkspace(n,t)}}const yp=new WeakMap,wp=e=>yp.get(e).base;class vp{constructor(e){yp.set(this,{base:e})}get type(){return"row"}get id(){return wp(this).getId(this)}get frameId(){return wp(this).getFrameId(this)}get workspaceId(){return wp(this).getWorkspaceId(this)}get positionIndex(){return wp(this).getPositionIndex(this)}get children(){return wp(this).getAllChildren(this)}get parent(){return wp(this).getMyParent(this)}get frame(){return wp(this).getMyFrame(this)}get workspace(){return wp(this).getMyWorkspace(this)}get allowDrop(){return wp(this).getAllowDrop(this)}get allowSplitters(){return wp(this).getAllowSplitters(this)}get minWidth(){return wp(this).getMinWidth(this)}get minHeight(){return wp(this).getMinHeight(this)}get maxWidth(){return wp(this).getMaxWidth(this)}get maxHeight(){return wp(this).getMaxHeight(this)}get width(){return wp(this).getWidthInPx(this)}get height(){return wp(this).getHeightInPx(this)}get isPinned(){return wp(this).getIsPinned(this)}get isMaximized(){return wp(this).getIsMaximized(this)}get maximizationBoundary(){return wp(this).getMaximizationBoundary(this)}addWindow(e){return wp(this).addWindow(this,e,"row")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return wp(this).addParent(this,"group","row",e)}async addColumn(e){if(e?.type&&"column"!==e.type)throw new Error(`Expected a column definition, but received ${e.type}`);return wp(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return wp(this).removeChild(this,e)}maximize(){return wp(this).maximize(this)}restore(){return wp(this).restore(this)}close(){return wp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters}):e;const n=void 0===t?void 0:Lh.runWithException(t);return wp(this).lockContainer(this,n)}async setHeight(e){return Bc.runWithException(e),wp(this).setHeight(this,e)}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await wp(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Qh.runWithException(e);return wp(this).setMaximizationBoundary(this,t)}}const bp=new WeakMap,Cp=e=>bp.get(e).base;class Sp{constructor(e){bp.set(this,{base:e})}get type(){return"column"}get id(){return Cp(this).getId(this)}get frameId(){return Cp(this).getFrameId(this)}get workspaceId(){return Cp(this).getWorkspaceId(this)}get positionIndex(){return Cp(this).getPositionIndex(this)}get children(){return Cp(this).getAllChildren(this)}get parent(){return Cp(this).getMyParent(this)}get frame(){return Cp(this).getMyFrame(this)}get workspace(){return Cp(this).getMyWorkspace(this)}get allowDrop(){return Cp(this).getAllowDrop(this)}get allowSplitters(){return Cp(this).getAllowSplitters(this)}get minWidth(){return Cp(this).getMinWidth(this)}get minHeight(){return Cp(this).getMinHeight(this)}get maxWidth(){return Cp(this).getMaxWidth(this)}get maxHeight(){return Cp(this).getMaxHeight(this)}get width(){return Cp(this).getWidthInPx(this)}get height(){return Cp(this).getHeightInPx(this)}get isPinned(){return Cp(this).getIsPinned(this)}get isMaximized(){return Cp(this).getIsMaximized(this)}get maximizationBoundary(){return Cp(this).getMaximizationBoundary(this)}addWindow(e){return Cp(this).addWindow(this,e,"column")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Cp(this).addParent(this,"group","column",e)}async addColumn(){throw new Error("Adding columns as column children is not supported")}async addRow(e){if(e?.type&&"row"!==e.type)throw new Error(`Expected a row definition, but received ${e.type}`);return Cp(this).addParent(this,"row","column",e)}removeChild(e){return Cp(this).removeChild(this,e)}maximize(){return Cp(this).maximize(this)}restore(){return Cp(this).restore(this)}close(){return Cp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters}):e;const n=void 0===t?void 0:Fh.runWithException(t);return Cp(this).lockContainer(this,n)}async setWidth(e){return Bc.runWithException(e),Cp(this).setWidth(this,e)}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Cp(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Qh.runWithException(e);return Cp(this).setMaximizationBoundary(this,t)}}const Ip=new WeakMap,kp=e=>Ip.get(e).base;class Tp{constructor(e){Ip.set(this,{base:e})}get type(){return"group"}get id(){return kp(this).getId(this)}get frameId(){return kp(this).getFrameId(this)}get workspaceId(){return kp(this).getWorkspaceId(this)}get positionIndex(){return kp(this).getPositionIndex(this)}get children(){return kp(this).getAllChildren(this)}get parent(){return kp(this).getMyParent(this)}get frame(){return kp(this).getMyFrame(this)}get workspace(){return kp(this).getMyWorkspace(this)}get allowExtract(){return kp(this).getAllowExtract(this)}get allowReorder(){return kp(this).getAllowReorder(this)}get allowDropLeft(){return kp(this).getAllowDropLeft(this)}get allowDropRight(){return kp(this).getAllowDropRight(this)}get allowDropTop(){return kp(this).getAllowDropTop(this)}get allowDropBottom(){return kp(this).getAllowDropBottom(this)}get allowDropHeader(){return kp(this).getAllowDropHeader(this)}get allowDrop(){return kp(this).getAllowDrop(this)}get showMaximizeButton(){return kp(this).getShowMaximizeButton(this)}get showEjectButton(){return kp(this).getShowEjectButton(this)}get showAddWindowButton(){return kp(this).getShowAddWindowButton(this)}get minWidth(){return kp(this).getMinWidth(this)}get minHeight(){return kp(this).getMinHeight(this)}get maxWidth(){return kp(this).getMaxWidth(this)}get maxHeight(){return kp(this).getMaxHeight(this)}get width(){return kp(this).getWidthInPx(this)}get height(){return kp(this).getHeightInPx(this)}get isMaximized(){return kp(this).getIsMaximized(this)}addWindow(e){return kp(this).addWindow(this,e,"group")}async addGroup(){throw new Error("Adding groups as group child is not supported")}async addColumn(){throw new Error("Adding columns as group child is not supported")}async addRow(){throw new Error("Adding rows as group child is not supported")}removeChild(e){return kp(this).removeChild(this,e)}maximize(){return kp(this).maximize(this)}restore(){return kp(this).restore(this)}close(){return kp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropRight:this.allowDropRight,allowDropTop:this.allowDropTop,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton}):e;const n=void 0===t?void 0:Mh.runWithException(t);return kp(this).lockContainer(this,n)}async setSize(e){const t=Ph.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return kp(this).setSize(this,e.width,e.height)}async bundleToRow(){await kp(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await kp(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await kp(this).processLocalSubscription(this,t)}}const xp=new WeakMap,Ap=e=>xp.get(e).manager.getWorkspaceData(e),Ep=e=>xp.get(e).manager;class Wp{constructor(e){xp.set(this,{manager:e})}get id(){return Ap(this).id}get frameId(){return Ap(this).config.frameId}get positionIndex(){return Ap(this).config.positionIndex}get title(){return Ap(this).config.title}get layoutName(){return Ap(this).config.layoutName}get isHibernated(){return Ap(this).config.isHibernated}get isSelected(){return Ap(this).config.isSelected}get children(){return Ap(this).children}get frame(){return Ap(this).frame}get allowSplitters(){return Ap(this).config.allowSplitters}get allowSystemHibernation(){return Ap(this).config.allowSystemHibernation}get allowDrop(){return Ap(this).config.allowDrop}get allowDropLeft(){return Ap(this).config.allowDropLeft}get allowDropTop(){return Ap(this).config.allowDropTop}get allowDropRight(){return Ap(this).config.allowDropRight}get allowDropBottom(){return Ap(this).config.allowDropBottom}get allowExtract(){return Ap(this).config.allowExtract}get allowWindowReorder(){return Ap(this).config.allowWindowReorder}get showCloseButton(){return Ap(this).config.showCloseButton}get showSaveButton(){return Ap(this).config.showSaveButton}get allowWorkspaceTabReorder(){return Ap(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return Ap(this).config.allowWorkspaceTabExtract}get minWidth(){return Ap(this).config.minWidth}get minHeight(){return Ap(this).config.minHeight}get maxWidth(){return Ap(this).config.maxWidth}get maxHeight(){return Ap(this).config.maxHeight}get width(){return Ap(this).config.widthInPx}get height(){return Ap(this).config.heightInPx}get showWindowCloseButtons(){return Ap(this).config.showWindowCloseButtons}get showEjectButtons(){return Ap(this).config.showEjectButtons}get showAddWindowButtons(){return Ap(this).config.showAddWindowButtons}get isPinned(){return Ap(this).config.isPinned}get windowDragMode(){return up()?Ap(this).config.windowDragMode:"keepInside"}get loadingStrategy(){return up()||console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser"),Ap(this).config.loadingStrategy}async setLoadingStrategy(e){if(!up())throw new Error("Not supported in IO Connect Browser");const t=Ap(this).controller;await t.setLoadingStrategy(this.id,e),await this.refreshReference()}async removeChild(e){Yc(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){Yc(e);const t=Ap(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await Ap(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=Ap(this).controller,t=await e.isLastWorkspaceInFrame(this.id,this.frameId),n=(await e.getPlatformFrameId()).id;if(t&&n!==this.frame.id)return this.frame.close();await e.closeItem(this.id)}snapshot(){return Ap(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){jc.runWithException(e),await Ap(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple})}async setTitle(e){jc.runWithException(e);const t=Ap(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return Ap(this).controller.getWorkspaceContext(this.id)}setContext(e){return Ap(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return Ap(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return Ap(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await Ap(this).controller.getSnapshot(this.id,"workspace"),t=Ap(this).controller.flatChildren(Ap(this).children),n=Ap(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),r=this.frame;let o;if(r.id===e.config.frameId)Ep(this).remapFrame(r,e.frameSummary),o=r;else{const t={summary:e.frameSummary};o=Ap(this).ioc.getModel("frame",t)}Ep(this).remapWorkspace(this,{config:e.config,children:n,frame:o})}async getIcon(){return Ap(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return Ap(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){Yc(e);const t=Ap(this).children;return Ap(this).controller.iterateFindChild(t,t=>"window"!==t.type&&e(t))}getAllBoxes(e){Yc(e,!0);const t=Ap(this).children,n=Ap(this).controller.iterateFilterChildren(t,e=>"window"!==e.type);return e?n.filter(e):n}getRow(e){return Yc(e),this.getBox(t=>"row"===t.type&&e(t))}getAllRows(e){return Yc(e,!0),e?this.getAllBoxes(t=>"row"===t.type&&e(t)):this.getAllBoxes(e=>"row"===e.type)}getColumn(e){return Yc(e),this.getBox(t=>"column"===t.type&&e(t))}getAllColumns(e){return Yc(e,!0),e?this.getAllBoxes(t=>"column"===t.type&&e(t)):this.getAllBoxes(e=>"column"===e.type)}getGroup(e){return Yc(e),this.getBox(t=>"group"===t.type&&e(t))}getAllGroups(e){return Yc(e,!0),e?this.getAllBoxes(t=>"group"===t.type&&e(t)):this.getAllBoxes(e=>"group"===e.type)}getWindow(e){Yc(e);const t=Ap(this).children;return Ap(this).controller.iterateFindChild(t,t=>"window"===t.type&&e(t))}getAllWindows(e){Yc(e,!0);const t=Ap(this).children,n=Ap(this).controller.iterateFilterChildren(t,e=>"window"===e.type);return e?n.filter(e):n}addRow(e){return Ap(this).base.addParent(this,"row","workspace",e)}addColumn(e){return Ap(this).base.addParent(this,"column","workspace",e)}addGroup(e){return Ap(this).base.addParent(this,"group","workspace",e)}addWindow(e){return Ap(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await Ap(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await Ap(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await Ap(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await Ap(this).controller.resumeWorkspace(this.id),await this.refreshReference()}async lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowWindowReorder:this.allowWindowReorder,allowSplitters:this.allowSplitters,showCloseButton:this.showCloseButton,showSaveButton:this.showSaveButton,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,showAddWindowButtons:this.showAddWindowButtons,showEjectButtons:this.showEjectButtons,showWindowCloseButtons:this.showWindowCloseButtons}):e;const n=void 0===t?void 0:Oh.runWithException(t);await Ap(this).controller.lockWorkspace(this.id,n),await this.refreshReference()}async pin(e){zh.runWithException(e),await Ap(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await Ap(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!up())throw new Error("Not supported in IO Connect Browser");await Ap(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!up())throw new Error("Not supported in IO Connect Browser");await Ap(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!up())throw new Error("Not supported in IO Connect Browser");Uc.runWithException(e),await Ap(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){Yc(e);const t=Ap(this).id,n={action:"closed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}};return await Ap(this).controller.processLocalSubscription(n,t)}async onHibernated(e){Yc(e);const t=Ap(this).id,n={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Ap(this).controller.processLocalSubscription(n,t)}async onResumed(e){Yc(e);const t=Ap(this).id,n={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowAdded(e){Yc(e);const t=Ap(this).id,n={action:"added",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowRemoved(e){Yc(e);const t=Ap(this).id,n={action:"removed",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowLoaded(e){Yc(e);const t=Ap(this).id,n={action:"loaded",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getWindow(e=>e.id&&e.id===t.windowSummary.config.windowId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowMaximized(e){Yc(e);const t=Ap(this).id,n={action:"maximized",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowRestored(e){Yc(e);const t=Ap(this).id,n={action:"restored",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowSelected(e){Yc(e);const t=Ap(this).id,n={action:"selected",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onLockConfigurationChanged(e){Yc(e);const t=Ap(this).id,n={action:"lock-configuration-changed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowSplitters:this.allowSplitters,allowWindowReorder:this.allowWindowReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,showAddWindowButtons:this.showAddWindowButtons,showCloseButton:this.showCloseButton,showEjectButtons:this.showEjectButtons,showSaveButton:this.showSaveButton,showWindowCloseButtons:this.showWindowCloseButtons})}};return await Ap(this).controller.processLocalSubscription(n,t)}}const Op=new WeakMap,Dp=e=>Op.get(e).manager.getWindowData(e);class _p{constructor(e){Op.set(this,{manager:e})}get id(){return Dp(this).config.windowId}get elementId(){return Dp(this).id}get type(){return"window"}get frameId(){return Dp(this).frame.id}get workspaceId(){return Dp(this).workspace.id}get positionIndex(){return Dp(this).config.positionIndex}get isMaximized(){return Dp(this).config.isMaximized}get isLoaded(){return Dp(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return Dp(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return Dp(this).config.title}get allowExtract(){return Dp(this).config.allowExtract}get allowReorder(){return Dp(this).config.allowReorder}get showCloseButton(){return Dp(this).config.showCloseButton}get width(){return Dp(this).config.widthInPx}get height(){return Dp(this).config.heightInPx}get minWidth(){return Dp(this).config.minWidth}get minHeight(){return Dp(this).config.minHeight}get maxWidth(){return Dp(this).config.maxWidth}get maxHeight(){return Dp(this).config.maxHeight}get workspace(){return Dp(this).workspace}get frame(){return Dp(this).frame}get parent(){return Dp(this).parent}get appName(){return Dp(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=Dp(this).controller,t=Dp(this).id,n=await e.forceLoadWindow(t);Dp(this).config.windowId=n,await this.workspace.refreshReference()}async focus(){const e=Dp(this).id,t=Dp(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=Dp(this).id,t=Dp(this).controller;await t.closeItem(e),await Dp(this).parent.removeChild(t=>t.id===e),await this.workspace.refreshReference()}async setTitle(e){jc.runWithException(e);const t=Dp(this).id,n=Dp(this).controller;await n.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=Dp(this).id,t=Dp(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=Dp(this).id,t=Dp(this).controller;await t.restoreItem(e),await this.workspace.refreshReference()}async eject(){if(!this.isLoaded)throw new Error("Cannot eject this window, because it is not loaded yet");const e=Dp(this).id,t=await Dp(this).controller.ejectWindow(e);return Dp(this).config.windowId=t,await this.workspace.refreshReference(),this.getGdWindow()}getGdWindow(){if(!this.isLoaded)throw new Error("Cannot fetch this GD window, because the window is not yet loaded");const e=Dp(this).config.windowId;return Dp(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof vp||e instanceof Sp||e instanceof Tp))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=Dp(this).id,n=Dp(this).controller,r=await n.getParent(t=>t.id===e.id);if(!r)throw new Error("Cannot move the window to the selected parent, because this parent does not exist.");await n.moveWindowTo(t,e.id),await this.workspace.refreshReference()}async lock(e){let t;t="function"==typeof e?e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton}):e;const n=void 0===t?void 0:_h.runWithException(t),r=Dp(this).id;await Dp(this).controller.lockWindow(r,n),await this.workspace.refreshReference()}async setSize(e){const t=Ph.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const n=Dp(this).id,r=Dp(this).controller;await r.resizeItem(n,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){Yc(e);const t=Dp(this).id,n={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await Dp(this).controller.processLocalSubscription(n,t)}async onLockConfigurationChanged(e){Yc(e);const t=Dp(this).id,n={callback:async()=>{await this.workspace.refreshReference(),e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})},action:"lock-configuration-changed",eventType:"window",scope:"window"};return await Dp(this).controller.processLocalSubscription(n,t)}}const Pp=new WeakMap,Rp=e=>Pp.get(e).manager.getFrameData(e);class Lp{constructor(e){Pp.set(this,{manager:e})}async registerShortcut(e,t){jc.runWithException(e),Yc(t);const n=Rp(this).summary.id;return await Rp(this).controller.registerShortcut(e,n,t)}get id(){return Rp(this).summary.id}get isInitialized(){return Rp(this).summary.isInitialized}getBounds(){const e=Rp(this).summary.id;return Rp(this).controller.getFrameBounds(e)}async resize(e){const t=sh.runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.resizeItem(n,t)}async move(e){const t=ah.runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.moveFrame(n,t)}focus(){const e=Rp(this).summary.id;return Rp(this).controller.focusItem(e)}async state(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.getFrameState(e)}setIcon(e){if(!up())throw new Error("frame.setIcon() is not supported in IO Connect Browser");Gc.runWithException(e);const t=this.id;return Rp(this).controller.setTaskbarIcon(e,t)}getIcon(){if(!up())throw new Error("frame.getIcon() is not supported in IO Connect Browser");const e=this.id;return Rp(this).controller.getTaskbarIcon(e)}async minimize(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"maximized")}async restore(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"normal")}close(e){const t=Fc(uh).runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.closeFrame(n,t)}snapshot(){const e=Rp(this).summary.id;return Rp(this).controller.getSnapshot(e,"frame")}async workspaces(){return Rp(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=Rp(this).controller,t=Rp(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){jc.runWithException(e);const n=pd.runWithException(t);return Rp(this).controller.restoreWorkspace(e,n)}createWorkspace(e,t){const n=fd.runWithException(e),r=Zc.runWithException(t);return Rp(this).controller.createWorkspace(n,r)}async init(e){if(vd.runWithException(e),Rp(this).summary.isInitialized)throw new Error("The frame has already been initialized");return Rp(this).controller.initFrame(this.id,e)}async onClosing(e){if(!up())throw new Error("Frame closing operations are not supported in io.Connect Browser");return Yc(e),await Rp(this).controller.registerFrameOnClosing(this.id,async()=>{let t=!1;return await e({prevent:()=>t=!0}),{prevent:t}})}async onClosed(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onMaximized(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onMinimized(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onNormal(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceOpened(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=await Rp(this).controller.transformStreamPayloadToWorkspace(t);e(n)},action:"opened",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceSelected(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=await Rp(this).controller.getWorkspaceById(t.workspaceSummary.id);e(n)},action:"selected",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceClosed(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowAdded(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=(await Rp(this).controller.getParent(e=>e.id===t.windowSummary.parentId)).children.find(e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex);e(n)},action:"added",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowRemoved(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})},action:"removed",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowLoaded(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=(await Rp(this).controller.getParent(e=>e.id===t.windowSummary.parentId)).children.find(e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex);e(n)},action:"loaded",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onInitializationRequested(e){return Yc(e),this.isInitialized||e(Rp(this).summary.initializationContext),()=>{}}async onFocusChanged(e){Yc(e);const t=Rp(this),{id:n}=t.summary,r={callback:t=>{e({isFocused:t.frameSummary.isFocused})},action:"focus",eventType:"frame",scope:"frame"};return await t.controller.processLocalSubscription(r,n)}}class Fp{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof _p&&this.windowsData.delete(e),e instanceof Wp&&this.workspacesData.delete(e),(e instanceof vp||e instanceof Sp||e instanceof Tp)&&this.parentsData.delete(e),e instanceof Lp&&this.framesData.delete(e)}setWindowData(e,t){this.windowsData.set(e,t)}setWorkspaceData(e,t){this.workspacesData.set(e,t)}setParentData(e,t){this.parentsData.set(e,t)}setFrameData(e,t){this.framesData.set(e,t)}getWindowData(e){return this.windowsData.get(e)}getWorkspaceData(e){return this.workspacesData.get(e)}getParentData(e){return this.parentsData.get(e)}getFrameData(e){return this.framesData.get(e)}remapChild(e,t){if(e instanceof _p){const n=this.windowsData.get(e);n.parent=t.parent||n.parent,n.config=t.config||n.config}if(e instanceof vp||e instanceof Sp||e instanceof Tp){const n=this.parentsData.get(e);n.parent=t.parent||n.parent,n.config=t.config||n.config,n.children=t.children||n.children}}remapFrame(e,t){this.framesData.get(e).summary=t}remapWorkspace(e,t){const n=this.workspacesData.get(e);n.frame=t.frame||n.frame,n.config=t.config||n.config,n.children=t.children||n.children}}const Mp=new WeakMap,$p=(e,t)=>{const n=Mp.get(e).manager;return t instanceof Wp?n.getWorkspaceData(t):Mp.get(e).manager.getParentData(t)};class Np{frameId;workspaceId;positionIndex;constructor(e){Mp.set(this,{manager:e})}getId(e){return $p(this,e).id}getPositionIndex(e){return $p(this,e).config.positionIndex}getWorkspaceId(e){const t=$p(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return $p(this,e).frame.id}getAllChildren(e,t){Yc(t,!0);const n=$p(this,e).children;return void 0===t?n:n.filter(t)}getMyParent(e){return e instanceof Wp?e:$p(this,e).parent}getMyFrame(e){return $p(this,e).frame}getMyWorkspace(e){return e instanceof Wp?e:$p(this,e).workspace}async addWindow(e,t,n){if(!t.appName&&!t.windowId)throw new Error("The window definition should contain either an appName or a windowId");const r=od.runWithException(t),o=$p(this,e).controller,i=await o.add("window",$p(this,e).id,n,r);if(e instanceof Wp)return await e.refreshReference(),e.getWindow(e=>e.elementId===i.itemId);const s=this.getMyWorkspace(e);return await s.refreshReference(),s.getWindow(e=>e.elementId===i.itemId)}async addParent(e,t,n,r){const o=this.transformDefinition(t,r),i=$p(this,e).controller,s=(await i.add("container",$p(this,e).id,n,o)).itemId;if(e instanceof Wp)return await e.refreshReference(),e.getBox(e=>e.id===s);const a=this.getMyWorkspace(e);return await a.refreshReference(),a.getBox(e=>e.id===s)}async removeChild(e,t){Yc(t);const n=this.getAllChildren(e).find(t);n&&(await n.close(),e instanceof Wp?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:n}=$p(this,e);await t.maximizeItem(n),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:n}=$p(this,e);await t.restoreItem(n),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=$p(this,e),n=$p(this,e).controller;await n.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const n=$p(this,e),r=$p(this,e).controller;await r.lockContainer(n.id,e.type,t),await this.getMyWorkspace(n.parent).refreshReference()}getAllowDrop(e){return $p(this,e).config.allowDrop}getAllowDropLeft(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropLeft is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropLeft}getAllowDropRight(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropRight is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropRight}getAllowDropTop(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropTop is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropTop}getAllowDropBottom(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropBottom is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropBottom}getAllowDropHeader(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropHeader is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropHeader}getAllowSplitters(e){const t=$p(this,e);if("group"===t.type)throw new Error(`Cannot get allow splitters from private data ${t.type}`);return t.config.allowSplitters}getAllowExtract(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowExtract}getAllowReorder(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowReorder}getShowMaximizeButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get show maximize button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showMaximizeButton}getShowEjectButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get show eject button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showEjectButton}getShowAddWindowButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get add window button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showAddWindowButton}getMinWidth(e){return $p(this,e).config.minWidth}getMaxWidth(e){return $p(this,e).config.maxWidth}getMinHeight(e){return $p(this,e).config.minHeight}getMaxHeight(e){return $p(this,e).config.maxHeight}getWidthInPx(e){return $p(this,e).config.widthInPx}getHeightInPx(e){return $p(this,e).config.heightInPx}getIsPinned(e){return $p(this,e).config.isPinned}getIsMaximized(e){return $p(this,e).config.isMaximized}getMaximizationBoundary(e){return $p(this,e).config.maximizationBoundary}async setHeight(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.resizeItem(o,{height:t}),await this.getMyWorkspace(n.parent).refreshReference()}async setWidth(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.resizeItem(o,{width:t}),await this.getMyWorkspace(n.parent).refreshReference()}async setSize(e,t,n){const r=$p(this,e),{controller:o,id:i}=r;await o.resizeItem(i,{width:t,height:n}),await this.getMyWorkspace(r.parent).refreshReference()}async setMaximizationBoundary(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.setMaximizationBoundary(o,t),await this.getMyWorkspace(n.parent).refreshReference()}async bundleTo(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.bundleItemTo(t,o)}async processLocalSubscription(e,t){return $p(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let n;return void 0===t?n={type:e,children:[]}:t instanceof pp?n=t.serialize():(void 0===t.type&&(t.type=e),n=cd.runWithException(t),n.children=n.children||[]),n}}class jp{ioc;windows;contexts;layouts;constructor(e,t,n,r){this.ioc=e,this.windows=t,this.contexts=n,this.layouts=r}get bridge(){return this.ioc.bridge}get privateDataManager(){return this.ioc.privateDataManager}checkIsWindowLoaded(e){return!!e&&this.windows.list().some(t=>t.id===e)}async createWorkspace(e){const t=await this.bridge.send(sp.createWorkspace.name,e),n={summary:t.frameSummary},r={frame:this.ioc.getModel("frame",n),snapshot:t};return this.ioc.getModel("workspace",r)}async createEmptyFrame(e){const t={summary:await this.bridge.send(sp.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(sp.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const n=await this.bridge.send(sp.openWorkspace.name,{name:e,restoreOptions:t}),r={summary:await this.bridge.send(sp.getFrameSummary.name,{itemId:n.config.frameId})},o={frame:this.ioc.getModel("frame",r),snapshot:n};return this.ioc.getModel("workspace",o)}async add(e,t,n,r){let o;const i={definition:r,parentId:t,parentType:n};if("window"===e)o=sp.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);o=sp.addContainer.name}return await this.bridge.send(o,i)}async getFrame(e){const t={summary:await this.bridge.send(sp.getFrameSummary.name,{itemId:e})};return this.ioc.getModel("frame",t)}getFrames(e,t){return e.reduce((e,n)=>{const r={summary:n},o=this.ioc.getModel("frame",r);return t&&!t(o)||e.push(o),e},[])}getAllWorkspaceSummaries(...e){return e.reduce((e,t)=>(e.push(...t.summaries),e),[]).map(e=>Object.assign({},{id:e.id,width:e.config.widthInPx,height:e.config.heightInPx},e.config))}handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)},n=this.layouts.onAdded(t),r=this.layouts.onChanged(t);return()=>{n(),r()}}handleOnRemoved(e){return this.layouts.onRemoved(t=>{"Workspace"===t.type&&e(t)})}async importLayouts(e,t){await this.layouts.import(e,t)}async transformStreamPayloadToWorkspace(e){const t={summary:e.frameSummary},n={frame:this.ioc.getModel("frame",t),snapshot:e.workspaceSnapshot||await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",n)}async fetchWorkspace(e){const t=await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e}),n={summary:t.frameSummary},r={frame:this.ioc.getModel("frame",n),snapshot:t};return this.ioc.getModel("workspace",r)}async bundleWorkspaceTo(e,t){await this.bridge.send(sp.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(sp.bundleItem.name))throw new Error(`Operation ${sp.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(sp.bundleItem.name,{type:e,itemId:t})}async getTaskbarIcon(e){return await this.bridge.send(sp.getTaskbarIcon.name,{frameId:e})}async setTaskbarIcon(e,t){await this.bridge.send(sp.setTaskbarIcon.name,{icon:e,frameId:t})}getWorkspaceContext(e){const t=`___workspace___${e}`;return this.contexts.get(t)}setWorkspaceContext(e,t){const n=`___workspace___${e}`;return this.contexts.set(n,t)}updateWorkspaceContext(e,t){const n=`___workspace___${e}`;return this.contexts.update(n,t)}subscribeWorkspaceContextUpdated(e,t){const n=`___workspace___${e}`;return this.contexts.subscribe(n,t)}async restoreItem(e){await this.bridge.send(sp.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(sp.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(sp.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send(sp.closeItem.name,{itemId:e})}async closeFrame(e,t){await this.bridge.send(sp.closeItem.name,{itemId:e,closeOptions:t})}async resizeItem(e,t){await this.bridge.send(sp.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(sp.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(sp.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(sp.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send(sp.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send(sp.moveFrame.name,Object.assign({},{itemId:e},t))}getGDWindow(e){return this.windows.list().find(t=>t.id===e)}async forceLoadWindow(e){return(await this.bridge.send(sp.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send(sp.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send(sp.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let n;return"workspace"===t?n=await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(n=await this.bridge.send(sp.getFrameSnapshot.name,{itemId:e})),n}async setItemTitle(e,t){await this.bridge.send(sp.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:n,existingChildren:r,workspace:o}=e;if(t instanceof _p||"window"===t.type)return;const i=n.map(e=>{let n=r.find(t=>"window"===t.type?t.elementId===e.id:t.id===e.id);if(n)this.privateDataManager.remapChild(n,{parent:t,children:[],config:e.config});else{let r;r="window"===e.type?{id:e.id,parent:t,frame:o.frame,workspace:o,config:e.config}:{id:e.id,parent:t,frame:o.frame,workspace:o,config:e.config,children:[]},n=this.ioc.getModel(e.type,r)}return"window"!==e.type&&this.refreshChildren({workspace:o,existingChildren:r,children:e.children,parent:n}),n});return t instanceof Wp||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let n=e.find(e=>t(e));return n||(e.some(e=>!(e instanceof _p)&&(n=this.iterateFindChild(e.children,t),!!n||void 0)),n)}iterateFilterChildren(e,t){const n=e.filter(e=>t(e)),r=e.reduce((e,n)=>(n instanceof _p||e.push(...this.iterateFilterChildren(n.children,t)),e),[]);return n.push(...r),n}notifyWindowAdded(e){return new Promise(t=>{if(this.windows.list().some(t=>t.id===e))return t();const n=this.windows.onWindowAdded(r=>{r.id===e&&(n&&n(),t())})})}async hibernateWorkspace(e){await this.bridge.send(sp.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(sp.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(sp.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(sp.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,n){await this.bridge.send(sp.lockContainer.name,{itemId:e,type:t,config:n})}async pinWorkspace(e,t){await this.bridge.send(sp.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(sp.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(sp.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(sp.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(sp.getPlatformFrameId.name,{})}catch(e){return{}}}async setLoadingStrategy(e,t){return await this.isOperationSupported(sp.setLoadingStrategy.name),this.bridge.send(sp.setLoadingStrategy.name,{itemId:e,strategy:t})}async isOperationSupported(e){return up()?{isSupported:!0}:await this.bridge.send(sp.operationCheck.name,{operation:e})}}class Bp{bridge;base;shortcutsController;closingController;constructor(e,t,n,r){this.bridge=e,this.base=t,this.shortcutsController=n,this.closingController=r}setTaskbarIcon(e,t){return this.base.setTaskbarIcon(e,t)}getTaskbarIcon(e){return this.base.getTaskbarIcon(e)}checkIsWindowLoaded(e){return this.base.checkIsWindowLoaded(e)}async checkIsInSwimlane(e){return(await this.bridge.send(sp.isWindowInWorkspace.name,{itemId:e})).inWorkspace}async createWorkspace(e,t){const n=Object.assign({},e,{saveConfig:t});return await this.base.createWorkspace(n)}async createEmptyFrame(e){return await this.base.createEmptyFrame(e)}async initFrame(e,t){return this.base.initFrame(e,t)}async restoreWorkspace(e,t){if(!(await this.getLayoutSummaries()).some(t=>t.name===e))throw new Error(`This layout: ${e} cannot be restored, because it doesn't exist.`);if(t?.frameId&&!(await this.bridge.send(sp.getAllFramesSummaries.name)).summaries.some(e=>e.id===t.frameId))throw new Error(`Cannot reuse the frame with id: ${t.frameId}, because there is no frame with that ID found`);return await this.base.restoreWorkspace(e,t)}async add(e,t,n,r){return await this.base.add(e,t,n,r)}processLocalSubscription(e,t){return up()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,n){return up()?this.handleEnterpriseGlobalSubscription(e,t,n):this.handleCoreGlobalSubscription(e,t,n)}async getFrame(e){if(e.windowId)return await this.base.getFrame(e.windowId);if(e.predicate)return(await this.getFrames(e.predicate))[0];throw new Error(`The provided selector is not valid: ${JSON.stringify(e)}`)}async getFrames(e){const t=await this.bridge.send(sp.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return up()?this.base.fetchWorkspace(e):(await this.getWorkspaces(t=>!!t.getWindow(t=>t.id===e)))[0]}transformStreamPayloadToWorkspace(e){return this.base.transformStreamPayloadToWorkspace(e)}async getWorkspace(e){let t;return await this.iterateWorkspaces((n,r)=>{e(n)&&(t=n,r())}),t}async getWorkspaces(e){const t=[];return await this.iterateWorkspaces(n=>{e&&!e(n)||t.push(n)}),t}async getWorkspacesByFrameId(e){const t=(await this.getAllWorkspaceSummaries()).filter(t=>t.frameId===e);return await Promise.all(t.map(e=>this.base.fetchWorkspace(e.id)))}async isLastWorkspaceInFrame(e,t){const n=(await this.getAllWorkspaceSummaries()).filter(e=>e.frameId===t);return 1===n.length&&n[0].id===e}async getAllWorkspaceSummaries(){const e=await this.bridge.send(sp.getAllWorkspacesSummaries.name,{});return this.base.getAllWorkspaceSummaries(e)}async getWindow(e){let t;return await this.iterateWorkspaces((n,r)=>{const o=n.getWindow(e);o&&(t=o,r())}),t}async getParent(e){let t;return await this.iterateWorkspaces((n,r)=>{const o=n.getBox(e);o&&(t=o,r())}),t}async getLayoutSummaries(){return(await this.bridge.send(sp.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(sp.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send(sp.exportAllLayouts.name)).layouts.reduce((t,n)=>(e&&!e(n)||t.push(n),t),[])}async saveLayout(e){return await this.bridge.send(sp.saveLayout.name,e)}async importLayouts(e,t){if(up())try{await this.bridge.send(sp.importLayouts.name,{layouts:e,mode:t})}catch(n){await Promise.all(e.map(e=>this.bridge.send(sp.importLayout.name,{layout:e,mode:t})))}else await this.base.importLayouts(e,t)}handleOnSaved(e){return this.base.handleOnSaved(e)}handleOnRemoved(e){return this.base.handleOnRemoved(e)}async bundleWorkspaceTo(e,t){return await this.base.bundleWorkspaceTo(e,t)}async bundleItemTo(e,t){return await this.base.bundleItemTo(e,t)}getWorkspaceContext(e){return this.base.getWorkspaceContext(e)}setWorkspaceContext(e,t){return this.base.setWorkspaceContext(e,t)}updateWorkspaceContext(e,t){return this.base.updateWorkspaceContext(e,t)}subscribeWorkspaceContextUpdated(e,t){return this.base.subscribeWorkspaceContextUpdated(e,t)}async restoreItem(e){return await this.base.restoreItem(e)}async maximizeItem(e){return await this.base.maximizeItem(e)}async focusItem(e){return await this.base.focusItem(e)}async changeFrameState(e,t){await this.bridge.send(sp.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(sp.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(sp.getFrameState.name,{itemId:e})).state}async closeItem(e){return await this.base.closeItem(e)}async closeFrame(e,t){return await this.base.closeFrame(e,t)}async resizeItem(e,t){return await this.base.resizeItem(e,t)}async setMaximizationBoundary(e,t){return await this.base.setMaximizationBoundary(e,t)}async showWorkspaceLoadingAnimation(e){return await this.base.showWorkspaceLoadingAnimation(e)}async hideWorkspaceLoadingAnimation(e){return await this.base.hideWorkspaceLoadingAnimation(e)}async setWindowDragMode(e,t){return await this.base.setWindowDragMode(e,t)}async moveFrame(e,t){return await this.base.moveFrame(e,t)}getGDWindow(e){return this.base.getGDWindow(e)}async forceLoadWindow(e){const t=await this.base.forceLoadWindow(e);return await this.base.notifyWindowAdded(t),t}async ejectWindow(e){const t=(await this.base.ejectWindow(e)).windowId;return await this.base.notifyWindowAdded(t),t}async moveWindowTo(e,t){return await this.base.moveWindowTo(e,t)}async getSnapshot(e,t){return await this.base.getSnapshot(e,t)}async setItemTitle(e,t){return await this.base.setItemTitle(e,t)}flatChildren(e){return e.reduce((e,t)=>(e.push(t),"window"!==t.type&&e.push(...this.flatChildren(t.children)),e),[])}refreshChildren(e){return this.base.refreshChildren(e)}iterateFindChild(e,t){return this.base.iterateFindChild(e,t)}iterateFilterChildren(e,t){return this.base.iterateFilterChildren(e,t)}hibernateWorkspace(e){return this.base.hibernateWorkspace(e)}resumeWorkspace(e){return this.base.resumeWorkspace(e)}lockWorkspace(e,t){return this.base.lockWorkspace(e,t)}lockWindow(e,t){return this.base.lockWindow(e,t)}lockContainer(e,t,n){return this.base.lockContainer(e,t,n)}pinWorkspace(e,t){return this.base.pinWorkspace(e,t)}unpinWorkspace(e){return this.base.unpinWorkspace(e)}getWorkspaceIcon(e){return this.base.getWorkspaceIcon(e)}setWorkspaceIcon(e,t){return this.base.setWorkspaceIcon(e,t)}async getFrameConstraints(e){const t=await this.getSnapshot(e,"frame");return{minWidth:t.config.minWidth,maxWidth:t.config.maxWidth,minHeight:t.config.minHeight,maxHeight:t.config.maxHeight}}registerShortcut(e,t,n){return this.shortcutsController.registerShortcut(e,t,n)}getPlatformFrameId(){return this.base.getPlatformFrameId()}setLoadingStrategy(e,t){return this.base.setLoadingStrategy(e,t)}registerFrameOnClosing(e,t){return this.closingController.registerFrameOnClosing(e,t)}async handleCoreLocalSubscription(e,t){if(await this.bridge.createCoreEventSubscription(),e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,n=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=n}return this.bridge.handleCoreSubscription(e)}handleEnterpriseLocalSubscription(e,t){if(e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,n=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=n}return this.bridge.subscribe(e)}async handleCoreGlobalSubscription(e,t,n){await this.bridge.createCoreEventSubscription();const r={eventType:t,callback:e,action:n,scope:"global"};if("window"===t&&"loaded"===n){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};r.callback=t}return this.bridge.handleCoreSubscription(r)}handleEnterpriseGlobalSubscription(e,t,n){const r={eventType:t,callback:e,action:n,scope:"global"};if("window"===t&&"loaded"===n){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};r.callback=t}return this.bridge.subscribe(r)}async iterateWorkspaces(e){let t=!1;const n=()=>{t=!0},r=await this.getAllWorkspaceSummaries();for(const o of r){if(t)return;e(await this.base.fetchWorkspace(o.id),n)}}}class qp{bridge;_shortcuts=mc();constructor(e){this.bridge=e,this.bridge.onOperation(e=>{if(e.operation===ip.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}})}async registerShortcut(e,t,n){await this.bridge.send(sp.registerShortcut.name,{shortcut:e,frameId:t});const r=this._shortcuts.add(`${t}-${e}`,n);return()=>{r(),this.bridge.send(sp.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Up{bridge;registry=mc();constructor(e){this.bridge=e,this.subscribeToFrameClosing()}async registerFrameOnClosing(e,t){return await this.bridge.send(sp.subscribeToFrameClosing.name,{itemId:e}),this.registry.add(e,t)}subscribeToFrameClosing(){this.bridge.onOperationWithResponse(async e=>{if(e.operation!==ip.frameClosing.name)return;const t=e.data,n=await Promise.all(this.registry.execute(t.frameId));return this.aggregateFrameClosingResult(n)})}aggregateFrameClosingResult(e){return{prevent:e.some(e=>e?.prevent)}}}class zp{agm;windows;layouts;contexts;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;_closingController;constructor(e,t,n,r){this.agm=e,this.windows=t,this.layouts=n,this.contexts=r}get baseController(){return this._baseController||(this._baseController=new jp(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new Bp(this.bridge,this.baseController,this.shortcutsController,this.closingController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new qp(this.bridge)),this._shortcutsController}get closingController(){return this._closingController||(this._closingController=new Up(this.bridge)),this._closingController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new lp(this.transport,mc())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new dp(this.agm,mc())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new Fp),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new Np(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new Lp(this.privateDataManager),{summary:n}=t,r={summary:n,controller:this.controller};return this.privateDataManager.setFrameData(e,r),e}case"window":{const{id:e,parent:n,frame:r,workspace:o,config:i}=t,s={type:"window",controller:this.controller,config:i,id:e,parent:n,frame:r,workspace:o},a=new _p(this.privateDataManager);return this.privateDataManager.setWindowData(a,s),a}case"row":case"column":case"group":{const{id:n,children:r,parent:o,frame:i,workspace:s,config:a}=t,l="column"===e?new Sp(this.parentBase):"row"===e?new vp(this.parentBase):new Tp(this.parentBase),u=this.buildChildren(r,i,s,l),c={id:n,parent:o,frame:i,workspace:s,config:a,type:e,controller:this.controller,children:u};return this.privateDataManager.setParentData(l,c),l}case"workspace":{const{snapshot:e,frame:n}=t,r=new Wp(this.privateDataManager),o=this.buildChildren(e.children,n,r,r),i={id:e.id,type:"workspace",config:e.config,base:this.parentBase,controller:this.controller,children:o,frame:n,ioc:this};return this.privateDataManager.setWorkspaceData(r,i),r}default:throw new Error(`Unrecognized type: ${e}`)}}getBuilder(e){e.definition=e.definition||{},Array.isArray(e.definition.children)||(e.definition.children=[]);const t=new gp(this.getBuilder.bind(this));switch(e.type){case"workspace":return new mp(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new pp(e.definition,t);default:throw new Error(`Unexpected Builder creation error, provided config: ${JSON.stringify(e)}`)}}buildChildren(e,t,n,r){return e.map(e=>{switch(e.type){case"window":return this.getModel("window",{id:e.id,config:e.config,frame:t,workspace:n,parent:r});case"column":case"row":case"group":return this.getModel(e.type,{id:e.id,config:e.config,children:e.children,frame:t,workspace:n,parent:r});default:throw new Error(`Unsupported child type: ${e.type}`)}})}}const Gp=async e=>{const t=new zp(e.agm,e.windows,e.layouts,e.contexts),n=e.interop.instance.windowId;await t.initiate(n),e.workspaces=((e,t)=>{const n=t.controller,r=async e=>(Yc(e,!0),n.getFrames(e)),o=async e=>(Yc(e),await n.processGlobalSubscription(n=>{const r={summary:n.frameSummary},o=t.getModel("frame",r);e(o)},"frame","opened"));return{inWorkspace:()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");return n.checkIsInSwimlane(t)},getBuilder:e=>{const n=Cd.runWithException(e);return t.getBuilder(n)},getMyFrame:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");if(!await n.checkIsInSwimlane(t))throw new Error("Cannot fetch your frame, because this window is not in a workspace");return n.getFrame({windowId:t})},getFrame:async e=>(Yc(e),n.getFrame({predicate:e})),getAllFrames:r,getAllWorkspacesSummaries:()=>n.getAllWorkspaceSummaries(),getMyWorkspace:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my workspace, because my id is undefined.");if(!await n.checkIsInSwimlane(t))throw new Error("Cannot fetch your workspace, because this window is not in a workspace");return await n.getWorkspaceByWindowId(t)},getWorkspace:async e=>(Yc(e),(await n.getWorkspaces(e))[0]),getWorkspaceById:async e=>(jc.runWithException(e),n.getWorkspaceById(e)),getAllWorkspaces:e=>(Yc(e,!0),n.getWorkspaces(e)),getWindow:async e=>(Yc(e),n.getWindow(e)),getBox:async e=>(Yc(e),n.getParent(e)),restoreWorkspace:async(e,t)=>{jc.runWithException(e);const r=pd.runWithException(t);return n.restoreWorkspace(e,r)},createWorkspace:async(e,t)=>{const r=fd.runWithException(e),o=Zc.runWithException(t);return n.createWorkspace(r,o)},createEmptyFrame:async e=>{const t=wd.runWithException(e);return n.createEmptyFrame(t??{})},waitForFrame:async e=>(jc.runWithException(e),new Promise((t,n)=>{let i=()=>{};o(n=>{n.id===e&&(t(n),i())}).then(e=>(i=e,r())).then(n=>{const r=n.find(t=>t.id===e);r&&(t(r),i())}).catch(n)})),layouts:{getSummaries:()=>n.getLayoutSummaries(),delete:async e=>(jc.runWithException(e),n.deleteLayout(e)),export:async e=>(Yc(e,!0),n.exportLayout(e)),import:async(e,t="replace")=>{if(!Array.isArray(e))throw new Error(`The provided layouts argument is not an array: ${JSON.stringify(e)}`);return e.forEach(e=>Bd.runWithException(e)),n.importLayouts(e,t)},save:async e=>{const t=Wh.runWithException(e);return n.saveLayout(t)},onSaved:async e=>(Yc(e),n.handleOnSaved(e)),onRemoved:async e=>(Yc(e),n.handleOnRemoved(e))},onFrameOpened:o,onFrameClosed:async e=>(Yc(e),await n.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},"frame","closed")),onWorkspaceOpened:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","opened")),onWorkspaceClosed:async e=>(Yc(e),await n.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},"workspace","closed")),onWorkspaceHibernated:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","hibernated")),onWorkspaceResumed:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","resumed")),onWindowAdded:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","added")),onWindowLoaded:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getWindow(e=>e.id&&e.id===r.windowSummary.config.windowId);e(a)},"window","loaded")),onWindowRemoved:async e=>(Yc(e),await n.processGlobalSubscription(t=>{const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})},"window","removed")),onWindowMaximized:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","maximized")),onWindowRestored:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","restored")),onWindowSelected:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","selected")),version:"4.0.2"}})(e,t)};"undefined"!=typeof window&&(window.IOWorkspaces=Gp);var Hp=n(4744),Vp=n.n(Hp),Qp=n(2543),Jp=n.n(Qp);class Kp{static delay(e){return new Promise(t=>setTimeout(t,e))}get ended(){return this.rejected||this.resolved}constructor(){this.rejected=!1,this.resolved=!1,this.promise=new Promise((e,t)=>{this.resolve=t=>{this.resolved||this.rejected||(this.resolved=!0,e(t))},this.reject=e=>{this.resolved||this.rejected||(this.rejected=!0,t(e))}})}setTimeout(e,t){return setTimeout(()=>{this.reject(null!=t?t:"PromiseWrapper timed out")},e)}}var Yp=n(4342),Zp=n.n(Yp);let Xp=Promise;const eg=()=>Xp,tg="$FINSEMBLECONFIG",ng="$FINSEMBLECREDENTIALS",rg="$FINSEMBLEDIMENSIONMEMORY";class og{constructor(){this.gatePromises=[]}async runOldest(){var e;const t=this.gatePromises[this.gatePromises.length-1],n=await t.func();this.gatePromises=this.gatePromises.filter(e=>e!==t),null===(e=t.resolve)||void 0===e||e.call(t,n),this.gatePromises.length&&this.runOldest()}async wait(e){const t={func:e};return t.gatePromise=new Promise(e=>{t.resolve=e}),this.gatePromises=this.gatePromises.concat(t),1===this.gatePromises.length&&this.runOldest(),t.gatePromise}}const ig=(e,t)=>(n,r)=>{try{const o=e(n,r);return(null==o?void 0:o.catch)&&o.catch(e=>{(null!=t?t:console).error("Unhandled exception or rejection in interop.register handler",e)}),o}catch(e){throw(null!=t?t:console).error("Unhandled exception in interop.register handler",e),e}},sg=async(e,t)=>{const n=e.map(e=>t(e)),r=await eg().allSettled(n),o=r.filter(e=>"rejected"===e.status);if(o.length)throw o.map(e=>e.reason);return r.flatMap(e=>"fulfilled"===e.status?[e.value]:[])},ag=async(e,t)=>{const n=e.map(e=>t(e)),r=await Promise.allSettled(n),o=r.filter(e=>"rejected"===e.status);if(o.length)throw o.map(e=>e.reason);return r},lg=async e=>{var t,n;const r=await(null===(t=e.windows)||void 0===t?void 0:t.my());return{windowName:null!==(n=null==r?void 0:r.id)&&void 0!==n?n:"Unknown Window: running in node?",componentType:null==r?void 0:r.name}},ug=async(e,t)=>{const n=await e.windows.list(),r=await e.appManager.getConfigurations(n.filter(e=>e.application).map(e=>e.application.name));return n.filter(e=>t?t.includes(e.id):e.isVisible&&!((e,t)=>{var n;if(!1===e.settings.ignoreFromLayouts||!0===e.settings.ignoreFromLayouts)return e.settings.ignoreFromLayouts;const r=t.find(t=>t.name===e.name);return!r||null!==(n=null==r?void 0:r.ignoreFromLayouts)&&void 0!==n&&n})(e,r))},cg=async(e,t,n)=>{let r=[];return await ag(await ug(e,null==t?void 0:t.windowList),async e=>{const{group:t}=e;r.includes(null==t?void 0:t.id)||((null==t?void 0:t.id)&&r.push(t.id),"minimized"===e.state?await e.restore():await e.focus())}),null==n||n(null),{err:null}},dg=async(e,t,n)=>(await ag(await ug(e,null==t?void 0:t.windowList),async e=>{await e.minimize()}),null==n||n(null),{err:null}),hg=e=>!1===e||!0!==e&&(null!=e?e:void 0),pg=async(e,t)=>{var n;try{const n=await e();return null==t||t(null,n),{err:null,data:n}}catch(e){const r=e instanceof Error?e.toString():null!==(n=e.message)&&void 0!==n?n:JSON.stringify(e);return null==t||t(r),{err:r}}},gg=async(e,t)=>{var n,r;const{err:o,data:i}=await pg(e);if(o||!i)return null==t||t(o),{err:o};const s=i.all_errors?i.all_errors.join(" "):null;if(s)return null==t||t(s),{err:s};const a=i.returned;return Object.prototype.hasOwnProperty.call(a,"err")||Object.prototype.hasOwnProperty.call(a,"data")?(null==t||t(null!==(n=a.err)&&void 0!==n?n:null,a.data),{err:null!==(r=a.err)&&void 0!==r?r:null,data:a.data}):(null==t||t(null,a),{data:a,invocationResult:i})},fg=e=>null!=e,mg=(e,t,n,r)=>{var o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S,I,k,T,x,A;if(null==(null!==(u=null!==(l=null!==(a=null!==(s=null!==(i=null!==(o=null==t?void 0:t.left)&&void 0!==o?o:null==t?void 0:t.right)&&void 0!==i?i:null==t?void 0:t.top)&&void 0!==s?s:null==t?void 0:t.bottom)&&void 0!==a?a:null==t?void 0:t.width)&&void 0!==l?l:null==t?void 0:t.height)&&void 0!==u?u:null==t?void 0:t.monitor))return;const E=null!==(c=null==t?void 0:t.left)&&void 0!==c?c:null===(d=null==t?void 0:t.options)||void 0===d?void 0:d.left,W=null!==(h=null==t?void 0:t.top)&&void 0!==h?h:null===(p=null==t?void 0:t.options)||void 0===p?void 0:p.top,O=null!==(g=null==t?void 0:t.right)&&void 0!==g?g:null===(f=null==t?void 0:t.options)||void 0===f?void 0:f.right,D=null!==(m=null==t?void 0:t.bottom)&&void 0!==m?m:null===(y=null==t?void 0:t.options)||void 0===y?void 0:y.bottom,_=null!==(w=null==t?void 0:t.width)&&void 0!==w?w:null===(v=null==t?void 0:t.options)||void 0===v?void 0:v.width,P=null!==(b=null==t?void 0:t.height)&&void 0!==b?b:null===(C=null==t?void 0:t.options)||void 0===C?void 0:C.height,R={snapped:null!==(k=null===(I=null===(S=null==r?void 0:r.details)||void 0===S?void 0:S.placement)||void 0===I?void 0:I.snapped)&&void 0!==k&&k,left:E,top:W,right:O,bottom:D,width:_,height:P,display:null!=n?n:null===(x=null===(T=null==r?void 0:r.details)||void 0===T?void 0:T.placement)||void 0===x?void 0:x.display};return yg(R,t,null===(A=null==r?void 0:r.details)||void 0===A?void 0:A.placement),""===R.width&&delete R.width,""===R.height&&delete R.height,0!==R.height&&"0"!==R.height||(R.height=1),0!==R.width&&"0"!==R.width||(R.width=1),L=R,Object.keys(L).forEach(e=>{null!==L[e]&&void 0!==L[e]||delete L[e]}),L;var L},yg=(e,t,n)=>{var r,o,i;"center"===e.top&&(e.verticalAlignment="center"),"center"===e.left&&(e.horizontalAlignment="center"),(null==t?void 0:t.dockable)&&(null==t?void 0:t.docked)&&t.dockable.some(e=>e===t.docked)&&(e.snapped=!0,e.height=null!==(r=t.dockedHeight)&&void 0!==r?r:e.height,e.verticalAlignment="bottom"===t.docked?"bottom":"top",e.horizontalAlignment="stretch"),!e.horizontalAlignment&&fg(e.right)&&(e.horizontalAlignment="right"),!e.horizontalAlignment&&fg(e.left)&&(e.horizontalAlignment="left"),!e.verticalAlignment&&fg(e.bottom)&&(e.verticalAlignment="bottom"),!e.verticalAlignment&&fg(e.top)&&(e.verticalAlignment="top"),e.horizontalAlignment||(e.horizontalAlignment=null!==(o=null==n?void 0:n.horizontalAlignment)&&void 0!==o?o:"left"),e.verticalAlignment||(e.verticalAlignment=null!==(i=null==n?void 0:n.verticalAlignment)&&void 0!==i?i:"top")},wg=async(e,t)=>{var n,r;if(!t||"mine"===t){const t=null===(n=e.windows.my())||void 0===n?void 0:n.id,o=t?await e.displays.getByWindowId(t):void 0;return null===(r=null==o?void 0:o.isPrimary)||void 0===r||r?"main":null==o?void 0:o.index.toString()}return bg(t)},vg=async(e,t,n)=>{var r,o;const i=await e.displays.all(),s=t.display,a=i.find(e=>e.index===Number(s)||"current"===s&&e.index===Number(n)||"object"==typeof s&&s.index===e.index||!("main"!==s||!e.isPrimary)),l=i.find(e=>e.isPrimary),u=a?a.workArea.top:0,c=a?a.workArea.left:0,d=a?a.bounds.top:0,h=a?a.bounds.left:0,p=(null!==(r=null==a?void 0:a.scaleFactor)&&void 0!==r?r:1)/(null!==(o=null==l?void 0:l.scaleFactor)&&void 0!==o?o:1);"number"==typeof t.left&&(t.left-=(c-h)/p,t.left=t.left/p),"number"==typeof t.top&&(t.top-=(u-d)/p,t.top=t.top/p),t.display&&"object"!=typeof t.display&&(t.display=(parseInt(t.display)+1).toString())},bg=e=>"number"==typeof e?(e+1).toString():"main",Cg=async(e,t)=>{var n;const r=await(null==t?void 0:t.getContext()),o=null!==(n=null==r?void 0:r["#finsemble-componentState"])&&void 0!==n?n:{};let i;if(null==e?void 0:e.field)i=o[e.field];else if(null==e?void 0:e.fields){i={};for(let t=0;t<e.fields.length;t++)i[e.fields[t]]=o[e.fields[t]]}else i={...o};return{err:null,data:i}},Sg=async(e,t)=>{var n,r;const o=e.windows.list(),i=await(null===(n=e.windows.findById(t))||void 0===n?void 0:n.getBounds());if(!i)return void console.log("formGroup() called on invalid window?",t);i.right=i.left+i.width,i.bottom=i.top+i.height;const s=e=>{if(e.right=e.left+e.width,e.bottom=e.top+e.height,i.left>e.right)return null;if(i.right<e.left)return null;if(i.top>e.bottom)return null;if(i.bottom<e.top)return null;const t=[{direction:"left",distance:e.right-i.left},{direction:"right",distance:i.right-e.left},{direction:"top",distance:e.bottom-i.top},{direction:"bottom",distance:i.bottom-e.top}].flatMap(e=>e.distance<0?[]:e);return t.length?t.sort((e,t)=>e.distance>t.distance?1:t.distance>e.distance?-1:0)[0].direction:null};for(let n=0;n<o.length;n++){const i=o[n];if(i.id===t)continue;if(!i.isVisible)continue;if(!i.isSticky)continue;const a=s(i.bounds);if(a){console.log(i.name,"snap to",null===(r=e.windows.findById(t))||void 0===r?void 0:r.name," ",a),i.snap(t,a);break}}},Ig=async(e,t)=>{var n;if(!(null==e?void 0:e.field)&&!(null==e?void 0:e.fields))return{err:null};let r={};try{const o=await(null==t?void 0:t.getContext()),i=null!==(n=null==o?void 0:o["#finsemble-componentState"])&&void 0!==n?n:{};e.field?r=Object.assign(i,{[e.field]:e.value}):e.fields&&(r=Object.assign(i,...e.fields.map(({field:e,value:t})=>({[e]:t})))),await(null==t?void 0:t.updateContext({"#finsemble-componentState":r}))}catch(e){return{err:e.toString()}}return{err:null}},kg=async(e,t)=>{if(!(null==e?void 0:e.field)&&!(null==e?void 0:e.fields))return{err:null};const n=await(null==t?void 0:t.getContext()),r=null==n?void 0:n["#finsemble-componentState"];return r?(e.field?null==r||delete r[e.field]:e.fields&&e.fields.forEach(e=>{delete r[null==e?void 0:e.field]}),null==t||t.updateContext({"#finsemble-componentState":r}),{err:null}):{err:null}},Tg=async(e,t)=>{var n,r;if("about:blank"!==(r=t)&&!new RegExp("^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?)?([;&a-z\\d\\/#\\?%_.~+=-]*)?","i").test(r))return{err:`Failed to open browser - invalid url provided: '${t}'`};try{await(null===(n=e.appManager.application("open-browser"))||void 0===n?void 0:n.start({url:t}))}catch(e){}return{}},xg=async e=>{var t,n,r,o,i,s,a,l,u;const c=await Wg(e),d=await(null==e?void 0:e.getContext());return{componentType:null==e?void 0:e.name,resizable:null===(t=null==c?void 0:c.details.hasSizeAreas)||void 0===t||t,customData:{component:{type:null==e?void 0:e.name},interop:{useLinker:null===(r=null===(n=null==c?void 0:c.details.channelSelector)||void 0===n?void 0:n.enabled)||void 0===r||r},appConfig:null===(o=null==c?void 0:c.customProperties)||void 0===o?void 0:o.appd,custom:null===(l=null===(a=null===(s=null===(i=null==c?void 0:c.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble)||void 0===l?void 0:l.custom,isAnApp:!!(null===(u=null==c?void 0:c.customProperties)||void 0===u?void 0:u.appd),spawnData:null==d?void 0:d["#finsemble-spawnData"]}}},Ag={},Eg=new og,Wg=async e=>await Eg.wait(async()=>{var t;if(!(null===(t=null==e?void 0:e.application)||void 0===t?void 0:t.name))return;if(Ag[e.application.name])return Ag[e.application.name];const n=await e.application.getConfiguration();return n&&(Ag[e.application.name]=n),n}),Og=async(e,t,n)=>{var r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S,I,k,T,x,A,E,W,O,D,_,P,R,L,F,M,$,N,j,B,q,U,z,G,H,V,Q,J,K,Y,Z,X,ee,te,ne,re,oe,ie,se,ae,le;const ue=null!=t?t:{},ce=null===(r=e.windows.my())||void 0===r?void 0:r.tabGroupId,de={ignoreSavedLayout:!0},he=await wg(e,null==t?void 0:t.monitor);let pe=mg(0,ue,he,n);pe&&(pe=await(async(e,t,n,r)=>{var o,i,s,a;if("absolute"===r||"virtual"===r)return t;const l=n?e.windows.findById(n):e.windows.my(),u=await(null==l?void 0:l.getDisplay());if(!l||!u)return t;if("monitor"===r||!r)return(t=null!=t?t:{snapped:!1}).display=u.index+1,t;const c={relative:l.bounds,available:u.workArea};if(Object.hasOwnProperty.call(c,r)&&t){const{left:e,top:n,height:l,width:u}=c[r];(Number.isInteger(t.left)||Number.isInteger(t.top))&&(t.left=(null!==(o=t.left)&&void 0!==o?o:0)+e,t.top=(null!==(i=t.top)&&void 0!==i?i:0)+n),(null===(s=t.height)||void 0===s?void 0:s.toString().includes("%"))&&(t.height=parseFloat(t.height)/100*l),(null===(a=t.width)||void 0===a?void 0:a.toString().includes("%"))&&(t.width=parseFloat(t.width)/100*u),t.horizontalAlignment="left",t.verticalAlignment="top"}return t})(e,pe,null===(o=ue.relativeWindow)||void 0===o?void 0:o.windowName,null==t?void 0:t.position)),de.placement=pe,de.cascade=(e=>{const t=null==e?void 0:e.staggerPixels;return{enabled:!0,offset:null!=t?t:50}})(ue);const ge=((e,t)=>{var n,r,o,i,s,a,l,u,c,d,h;const p="adjacent",g={};return(null!==(n=null==t?void 0:t.left)&&void 0!==n?n:null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.left)===p&&(g.relativeDirection="right"),(null!==(o=null==t?void 0:t.top)&&void 0!==o?o:null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.top)===p&&(g.relativeDirection="bottom"),(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:null===(a=null==t?void 0:t.options)||void 0===a?void 0:a.right)===p&&(g.relativeDirection="left"),(null!==(l=null==t?void 0:t.bottom)&&void 0!==l?l:null===(u=null==t?void 0:t.options)||void 0===u?void 0:u.bottom)===p&&(g.relativeDirection="top"),Object.keys(g).length>0&&(g.relativeTo=null!==(d=null===(c=null==t?void 0:t.relativeWindow)||void 0===c?void 0:c.windowName)&&void 0!==d?d:null===(h=e.windows.my())||void 0===h?void 0:h.id),g})(e,ue);ue.ephemeral&&(de.showInTaskbar=ue.ephemeral,de.onTop=!0,de.hasSizeAreas=!1,de.isSticky=!1);const fe=null===(a=null===(s=null===(i=null==n?void 0:n.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble,me=null!==(d=null===(c=null===(u=null===(l=null==fe?void 0:fe.foreign)||void 0===l?void 0:l.services)||void 0===u?void 0:u.windowService)||void 0===c?void 0:c.addToWorkspace)&&void 0!==d?d:null===(h=null==fe?void 0:fe.window)||void 0===h?void 0:h.addToWorkspace,ye=null!==(p=null!=me?me:ue.addToWorkspace)&&void 0!==p&&p;if(de.ignoreFromLayouts=hg(ye),fg(ge.relativeTo)&&(de.relativeTo=ge.relativeTo),fg(ge.relativeDirection)&&(de.relativeDirection=ge.relativeDirection),fg(ue.canGroup)&&(de.isSticky=null!==(g=ue.canGroup)&&void 0!==g?g:void 0),fg(null===(f=ue.options)||void 0===f?void 0:f.showTaskbarIcon)&&(de.showInTaskbar=null===(m=ue.options)||void 0===m?void 0:m.showTaskbarIcon),fg(null===(y=ue.options)||void 0===y?void 0:y.resizable)&&(de.hasSizeAreas=null===(w=ue.options)||void 0===w?void 0:w.resizable),fg(null===(v=ue.options)||void 0===v?void 0:v.alwaysOnTop)&&(de.onTop=null===(b=ue.options)||void 0===b?void 0:b.alwaysOnTop),fg(null===(C=ue.options)||void 0===C?void 0:C.autoShow)&&(de.hidden=null!==(I=hg(null===(S=ue.options)||void 0===S?void 0:S.autoShow))&&void 0!==I?I:void 0),fg(ue.minWidth)&&(de.minWidth=ue.minWidth),fg(ue.minHeight)&&(de.minHeight=ue.minHeight),fg(ue.maxWidth)&&(de.maxWidth=ue.maxWidth),fg(ue.maxHeight)&&(de.maxHeight=ue.maxHeight),fg(ue.slave)&&(de.isChild=ue.slave),fg(null===(k=ue.options)||void 0===k?void 0:k.windowState)&&(de.windowState=null===(T=ue.options)||void 0===T?void 0:T.windowState),fg(ue.frame)&&(de.showTitleBar=null!==(x=hg(ue.frame))&&void 0!==x?x:void 0),ue.addToTabCollection&&(de.tabGroupId="string"==typeof ue.addToTabCollection?ue.addToTabCollection:ce),(null===(A=ue.options)||void 0===A?void 0:A.preloadScripts)&&(de.preloadScripts=ue.options.preloadScripts),!1===ue.autoFocus&&(de.focus=!1),ue.url&&(de.url=ue.url),ue.path){const e=ue.path.split(/[\\/]/),t=e.pop(),n=e.join("/");de.command=t,de.path=n}fg(null===(E=ue.options)||void 0===E?void 0:E.windowSpawnTimeout)&&(de.timeout=null===(W=ue.options)||void 0===W?void 0:W.windowSpawnTimeout);const we=null!==(O=ue.argumentsAsQueryString)&&void 0!==O?O:null===(L=null===(R=null===(P=null===(_=null===(D=n.customProperties)||void 0===D?void 0:D.appd)||void 0===_?void 0:_.hostManifests)||void 0===P?void 0:P.Finsemble)||void 0===R?void 0:R.window)||void 0===L?void 0:L.argumentsAsQueryString;if(fg(ue.arguments)&&(we?de.urlLoadOptions={queryString:ue.arguments}:de.parameters=ue.arguments),fg(ue.env)&&(de.env=ue.env),"exe"===n.type||"assimilation"===(null===(j=null===(N=null===($=null===(M=null===(F=null==n?void 0:n.customProperties)||void 0===F?void 0:F.appd)||void 0===M?void 0:M.hostManifests)||void 0===$?void 0:$.Finsemble)||void 0===N?void 0:N.window)||void 0===j?void 0:j.windowType)){let t=null!==(Y=null!==(G=null!==(B=de.parameters)&&void 0!==B?B:null===(z=null===(U=null===(q=null==n?void 0:n.customProperties)||void 0===q?void 0:q.appd)||void 0===U?void 0:U.details)||void 0===z?void 0:z.arguments)&&void 0!==G?G:null===(K=null===(J=null===(Q=null===(V=null===(H=null==n?void 0:n.customProperties)||void 0===H?void 0:H.appd)||void 0===V?void 0:V.hostManifests)||void 0===Q?void 0:Q.Finsemble)||void 0===J?void 0:J.window)||void 0===K?void 0:K.arguments)&&void 0!==Y?Y:"";if("exe"===n.type&&"assimilation"!==(null===(ne=null===(te=null===(ee=null===(X=null===(Z=null==n?void 0:n.customProperties)||void 0===Z?void 0:Z.appd)||void 0===X?void 0:X.hostManifests)||void 0===ee?void 0:ee.Finsemble)||void 0===te?void 0:te.window)||void 0===ne?void 0:ne.windowType)&&"external"!==(null===(ae=null===(se=null===(ie=null===(oe=null===(re=null==n?void 0:n.customProperties)||void 0===re?void 0:re.appd)||void 0===oe?void 0:oe.hostManifests)||void 0===ie?void 0:ie.Finsemble)||void 0===se?void 0:se.window)||void 0===ae?void 0:ae.windowType)&&(ve=t,be=n.name,t=ve.concat(` "componentType=${null!=be?be:"Unknown"}"`,` "iocdGatewayAddress=${globalThis.glue42gd.gwURL}"`," hostType=iocd"),!t.includes("apiToLogFile"))){const n=await e.contexts.get(tg);!0===(null===(le=null==n?void 0:n.iocd)||void 0===le?void 0:le.apiToLogFile)&&(t=t.concat(" apiToLogFile=true"))}de.parameters=t}var ve,be;return de.ignoreFromLayouts&&(de.isSticky=!1,"tab"!==de.mode&&"tab"!==n.details.mode||(de.mode="flat")),fg(de.iocd)?Vp()(de,de.iocd):de};class Dg{constructor(){this.promises=[]}addConstructor(){const e=new Kp;return this.promises.push(e.promise),e}finishConstructor(e){e.resolve()}async ready(){await eg().allSettled(this.promises)}}const _g=(e,t,n)=>n.indexOf(e)===t,Pg=(e,t,n)=>n.filter(t=>t===e).length>1,Rg=(e,t)=>t.failed.find(t=>t.name===e)?"failed":"success",Lg=(e,t)=>{var n;const r=null===(n=e.windowData)||void 0===n?void 0:n.filter(e=>"StackedWindow"===e.windowType),o=null==r?void 0:r.find(e=>{var n;return null===(n=e.childWindowIdentifiers)||void 0===n?void 0:n.some(e=>e.windowName===t.name)});return null!=o?o:null},Fg=e=>{var t,n;const r=e.icon&&""!==e.icon?{imageType:"url",path:e.icon}:void 0;return{window:{},component:{displayName:e.title,type:e.name,isUserDefined:!!(null===(t=e.customProperties)||void 0===t?void 0:t.isUserDefined)},foreign:{components:{"App Launcher":{launchableByUser:null===(n=hg(e.hidden))||void 0===n||n}}},icons:{toolbarIcon:r,taskbarIcon:r,titleBarIcon:r}}},Mg=(e,t,n)=>{var r;const o=(null!==(r=t.windowData)&&void 0!==r?r:[]).flatMap(e=>{var n,r,o,i,s,a,l;if("StackedWindow"===e.windowType)return[];const u=$g(((e,t)=>{var n,r,o,i;return null!==(i=null===(o=null===(r=null===(n=null==e?void 0:e.componentStates)||void 0===n?void 0:n[t.name])||void 0===r?void 0:r["Interop-#Linker-linkedChannels"])||void 0===o?void 0:o.channels)&&void 0!==i?i:[]})(t,e)),c=(e=>0===e?{windowState:"Normal",restoreState:"Normal"}:1===e?{windowState:"Minimized",restoreState:"Normal"}:3===e?{windowState:"Minimized",restoreState:"Maximized"}:2===e?{windowState:"Maximized",restoreState:"Normal"}:{windowState:"Normal",restoreState:"Normal"})(e.windowState),d=null===(n=Lg(t,e))||void 0===n?void 0:n.name,h=((e,t)=>{var n,r;const o=null!==(r=null===(n=e.componentStates)||void 0===n?void 0:n[t])&&void 0!==r?r:{},i={};return Object.keys(o).forEach(e=>{if("#finsemble-windowName"!==e&&"#finsemble-spawnData"!==e)if("Interop-#Linker-linkedChannels"!==e){if("Interop-#Workspace-contexts"===e){const t=o[e];return Object.entries(t).forEach(([e,t])=>{o[`#finsemble-persistedContext-${e}`]=t}),void delete o[e]}i[e]=o[e],delete o[e]}else delete o[e]}),o["#finsemble-componentState"]=i,o})(t,e.name),p=null!==(o=null===(r=t.componentStates)||void 0===r?void 0:r[e.name])&&void 0!==o?o:{},g={channels:Object.entries(null!==(i=p["customFDC3-channels"])&&void 0!==i?i:{}).flatMap(([e,t])=>"Both"===t?[{name:e,read:!0,write:!0}]:"Broadcast"===t?[{name:e,read:!1,write:!0}]:"Listen"===t?[{name:e,read:!0,write:!1}]:[])},f={application:e.componentType,type:null!==(s=e.type)&&void 0!==s?s:"window",componentType:"application",state:{context:h,isCollapsed:!1,windowState:c.windowState,channelSelector:{enabled:!0},channelRestrictions:g,mode:"tab",channelId:u,restoreState:c.restoreState,bounds:{left:e.left,top:e.top,width:e.width,height:e.height},isSticky:!0,instanceId:e.name}},{workspaces:m}=e;m&&(f.state.workspaces=m);const y=null!==(a=p.persistedTitle)&&void 0!==a?a:null;y&&(f.state.userTitle=y);const w=((e,t)=>{var n,r,o;const i=Lg(e,t),s=null!==(r=null===(n=null==i?void 0:i.childWindowIdentifiers)||void 0===n?void 0:n.findIndex(e=>e.windowName===t.name))&&void 0!==r?r:0,a=(null===(o=null==i?void 0:i.visibleWindowIdentifier)||void 0===o?void 0:o.windowName)===t.name;return(s+1)*(!i||a?-1:1)})(t,e),v=null!==(l=((e,t)=>{const n=Lg(e,t);return null==n?void 0:n.name})(t,e))&&void 0!==l?l:Zp()(),b=((e,t,n)=>{var r;const[o]=null!==(r=Object.entries(e.groups).find(([e,r])=>(e=>{let r=!1;return e.isMovable&&(r=e.windowNames.includes(t.name)||e.windowNames.includes(null!=n?n:""),r||e.windowNames.forEach(e=>{t.name.endsWith(e)&&(r=!0)})),r})(r)))&&void 0!==r?r:[null];return o})(t,e,d);return fg(w)&&(f.state.tabIndex=w),f.state.tabGroupId=v,("exe"!==e.type||b)&&(f.state.restoreSettings={groupId:null!=b?b:`${v}-1`,groupZOrder:0}),[f]}),i={"iop#position":n};return t.id&&(i.id=t.id),{name:e,type:"Global",components:o,context:{},metadata:i,version:2}},$g=e=>e.join("+++"),Ng=e=>""!==e&&e?e.split("+++"):[],jg=e=>{var t;const n=(e=>{const t=e.map(e=>{var t,n;return null===(n=null===(t=e.state)||void 0===t?void 0:t.restoreSettings)||void 0===n?void 0:n.groupId}).filter(fg).filter(_g),n=t.map(t=>[t,{isMovable:!0,isAlwaysOnTop:!1,windowNames:e.flatMap(e=>{var n,r;return(null===(r=null===(n=e.state)||void 0===n?void 0:n.restoreSettings)||void 0===r?void 0:r.groupId)===t?[e.state.instanceId]:[]})}]).filter(e=>e[1].windowNames.length>1);return Object.fromEntries(n)})(e.components),{windowData:r,stacks:o}=(e=>{const t=e.map(e=>{var t,n,r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b;const C=e.application;return{componentType:C,name:`${C}${e.state.instanceId}`,opacity:1,windowState:(S=e.state.windowState,I=e.state.restoreState,"Normal"===S?0:"Minimized"===S&&"Normal"===I?1:"Minimized"===S&&"Maximized"===I?3:"Maximized"===S?2:0),left:null===(n=null===(t=e.state)||void 0===t?void 0:t.bounds)||void 0===n?void 0:n.left,top:null===(o=null===(r=e.state)||void 0===r?void 0:r.bounds)||void 0===o?void 0:o.top,width:null===(s=null===(i=e.state)||void 0===i?void 0:i.bounds)||void 0===s?void 0:s.width,height:null===(l=null===(a=e.state)||void 0===a?void 0:a.bounds)||void 0===l?void 0:l.height,right:null===(c=null===(u=e.state)||void 0===u?void 0:u.bounds)||void 0===c?void 0:c.right,bottom:null===(h=null===(d=e.state)||void 0===d?void 0:d.bounds)||void 0===h?void 0:h.bottom,defaultLeft:null===(g=null===(p=e.state)||void 0===p?void 0:p.bounds)||void 0===g?void 0:g.left,defaultTop:null===(m=null===(f=e.state)||void 0===f?void 0:f.bounds)||void 0===m?void 0:m.top,defaultWidth:null===(w=null===(y=e.state)||void 0===y?void 0:y.bounds)||void 0===w?void 0:w.width,defaultHeight:null===(b=null===(v=e.state)||void 0===v?void 0:v.bounds)||void 0===b?void 0:b.height,workspaces:e.state.workspaces,type:e.type};var S,I}),n=e.map(e=>e.state.tabGroupId).filter(fg).filter(Pg).filter(_g),r=(e,t)=>Math.abs(e.state.tabIndex)>Math.abs(t.state.tabIndex)?1:Math.abs(e.state.tabIndex)<Math.abs(t.state.tabIndex)?-1:0,o=n.map(t=>{const n=e.find(e=>e.state.tabGroupId===t&&e.state.tabIndex<0),o=e.filter(e=>e.state.tabGroupId===t).sort(r).map(e=>({windowName:`${e.application}${e.state.instanceId}`}));return{name:t,windowType:"StackedWindow",componentType:"StackedWindow",visibleWindowIdentifier:{windowName:n?`${n.application}${n.state.instanceId}`:void 0},childWindowIdentifiers:o,left:null==n?void 0:n.state.bounds.left,top:null==n?void 0:n.state.bounds.top,width:null==n?void 0:n.state.bounds.width,height:null==n?void 0:n.state.bounds.height,bounds:{left:null==n?void 0:n.state.bounds.left,top:null==n?void 0:n.state.bounds.top,width:null==n?void 0:n.state.bounds.width,height:null==n?void 0:n.state.bounds.height}}});return{windowData:t.concat(o),stacks:o}})(e.components),i=(e=>{const t=e.map(e=>{var t,n,r,o,i,s;const a=`${e.application}${e.state.instanceId}`,l=Ng(e.state.channelId),u=e.state.channelId?{"Interop-#Linker-linkedChannels":{channels:l}}:{},c={...null!==(n=null===(t=e.state)||void 0===t?void 0:t.context)&&void 0!==n?n:{},...null===(o=null===(r=e.state)||void 0===r?void 0:r.context)||void 0===o?void 0:o["#finsemble-componentState"],...u};delete c["#finsemble-componentState"];const d=null!==(s=null===(i=e.state.channelRestrictions)||void 0===i?void 0:i.channels)&&void 0!==s?s:[];return c["customFDC3-channels"]=Object.fromEntries(l.map(e=>{const t=d.find(t=>t.name===e);return t&&!t.read?[e,"Broadcast"]:t&&!t.write?[e,"Listen"]:[e,"Both"]})),e.state.userTitle&&(c.persistedTitle=e.state.userTitle),(e=>{const t={};Object.keys(e).forEach(n=>{const r=n.split("#finsemble-persistedContext-")[1];r&&(t[r]=e[n],delete e[n])}),e["Interop-#Workspace-contexts"]=t})(c),[a,c]});return Object.fromEntries(t)})(e.components);o.forEach(e=>i[e.name]={});const s=r.map(e=>e.name),a={version:"1.0.0",name:e.name,type:"workspace",groups:n,windows:s,componentStates:i,custom:{},windowData:r,tabCollections:[]};return(null===(t=e.metadata)||void 0===t?void 0:t.id)&&(a.id=e.metadata.id),a},Bg=e=>{var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return;const n={left:(null===(t=e.workArea)||void 0===t?void 0:t.left)*(null==e?void 0:e.scaleFactor),top:e.workArea.top*e.scaleFactor,width:e.workArea.width,height:e.workArea.height};n.right=n.left+n.width,n.bottom=n.top+n.height;const r={left:e.bounds.left*e.scaleFactor,top:e.bounds.top*e.scaleFactor,width:e.bounds.width,height:e.bounds.height};return r.right=r.left+r.width,r.bottom=r.top+r.height,{availableRect:n,monitorRect:r}},qg=e=>{var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return null;const{availableRect:n,monitorRect:r}=Bg(e);return{monitor:{dipRect:n,scaledRect:n},availableRect:n,monitorRect:r,name:`device${e.index}`,deviceId:Number(null!==(t=e.id)&&void 0!==t?t:0).toString(),deviceScaleFactor:1/e.scaleFactor,displayDeviceActive:!0,position:e.index,whichMonitor:e.isPrimary?"primary":e.index}},Ug=(e,t)=>{if(t.includes("%")){const n=parseFloat(t)/100;return Math.abs(e*n)}return parseInt(t)},zg=(e,t)=>{const n="string"==typeof t.top?Ug(e.height,t.top):t.top,r="string"==typeof t.left?Ug(e.width,t.left):t.left,o="string"==typeof t.height?Ug(e.height,t.height):t.height;return{top:n,left:r,width:"string"==typeof t.width?Ug(e.width,t.width):t.width,height:o}},Gg=async(e,t,n)=>{const r=`#internal-tmp-${Zp()()}`,{err:o}=await pg(()=>e.layouts.save({name:r,type:"Global",setAsCurrent:!1,metadata:null==n?void 0:n.metadata}));o&&t("getBlobForCurrentLayout layouts.save()","error",o.toString());const{err:i,data:s}=await pg(()=>e.layouts.export("Global"));i&&t("getBlobForCurrentLayout layouts.export()","error",i.toString());const a=null==s?void 0:s.find(e=>e.name===r),{err:l}=await pg(()=>e.layouts.remove("Global",r));return l&&t("getBlobForCurrentLayout layouts.remove()","error",l.toString()),a},Hg=async(e,t)=>{var n,r;const o=e=>e.map(e=>{var t,n,r,o,i,s,a,l,u,c,d,h;return{application:e.application,state:{userTitle:e.state.userTitle,bounds:{left:null===(n=null===(t=e.state)||void 0===t?void 0:t.bounds)||void 0===n?void 0:n.left,top:null===(o=null===(r=e.state)||void 0===r?void 0:r.bounds)||void 0===o?void 0:o.top,width:null===(s=null===(i=e.state)||void 0===i?void 0:i.bounds)||void 0===s?void 0:s.width,height:null===(l=null===(a=e.state)||void 0===a?void 0:a.bounds)||void 0===l?void 0:l.height},channelId:null===(u=null==e?void 0:e.state)||void 0===u?void 0:u.channelId,channelRestrictions:null===(c=null==e?void 0:e.state)||void 0===c?void 0:c.channelRestrictions,tabIndex:null===(d=null==e?void 0:e.state)||void 0===d?void 0:d.tabIndex,windowState:null===(h=null==e?void 0:e.state)||void 0===h?void 0:h.windowState}}});try{const i=await e.layouts.getCurrentLayout(),s=await Gg(e,t,i),a=(await e.layouts.export("Global")).find(e=>e.name===(null==i?void 0:i.name)),l=o(null!==(n=null==a?void 0:a.components)&&void 0!==n?n:[]),u=o(null!==(r=null==s?void 0:s.components)&&void 0!==r?r:[]);t("isWorkspaceDirty","debug",{minimalOld:l,minimalNew:u});const c=JSON.stringify(l)!==JSON.stringify(u);return t("isWorkspaceDirty","return",c),c}catch(e){t("isWorkspaceDirty","error",e)}return t("isWorkspaceDirty","return",!1),!1},Vg=async(e,t,n,r,o)=>{var i,s,a,l,u,c,d,h,p;if(null==o?void 0:o.bypassSaving)return!1;const g=await e.contexts.get(tg);if(null!==(a=null===(s=null===(i=null==g?void 0:g.servicesConfig)||void 0===i?void 0:i.workspace)||void 0===s?void 0:s.discardUnsavedChanges)&&void 0!==a&&a)return!1;const f=await Hg(e,()=>{});if(!f)return!1;if(f&&(null==o?void 0:o.forceRestart))return n(),!1;if(null===(d=null===(c=null===(u=null===(l=null==g?void 0:g.finsemble)||void 0===l?void 0:l.servicesConfig)||void 0===u?void 0:u.workspace)||void 0===c?void 0:c.promptUserOnDirtyWorkspace)||void 0===d||d){const o=await e.layouts.getCurrentLayout(),i=null!==(p=null===(h=null==g?void 0:g.finsemble)||void 0===h?void 0:h.shutdownTimeout)&&void 0!==p?p:15e3,s=new Kp;t("YesNoDialog",{monitor:"primary",title:"Save your workspace?",question:`Would you like to save "${null==o?void 0:o.name}" before ${r?"restarting":"shutting down"}?`,showTimer:!0,timerDuration:i-5e3,negativeResponseLabel:"Don't Save",affirmativeResponseLabel:"Save",showCancelButton:!1},(e,t)=>{s.resolve(t)});const a=await s.promise;if("cancel"===(null==a?void 0:a.choice))return!0;"affirmative"===(null==a?void 0:a.choice)&&n(),"expired"===(null==a?void 0:a.choice)&&n()}return!1},Qg="FSBL.SearchProvider.",Jg=async(e,t,n)=>{const{err:r,data:o}=await gg(()=>e.interop.invoke("FSBL.Clients.WorkspaceClient.triggerEventHandlers",{event:t,workspaceName:n}));return{err:r,data:o}},Kg=(e,t,{api:n,method:r,type:o,data:i})=>{if("start"===o&&(null==t||t.metrics.featureMetric("finsemble-polyfill",n,r)),"deprecated"===o)return null==t||t.metrics.featureMetric("finsemble-polyfill-deprecated",n,r),void e.error("DEPRECATED FUNCTION CALLED",`${n}.${r}()`,o,i);e[o]?e[o](`${n}.${r}()`,i):e.debug(`${n}.${r}()`,o,i)};var Yg;!function(e){e[e.NORMAL=0]="NORMAL",e[e.MINIMIZED_WAS_NORMAL=1]="MINIMIZED_WAS_NORMAL",e[e.MAXIMIZED=2]="MAXIMIZED",e[e.MINIMIZED_WAS_MAXIMIZED=3]="MINIMIZED_WAS_MAXIMIZED"}(Yg||(Yg={}));class Zg{constructor(e,t){this.asyncConstructors=t,this.windowOptions={},this.gate=new og,this.eventHandlers=[],this.closeRequestedHandlers=[],this.wrap=Zg.getInstance;const n=t.addConstructor();e.then(async e=>{var r,o,i,s;this.glue=e;const a=null===(r=this.glue.windows)||void 0===r?void 0:r.my();if(a){this.gdwin=a,this.windowName=null!==(i=null===(o=this.gdwin)||void 0===o?void 0:o.context["#finsemble-windowName"])&&void 0!==i?i:null===(s=this.gdwin)||void 0===s?void 0:s.id,this.name=this.windowName,this.windowOptions=await xg(this.gdwin);const{data:e}=await Cg({field:"isAlwaysOnTop"},this.gdwin);e?await this.gdwin.setOnTop("always"):this.gdwin.settings.onTop&&await Ig({field:"isAlwaysOnTop",value:this.gdwin.settings.onTop},this.gdwin)}else globalThis.window&&this.logStatus("constructor","warn","Constructing FinsembleWindow on incompatible window type.");t.finishConstructor(n)})}logStatus(e,t,n){Kg(Zg.loggerClient,this.glue,{api:"FinsembleWindow",method:e,type:t,data:n})}static setStaticInstances(e,t){Zg.glueInstance=e,Zg.loggerClient=t}async getComponentState(e,t){this.logStatus("getComponentState","start"),await this.asyncConstructors.ready();const n=(null==e?void 0:e.windowName)?this.glue.windows.findById(e.windowName):this.gdwin,r=await Cg(e,n);return this.logStatus("getComponentState","return",r),null==t||t(r.err,r.data),r}async setComponentState(e,t){return await this.gate.wait(async()=>this.setComponentStateInternal(e,t))}async setComponentStateInternal(e,t){this.logStatus("setComponentState","start"),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await Ig(e,n);return this.logStatus("setComponentState","return"),null==t||t(r.err,r.data),r}async removeComponentState(e,t){this.logStatus("removeComponentState","start"),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await kg(e,n);return this.logStatus("removeComponentState","return"),null==t||t(r.err,r.data),r}static async getInstance(e,t){var n,r,o,i,s;Zg.loggerClient.debug("FinsembleWindowImpl.getInstance","start");const a=new Dg,l=new Zg(Zg.glueInstance,a);await a.ready();const u=null!==(r=null!==(n=null==e?void 0:e.windowName)&&void 0!==n?n:null==e?void 0:e.name)&&void 0!==r?r:null==e?void 0:e.id,c=null!==(i=null!==(o=l.glue.windows.findById(u))&&void 0!==o?o:l.glue.windows.list().find(e=>e.name===u))&&void 0!==i?i:l.glue.windows.list().find(e=>e.context["#finsemble-windowName"]===u);if(c)return l.gdwin=c,l.windowName=null!==(s=null==c?void 0:c.context["#finsemble-windowName"])&&void 0!==s?s:null==c?void 0:c.id,l.name=l.windowName,l.windowOptions=await xg(c),null==t||t(null,l),Zg.loggerClient.debug("FinsembleWindowImpl.getInstance","return"),{wrap:l};{const e=`FinsembleWindow.getInstance(): Cannot find window instance for id ${u}`;throw null==t||t(e),new Error(e)}}removeEventListener(e,t,n=!1){if(this.logStatus("removeEventListener","start",e),"close-requested"===e){const e=this.closeRequestedHandlers.findIndex(e=>e.handler===t);e>-1&&(this.closeRequestedHandlers[e].gdwin.onClosing(async()=>{}),this.closeRequestedHandlers.splice(e,1))}else{const n=this.eventHandlers.findIndex(n=>(null==n?void 0:n.eventName)===e&&(null==n?void 0:n.handler)===t);this.eventHandlers[n].unsubscriber(),delete this.eventHandlers[n]}this.logStatus("removeEventListener","return")}addEventListener(e,t){switch(this.logStatus("addEventListener","start",e),e){case"maximized":{const n=this.gdwin.onMaximized(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"minimized":{const n=this.gdwin.onMinimized(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"restored":{const n=this.gdwin.onNormal(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"blurred":{const n=this.gdwin.onFocusChanged(()=>{this.gdwin.isFocused||t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"focused":{const n=this.gdwin.onFocusChanged(()=>{this.gdwin.isFocused&&t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"shown":{const n=this.gdwin.onVisibilityChanged(()=>{this.gdwin.isVisible&&t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"hidden":{const n=this.gdwin.onVisibilityChanged(()=>{this.gdwin.isVisible||t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"title-changed":{const n=this.gdwin.onTitleChanged(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"bounds-changed":{const n=this.gdwin.onBoundsChanged(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"clicked":{const n=this.gdwin.onFrameButtonClicked(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"created":{const n=this.glue.windows.onWindowAdded(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"closed":case"close-complete":{const n=this.gdwin.onClose(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"close-requested":{const e={handler:t,gdwin:this.gdwin};this.closeRequestedHandlers.push(e);const n=async e=>{await new Promise(n=>{let r=!1,o=!1;t({wait:()=>{r=!0},done:()=>{o=!0,n()},cancel:()=>{o=!0,e({showDialog:!1}),n()}}),r||o||n()})};return this.gdwin.onClosing(n),()=>{console.error("iocd does not support unsubscribing from onClosing() handler")}}default:return()=>{console.log(`Event ${e} is not implemented`)}}}removeListener(e,t,n=!1){return this.logStatus("removeListener","start",e),this.removeEventListener(e,t,n)}addListener(e,t){return this.addEventListener(e,t)}ejectFromGroup(){this.logStatus("ejectFromGroup","start"),console.log("ejectFromGroup is not implemented in the Finsemble polyfill")}formGroup(){this.logStatus("formGroup","start"),Sg(this.glue,this.gdwin.id),this.logStatus("formGroup","return")}async getOptions(e){return this.logStatus("getOptions","start"),null==e||e(null,this.windowOptions),{data:this.windowOptions}}getMonitor(e){this.logStatus("getMonitor","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.getDisplay().then(t=>{const n=this.convertGetMonitor(t);e(n)})}),this.logStatus("getMonitor","return")}convertGetMonitor(e){var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return;const{availableRect:n,monitorRect:r}=Bg(e);return{name:"device"+(Number(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.replace(/\D/g,""))-1),left:n.left,top:n.top,right:n.right,bottom:n.bottom,availableRect:n,monitorRect:r,bounds:{max:{x:n.right,y:n.bottom},min:{x:n.left,y:n.top}}}}setOpacity(e,t){this.logStatus("setOpacity","start"),console.log("setOpacity is not implemented in the Finsemble polyfill")}showNativeOpenDialog(e={},t){this.logStatus("showNativeOpenDialog","start"),console.log("showNativeOpenDialog is not implemented in the Finsemble polyfill")}async close(e={},t){this.logStatus("close","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.close(),t);return this.logStatus("close","return"),{err:n}}showAt(e,t){this.logStatus("showAt","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.isVisible||this.gdwin.show(),this.gdwin.moveTo(null==e?void 0:e.top,null==e?void 0:e.left).then(()=>{this.logStatus("showAt","return"),null==t||t(null)})})}async show(e={},t){this.logStatus("show","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.show(),t);return this.logStatus("show","return"),{err:n}}reload(e={},t){this.logStatus("reload","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.refresh(!1).then(()=>{this.logStatus("reload","return"),null==t||t(null)})})}async hide(e={},t){this.logStatus("hide","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.hide(),t);return this.logStatus("hide","return"),{err:n}}updateOptions(e,t){this.logStatus("updateOptions","start"),console.log("updateOptions is not implemented in the Finsemble polyfill")}async getBounds(e,t){this.logStatus("getBounds","start"),await this.asyncConstructors.ready();const n="function"==typeof e?e:t,{err:r,data:o}=await pg(()=>this.gdwin.getBounds());return r&&this.logStatus("getBounds","error",r),null==n||n(null,o),this.logStatus("getBounds","return",o),{err:null,data:o}}async setBounds(e={bounds:{}},t){this.logStatus("setBounds","start"),await this.asyncConstructors.ready(),"function"==typeof e||e.bounds||(e={bounds:e});const{err:n}=await pg(()=>this.gdwin.moveResize(e.bounds),t);return this.logStatus("setBounds","return"),{err:n}}async setViewBounds(e,t){this.logStatus("setViewBounds","start"),console.log("setViewBounds is not implemented in the Finsemble polyfill")}async bringViewToFront(e,t){this.logStatus("bringViewToFront","start"),console.log("bringViewToFront is not implemented in the Finsemble polyfill")}async removeBrowserView(e,t){this.logStatus("removeBrowserView","start"),console.log("removeBrowserView is not implemented in the Finsemble polyfill")}async addBrowserView(e,t){return this.logStatus("addBrowserView","start"),console.log("addBrowserView is not implemented in the Finsemble polyfill"),null}async showBrowserView(e,t){this.logStatus("showBrowserView","start"),console.log("showBrowserView is not implemented in the Finsemble polyfill")}async hideBrowserView(e,t){this.logStatus("hideView","start"),console.log("hideView is not implemented in the Finsemble polyfill")}setShape(e,t){this.logStatus("setShape","start"),console.log("setShape is not implemented in the Finsemble polyfill")}isShowing(e={},t){this.logStatus("isShowing","start"),t(null,this.gdwin.isVisible&&"minimized"!==this.gdwin.state),this.logStatus("isShowing","return")}async isAlwaysOnTop(e={},t){this.logStatus("isAlwaysOnTop","start");const{data:n}=await this.getComponentState({field:"isAlwaysOnTop"});return null==t||t(null,n),this.logStatus("isAlwaysOnTop","return"),n}async setAlwaysOnTop(e={alwaysOnTop:!0},t){this.logStatus("setAlwaysOnTop","start"),await this.asyncConstructors.ready(),this.setComponentState({field:"isAlwaysOnTop",value:e.alwaysOnTop});const{err:n}=await pg(()=>this.gdwin.setOnTop(!!e.alwaysOnTop&&"always"),t);return this.logStatus("setAlwaysOnTop","return"),{err:n}}async bringToFront(e=null,t){this.logStatus("bringToFront","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.show()),{err:r}=await pg(()=>this.gdwin.focus());return null==t||t(null!=n?n:r),this.logStatus("bringToFront","return"),{err:null!=n?n:r}}async focus(e=null,t){this.logStatus("focus","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.focus(),t);return this.logStatus("focus","return"),{err:n}}async blur(e=null,t){return this.logStatus("blur","start"),await this.asyncConstructors.ready(),console.log("blur is not implemented in the Finsemble polyfill"),{err:null}}async restore(e=null,t){this.logStatus("restore","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.restore(),t);return this.logStatus("restore","return"),{err:n}}async maximize(e=null,t){this.logStatus("maximize","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.maximize(),t);return this.logStatus("maximize","return"),{err:n}}async minimize(e=null,t){this.logStatus("minimize","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.minimize(),t);return this.logStatus("minimize","return"),{err:n}}}Zg.WINDOWSTATE=Yg;const Xg={};class ef{constructor(e,t,n,r){this.asyncConstructors=t,this.routerClient=n,this.loggerClient=r;const o=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(o)}),this.bringWindowsToFront=this.bringWindowsToFront.bind(this),this.minimizeWindows=this.minimizeWindows.bind(this)}async getInstance(e,t){try{t&&(this.logStatus("spawn","debug","waiting for instance.getWindow()"),await t.getWindow());const{wrap:n}=await Zg.getInstance({windowName:e});return n}catch(e){return this.logStatus("getInstance","error",e.toString()),null}}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AppsClient",method:e,type:t,data:n})}async addUserDefinedComponent(e,t){const n={type:"window",name:e.name,title:e.name,details:{url:e.url},customProperties:{isUserDefined:!0}},{err:r}=await pg(()=>this.glue.appManager.inMemory.import([n],"merge"));if(!r){const t={[e.name]:e};await pg(()=>this.glue.prefs.updateFor("IO.Global.UserDefinedApps",t))}return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.addUserDefinedComponent",e)),null==t||t(r),{err:r}}async removeUserDefinedComponent(e,t){var n;const{err:r}=await pg(()=>this.glue.appManager.inMemory.remove(e.name));if(!r){const{data:t}=await pg(()=>this.glue.prefs.get("IO.Global.UserDefinedApps")),r=null!==(n=null==t?void 0:t.data)&&void 0!==n?n:{};delete r[e.name],await pg(()=>this.glue.prefs.setFor("IO.Global.UserDefinedApps",r))}return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.removeUserDefinedComponent",e)),null==t||t(r),{err:r}}async getApps(e,t){this.logStatus("getApps","start",{appIds:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await pg(()=>this.glue.appManager.getConfigurations());if(n||!r){const r=`AppsClient.getApps:getConfigurations ${n}`;return this.logStatus("getApps","error",{appIds:e}),null==t||t(r),{err:r}}const o=r.flatMap(e=>{var t,n,r,o;return(null===(t=null==e?void 0:e.customProperties)||void 0===t?void 0:t.component)?[]:[Vp()(null!==(n=(e=>{const t=Fg(e);return{appId:e.name,type:"exe"===e.type?"native":"web",hostManifests:{Finsemble:t},details:e.details.url?{url:e.details.url}:{path:e.details.command}}})(e))&&void 0!==n?n:{},null!==(o=null===(r=null==e?void 0:e.customProperties)||void 0===r?void 0:r.appd)&&void 0!==o?o:{})]}),i=o.filter(t=>!e||e.includes(t.appId));return this.logStatus("getApps","return",{err:null,data:i}),null==t||t(null,i),{err:null,data:i}}async getComponentList(e){this.logStatus("getComponentList","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await(async e=>{const{err:t,data:n}=await pg(()=>e.appManager.getConfigurations());if(t||!n)return{err:`getComponentList:getConfigurations ${t}`};const r=n.flatMap(e=>{var t,n,r,o,i,s;const a=null!==(n=null===(t=null==e?void 0:e.customProperties)||void 0===t?void 0:t.component)&&void 0!==n?n:null===(i=null===(o=null===(r=null==e?void 0:e.customProperties)||void 0===r?void 0:r.appd)||void 0===o?void 0:o.hostManifests)||void 0===i?void 0:i.Finsemble,l=Vp()(null!=a?a:{},Fg(e));return[Vp()(l,{appConfig:null===(s=null==e?void 0:e.customProperties)||void 0===s?void 0:s.appd})]}),o=Object.fromEntries(r.map(e=>{var t,n;return[null!==(n=null===(t=null==e?void 0:e.component)||void 0===t?void 0:t.type)&&void 0!==n?n:"Unknown Component",e]}));return{err:null,data:o}})(this.glue);return this.logStatus("getComponentList","return",{err:t,data:n}),null==e||e(t,n),{err:t,data:n}}async addApps(e,t){this.logStatus("addApps","start",{apps:e}),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.addApps",{apps:e}));return this.logStatus("addApps","return",{err:n,data:e}),null==t||t(n,e),{err:n,data:e}}async removeApps(e,t){this.logStatus("removeApps","start",{appIds:e}),await this.asyncConstructors.ready();const n=e.map(e=>this.glue.appManager.inMemory.remove(e)),r=(await eg().allSettled(n)).flatMap(e=>"rejected"===e.status?[e.reason]:[]),o=r.length?r.join(" "):null;return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.removeApps",{appIds:e})),this.logStatus("removeApps","return",{err:o,data:e}),null==t||t(o,e),{err:o,data:e}}async getActiveDescriptors(e){this.logStatus("getActiveDescriptors","start"),await this.asyncConstructors.ready();const t=this.glue.windows.list(),n=await this.glue.appManager.getConfigurations(),r=t.map(e=>((e,t)=>{var n,r,o,i,s,a,l,u,c;const d=t.find(t=>t.name===e.name);return{name:null!==(n=e.context["#finsemble-windowName"])&&void 0!==n?n:e.id,iocdID:e.id,defaultLeft:e.bounds.left,defaultTop:e.bounds.top,defaultBottom:e.bounds.top+e.bounds.height,defaultWidth:e.bounds.width,defaultHeight:e.bounds.height,defaultRight:e.bounds.left+e.bounds.width,componentType:e.name,customData:{isAnApp:!!(null===(r=null==d?void 0:d.customProperties)||void 0===r?void 0:r.appd),appConfig:{appId:e.name,component:e.name},spawnData:null===(o=e.context)||void 0===o?void 0:o["#finsemble-spawnData"],preload:null!==(c=null===(u=null===(l=null===(a=null===(s=null===(i=null==d?void 0:d.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble)||void 0===l?void 0:l.component)||void 0===u?void 0:u.preload)&&void 0!==c?c:[]},left:e.bounds.left,top:e.bounds.top,right:e.bounds.left+e.bounds.width,bottom:e.bounds.top+e.bounds.height,width:e.bounds.width,height:e.bounds.height}})(e,n)),o=Object.fromEntries(r.map(e=>[e.name,e]));return this.logStatus("getActiveDescriptors","return",{err:null,data:o}),null==e||e(null,o),{err:null,data:o}}async getMyWindowIdentifier(e){this.logStatus("getMyWindowIdentifier","start"),await this.asyncConstructors.ready();const t=await lg(this.glue);return this.logStatus("getMyWindowIdentifier","return",t),null==e||e(t),t}async bringWindowsToFront(e,t){return await this.asyncConstructors.ready(),await cg(this.glue,e,t)}async minimizeWindows(e,t){return await this.asyncConstructors.ready(),await dg(this.glue,e,t)}async spawnTabCollection({componentList:e,globalParams:t},n){var r,o,i;this.logStatus("spawnTabCollection","start",{componentList:e,globalParams:t}),await this.asyncConstructors.ready();let s=null;const a=await(async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)try{const o=await t(e[r]);n.push({status:"fulfilled",value:o})}catch(e){n.push({status:"rejected",reason:e.toString()})}return n.flatMap(e=>"fulfilled"===e.status?[e.value]:[])})(e,async e=>{var n,r,o,i,a,l;const u=this.glue.appManager.application(e.appID);if(!u)return{err:`Application ${e.appID} not found`,data:null};const c=await this.glue.appManager.getConfigurations([e.appID]),d=await Og(this.glue,(0,Qp.merge)({},null!==(n=e.individualParams)&&void 0!==n?n:{},null!=t?t:{}),null!==(r=c[0])&&void 0!==r?r:{});s&&(d.tabGroupId=s);const h=null!==(a=null===(i=null===(o=e.individualParams)||void 0===o?void 0:o.options)||void 0===i?void 0:i.customData)&&void 0!==a?a:null===(l=e.individualParams)||void 0===l?void 0:l.data,p=h?{"#finsemble-spawnData":h}:{},g=await u.start(p,d);return s=g.window.tabGroupId,{err:null,data:g}}),l={id:null!==(i=null===(o=null===(r=null==a?void 0:a[0])||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)&&void 0!==i?i:"",windows:await sg(a,async e=>{var t,n,r,o,i,s;const a=await this.getInstance(null===(t=e.data)||void 0===t?void 0:t.id,e.data);return{windowDescriptor:{name:null!==(r=null===(n=e.data)||void 0===n?void 0:n.id)&&void 0!==r?r:""},windowIdentifier:{windowName:null!==(i=null===(o=e.data)||void 0===o?void 0:o.id)&&void 0!==i?i:"",componentType:null===(s=e.data)||void 0===s?void 0:s.window.name},finWindow:a}})};return this.logStatus("spawnTabCollection","return",{err:null,data:l}),null==n||n(null,l),{err:null,data:l}}async clone(e,t,n){this.logStatus("clone","start",{toClone:e,spawnParams:t}),await this.asyncConstructors.ready();const r=e?this.glue.windows.findById(e.windowName):this.glue.windows.my();if(!r){const e="Attempt to clone incompatible window type (called from webgroup?)";return this.logStatus("clone","error",e),null==n||n(e),{error:e}}try{const e=await r.clone();this.logStatus("clone","return");const t=await this.getInstance(e.id),o={windowDescriptor:{name:e.id},windowIdentifier:{windowName:e.id,componentType:e.name},finWindow:t};return null==n||n(null,o),{error:null,response:o}}catch(e){const t=e.toString();return this.logStatus("clone","error",t),null==n||n(t),{error:t}}}async spawn(e,t,n){var r,o,i,s,a,l;this.logStatus("spawn","start",{component:e,params:t}),await this.asyncConstructors.ready();const u=await this.glue.appManager.getConfigurations([e]),{error:c,data:d,launchGroupWindows:h}=await(async(e,t,n)=>{var r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S;const I=await e.appManager.getConfigurations([t]),{didSpawn:k,error:T,instance:x,launchGroupWindows:A}=await(async(e,t,n)=>{var r,o,i,s,a,l;if(!n)return{didSpawn:!1};if("launchGroup"!==(null===(a=null===(s=null===(i=null===(o=null===(r=n.customProperties)||void 0===r?void 0:r.appd)||void 0===o?void 0:o.hostManifests)||void 0===i?void 0:i.Finsemble)||void 0===s?void 0:s.window)||void 0===a?void 0:a.windowType))return{didSpawn:!1};const{err:u,data:c}=await(async(e,t,n)=>{var r,o,i,s,a,l,u;const c=null!==(r=t.title)&&void 0!==r?r:"Group",d=null!==(o=null==n?void 0:n.toSpawn)&&void 0!==o?o:null===(a=null===(s=null===(i=t.hostManifests)||void 0===i?void 0:i.Finsemble)||void 0===s?void 0:s.window)||void 0===a?void 0:a.toSpawn;if(!d||!Array.isArray(d))return{err:`convertFinsembleLaunchGroupAppd2GlueGroupOptions: Unexpected value in appd hostManifests.Finsemble.window.toSpawn property. Expected array, received: ${d}`};let h=e.windows.my();h||(h=e.windows.find("Toolbar"));const p=await(null==h?void 0:h.getDisplay());if(!p)return{err:"convertFinsembleLaunchGroupAppd2GlueGroupOptions: Can't get display"};const g=await zg(null==p?void 0:p.bounds,null===(u=null===(l=t.hostManifests)||void 0===l?void 0:l.Finsemble)||void 0===u?void 0:u.window),f=d.map(e=>{var t;const{top:n,left:r,height:o,width:i}=null!==(t=e.spawnOptions)&&void 0!==t?t:{},s=zg(g,{top:n,left:r,height:o,width:i});return"components"in e?{mode:"tab",bounds:s,applications:e.components.map(({componentType:e})=>({name:e}))}:{mode:"tab",bounds:s,applications:[{name:e.componentType}]}});return{data:{context:{},groups:[{title:c,frames:f}]}}})(e,null===(l=n.customProperties)||void 0===l?void 0:l.appd,t);if(!c)return{didSpawn:!1};const{err:d,data:h}=await pg(()=>e.windows.groups.create(c));if(d||!h)return{didSpawn:!1,error:null!=d?d:"No data returned"};const p=h[0];return{didSpawn:!0,error:d,instance:p,launchGroupWindows:p.windows.map(({id:e})=>e)}})(e,null!=n?n:{},null!==(r=I[0])&&void 0!==r?r:{});if(k)return{error:T,data:x,launchGroupWindows:A};const{err:E,data:W}=await pg(()=>e.appManager.application(t));if(E||!W){const e=`AppsClient.spawn:application ${E}`;return console.log(e),{error:e,data:void 0}}const O=await Og(e,n,null!==(o=I[0])&&void 0!==o?o:{});O.awaitInterop=!1;const{data:D}=null!==(i=await pg(()=>Wg(e.windows.my())))&&void 0!==i?i:{},_=(null!==(d=null===(c=null===(u=null===(l=null===(a=null===(s=null==D?void 0:D.customProperties)||void 0===s?void 0:s.appd)||void 0===a?void 0:a.hostManifests)||void 0===l?void 0:l.Finsemble)||void 0===u?void 0:u.interop)||void 0===c?void 0:c.selectConnect)&&void 0!==d?d:[]).find(e=>e.autoAssociate);if(_){const n=await e.channels.current();(_.autoAssociate.allChildren||(null===(h=_.autoAssociate.selectChildren)||void 0===h?void 0:h.includes(t)))&&(O.channelId=n)}const P=(0,Qp.merge)(null!==(v=null===(w=null===(y=null===(m=null===(f=null===(g=null===(p=I[0])||void 0===p?void 0:p.customProperties)||void 0===g?void 0:g.appd)||void 0===f?void 0:f.hostManifests)||void 0===m?void 0:m.Finsemble)||void 0===y?void 0:y.window)||void 0===w?void 0:w.data)&&void 0!==v?v:{},null!==(S=null!==(b=null==n?void 0:n.data)&&void 0!==b?b:null===(C=null==n?void 0:n.options)||void 0===C?void 0:C.customData)&&void 0!==S?S:{}),R=null==n?void 0:n.componentState,L=P?{"#finsemble-spawnData":P}:{};R&&(L["#finsemble-componentState"]=R),(null==n?void 0:n.name)&&(L["#finsemble-windowName"]=n.name);const{err:F,data:M}=await pg(()=>W.start(L,O));return{error:F,data:M}})(this.glue,e,t);if(c||!d){const e=`AppsClient.spawn:start ${c}`;return this.logStatus("spawn","error",e),null==n||n(e),{error:e}}const p="assimilation"===(null===(l=null===(a=null===(s=null===(i=null===(o=null===(r=u[0])||void 0===r?void 0:r.customProperties)||void 0===o?void 0:o.appd)||void 0===i?void 0:i.hostManifests)||void 0===s?void 0:s.Finsemble)||void 0===a?void 0:a.window)||void 0===l?void 0:l.windowType)?null:await this.getInstance(d.id,d),g={launchGroupWindows:h,windowDescriptor:{name:d.id},windowIdentifier:{windowName:d.id,componentType:e},finWindow:p};return this.logStatus("spawn","return",{error:null,response:g}),null==n||n(null,g),{error:null,response:g}}async toggleWindowOnClick(e,t,n){this.logStatus("toggleWindowOnClick","start",{element:e,windowLocator:t,params:n});const r="windowName"in t?t.windowName:t,o="componentType"in t?t.componentType:null,i=this.glue.windows.list().find(e=>"string"==typeof r?r===e.id||r===e.name||r===e.title:o===e.name);if(!i){const e=["AppsClient.toggleWindowOnClick() cannot find window",t];return void this.logStatus("toggleWindowOnClick","error",...e)}const s=i.id;if(!1===Xg[s])return void(Xg[s]=!0);n.position||(n.position="absolute");const{err:a}=await this.showWindow(t,n);if(a){const e=["AppsClient.toggleWindowOnClick() cannot show window",a];return void this.logStatus("toggleWindowOnClick","error",...e)}i.onFocusChanged(async()=>{if(i.isFocused)return;Xg[s]=!0;const t=await(async(e,t)=>{const n=await(async(e,t)=>{var n,r,o;const i="string"==typeof t?document.querySelector(t):t;i||console.error("getDesktopBoundingBox can't find element",t);const s=i?i.getBoundingClientRect():{top:0,left:0,width:0,height:0},a=await(null===(n=e.windows.my())||void 0===n?void 0:n.getBounds()),l=null!==(r=null==a?void 0:a.top)&&void 0!==r?r:0,u=null!==(o=null==a?void 0:a.left)&&void 0!==o?o:0,c={top:l+s.top,left:u+s.left,width:s.width,height:s.height,right:0,bottom:0};return c.right=c.left+c.width,c.bottom=c.top+c.height,c})(e,t);return r=await e.displays.getMousePosition(),(o=n).bottom||(o.bottom=o.top+o.height),o.right||(o.right=o.left+o.width),r.x>o.left&&r.x<o.right&&r.y<o.bottom&&r.y>o.top;var r,o})(this.glue,e);Xg[s]=!t}),this.logStatus("toggleWindowOnClick","return")}async showWindow(e,t={},n){var r,o,i;this.logStatus("showWindow","start",{windowLocator:e,params:t}),await this.asyncConstructors.ready();const s="windowName"in e?e.windowName:e,a="componentType"in e?e.componentType:null,l=this.glue.windows.list().find(e=>"string"==typeof s?s===e.id||s===e.name||s===e.title:a===e.name);if(!l){if(this.loggerClient.debug(`AppsClient.showWindow(): Window ${s} not found. Spawning.`),a){const{response:e,error:r}=await this.spawn(a,t,n);return this.logStatus("showWindow","return",{err:r,data:e}),{err:r,data:e}}const e=`Window ${s} type ${a} not found`;return this.loggerClient.warn("AppsClient.toggleWindowOnClick",{err:e}),{err:e}}const u=await wg(this.glue,null==t?void 0:t.monitor),c=mg(this.glue,t,u),d=await this.glue.contexts.get(rg),h=null!==(r=null==d?void 0:d[l.id])&&void 0!==r?r:await l.getBounds();if(!(null==d?void 0:d[l.id])){const{err:e}=await pg(()=>this.glue.contexts.update(rg,{[l.id]:h}));e&&this.logStatus("showWindow","error",{subFunction:"this.glue.contexts.update(FINSEMBLEDIMENSIONMEMORY)",err:e.toString()})}!1===t.autoFocus&&(l.settings.focus=!1),c&&(await vg(this.glue,c,u),c.width=null!==(o=c.width)&&void 0!==o?o:null==h?void 0:h.width,c.height=null!==(i=c.height)&&void 0!==i?i:null==h?void 0:h.height,await l.place(c)),t.setBoundsOnly||(await l.show(),await l.focus());const p=await this.getInstance(l.id),g={windowDescriptor:{name:l.id},windowIdentifier:{windowName:l.id},finWindow:p};return this.logStatus("showWindow","return",{err:null,data:g}),null==n||n(null,g),{err:null,data:g}}async getMonitorInfo(e={},t){var n,r,o,i,s;this.logStatus("getMonitorInfo","start",{params:e}),await this.asyncConstructors.ready();let a=null;if(null===(n=null==e?void 0:e.windowIdentifier)||void 0===n?void 0:n.windowName){const t=this.glue.windows.findById(e.windowIdentifier.windowName);a=await(null==t?void 0:t.getDisplay())}else if("primary"===(null==e?void 0:e.monitor))a=(await this.glue.displays.all()).find(e=>e.isPrimary);else if("number"==typeof(null==e?void 0:e.monitor))a=(await this.glue.displays.all()).find(t=>t.index===e.monitor);else if("previous"===(null==e?void 0:e.monitor)){const e=await(null===(r=this.glue.windows.my())||void 0===r?void 0:r.getDisplay());a=(await this.glue.displays.all()).find(t=>{var n;return t.index-1===(null!==(n=null==e?void 0:e.index)&&void 0!==n?n:0)})}else if("next"===(null==e?void 0:e.monitor)){const e=await(null===(o=this.glue.windows.my())||void 0===o?void 0:o.getDisplay());a=(await this.glue.displays.all()).find(t=>{var n;return t.index+1===(null!==(n=null==e?void 0:e.index)&&void 0!==n?n:0)})}else"mine"!==(null==e?void 0:e.monitor)&&(null===(i=null==e?void 0:e.windowIdentifier)||void 0===i?void 0:i.windowName)||(a=await(null===(s=this.glue.windows.my())||void 0===s?void 0:s.getDisplay()));const l=a?qg(a):null;if(!l){const e="Cannot fetch monitor. Check application.log for errors";return this.logStatus("getMonitorInfo","error",e),null==t||t(e),{err:e}}return this.logStatus("getMonitorInfo","return",{err:null,data:l}),null==t||t(null,l),{err:null,data:l}}async getMonitorInfoAll(e){this.logStatus("getMonitorInfoAll","start"),await this.asyncConstructors.ready();const t=(await this.glue.displays.all()).map(e=>qg(e)),n=t.filter(e=>null!==e);if(t.length!==n.length){const t="Cannot fetch some monitors. Check application.log for errors";return this.logStatus("getMonitorInfoAll","error",t),null==e||e(t),{err:t}}return this.logStatus("getMonitorInfoAll","return",{err:null,data:n}),null==e||e(null,n),{err:null,data:n}}async getComponentDefaultConfig(e,t){this.logStatus("getComponentDefaultConfig","start",{componentType:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await this.getComponentList();let o;if(!n&&r){const t=Object.entries(r).find(([t])=>t===e);t&&(o=t[1])}return this.logStatus("getComponentDefaultConfig","return",{err:n,data:o}),null==t||t(n,o),{err:n,data:o}}}class tf{constructor(e,t,n,r,o){this.asyncConstructors=t,this.loggerClient=n,this.Router=r,this.storageClient=o;const i=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(i)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AuthenticationClient",method:e,type:t,data:n})}async beginAuthentication(e,t){this.logStatus("beginAuthentication","start",e),await this.asyncConstructors.ready();const n=`FSBL.Clients.AuthenticationClient.beginAuthentication.handler.${Zp()()}`;this.glue.interop.register(n,ig((e,n)=>{null==t||t(e,n)}));const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AuthenticationClient.beginAuthentication",{...e,handlerName:n}));return r&&this.logStatus("beginAuthentication","error",r),this.logStatus("beginAuthentication","return",o),{err:r,data:o}}async completeOAUTH(e,t,n){if(this.logStatus("completeOAUTH","start",{err:e,params:t}),await this.asyncConstructors.ready(),!t){t={};const e=""===window.location.search?window.location.hash:window.location.search;new URLSearchParams(e).forEach((e,n)=>{t[n]=e})}const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AuthenticationClient.completeOAUTH",{err:e,data:t}));return r&&this.logStatus("completeOAUTH","error",r),this.logStatus("completeOAUTH","return",o),{err:r,data:o}}async getCurrentCredentials(e){this.logStatus("getCurrentCredentials","start"),await this.asyncConstructors.ready();const t=await this.glue.contexts.get(ng);return this.logStatus("getCurrentCredentials","return","For security reasons, credentials were not logged."),null==e||e(null,t),{err:null,data:t}}async publishAuthorization(e,t){var n,r;if(this.logStatus("publishAuthorization","start","For security reasons, credentials were not logged."),await this.asyncConstructors.ready(),this.glue.contexts.set(ng,{user:e,credentials:t}),"sso-application"===(null===(n=this.glue.windows.my())||void 0===n?void 0:n.name)){const n={user:e,token:null!==(r=null==t?void 0:t.token)&&void 0!==r?r:null,headers:t};this.loggerClient.debug("publishAuthorization() Calling authDone(credentials)"),globalThis.glue42gd.authDone(n),this.Router.publish("AuthorizationState",{state:"done"})}else if(this.loggerClient.debug("publishAuthorization","Called on window other than sso-application. Sending via backChannel."),this.glue.windows.find("sso-application")){const{err:n}=await gg(()=>this.glue.interop.invoke("Finsemble.Clients.AuthenticationClient.publishAuthorization.backChannel",{user:e,credentials:t}));n&&this.loggerClient.error("publishAuthorization error.",n.toString())}else this.loggerClient.debug("sso-application not running. Skipping backChannel communication."),this.loggerClient.debug("Calling StorageClient.setUser"),this.storageClient.setUser({user:e});this.logStatus("publishAuthorization","return")}}const nf=(e,t)=>e.split(".").reduceRight((e,t)=>({[t]:e}),t),rf=e=>{let t={};for(const n in e)t=(0,Qp.merge)(t,nf(n,e[n]));return t},of=e=>{return`${e.minute} ${e.hour} * * ${t=e.dayOfWeek,!1===t||void 0===t?"*":t.toString()}`;var t},sf=async(e,t,n,r)=>{const o=await(async e=>{var t,n,r,o,i,s,a,l,u;const c=null!==(t=await e.contexts.get(tg))&&void 0!==t?t:{},{data:d}=await pg(()=>e.prefs.get("IO.Global.FinsemblePreferences")),h=null!==(n=null==d?void 0:d.data)&&void 0!==n?n:{};return null===(u=null!==(i=null!==(r=null==h?void 0:h["finsemble.scheduledCloseDiscardUnsavedChanges"])&&void 0!==r?r:null===(o=null==c?void 0:c.finsemble)||void 0===o?void 0:o.scheduledCloseDiscardUnsavedChanges)&&void 0!==i?i:null===(l=null===(a=null===(s=null==c?void 0:c.finsemble)||void 0===s?void 0:s.servicesConfig)||void 0===a?void 0:a.workspace)||void 0===l?void 0:l.discardUnsavedChanges)||void 0===u||u})(e);if(n){const i=of(n);r("scheduledRestartOrShutdown","start",{command:t,value:n,discardUnsavedLayoutChanges:o,cronTime:i});const{err:s}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:`schedule-${t}`,args:{cronTime:i,title:t,message:`Are you sure you want to ${t}?`,timerDuration:60,discardUnsavedLayoutChanges:o}}));s&&r("scheduledRestartOrShutdown","error",s.toString())}else{r("scheduledRestartOrShutdown","start",{command:t,value:n});const{err:o}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:`cancel-${t}`,args:{}}));o&&r("scheduledRestartOrShutdown","error",o.toString())}r("scheduledRestartOrShutdown","return")},af="Invalid path - MUST be a path array. e.g. for myObject.property use ['myObj', 'property']",lf=(e,t)=>{if("object"!=typeof e)return;if(!t.length)return e;const n=t[0];return 1===t.length?e[n]:e[n]?lf(e[n],t.slice(1)):void 0},uf=e=>{const t=[],n=e=>{if("object"!=typeof e)return;const r=Object.keys(e);r.length&&(t.push(r[0]),n(e[r[0]]))};return n((0,Qp.set)({},e,"dummy")),t},cf=(e,t)=>{let n=t;for(let t=0;t<e.length-1;t++){const r=e[t];n[r]||(n[r]={}),n=n[r]}delete n[e[e.length-1]]};class df{async maybeSendCommandToIOCD(e){switch(e.field){case"finsemble.scheduledRestart":await sf(this.glue,"restart",e.value,this.logStatus);break;case"finsemble.scheduledShutdown":await sf(this.glue,"shutdown",e.value,this.logStatus);break;case"finsemble.scheduledCloseDiscardUnsavedChanges":await(async(e,t,n)=>{const r=await(async e=>{var t,n,r,o,i,s;const a=null!==(t=await e.contexts.get(tg))&&void 0!==t?t:{},{data:l}=await pg(()=>e.prefs.get("IO.Global.FinsemblePreferences")),u=null!==(n=null==l?void 0:l.data)&&void 0!==n?n:{},c=null!==(r=null==u?void 0:u["finsemble.scheduledShutdown"])&&void 0!==r?r:null===(o=null==a?void 0:a.finsemble)||void 0===o?void 0:o.scheduledShutdown,d=null!==(i=null==u?void 0:u["finsemble.scheduledRestart"])&&void 0!==i?i:null===(s=null==a?void 0:a.finsemble)||void 0===s?void 0:s.scheduledRestart;return{shutdown:c?of(c):void 0,restart:d?of(d):void 0}})(e);if(r.shutdown){const o=r.shutdown;n("scheduledCloseDiscardUnsavedChanges","start",{command:"shutdown",cronTime:o,discardUnsavedLayoutChanges:t});const{err:i}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"schedule-shutdown",args:{cronTime:o,title:"shutdown",message:"Are you sure you want to shutdown?",timerDuration:60,discardUnsavedLayoutChanges:t}}));i&&n("scheduledCloseDiscardUnsavedChanges","error",i.toString())}if(r.restart){const o=r.restart;n("scheduledCloseDiscardUnsavedChanges","start",{command:"restart",cronTime:o,discardUnsavedLayoutChanges:t});const{err:i}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"schedule-restart",args:{cronTime:o,title:"restart",message:"Are you sure you want to restart?",timerDuration:60,discardUnsavedLayoutChanges:t}}));i&&n("scheduledCloseDiscardUnsavedChanges","error",i.toString())}})(this.glue,e.value,this.logStatus);break;case"finsemble.initialWorkspace":case"finsemble.servicesConfig.workspace.promptUserOnDirtyWorkspace":case"finsemble.servicesConfig.workspace.discardUnsavedChanges":case"finsemble.servicesConfig.notifications.disableDotOnToolbarIcon":case"finsemble.servicesConfig.notifications.showDotOnToolbarIconForMutedNotifications":case"finsemble.servicesConfig.notifications.toastTimeoutOnActionableNotifications":case"finsemble.servicesConfig.notifications.informationalNotificationToastPeriodSeconds":case"finsemble.servicesConfig.notifications.defaultSnoozePeriodSeconds":case"finsemble.servicesConfig.notifications.newNotificationHaloPeriodSeconds":break;default:return}}maybeTriggerListeners(e){this.listeners.forEach(t=>{try{const{pathArray:n,listener:r,config:o}=t,i=lf(o,n),s=lf(e,n);JSON.stringify(i)!==JSON.stringify(s)&&r(null,{field:n.join("."),value:s}),t.config=e}catch(e){this.glue.logger.error(`ConfigClient, exception in listener: ${e.toString()}`)}})}async waitForUserStage(){const e=await this.glue.contexts.get("IO.Global.InUserStage");e||await this.glue.contexts.set("IO.Global.InUserStage",{inUserStage:!1}),(null==e?void 0:e.inUserStage)?this.preferencesAreAvailable.resolve():(await this.glue.contexts.subscribe("IO.Global.InUserStage",e=>{e.inUserStage&&this.preferencesAreAvailable.resolve()}),await this.preferencesAreAvailable.promise),this.glue.prefs.subscribeFor("IO.Global.FinsemblePreferences",async e=>{this.cachedPreferences=e.data;const t=await this.glue.contexts.get(tg);this.maybeTriggerListeners((0,Qp.merge)(t,e.data))})}async initialize(){this.waitForUserStage()}async subscribeToConfigContext(){this.listeners.length||await this.glue.contexts.subscribe(tg,async(e,t,n,r,o)=>{const i=await this.getPreferencesNoWait(),s=rf(i);this.maybeTriggerListeners((0,Qp.merge)(e,s))})}constructor(e,t,n,r){this.gluePromise=e,this.asyncConstructors=t,this.routerClient=n,this.loggerClient=r,this.cachedPreferences=null,this.listeners=[],this.preferencesAreAvailable=new Kp,this.whichContext=e=>"finsemble"!==e[0]?tg:"apps"===e[1]||"components"===e[1]?"$FINSEMBLECONFIGAPPS":tg;const o=t.addConstructor();this.loggerClient.debug("ConfigClient Constructor"),e.then(e=>{this.glue=e,this.initialize().finally(()=>{this.loggerClient.debug("ConfigClient initialized"),t.finishConstructor(o)})}),this.logStatus=this.logStatus.bind(this)}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"ConfigClient",method:e,type:t,data:n})}async addListener(e,t,n){this.logStatus("addListener","start",{params:e}),await this.asyncConstructors.ready();const r=Array.isArray(e)?e:e.field?uf(e.field):[],o=await this.glue.contexts.get(tg);await this.subscribeToConfigContext(),this.listeners.push({pathArray:r,listener:t,config:o}),null==n||n(),this.logStatus("addListener","return")}async addListeners(e,t,n){this.logStatus("addListeners","start",e),await this.asyncConstructors.ready();const r=e.map(e=>e?"string"==typeof e?this.addListener({field:e},t):"string"==typeof e.field?this.addListener({field:e.field},e.listener):this.addListener(e.field,e.listener):this.addListener({field:null},t));await eg().allSettled(r),null==n||n(),this.logStatus("addListeners","return")}async getValue(e,t){this.logStatus("getValue","start",e),await this.asyncConstructors.ready();const n="string"==typeof e?e:e.field,{err:r,data:o}=await this.get(uf(n));return this.logStatus("getValue","return",{err:r,data:o}),null==t||t(r,o),{err:r,data:o}}async getValues(e,t){if(this.logStatus("getValues","start",e),await this.asyncConstructors.ready(),!e){const e=this.getManifest(t);return this.logStatus("getValues","return",e),e}const n=e.map(e=>"string"==typeof e?e:e.field),r=n.map(e=>this.get(uf(e))),o=await eg().allSettled(r),i={};o.forEach((e,t)=>{"fulfilled"===e.status&&(i[n[t]]=e.value.data)});const s=o.map(e=>"fulfilled"===e.status?e.value.err:e.reason).find(e=>"string"==typeof e);return this.logStatus("getValues","return",{err:s,data:i}),null==t||t(s,i),{err:s,data:i}}async getManifest(e){this.logStatus("getManifest","start"),await this.asyncConstructors.ready();const t=this.get([],e);return this.logStatus("getManifest","return",t),t}async getPreferences(e){return this.preferencesAreAvailable.resolved||console.warn("ConfigClient.getPreferences() called before having entered UserStage. Waiting..."),await this.preferencesAreAvailable.promise,this.getPreferencesNoWait(e)}async getPreferencesNoWait(e){var t;if(this.logStatus("getPreferences","start"),await this.asyncConstructors.ready(),!this.preferencesAreAvailable.resolved)return{data:{}};if(this.cachedPreferences)return this.logStatus("getPreferences","return",{err:null,data:this.cachedPreferences}),null==e||e(null,this.cachedPreferences),{err:null,data:this.cachedPreferences};{const{err:n=null,data:r}=await pg(()=>this.glue.prefs.get("IO.Global.FinsemblePreferences")),o=null!==(t=null==r?void 0:r.data)&&void 0!==t?t:{};return this.cachedPreferences=o,this.logStatus("getPreferences","return",{err:n,data:o}),null==e||e(n,o),{err:n,data:o}}}async processAndSet(e,t){await this.asyncConstructors.ready();const{newConfig:n,replace:r,overwrite:o}=e,{err:i,data:s}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.ConfigClient.processAndSet",{newConfig:n,replace:r,overwrite:o}));return i||this.routerClient.publish("Config.changeNotification",{newConfig:n,finsemble:s}),null==t||t(i,{data:s}),this.logStatus("processAndSet","return"),{err:i,data:s}}removeListener(e,t,n){this.logStatus("removeListener","start",e);const r=Array.isArray(e)?e:e.field?uf(e.field):[];this.listeners=this.listeners.filter(e=>t&&e.listener!==t||e.pathArray.join(".")!==r.join(".")),this.logStatus("removeListener","return"),null==n||n()}removeListeners(e,t,n){this.logStatus("removeListeners","start",e),(Array.isArray(e)?e:[e]).map(e=>{if(e)return"string"==typeof e?void this.removeListener({field:e},t):"string"==typeof e.field?void this.removeListener({field:e.field},e.listener):void this.removeListener(e.field,e.listener);this.removeListener({field:null},t)}),this.logStatus("removeListeners","return"),null==n||n(null,!0)}async removeValue(e,t){this.logStatus("removeValue","start",e),await this.asyncConstructors.ready();const n="string"==typeof e?e:e.field,{err:r,data:o}=await this.remove(uf(n));return this.logStatus("removeValue","return",{err:r,data:o}),null==t||t(r,o),{err:r,data:o}}async removeValues(e,t){this.logStatus("removeValues","start",e),await this.asyncConstructors.ready();const n=e.map(e=>"string"==typeof e?e:e.field);let r=await this.glue.contexts.get(tg);return r||(r={}),n.map(e=>cf(uf(e),r)),await this.glue.contexts.set(tg,r),this.logStatus("removeValues","return",{err:null}),null==t||t(null),{err:null}}async setPreference(e,t){this.logStatus("setPreference","start",{params:e}),await this.asyncConstructors.ready(),await this.maybeSendCommandToIOCD(e);const{err:n=null,data:r}=await pg(()=>this.glue.prefs.updateFor("IO.Global.FinsemblePreferences",{[e.field]:e.value}));return this.logStatus("setPreference","return",{err:n,data:r}),null==t||t(n,r),{err:n,data:r}}async setValue(e,t){this.logStatus("setValue","start",e),await this.asyncConstructors.ready();const n=await this.set(uf(e.field),e.value),r=n.err?n.err.toString():null;return this.logStatus("setValue","return",{err:r}),null==t||t(r),{err:r}}async setValues(e,t){this.logStatus("setValues","start",e),await this.asyncConstructors.ready();const n=e.map(e=>this.setValue(e)),r=(await eg().allSettled(n)).map(e=>"fulfilled"===e.status?e.value.err:e.reason).find(e=>"string"==typeof e);return this.logStatus("setValues","return",{err:r}),null==t||t(r),{err:r}}async unsetPreference(e,t){this.logStatus("unsetPreference","start",{params:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await this.getPreferences();if(n)return this.logStatus("unsetPreference","error",{err:n}),null==t||t(n),{err:n};if(r&&Object.keys(r).length>0){delete r[e.field];const{err:n}=await pg(()=>this.glue.prefs.setFor("IO.Global.FinsemblePreferences",r));return this.logStatus("unsetPreference","return",{err:n,data:r}),null==t||t(n),{err:n}}return this.logStatus("unsetPreference","return",{err:null}),null==t||t(null),{err:null}}async get(e,t){if(this.logStatus("get","start",e),await this.asyncConstructors.ready(),null===e||!Array.isArray(e))return this.logStatus("get","error",{err:af}),null==t||t(af),{err:af};const{err:n,data:r={}}=await this.getPreferencesNoWait(),o=rf(r),i=await this.glue.contexts.get(this.whichContext(e)),s=0===Object.keys(i).length?"No config available. Is Finsemble service running?":null,a=(0,Qp.merge)(i,o),l={err:null!=s?s:n,data:lf(a,e)};return this.logStatus("get","return",l),null==t||t(l.err,l.data),l}async getMultiple(e,t){this.logStatus("getMultiple","start",e),await this.asyncConstructors.ready();const n=null,r=await this.glue.contexts.get(tg),{data:o={}}=await this.getPreferencesNoWait(),i=rf(o),s={};e.forEach(e=>{const t=lf(i,e);if(void 0!==t)return void(s[e.join(".")]=t);const n=lf(r,e);void 0!==n&&(s[e.join(".")]=n)});const a=Object.keys(s).length?s:void 0;return this.logStatus("getMultiple","return",{err:n,data:a}),null==t||t(n,a),{err:n,data:a}}async set(e,t,n){this.logStatus("set","start",{path:e,value:t}),await this.asyncConstructors.ready();const r=e.join("."),{err:o}=await pg(()=>this.glue.contexts.setPath(tg,r,t));return o&&this.logStatus("set","error",{subFunction:"this.glue.contexts.update(FINSEMBLECONFIG",err:o}),this.logStatus("set","return",{err:o,data:t}),null==n||n(o,t),{err:o,data:t}}async setMultiple(e,t){this.logStatus("setMultiple","start",{pathsAndValues:e}),await this.asyncConstructors.ready();const n=e.map(e=>({path:e.field.join("."),value:e.value})),{err:r}=await pg(()=>this.glue.contexts.setPaths(tg,n));return this.logStatus("setMultiple","start",{err:r,data:e}),null==t||t(r,e),{err:r,data:e}}async remove(e,t){this.logStatus("remove","start",{path:e}),await this.asyncConstructors.ready();let n=await this.glue.contexts.get(tg);return n||(n={}),cf(e,n),await this.glue.contexts.set(tg,n),this.logStatus("remove","return",{path:e}),null==t||t(null,e),{err:null,data:e}}async removeMultiple(e,t){this.logStatus("removeMultiple","start",e),await this.asyncConstructors.ready();const n=null;let r=await this.glue.contexts.get(tg);return r||(r={}),e.forEach(e=>{let t=r;for(let n=0;n<e.length-1;n++){const r=e[n];t[r]||(t[r]={}),t=t[r]}delete t[e[e.length-1]]}),await this.glue.contexts.set(tg,r),this.logStatus("removeMultiple","return",{err:n,data:e}),null==t||t(n,e),{err:n,data:e}}}class hf{constructor(e,t){this.glue=e,this.distributedStoreClient=t,this.initialized=!1,this.userInputTimeout=null,this.DialogStore=null,this.isDialog=!1,this.RESPONDER_CHANNEL=null,this.openerMessage=null,this.spawnData={}}async checkIfWindowIsDialog(e){var t,n,r,o,i,s,a;this.isDialog=!1;const l=null!==(t=await Wg(this.glue.windows.my()))&&void 0!==t?t:{};this.isDialog=null!==(a=null===(s=null===(i=null===(o=null===(r=null===(n=null==l?void 0:l.customProperties)||void 0===n?void 0:n.component)||void 0===r?void 0:r.foreign)||void 0===o?void 0:o.clients)||void 0===i?void 0:i.dialogManager)||void 0===s?void 0:s.isDialog)&&void 0!==a&&a,null==e||e(null)}async registerWithStore(e){var t,n;if(this.isDialog){const r=this.glue.windows.my();if(!r)return console.error("Attempt to register an incompatible window type as a dialog."),void(null==e||e());this.RESPONDER_CHANNEL=`Dialog.${r.id}.Show`,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","available",r.id],{windowName:r.id,componentType:null===(n=r.application)||void 0===n?void 0:n.name}))}null==e||e()}async initializeOnce(){this.initialized||(this.initialized=!0,await this.checkIfWindowIsDialog(),await this.createStore(),await this.registerWithStore())}async createStore(){const{err:e,data:t}=await this.distributedStoreClient.createStore({store:"DialogStore",values:{dialogs:{opened:{},available:{}}},global:!0});e||!t?console.error('DialogManagerClient could not create store "DialogStore"',e):this.DialogStore=t}async getAvailableDialog(e,t){if(!this.DialogStore){const e="DialogMangerClient.getAvailableDialogs() store not yet initialized}";return console.error(e),null==t||t(null),null}const{err:n,data:r}=await this.DialogStore.getGlobalValue("dialogs.available");if(n){const e=`DialogMangerClient.getAvailableDialogs() store error ${n}`;return console.error(e),null==t||t(null),null}for(const n in r){const o=r[n];if(o.componentType===e)return null==t||t(o),o}return null==t||t(null),null}async moveDialogFromOpenedToAvailable(e){var t,n;if(!this.DialogStore){const e="DialogMangerClient.moveDialogFromOpenedToAvailable() store not yet initialized}";return console.error(e),e}const{err:r,data:o}=await this.DialogStore.getGlobalValue("dialogs");if(r||!o){const e='DialogManagerClient.moveDialogFromOpenedToAvailable() no "dialogs" object returned from store';return console.error(e),e}const i=o.opened,s=o.available;return delete i[e.windowName],s[e.windowName]=e,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","opened"],i)),await(null===(n=this.DialogStore)||void 0===n?void 0:n.set(["dialogs","available"],s)),null}async moveDialogFromAvailableToOpened(e){var t,n;if(!this.DialogStore){const e="DialogMangerClient.moveDialogFromAvailableToOpened() store not yet initialized}";return console.error(e),e}const{err:r,data:o}=await this.DialogStore.getGlobalValue("dialogs");if(r||!o){const e='DialogManagerClient.moveDialogFromAvailableToOpened no "dialogs" object returned from store';return console.error(e),e}const i=o.available,s=o.opened;return delete i[e.windowName],s[e.windowName]=e,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","available"],i)),await(null===(n=this.DialogStore)||void 0===n?void 0:n.set(["dialogs","opened"],s)),null}}const pf={fdc3Resolver:"FDC3Resolver",linkerWindow:"LinkerWindow","Docking Move Mask":"DockingGroupMask",yesNo:"YesNoDialog",singleInput:"SingleInputDialog","Process Monitor":"ProcessMonitor","Advanced App Catalog":"AppCatalog"},gf=e=>`Dialog.${e}.ready`;class ff{constructor(e,t,n,r,o,i){this.gluePromise=e,this.asyncConstructors=t,this.router=n,this.appsClient=r,this.distributedStoreClient=o,this.loggerClient=i;const s=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(s)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DialogManagerClient",method:e,type:t,data:n})}async hideModal(){return null}async showModal(){return null}async getControllerInstance(){var e;const t=null!==(e=globalThis.DialogManagerClient)&&void 0!==e?e:new hf(this.glue,this.distributedStoreClient);return globalThis.DialogManagerClient=t,await t.initializeOnce(),t}async sendQueryToDialogInner(e,t,n,r,o){const i=e=>{console.warn(`No response from dialog ${n.windowName} after ${e/1e3} seconds. Check to make sure your dialog is sending back data.`)},s=await this.getControllerInstance();s.moveDialogFromAvailableToOpened(n);const a=`Dialog.${n.windowName}.Show`,l=gf(n.windowName);let u;const c=e.addListener(l,async(e,o)=>{if(e)return void console.log("DialogManagerClient.sendQueryToDialogInner() error from addListener",e);u=setTimeout(i.bind(null,o.data.userInputTimeout),o.data.userInputTimeout);const{err:s,data:a}=await t.showWindow(n,{monitor:r.monitor||"mine",left:"center",top:"center"});if(s||!a){const e=`DialogManagerClient.sendQueryToDialog error showing window ${n.windowName} ${s}`;return void console.error(e)}const l=await this.glue.windows.findById(n.windowName);null==l||l.setOnTop(!0),null==l||l.focus(),c()}),{err:d,response:h}=await e.query(a,r);d&&console.log(`DialogManagerClient.sendQueryToDialogInner() error contacting ${a}`,d),clearTimeout(u),s.moveDialogFromOpenedToAvailable(n),o(d,h.data)}set userInputTimeout(e){var t;(null!==(t=globalThis.DialogManagerClient)&&void 0!==t?t:new hf(this.glue,this.distributedStoreClient)).userInputTimeout=e}get openerMessage(){var e;return(null!==(e=globalThis.DialogManagerClient)&&void 0!==e?e:new hf(this.glue,this.distributedStoreClient)).openerMessage}async sendQueryToDialog(e,t,n){await this.asyncConstructors.ready();const r=t=>{console.warn(`No response from dialog ${e.windowName} after ${t/1e3} seconds. Check to make sure your dialog is sending back data.`)},o=await this.getControllerInstance();o.moveDialogFromAvailableToOpened(e);const i=`Dialog.${e.windowName}.Show`,s=gf(e.windowName);let a;const l=this.router.addListener(s,async(n,o)=>{a=setTimeout(r.bind(null,o.data.userInputTimeout),o.data.userInputTimeout);const{err:i,data:s}=await this.appsClient.showWindow(e,{monitor:t.monitor||"mine",left:"center",top:"center"});if(i||!s){const t=`DialogManagerClient.sendQueryToDialog() error showing window ${e.windowName} ${i}`;return void console.log(t)}const u=await this.glue.windows.findById(e.windowName);null==u||u.setOnTop(!0),null==u||u.focus(),l()}),{err:u,response:c}=await this.router.query(i,t);u&&console.log(`DialogManagerClient.sendQueryToDialog() error contacting ${i}`,u),clearTimeout(a),o.moveDialogFromOpenedToAvailable(e),n(u,c.data)}async spawnDialog(e,t,n,r){var o;this.logStatus("spawnDialog","start",{params:e,inputParams:t}),await this.asyncConstructors.ready();const i=`DialogChannel-${Zp()()}`;e.data={inputParams:t,responseChannel:i},e.left||0===e.left||e.right||0===e.right||(e.left="center"),e.top||0===e.top||e.bottom||0===e.bottom||(e.top="center");const s=this.router.addListener(i,(e,t)=>{n(e,t.data),s()});if("string"==typeof e.url){const t=await wg(this.glue,null==e?void 0:e.monitor),n=mg(this.glue,e,t);n&&await vg(this.glue,n,t);const i={placement:n,mode:"flat",ignoreFromLayouts:!0};return await this.glue.windows.open(null!==(o=e.name)&&void 0!==o?o:"",e.url,i),this.logStatus("spawnDialog","return",{err:null}),null==r||r(null),{err:null}}const{error:a,response:l}=await this.appsClient.spawn("dialogTemplate",e);return a&&n(a,l),this.logStatus("spawnDialog","return",{err:a,data:l}),null==r||r(a,l),{err:a,data:l}}async open(e,t,n){var r;this.logStatus("open","start",{type:e,options:t,onUserInput:n}),await this.asyncConstructors.ready(),e=null!==(r=pf[e])&&void 0!==r?r:e;const o=()=>new Promise(async r=>{(await this.getControllerInstance()).getAvailableDialog(e,e=>{e?(this.sendQueryToDialogInner(this.router,this.appsClient,e,t,n),r(!0)):r(!1)})});if(await o())return this.logStatus("open","return"),null;const i=e=>new Promise(t=>setTimeout(t,e)),{error:s}=await this.appsClient.spawn(e,{options:{customData:{foreign:{clients:{dialogManager:{isDialog:!0}}}}}});if(s)return this.logStatus("open","error",s),`DialogManagerClient.open launching dialog "${e}" error ${s}`;{const t=3e4;for(let e=0;e<15;e++){if(await o())return this.logStatus("open","return",null),null;await i(t/15)}const n=`DialogManagerClient.open error opening dialog "${e}. The dialog launched but didn't register within ${t} ms`;return this.logStatus("open","error",n),n}}async getParametersFromInDialog(){this.logStatus("getParametersFromInDialog","start"),await this.asyncConstructors.ready();const e=await this.getControllerInstance(),{inputParams:t}=e.spawnData;return this.logStatus("getParametersFromInDialog","return",{inputParams:t}),t}async respondAndExitFromInDialog(e){this.logStatus("respondAndExitFromInDialog","start",e),await this.asyncConstructors.ready();const t=await this.getControllerInstance(),{responseChannel:n}=t.spawnData;this.router.transmit(n,e),this.logStatus("respondAndExitFromInDialog","return")}async showDialog(){var e;this.logStatus("showDialog","start"),await this.asyncConstructors.ready();const t=await this.getControllerInstance(),n=this.glue.windows.my();if(!n)return void console.log("Use of showDialog in incompatible window type");const r=gf(n.id);this.router.transmit(r,{userInputTimeout:null!==(e=t.userInputTimeout)&&void 0!==e?e:1e4}),this.logStatus("showDialog","return")}async registerDialogCallback(e){this.logStatus("registerDialogCallback","start"),await this.asyncConstructors.ready();const t=await this.getControllerInstance();t.RESPONDER_CHANNEL&&this.router.addResponder(t.RESPONDER_CHANNEL,(n,r)=>{r&&(t.openerMessage=r),null==e||e(n,r)}),this.logStatus("registerDialogCallback","return")}async respondToOpener(e){var t;this.logStatus("respondToOpener","start",e),await this.asyncConstructors.ready();const n=await this.getControllerInstance();null===(t=n.openerMessage)||void 0===t||t.sendQueryResponse(null,e);const r=this.glue.windows.my();null==r||r.hide(),n.openerMessage=null,this.logStatus("respondToOpener","return")}}class mf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DialogManagerClient",method:e,type:t,data:n})}async open(e,t,n){this.logStatus("open","start",{type:e,options:t,onUserInput:n}),await this.asyncConstructors.ready();const r=this.glue.windows.my();if(!r){const e="Cannot open dialog from within an incompatible window type (e.g. webgroup). You must use the Finsemble dialog implementation";return console.error(e),e}const o=r.showDialog(((e,t)=>{var n,r,o,i,s,a,l,u,c;const d="SingleInputDialog"===e?"Enter value:":"Are you sure?",h=null!==(r=null!==(n=t.question)&&void 0!==n?n:t.inputLabel)&&void 0!==r?r:d;return{type:"YesNoDialog"===e?"YesNoCancel":e,mode:"WindowContainer",title:null!==(o=t.title)&&void 0!==o?o:"Yes/No Question",message:h,messageTitle:"",showAffirmativeButton:null===(i=t.showAffirmativeButton)||void 0===i||i,affirmativeButtonName:null!==(s=t.affirmativeResponseLabel)&&void 0!==s?s:"Yes",showNegativeButton:null===(a=t.showNegativeButton)||void 0===a||a,negativeButtonName:null!==(l=t.negativeResponseLabel)&&void 0!==l?l:"No",showCancelButton:null===(u=t.showCancelButton)||void 0===u||u,cancelButtonName:null!==(c=t.cancelResponseLabel)&&void 0!==c?c:"Cancel",...t,timerDuration:t.timerDuration?t.timerDuration/1e3:void 0}})(e,t));return o.then(e=>{const{action:t,button:r,value:o}=e;n(null,"closed"===t?{choice:"cancel"}:"affirmative"===r?{choice:"affirmative",value:o}:{choice:"negative"})}),this.logStatus("open","return",null),null}}class yf{constructor(e,t,n,r,o,i){this.gluePromise=e,this.asyncConstructors=t,this.finsembleImplementation=new ff(e,t,n,r,o,i),this.glueImplementation=new mf(e,t,i)}set userInputTimeout(e){this.finsembleImplementation.userInputTimeout=e}get openerMessage(){var e;return null!==(e=this.finsembleImplementation.openerMessage)&&void 0!==e?e:null}async sendQueryToDialog(e,t,n){return this.finsembleImplementation.sendQueryToDialog(e,t,n)}async hideModal(){return null}async showModal(){return null}async spawnDialog(e,t,n,r){var o;return null!==(o=this.finsembleImplementation.spawnDialog(e,t,n,r))&&void 0!==o?o:{}}async useGlueDialogs(){var e,t;const n=await this.gluePromise,r=null!==(e=await n.contexts.get(tg))&&void 0!==e?e:{};return!0===(null===(t=null==r?void 0:r.iocd)||void 0===t?void 0:t.iocdDialogs)}async open(e,t,n){var r,o;return await this.useGlueDialogs()?null!==(r=this.glueImplementation.open(e,t,n))&&void 0!==r?r:null:null!==(o=this.finsembleImplementation.open(e,t,n))&&void 0!==o?o:null}async getParametersFromInDialog(){return this.finsembleImplementation.getParametersFromInDialog()}async respondAndExitFromInDialog(e){return this.finsembleImplementation.respondAndExitFromInDialog(e)}async showDialog(){return this.finsembleImplementation.showDialog()}async registerDialogCallback(e){return this.finsembleImplementation.registerDialogCallback(e)}async respondToOpener(e){return this.finsembleImplementation.respondToOpener(e)}}const wf=(e,t)=>null===e?t:(0,Qp.get)(t,e),vf=e=>{let t=null;return e&&e.length>0&&(t=e.join(".")),t};class bf{constructor(e){var t,n;this.params=e,this.values={},this.listeners={},this.funcs=[],this.Dispatcher={register:e=>{this.funcs.push(e)},dispatch:e=>{this.funcs.forEach(t=>t(e))}},this.isGlobal=null!==(t=e.global)&&void 0!==t&&t,this.name=e.store,this.values=null!==(n=e.values)&&void 0!==n?n:{}}async init(){await this.initCore()}addListener(e,t,n){var r;let o="";o=Array.isArray(e)?e.join("."):null!==(r=e.field)&&void 0!==r?r:"";let i=this.listeners[o];i||(i=[],this.listeners[o]=i),i.push(t)}addListeners(e,t,n){var r,o;for(const n of e){let e={field:"",listener:t};if("string"==typeof n?e.field=n:"string"==typeof n.field?e={field:n.field,listener:null!==(r=n.listener)&&void 0!==r?r:t}:Array.isArray(n.field)&&(e={field:n.field.join("."),listener:null!==(o=n.listener)&&void 0!==o?o:t}),!e.listener)throw new Error(`no listener defined for field ${e.field}`);this.addListener({field:e.field},e.listener)}n&&n()}destroy(e){return this.listeners={},this.destroyCore(e)}async get(e,t){const n=vf(e);return{err:void 0,data:this.getValue(n,t)}}async getMultiple(e,t){const n=e.map(e=>vf(e)),r=[];for(const e of n)e&&r.push(e);return{err:null,response:{data:Jp().pick(this.values,r)}}}getAll(e){e(null,this.values)}async getGlobal(e,t){const n=vf(e),r=wf(n,this.values);return null==t||t(null,r),{err:null,data:r}}getValue(e,t){let n=null;null!==e&&(n="string"==typeof e?e:e.field);const r=wf(n,this.values);return null==t||t(null,r),r}async getGlobalValue(e,t){const n=await this.getValue(e,t);return null==t||t(null,n),{err:null,data:n}}async getValues(e,t){const n={};for(const t of null!=e?e:[]){const e=await this.getValue(t);n["string"==typeof t?t:t.field]=e.data}return t&&t(null,n),{err:null,data:n}}async removeListener(e,t,n){var r,o;let i="";i=Array.isArray(e)?e.join("."):null!==(r=e.field)&&void 0!==r?r:"";const s=(null!==(o=this.listeners[i])&&void 0!==o?o:[]).filter(e=>e!==t);this.listeners[i]=s,this.listeners[i].length||delete this.listeners[i]}async removeListeners(e,t,n){const r=Array.isArray(e)?e:[e];await ag(r,async e=>{const t=Array.isArray(e.field)?vf(e.field):e.field;t&&await this.removeListener({field:t},e.listener)}),null==n||n(null)}async remove(e,t){const n=e.join(".");return await this.setValue({field:n,value:null}),{err:null,data:void 0}}async removeMultiple(e,t){return this.setMultiple(e.map(e=>({field:e,value:null})))}removeValue(e,t){var n;return this.setValue({field:null!==(n=e.field)&&void 0!==n?n:e,value:null},t)}removeValues(e,t){const n=e.map(t=>{var n;return{field:null!==(n=e.field)&&void 0!==n?n:e,value:null}});return this.setValues(n)}async set(e,t,n){const r=e.join(".");return await this.setValue({field:r,value:t}),{err:null,data:void 0}}async setMultiple(e,t){return await ag(e,async e=>{await this.set(e.field,e.value)}),null==t||t(null),{err:null}}setValue(e,t){return this.setValueCore(e,t)}async setValues(e,t){for(const t of e)await this.setValue(t);t&&t(null)}initCore(){}destroyCore(e){}setValueCore(e,t){}notifyListeners(e){for(const t of Object.keys(this.listeners)){if(t!==e&&""!==t)continue;const n=""===t?this.values:wf(t,this.values),r=this.listeners[t],o=t;r.forEach(e=>{try{e(null,{field:o,value:n})}catch(e){console.log("DistributedStore notifyListeners error in handler",e)}})}}}const Cf=(e,t)=>{const n={different:[],missing_from_first:[],missing_from_second:[]};return Jp().reduce(e,(n,r,o)=>{if(t.hasOwnProperty(o)){if(Jp().isEqual(r,t[o]))return n;if("object"!=typeof e[o]||"object"!=typeof t[o])return n.different.push(o),n;{const r=Cf(e[o],t[o]);return n.different=n.different.concat(Jp().map(r.different,e=>o+"."+e)),n.missing_from_second=n.missing_from_second.concat(Jp().map(r.missing_from_second,e=>o+"."+e)),n.missing_from_first=n.missing_from_first.concat(Jp().map(r.missing_from_first,e=>o+"."+e)),n}}return n.missing_from_second.push(o),n},n),Jp().reduce(t,function(t,n,r){return e.hasOwnProperty(r)||t.missing_from_first.push(r),t},n),n};class Sf extends bf{constructor(e,t){super(t),this.glue=e,this.sharedContextName=`$FINSEMBLE:DS:${t.store}`}async setValueCore(e,t){const n="string"==typeof e?e:e.field;await this.glue.contexts.setPath(this.sharedContextName,n,e.value),this.values=await this.glue.contexts.get(this.sharedContextName),t&&t(null)}async initCore(){var e,t,n,r;const o=new Kp;await this.glue.contexts.subscribe(this.sharedContextName,e=>{o.resolved||o.resolve(),this.handleUpdate(e)});try{await this.glue.interop.invoke("FSBL.Clients.DistributedStoreClient.init",{store:this.sharedContextName,value:null!==(t=null===(e=this.params)||void 0===e?void 0:e.values)&&void 0!==t?t:{}},"best",{waitTimeoutMs:0})}catch(e){await this.glue.contexts.update(this.sharedContextName,null!==(r=null===(n=this.params)||void 0===n?void 0:n.values)&&void 0!==r?r:{})}await o.promise}async destroyCore(e){try{(await this.glue.contexts.all()).includes(this.sharedContextName)&&this.glue.contexts.destroy(this.sharedContextName)}catch(e){}e&&e(null,void 0)}handleUpdate(e){const t=Cf(this.values,null!=e?e:{}),n=t.different.concat(t.missing_from_first).concat(t.missing_from_second);this.values=e,n.forEach(e=>{this.notifyListeners(e)})}}class If extends bf{constructor(e,t){super(t)}async setValueCore(e,t){const n="string"==typeof e?e:e.field;((e,t,n)=>{(0,Qp.set)(e,t,n)})(this.values,n,e.value),this.notifyListeners(n)}}class kf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.localStores={};const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DistributedStore",method:e,type:t,data:n})}async createStore(e,t){this.logStatus("createStore","start",e),await this.asyncConstructors.ready();const n=await this.getOrCreateStoreObject(e);return this.logStatus("createStore","return",{err:null}),null==t||t(null,n),{err:null,data:n}}async getStore(e,t){this.logStatus("getStore","start",e),await this.asyncConstructors.ready();const n=await this.getOrCreateStoreObject(e);return this.logStatus("getStore","return",{err:null,data:n}),null==t||t(null,n),{err:null,data:n}}async removeStore(e,t){this.logStatus("removeStore","start",e),await this.asyncConstructors.ready();let n=!1;if(!e.global){const t=this.localStores[e.store];t&&(n=!0,delete this.localStores[e.store],t.destroy())}if(!n){const t=new Sf(this.glue,{store:e.store,global:e.global,values:null});await new Promise(e=>{t.destroy(()=>{e()})})}return this.logStatus("removeStore","return",{err:null,data:!0}),null==t||t(null,!0),{err:null,data:!0}}async getOrCreateStoreObject(e){await this.asyncConstructors.ready();const t=e.global,n="object"==typeof e.values?Vp()({},e.values):e.values;if(t){const t=new Sf(this.glue,{store:e.store,global:e.global,values:n});return await t.init(),t}{let t=this.localStores[e.store];return t||(t=new If(this.glue,{store:e.store,values:n}),t.getGlobalValue=async(e,t)=>(await this.getOrCreateStoreObject({store:e.store,global:!0})).getGlobalValue(e,t),await t.init(),this.localStores[e.store]=t),t}}}var Tf=n(9031),xf=n.n(Tf);class Af{get name(){return this.fin.windowName}focus(){this.fin.focus()}hide(){this.fin.hide()}async getSnapshot(e,t){return this.fin.getSnapshot(e,t)}getZoomFactor(e){this.fin.getZoomFactor(e)}setZoomFactor(e,t){this.fin.setZoomFactor(e,t)}getOptions(e){this.fin.getOptions(e)}constructor(e){this.fin=e}}class Ef{getCurrent(){return new Af(this.fin)}focus(){this.fin.focus()}hide(){this.fin.hide()}async getSnapshot(e,t){return this.fin.getSnapshot(e,t)}constructor(e){this.fin=e}}class Wf{getCommandLineArguments(e){this.fin.getCommandLineArguments(e)}constructor(e){this.fin=e}async openUrlWithBrowser(e,t){await this.fin.openUrlWithBrowser(e,t)}isTitlebarWindow(){return this.fin.isTitlebarWindow()}isBrowserView(){return this.fin.isBrowserView()}}class Of{constructor(e){this.fin=e,this.Window=new Ef(e),this.System=new Wf(e)}}class Df{logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"fin",method:e,type:t,data:n})}constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n,this.windowName="Window name not set yet. Please wait for FSBL 'onReady' event before calling getCurrent()",this.myWindow=null;const r=this.asyncConstructors.addConstructor();e.then(e=>{var t,n;this.glue=e,this.myWindow=null!==(n=null===(t=this.glue.windows)||void 0===t?void 0:t.my())&&void 0!==n?n:null,this.myWindow?this.windowName=this.myWindow.id:this.windowName="Not a valid window. Perhaps running in node?",this.asyncConstructors.finishConstructor(r)}),this.desktop=new Of(this)}async focus(){this.logStatus("focus","start"),await this.asyncConstructors.ready(),await new Promise(e=>setTimeout(()=>{var t;null===(t=this.myWindow)||void 0===t||t.focus(),e()},250)),this.logStatus("focus","return")}async hide(){var e;console.log("hide"),this.logStatus("hide","start"),await this.asyncConstructors.ready(),await(null===(e=this.myWindow)||void 0===e?void 0:e.hide()),this.logStatus("hide","return")}isBrowserView(){return!1}isTitlebarWindow(){return!1}async getOptions(e){this.logStatus("getOptions","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getOptions start");const t=this.glue.windows.my();if(t){const n=await xg(t);return null==e||e(n),this.loggerClient.debug("getOptions return"),this.logStatus("getOptions","return",n),n}return this.loggerClient.error("fin getOptions() called on non window"),null==e||e({}),this.logStatus("getOptions","return",{}),{}}async getSnapshot(e,t){var n;if(this.logStatus("getSnapshot","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getSnapshot start"),!this.myWindow)return null==t||t(""),this.logStatus("getSnapshot","return"),"";const r=await this.myWindow.getBounds(),o={size:{height:r.height,keepAspectRatio:!0,width:r.width}},i=await(null===(n=this.myWindow)||void 0===n?void 0:n.capture(o));return this.loggerClient.debug("getSnapshot return"),null==t||t(i),this.logStatus("getSnapshot","return"),i}async getCommandLineArguments(e){var t;this.logStatus("getCommandLineArguments","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getCommandLineArguments start");const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("T42.GD.Execute",{command:"get-cli-arguments"})),o=xf()(null!==(t=null==r?void 0:r.args)&&void 0!==t?t:[]);n&&this.loggerClient.error("getCommandLineArguments",n),null==e||e(o),this.loggerClient.debug("getCommandLineArguments return",o),this.logStatus("getCommandLineArguments","return",o)}async openUrlWithBrowser(e,t){this.logStatus("openUrlWithBrowser","start"),this.loggerClient.debug("openUrlWithBrowser","start",{url:e}),await this.asyncConstructors.ready();const{err:n}=await Tg(this.glue,e);n&&this.loggerClient.error("openUrlWithBrowser","error",n),null==t||t(n),this.loggerClient.debug("openUrlWithBrowser","return"),this.logStatus("openUrlWithBrowser","return")}async getZoomFactor(e){var t,n;this.logStatus("getZoomFactor","start"),await this.asyncConstructors.ready(),e({zoomFactor:(null!==(n=null===(t=this.glue.windows.my())||void 0===t?void 0:t.zoomFactor)&&void 0!==n?n:100)/100,status:"success"}),this.logStatus("getZoomFactor","return")}static getClosestZoomFactor(e){var t;return null===(t=window.iodesktop)||void 0===t?void 0:t.settings.zoom.factors.reduce((t,n)=>Math.abs(n-e)<=Math.abs(t-e)?n:t)}async setZoomFactor(e,t){var n,r;this.logStatus("setZoomFactor","start"),await this.asyncConstructors.ready();const o=Df.getClosestZoomFactor(100*e);if((null===(n=this.glue.windows.my())||void 0===n?void 0:n.zoomFactor)===o)return void(null==t||t());const i=new Promise(e=>{var n;null===(n=this.glue.windows.my())||void 0===n||n.onZoomFactorChanged(()=>{null==t||t(),e()})});await(null===(r=this.glue.windows.my())||void 0===r?void 0:r.setZoomFactor(o)),await i,this.logStatus("setZoomFactor","return")}}class _f{constructor(e,t,n){this.asyncConstructors=t,this.fin=new Df(e,this.asyncConstructors,n)}getCurrent(){return this.fin.desktop.Window.getCurrent()}}class Pf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.protocolHandlerEventChannel=null;const r=this.asyncConstructors.addConstructor();this.Window=new _f(e,this.asyncConstructors,this.loggerClient),e.then(e=>{this.glue=e,this.asyncConstructors.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"System",method:e,type:t,data:n})}setTrayIcon(e,t){this.logStatus("setTrayIcon","deprecated"),console.error("setTrayIcon() has been deprecated. See https://docs.interop.io/desktop/getting-started/how-to/rebrand-io-connect/user-interface/index.html#icons-tray")}launchExternalProcess(){this.logStatus("launchExternalProcess","deprecated"),console.error("launchExternalProcess() is no longer supported. Instead, configure an app config that points to the desired path of your executable and call `iop.appManager.application(name).start()`")}terminateExternalProcess(){this.logStatus("terminateExternalProcess","deprecated"),console.error("terminateExternalProcess() is no longer supported.")}async hideSplashScreen(){this.logStatus("hideSplashScreen","start"),await this.asyncConstructors.ready();const{err:e}=await gg(()=>this.glue.interop.invoke("T42.GD.Execute",{command:"hide-splash-screen"}));e&&this.logStatus("hideSplashScreen","error",e),this.logStatus("hideSplashScreen","return")}async exit(){this.logStatus("exit","start"),await this.asyncConstructors.ready(),await this.glue.appManager.exit({showDialog:!1,autoSave:!1}),this.logStatus("exit","return")}async getProcessList(e){var t,n,r,o;this.logStatus("getProcessList","start"),await this.asyncConstructors.ready();const i=(await this.glue.interop.invoke("T42.Telemetry",{command:"GetEvents",config:{stores:!0,system:!0,apps:!0}})).returned,s=(null!==(o=null===(r=null===(n=null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.system)||void 0===n?void 0:n.perfData)||void 0===r?void 0:r.apps)&&void 0!==o?o:[]).map(e=>{var t;return{cpuUsage:null===(t=e.cpu)||void 0===t?void 0:t.percentCPUUsage,name:e.name,type:e.type,peakWorkingSetSize:e.memoryKB,processId:e.pid,workingSetSize:e.memoryKB,webContents:{}}});return null==e||e(s),this.logStatus("getProcessList","return"),s}async clearCache(){this.logStatus("clearCache","start"),await this.asyncConstructors.ready();const e=globalThis;await e.glue42gd.clearCache(),this.logStatus("clearCache","return")}async showDeveloperTools(e,t=!0){this.logStatus("showDeveloperTools","start",{name:e,viewId:t}),await this.asyncConstructors.ready();const n=this.glue.appManager.instances().find(({_id:t})=>t===e);null==n||n.window.showDevTools(),null!==t&&!0!==t&&this.loggerClient.warn("The use of the 'viewId' parameter has been deprecated in showDeveloperTools()."),this.logStatus("showDeveloperTools","return")}async addEventListener(e,t){if(this.logStatus("addEventListener","start",{eventName:e}),await this.asyncConstructors.ready(),"protocol-handler-triggered"===e){this.protocolHandlerEventChannel=Zp()(),this.loggerClient.debug(`FSBL.System.addEventListener("protocol-handler-triggered") channel = ${this.protocolHandlerEventChannel}`),this.glue.interop.register(this.protocolHandlerEventChannel,e=>{null==t||t(e.command)});const{err:e}=await gg(()=>this.glue.interop.invoke("FSBL.Event.add.protocol-handler-triggered",{invoker:this.protocolHandlerEventChannel}));return e&&this.logStatus("addEventListener","error",e),void this.logStatus("addEventListener","return")}this.loggerClient.warn("FSBL.System.addEventListener called for unsupported event",e),this.logStatus("addEventListener","return")}addSelectClientCertificateListener(){this.logStatus("addSelectClientCertificateListener","deprecated"),console.warn("addSelectClientCertificateListener() is deprecated. Client certificate selection is now part of io.CD's UI.")}addCertificateErrorListener(){this.logStatus("addCertificateErrorListener","deprecated"),console.warn("addCertificateErrorListener() is deprecated. Client certificate selection is now part of io.CD's UI.")}async getFEAInfo(e){var t,n,r;this.logStatus("getFEAInfo","start"),await this.asyncConstructors.ready();const o=globalThis,i={"@interopio/desktop":this.glue.version,"io.Connect Desktop":null===(t=o.glue42gd)||void 0===t?void 0:t.version,Electron:null===(n=o.glue42gd)||void 0===n?void 0:n.electron,FEA:null===(r=o.glue42gd)||void 0===r?void 0:r.version,isDevLaunch:!1,sddEnabled:!1,isDevMode:!1};return this.logStatus("getFEAInfo","return",i),null==e||e(i),i}async getUpdateAvailable(e){return this.loggerClient.error("getUpdateAvailable() is not yet implemented in the polyfill."),await this.asyncConstructors.ready(),e(!1),!1}async openUrlWithBrowser(e,t){this.logStatus("openUrlWithBrowser","start",{url:e}),await this.asyncConstructors.ready();const{err:n}=await Tg(this.glue,e);n&&this.logStatus("openUrlWithBrowser","error",n),null==t||t(n),this.logStatus("openUrlWithBrowser","return")}async getProtocolString(e){this.logStatus("getProtocolString","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("FSBL.System.getProtocolString",{}));return t&&this.logStatus("getProtocolString","error",t),null==e||e(null==n?void 0:n.command),this.logStatus("getProtocolString","return",null==n?void 0:n.command),null==n?void 0:n.command}async terminate(){this.logStatus("terminate","start"),await this.exit(),this.logStatus("terminate","return")}async restart(){this.logStatus("restart","start"),await this.asyncConstructors.ready(),await this.glue.appManager.restart({showDialog:!1,autoSave:!1}),this.logStatus("restart","return")}async getEnvironmentVariable(e,t){var n,r;this.logStatus("getEnvironmentVariable","start",{envVar:e}),await this.asyncConstructors.ready();const o=(null!==(r=null===(n=globalThis.glue42gd)||void 0===n?void 0:n.env)&&void 0!==r?r:{})[e];return this.logStatus("getEnvironmentVariable","return",o),null==t||t(o),o}async getHostSpecs(e){var t,n;this.logStatus("getHostSpecs","start"),await this.asyncConstructors.ready();const r=null!==(n=null===(t=null===window||void 0===window?void 0:window.glue42gd)||void 0===t?void 0:t.env)&&void 0!==n?n:{},o={env:r,hostname:r.HOSTNAME};return this.logStatus("getHostSpecs","return",o),null==e||e(o),o}}const Rf={spacebar:"space",bs:"Backspace",bksp:"Backspace",shift:"Shift",shft:"Shift",lshift:"Shift",lshft:"Shift","left shift":"Shift",leftshift:"Shift",rshift:"Shift",rshft:"Shift","right shift":"Shift",rightshift:"Shift",commandorcontrol:"CommandOrControl",alternate:"Alt","space bar":"space",pgup:"PageUp","pg up":"PageUp","page down":"PageDown",pgdn:"PageDown","pg dn":"PageDown",pgdown:"PageDown","left arrow":"Left",left:"Left","up arrow":"Up",up:"Up","right arrow":"Right",right:"Right","down arrow":"Down",down:"Down",print:"PrintScreen",prnt:"PrintScreen","print screen":"PrintScreen",printscreen:"PrintScreen","print scrn":"PrintScreen",printscrn:"PrintScreen","prnt scrn":"PrintScreen",prntscrn:"PrintScreen","prt scrn":"PrintScreen",prtscrn:"PrintScreen","prt scn":"PrintScreen",prtscn:"PrintScreen","prt scr":"PrintScreen",prtscr:"PrintScreen","prt sc":"PrintScreen",prtsc:"PrintScreen","pr sc":"PrintScreen",prsc:"PrintScreen",insert:"Insert",ins:"Insert",delete:"Delete",del:"Delete",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",a:"A",b:"B",c:"C",d:"D",e:"E",f:"F",g:"G",h:"H",i:"I",j:"J",k:"K",l:"L",m:"M",n:"N",o:"O",p:"P",q:"Q",r:"R",s:"S",t:"T",u:"U",v:"V",w:"W",x:"X",y:"Y",z:"Z",windows:"Super","left windows":"Super","right windows":"Super","numpad 0":"num0","numpad 1":"num1","numpad 2":"num2","numpad 3":"num3","numpad 4":"num4","numpad 5":"num5","numpad 6":"num6","numpad 7":"num7","numpad 8":"num8","numpad 9":"num9",f1:"F1",fn1:"F1","function 1":"F1",f2:"F2",fn2:"F2","function 2":"F2",f3:"F3",fn3:"F3","function 3":"F3",f4:"F4",fn4:"F4","function 4":"F4",f5:"F5",fn5:"F5","function 5":"F5",f6:"F6",fn6:"F6","function 6":"F6",f7:"F7",fn7:"F7","function 7":"F7",f8:"F8",fn8:"F8","function 8":"F8",f9:"F9",fn9:"F9","function 9":"F9",f10:"F10",fn10:"F10","function 10":"F10",f11:"F11",fn11:"F11","function 11":"F11",f12:"F12",fn12:"F12","function 12":"F12",f13:"F13",fn:"F13","function 13":"F13",f14:"F14",fn14:"F14","function 14":"F14",f15:"F15",fn15:"F15","function 15":"F15",f16:"F16",fn16:"F16","function 16":"F16","num lock":"Numlock",numlock:"Numlock","number lock":"Numlock","numeric lock":"Numlock","scroll lock":"Scrolllock",sclk:"Scrolllock",scrlk:"Scrolllock",slk:"Scrolllock","*":"*","+":"+","-":"-","/":"/",";":";","=":"=",",":",",".":".","`":"`","[":"[","]":"]","'":"'"},Lf=e=>e.map(e=>{var t;return null!==(t=Rf[e.toString().toLowerCase()])&&void 0!==t?t:e}).join("+").replace(/windows/i,"super").replace(/spacebar/i,"space");class Ff{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"HotkeyClient",method:e,type:t,data:n})}onClose(e){this.removeAllHotkeys(e)}async removeAllHotkeys(e){return this.logStatus("removeAllHotkeys","start"),await this.asyncConstructors.ready(),await this.glue.hotkeys.unregisterAll(),this.logStatus("removeAllHotkeys","return",{err:null}),null==e||e(null),{err:null}}async removeGlobalHotkey(e,t,n){return this.logStatus("removeGlobalHotkey","start",{keyArr:e}),await this.asyncConstructors.ready(),await this.glue.hotkeys.unregister(Lf(e)),this.logStatus("removeGlobalHotkey","return"),null==n||n(null),{err:null}}async addGlobalHotkey(e,t,n){this.logStatus("addGlobalHotkey","start",e),await this.asyncConstructors.ready();const r=Lf(e);return await this.glue.hotkeys.register(r,()=>{this.loggerClient.debug("Got hotkey",r),t()}),this.logStatus("addGlobalHotkey","return"),null==n||n(null),{err:null}}addBrowserHotkey(e,t,n){console.warn("The method addBrowserHotkey() has been deprecated. Use local keypress event handlers instead.")}}class Mf{warn(...e){globalThis.console.warn(...e)}info(...e){globalThis.console.info(...e)}log(...e){globalThis.console.log(...e)}debug(...e){globalThis.console.debug(...e)}error(...e){globalThis.console.error(...e)}verbose(...e){globalThis.console.debug(...e)}deprecated(...e){globalThis.console.error(...e)}}class $f{constructor(e,t){this.asyncConstructors=t,this.queue=[],this.logState={Error:!0,Warn:!0,Log:!0,Info:!1,Debug:!1,Verbose:!1,Console:!1},this.componentSelected=!1,this.centralLoggerReady=!1,this.enableLegacyLoggerRecipe=!1,this.routerClient=null;const n=t.addConstructor();e.then(async e=>{var r,o,i,s;this.glue=e;const a=null!==(i=null===(o=null===(r=this.glue.windows)||void 0===r?void 0:r.my())||void 0===o?void 0:o.name)&&void 0!==i?i:"unknown window";await this.glue.contexts.subscribe("central-logger-component-states",({componentLogState:e,componentFilterState:t})=>{a in e&&a in t&&(this.logState=e[a],this.componentSelected=t[a],this.centralLoggerReady=!0,this.processQueue())});const l=await e.contexts.get(tg);this.enableLegacyLoggerRecipe=null===(s=l.iocd)||void 0===s?void 0:s.enableLegacyLoggerRecipe,t.finishConstructor(n)}),this.system={warn:(...e)=>{this.logIt("system","Warn",e)},info:(...e)=>{this.logIt("system","Info",e)},log:(...e)=>{this.logIt("system","Log",e)},error:(...e)=>{this.logIt("system","Error",e)},debug:(...e)=>{this.logIt("system","Debug",e)},verbose:(...e)=>{this.logIt("system","Verbose",e)},deprecated:(...e)=>{this.logIt("system","Error",e)}},this.perf={warn:(...e)=>{this.logIt("perf","Warn",e)},info:(...e)=>{this.logIt("perf","Info",e)},log:(...e)=>{this.logIt("perf","Log",e)},error:(...e)=>{this.logIt("perf","Error",e)},debug:(...e)=>{this.logIt("perf","Debug",e)},verbose:(...e)=>{this.logIt("perf","Verbose",e)},deprecated:(...e)=>{this.logIt("perf","Error",e)}},this.console=new Mf}logIt(e,t,n){var r,o,i,s;const a={category:e,logType:t,logClientName:null!==(s=null===(i=null===(o=null===(r=this.glue)||void 0===r?void 0:r.windows)||void 0===o?void 0:o.my())||void 0===i?void 0:i.name)&&void 0!==s?s:"",logData:n,logTimestamp:(new Date).valueOf()};this.queue.push(a),this.processQueue()}async processQueue(){var e;if(!this.centralLoggerReady||0===this.queue.length)return;await this.asyncConstructors.ready();const t=this.queue.slice(0);if(this.queue=[],!this.componentSelected)return;const n=t.filter(e=>this.logState[e.logType]);if(n.length){n.forEach(e=>{var t,n,r,o;e.logClientName=null!==(o=null===(r=null===(n=null===(t=this.glue)||void 0===t?void 0:t.windows)||void 0===n?void 0:n.my())||void 0===r?void 0:r.name)&&void 0!==o?o:""});const t=e=>({Error:"error",Log:"log",Debug:"debug",Info:"info",Warn:"warn",Verbose:"debug",Console:"log"}[e]);this.logState.Console&&n.forEach(e=>this.console[t(e.logType)](...e.logData)),await gg(()=>this.glue.interop.invoke("fsbl-logger-service-log-messages",{data:n}));const r=n.filter(e=>"Error"===e.logType||"Warn"===e.logType);this.enableLegacyLoggerRecipe&&r.length&&(null===(e=this.routerClient)||void 0===e||e.transmit("logger.service.logMessages",r.map(e=>({...e,logData:JSON.stringify(e.logData)}))))}}warn(...e){this.logIt("dev","Warn",e)}info(...e){this.logIt("dev","Info",e)}log(...e){this.logIt("dev","Log",e)}debug(...e){this.logIt("dev","Debug",e)}error(...e){this.logIt("dev","Error",e)}verbose(...e){this.logIt("dev","Verbose",e)}deprecated(...e){this.logIt("dev","Error",e)}initialize(e){this.routerClient=e}}class Nf{}class jf{constructor(){this.actions=[],this.isRead=!1,this.isSnoozed=!1,this.isMuted=!1,this.isDeleted=!1,this.actionsHistory=[],this.meta=new Nf,this.stateHistory=[],this.issuedAt="",this.title="",this.devModeOnly=!1}}class Bf{constructor(){this.id="",this.buttonText="",this.type=""}}class qf{constructor(e,t){this.id=e||null,this.filter=t,this.channel=""}}const Uf=(e,t)=>{var n;let r=!0;return e.type&&e.type!==t.type&&(r=!1),e.source&&e.source!==t.source&&(r=!1),e.title&&(e.title!==t.title&&(r=!1),e._text&&t.title.includes(e.title)&&(r=!0)),e.details&&(e.details!==t.body&&(r=!1),e._text&&(null===(n=t.body)||void 0===n?void 0:n.includes(e.details))&&(r=!0)),r};class zf{constructor(){this.include=[],this.exclude=[]}}var Gf;!function(e){e.DISMISS="DISMISS",e.SNOOZE="SNOOZE",e.SPAWN="SPAWN",e.QUERY="QUERY",e.PUBLISH="PUBLISH",e.TRANSMIT="TRANSMIT"}(Gf||(Gf={}));const Hf=(e,t)=>{if(!t)return!0;if(t.exclude){if(t.exclude.find(({type:t})=>t===e.type))return!1;if(t.exclude.find(({source:t})=>t===e.source))return!1}if(t.include&&t.include.length){const n=Object.entries(e);return Object.entries(t.include).some(([t,r])=>Object.entries(r).every(([t,r])=>{if(t.includes(".")){const n=(0,Qp.get)(e,t,void 0);return r===n}return n.some(([e,n])=>t===e&&r===n)}))}return!0},Vf=(e,t)=>({action:`finsemble-notification-polyfill-${e.type}`,title:e.buttonText,interop:{method:"FSBL.Clients.NotificationClient.performAction",arguments:{id:t.id,...e,payload:{notification:t,actionPayload:e.payload}}}}),Qf=(e,t)=>{var n,r;if(!(null==t?void 0:t.types))return e;let o;const i=e.type;if(i&&(null===(n=null==t?void 0:t.types)||void 0===n?void 0:n[i])?o=t.types[i]:(null===(r=null==t?void 0:t.types)||void 0===r?void 0:r.default)&&(o=t.types.default),o&&o.hasOwnProperty("defaults"))for(const[t,n]of Object.entries(o.defaults)){const r=e[t];(null==r||""===r||Array.isArray(r)&&0===r.length)&&(e[t]=n)}return e},Jf=e=>{var t,n,r;const o={title:null!==(t=e.title)&&void 0!==t?t:"Notification"};return o.id=e.id,"details"in e&&(o.body=e.details),"contentLogo"in e&&(o.icon=e.contentLogo),"timeout"in e&&(o.toastExpiry=(null!==(n=e.timeout)&&void 0!==n?n:3e3)/1e3),"actions"in e&&(o.actions=e.actions.flatMap(t=>{const n=Vf(t,e);return n?[n]:[]})),"type"in e&&(o.type=e.type),o.data={...e.meta},"cssClassName"in e&&(o.data.cssClassName=e.cssClassName),o.data.issuedAt=null!==(r=e.issuedAt)&&void 0!==r?r:new Date,o},Kf=(e,t=null)=>{var n,r,o,i,s;const a=e.timestamp?1e3*e.timestamp:(new Date).getTime();let l=new Date(a).toISOString();try{l=new Date(null!==(r=null===(n=e.data)||void 0===n?void 0:n.issuedAt)&&void 0!==r?r:a).toISOString()}catch(e){}const u=null===(o=null==t?void 0:t.muted)||void 0===o?void 0:o.includes(e.source);return JSON.parse(JSON.stringify({actions:[],actionsHistory:[],stateHistory:[],id:null!==(i=e.id)&&void 0!==i?i:Zp()(),issuedAt:l,receivedAt:new Date(a).toISOString(),meta:e.data,title:e.title,source:e.source,details:e.body,contentLogo:e.icon,timeout:e.toastExpiry,type:e.type,cssClassName:null===(s=e.data)||void 0===s?void 0:s.cssClassName,isRead:"Active"!==e.state,isDeleted:"Closed"===e.state,isSnoozed:"Snoozed"===e.state,isMuted:null!=u&&u}))};class Yf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.Notification=jf,this.ActionTypes=Gf,this.Subscription=qf,this.Action=Bf,this.Filter=zf,this.actionTypes=Gf,this.subscriptionMap=new Map,this.notificationServiceConfig={};const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,t.finishConstructor(r),this.initializeNotificationConfig()})}async initializeNotificationConfig(){var e;const t=null!==(e=await this.glue.contexts.get(tg))&&void 0!==e?e:{};this.notificationServiceConfig=(0,Qp.get)(t,"finsemble.servicesConfig.notifications".split("."),{})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"NotificationClient",method:e,type:t,data:n})}async onClose(e){this.unsubscribeAll(),null==e||e()}async getPreferences(){this.logStatus("getPreferences","start"),await this.asyncConstructors.ready();const e=await this.glue.notifications.getConfiguration(),t={disableDotOnToolbarIcon:!1,showDotOnToolbarIconForMutedNotifications:e.showNotificationBadge,informationalNotificationToastPeriodSeconds:e.toastExpiry/1e3,defaultSnoozePeriodSeconds:e.snooze.duration,newNotificationHaloPeriodSeconds:0,toastTimeoutOnActionableNotifications:!0};return this.logStatus("getPreferences","return",t),t}async getMuteFilters(){this.logStatus("getMuteFilters","start"),await this.asyncConstructors.ready();const e=(await this.glue.notifications.getFilter()).muted.map(e=>({source:e}));return this.logStatus("getMuteFilters","return",e),e}async getSources(){return this.logStatus("getSources","start"),await this.asyncConstructors.ready(),console.warn("NotificationClient.getSources() is not available in iocd"),this.logStatus("getSources","return",[]),[]}async unmute(e){this.logStatus("unmute","start",e),await this.asyncConstructors.ready();const t=(Array.isArray(e)?e:[e]).map(e=>e.source),n=await this.glue.notifications.getFilter();n.muted=n.muted.filter(e=>!t.includes(e)),await this.glue.notifications.setFilter(n),this.logStatus("unmute","return")}async mute(e){this.logStatus("mute","start",e),await this.asyncConstructors.ready();const t=(Array.isArray(e)?e:[e]).map(e=>e.source),n=await this.glue.notifications.getFilter();n.muted=n.muted.concat(t),await this.glue.notifications.setFilter(n),this.logStatus("mute","return")}unsubscribeAll(){this.logStatus("unsubscribeAll","start"),this.subscriptionMap.forEach(e=>{e.unsubscribe()}),this.subscriptionMap.clear(),this.logStatus("unsubscribeAll","return")}async unsubscribe(e){var t,n;this.logStatus("unsubscribe","start",e),await this.asyncConstructors.ready(),null===(n=null===(t=this.subscriptionMap.get(e))||void 0===t?void 0:t.unsubscribe)||void 0===n||n.call(t),this.logStatus("unsubscribe","return")}async subscribe(e,t){var n,r,o;this.logStatus("subscribe","start",e),await this.asyncConstructors.ready();const i=this.glue.notifications.onClosed(async e=>{this.logStatus("subscribe","debug",`Received closed for ${e.id}`),e.isDeleted=!0,t(e)}),s=this.glue.notifications.onStateChanged(async(n,r)=>{if(this.logStatus("subscribe","debug",`Received state ${r} for ${n.id}`),"Active"===r)return;const o=(await this.glue.notifications.list()).find(e=>e.id===n.id);if(!o)return void this.logStatus("subscribe","warn","Can't find notification id for state change");o.isDeleted=!0;const i=await this.glue.notifications.getFilter(),s=Kf(o,i);Hf(s,e.filter)?t(s):this.logStatus("subscribe","debug",{message:"Filtered notification",notification:o})}),a=this.glue.notifications.onRaised(async n=>{const r=await this.glue.notifications.getFilter(),o=Kf(n,r);Hf(o,e.filter)?t(o):this.logStatus("subscribe","debug",{message:"Filtered notification",glueNotification:n,finsembleNotification:o})}),l=null!==(n=e.id)&&void 0!==n?n:Zp()();return this.subscriptionMap.set(l,{unsubscribe:()=>{a(),s(),i()}}),this.logStatus("subscribe","return",{id:l,channel:null!==(r=e.channel)&&void 0!==r?r:""}),{id:l,channel:null!==(o=e.channel)&&void 0!==o?o:""}}async notify(e){this.logStatus("notify","start",e),await this.asyncConstructors.ready();const t=Array.isArray(e)?e:[e],n=await this.glue.notifications.list();for(const e of t){const t=Qf(e,this.notificationServiceConfig),r=Jf(t),o=t.id&&n.some(e=>e.id===r.id);o&&await pg(()=>this.glue.notifications.clear(r.id));const{err:i}=await pg(()=>this.glue.notifications.raise(r));i?this.loggerClient.debug(`NotificationClient.Notify:raise ${i}`):this.loggerClient.debug("[FSBL] [NotificationClient.notify] raised notification: ",e," Post-process details",r)}this.logStatus("notify","return")}async deleteNotifications(e){this.logStatus("deleteNotifications","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.clear(e.id)}),this.logStatus("deleteNotifications","return")}async markUnread(e){this.logStatus("markUnread","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.setState(e.id,"Active")}),this.logStatus("markUnread","return")}async markRead(e){this.logStatus("markRead","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.setState(e.id,"Acknowledged")}),this.logStatus("markRead","return")}async performAction(e,t){this.logStatus("performAction","start",{notifications:e,action:t}),await this.asyncConstructors.ready(),this.logStatus("performAction","debug",{action:t,notifications:e}),await ag(e,async e=>{const n=Vf(t,e);n?await gg(()=>this.glue.interop.invoke(n.interop.method,n.interop.arguments)):this.logStatus("performAction","error",`Unable to parse action ${t}`)}),this.logStatus("performAction","return")}async getLastIssuedAt(e){var t,n;this.logStatus("getLastIssuedAt","start",e),await this.asyncConstructors.ready();const r=await gg(()=>this.glue.interop.invoke("FSBL.Clients.NotificationClient.getLastIssuedAt",{source:e}));return this.logStatus("getLastIssuedAt","return",r),null!==(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.lastIssuedAt)&&void 0!==n?n:""}async fetchHistory(e,t){this.logStatus("fetchHistory","start",{options:e,filter:t}),await this.asyncConstructors.ready();const n="string"==typeof e?{sentAfter:e}:e,r=((null==n?void 0:n.sentBefore)?new Date(null==n?void 0:n.sentBefore):new Date).getTime(),o=((null==n?void 0:n.sentAfter)?new Date(null==n?void 0:n.sentAfter):new Date(0)).getTime(),i=(await this.glue.notifications.list()).filter(e=>{const t=(e.timestamp?new Date(1e3*e.timestamp):new Date).getTime();return!(r&&t>r||o&&t<o)}),s=t?((e,t)=>{const{exclude:n=[],include:r=[]}=t;return e.filter(e=>{let t=!0;return r.length&&(t=!1,r.some(t=>Uf(t,e))&&(t=!0)),n.some(t=>Uf(t,e))&&(t=!1),t})})(i,t):i,a=await this.glue.notifications.getFilter(),l=s.map(e=>Kf(e,a));return this.logStatus("fetchHistory","return",l),l}}class Zf{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n,this.subscriptions={};const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.transmit",method:e,type:t,data:n})}addListener(e,t){this.logStatus("addListener","start",{channel:e});let n=null;return(async()=>{var r;await this.asyncConstructors.ready(),n=await this.glue.bus.subscribe(e,(n,r,o)=>{const{peerId:i="Unknown peer"}=o,s={data:n._data,originatedHere:()=>o.peerId===this.glue.interop.instance.peerId,options:{suppressWarnings:!1},header:{type:"transmit",channel:e,incomingTransportInfo:{lastClient:i,origin:i,transportID:"FinsembleTransport"},lastClient:i,origin:i,originMetadata:{routerConnectionId:"",transportInfo:{transportID:"FinsembleTransport"},windowName:"",appId:"",webContentsName:""}}};t(null,s)}),this.subscriptions[e]=(null!==(r=this.subscriptions[e])&&void 0!==r?r:[]).concat({iocdSubscription:n,eventHandler:t})})(),this.logStatus("addListener","return"),()=>{var t;n&&(this.subscriptions[e]=(null!==(t=this.subscriptions.channel)&&void 0!==t?t:[]).filter(e=>e.iocdSubscription!==n),this.subscriptions[e].length||delete this.subscriptions[e],n.unsubscribe())}}removeListener(e,t){this.logStatus("removeListener","start",{channel:e}),(async()=>{var n,r;await this.asyncConstructors.ready(),(null!==(n=this.subscriptions[e])&&void 0!==n?n:[]).forEach(n=>{t&&n.eventHandler!==t||(n.iocdSubscription.unsubscribe(),this.subscriptions[e]=this.subscriptions[e].filter(e=>e!==n))}),(null===(r=this.subscriptions[e])||void 0===r?void 0:r.length)||delete this.subscriptions[e]})(),this.logStatus("removeListener","return")}async transmit(e,t,n){this.logStatus("transmit","start",{toChannel:e}),await this.asyncConstructors.ready();try{await this.glue.bus.publish(e,{_data:t})}catch(e){console.error("Router transmit() error calling invoke",e)}this.logStatus("transmit","return")}}class Xf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.lastSubId=0,this.unsubscribeFunctions={},this.catalogue={},this.gate=new og,this.alreadyRegisteredWithIOCD=!1,this.responders=[];const r=t.addConstructor();e.then(e=>{this.glue=e,this.initialize(),t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.pubsub",method:e,type:t,data:n})}async initialize(){await this.glue.contexts.subscribe("finsemble-pubsub-catalogue",e=>{this.catalogue=e})}getLocalResponder(e){const t=this.responders.find(t=>t.topic===e),n=this.responders.find(t=>new RegExp(t.topic).test(e));return null!=t?t:n}handleIncomingPublish(e,t,n){var r;e.publishCallback?e.publishCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===this.glue.interop.instance.peerId,sendNotifyToAllSubscribers:(n,r)=>{var o;n||null===(o=e.updateCallback)||void 0===o||o.call(e,t.topic,r)}}):null===(r=e.updateCallback)||void 0===r||r.call(e,t.topic,t.data)}handleIncomingSubscribe(e,t,n){var r;const o=new Kp;return e.subscribeCallback?(e.subscribeCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===e.peerId,sendNotifyToSubscriber:(t,n)=>{o.resolve({error:t||void 0,data:n?{data:n}:void 0,initialData:e.initialState})}}),o.promise):Promise.resolve({data:void 0,initialData:null!==(r=e.initialState)&&void 0!==r?r:{}})}handleIncomingUnsubscribe(e,t,n){var r;const o=new Kp;return e.unsubscribeCallback?(e.unsubscribeCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===e.peerId,removeSubscriber:()=>{var t;o.resolve({data:void 0,initialData:null!==(t=e.initialState)&&void 0!==t?t:{}})}}),o.promise):Promise.resolve({data:void 0,initialData:null!==(r=e.initialState)&&void 0!==r?r:{}})}async registerResponder(e,t,n){var r,o,i;const s=e instanceof RegExp?e.source:e;if(this.responders.find(e=>s===e.topic))throw new Error(`Router:registerResponder(): A local responder for topic already exists:'${s}'`);if(this.responders.push({topic:s,initialState:n,updateCallback:(e,t)=>{const n=`finsemble-pubsub-topic-${e}`;this.glue.contexts.set(n,t)},subscribeCallback:null==t?void 0:t.subscribeCallback,unsubscribeCallback:null==t?void 0:t.unsubscribeCallback,publishCallback:null==t?void 0:t.publishCallback,peerId:null!==(r=this.glue.interop.instance.peerId)&&void 0!==r?r:"Unknown peer"}),!this.alreadyRegisteredWithIOCD){const{err:e}=await pg(()=>this.glue.interop.register("finsemble-pubsub-responder",ig(async(e,t)=>{const n=this.getLocalResponder(e.topic);if(n)if("publish"===e.action)this.handleIncomingPublish(n,e,t);else{if("subscribe"===e.action)return this.handleIncomingSubscribe(n,e,t);if("unsubscribe"===e.action)return this.handleIncomingUnsubscribe(n,e,t)}})));if(e)return{err:e};this.alreadyRegisteredWithIOCD=!0}const a=null!==(o=this.glue.interop.instance.peerId)&&void 0!==o?o:"Unknown peer",l=(null!==(i=this.catalogue[a])&&void 0!==i?i:[]).concat({topic:s,isRegex:e instanceof RegExp,peerId:a}),{err:u}=await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[a]:l}));return{err:u}}findRemoteResponder(e){const t=e=>this.glue.interop.servers().find(t=>t.peerId===e),n=Object.keys(this.catalogue).filter(e=>!t(e));if(n){let e={};n.forEach(t=>{e[t]=null,delete this.catalogue[t]}),this.glue.contexts.update("finsemble-pubsub-catalogue",e)}const r=Object.keys(this.catalogue).find(t=>this.catalogue[t].find(t=>!t.isRegex&&t.topic===e)),o=Object.keys(this.catalogue).find(t=>this.catalogue[t].find(t=>t.isRegex&&new RegExp(t.topic).test(e)));return null!=r?r:o}subscribe(e,t){this.logStatus("subscribe","start",{topic:e});const n=""+this.lastSubId++;return(async()=>{var r,o,i,s,a,l;await this.asyncConstructors.ready();const u=this.findRemoteResponder(e),c=`finsemble-pubsub-topic-${e}`;let d=!1;const h=await this.glue.contexts.subscribe(c,(n,r,o,i,s)=>{var a;if(!d)return;const l={data:null!==(a=null==n?void 0:n.envelope)&&void 0!==a?a:n,header:{topic:e,type:"",origin:"",subscribeID:""},originatedHere:()=>!s.updateId};t(void 0,l)}),p=async()=>{h();const{err:t}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{action:"unsubscribe",topic:e,options:{},header:{}},{peerId:u},{waitTimeoutMs:3e4}));t&&this.logStatus("unsubscribe","error",t)};let g=null;if(u){const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{action:"subscribe",topic:e,options:{},header:{}},{peerId:u},{waitTimeoutMs:3e4}));if(g=null!=r?r:null,n)return p(),void t(n,{})}this.unsubscribeFunctions[n]=p;let f=await this.glue.contexts.get(c);0===Object.keys(f).length&&(f=void 0);const m=this.getLocalResponder(e);let y=null;if(null==m?void 0:m.subscribeCallback){const t=new Kp;m.subscribeCallback(null,{data:{topic:e},header:{},options:{suppressWarnings:!1},originatedHere:()=>!0,sendNotifyToSubscriber:(e,n)=>{t.resolve(n)}}),y=await t.promise}const w=null!==(s=null!==(i=null!==(o=null!==(r=null==g?void 0:g.data)&&void 0!==r?r:f)&&void 0!==o?o:null==g?void 0:g.initialData)&&void 0!==i?i:y)&&void 0!==s?s:null==m?void 0:m.initialState;t(void 0,{data:null!==(l=null!==(a=null==w?void 0:w.envelope)&&void 0!==a?a:w)&&void 0!==l?l:{},header:{topic:e,type:"",origin:"",subscribeID:""},originatedHere:()=>!1}),d=!0})(),this.logStatus("subscribe","return"),{subscribeID:n,topic:e}}unsubscribe(e){this.logStatus("unsubscribe","start",{subscribeIDStruct:e});const t=this.unsubscribeFunctions[e.subscribeID];t?t():setTimeout(()=>{this.unsubscribe(e)},100),this.logStatus("unsubscribe","return")}async publish(e,t){this.logStatus("publish","start",{topic:e}),await this.asyncConstructors.ready(),await this.gate.wait(async()=>{let n=this.findRemoteResponder(e);const r={envelope:t,transactionID:Zp()()};if(n){const{err:t}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{data:r,action:"publish",topic:e,options:{},header:{}},{peerId:n}));t&&this.logStatus("publish","error",t)}else{const t=`finsemble-pubsub-topic-${e}`;this.glue.contexts.set(t,r)}}),this.logStatus("publish","return")}addPubSubResponder(e,t,n,r){return this.logStatus("addPubSubResponder","start",{topic:e}),(async()=>{await this.asyncConstructors.ready();const{err:o}=await this.registerResponder(e,null!=n?n:{},{envelope:t});o&&this.logStatus("addPubSubResponder","error",{topic:e,err:o}),null==r||r(null!=o?o:void 0,o?void 0:"success"),this.logStatus("addPubSubResponder","return")})()}async removePubSubResponder(e){var t,n;this.logStatus("removePubSubResponder","start",{topic:e}),this.responders=this.responders.filter(t=>t.topic!==e);const r=await this.glue.contexts.get("finsemble-pubsub-catalogue"),o=null!==(t=this.glue.interop.instance.peerId)&&void 0!==t?t:"Unknown peer",i=(null!==(n=r[o])&&void 0!==n?n:[]).filter(t=>t.topic!==e),{err:s}=await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[o]:i}));s&&this.logStatus("removePubSubResponder","error",{err:s}),this.logStatus("removePubSubResponder","return")}trustedMessage(e){return!0}async disconnectAll(){var e;this.logStatus("disconnectAll","start"),await this.asyncConstructors.ready(),Object.values(this.unsubscribeFunctions).forEach(e=>e()),this.unsubscribeFunctions={};const t=null!==(e=this.glue.interop.instance.peerId)&&void 0!==e?e:"Unknown peer";await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[t]:null})),await pg(()=>this.glue.interop.unregister("finsemble-pubsub-responder")),this.responders=[],this.logStatus("disconnectAll","return")}calibrateTimeWithRouterService(e){e(0)}}class em{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.queries",method:e,type:t,data:n})}isInteropEndpointRegistered(e){return this.glue.interop.methods().some(t=>t.name===e)}async addResponder(e,t){if(this.logStatus("addResponder","start",{channel:e}),await this.asyncConstructors.ready(),this.isInteropEndpointRegistered(e)){const t=`addResponder failed because responder already added to ${e}`;throw this.logStatus("addResponder","error",t),new Error(t)}await this.glue.interop.register(e,ig(async(n,r)=>{var o,i,s;const a=new Kp,l={origin:null!==(o=r.instance)&&void 0!==o?o:"Unknown origin",type:"query",queryID:"",channel:e,logWhenNoResponder:!1,error:null,subscribeID:e,lastClient:"",incomingTransportInfo:{lastClient:"",origin:null!==(i=r.instance)&&void 0!==i?i:"",transportID:"FinsembleTransport"}},u={data:null!==(s=null==n?void 0:n["#primitives-wrapper"])&&void 0!==s?s:n,header:l,options:{suppressWarnings:!1},sendQueryResponse:(e,t)=>{const n="object"!=typeof t||Array.isArray(t)?{"#primitives-wrapper":t}:t;a.resolve({err:e,data:n})},originatedHere:()=>{var e,t;return r.windowId===(null!==(t=null===(e=this.glue.windows.my())||void 0===e?void 0:e.id)&&void 0!==t?t:"Unknown or incompatible window type")}};return t(null,u),this.logStatus("addResponder","return"),await a.promise}))}removeResponder(e){this.logStatus("removeResponder","start",{responderChannel:e}),this.glue.interop.unregister(e),this.logStatus("removeResponder","return")}async query(e,t,n,r){var o;this.logStatus("query","start",{channel:e}),await this.asyncConstructors.ready();const i="function"==typeof n?n:r,s="object"!=typeof t||Array.isArray(t)?{"#primitives-wrapper":t}:t,a=null==n?void 0:n.timeout,l=a?{methodResponseTimeoutMs:a}:void 0,u={channel:e,topic:e,type:"",origin:"",subscribeID:e,lastClient:"",incomingTransportInfo:{lastClient:"",origin:"",transportID:"FinsembleTransport"},originMetadata:{routerConnectionId:"",transportInfo:{transportID:"FinsembleTransport"},windowName:"",appId:"",webContentsName:""}};if(!this.isInteropEndpointRegistered(e)){const t=`query failed since no responder on ${e}`;return this.logStatus("query","error",t),null==i||i(t,{header:u}),{err:t,response:{header:u}}}const{err:c,data:d}=await gg(()=>this.glue.interop.invoke(e,s,void 0,l)),h={data:null!==(o=null==d?void 0:d["#primitives-wrapper"])&&void 0!==o?o:d,header:u};return this.logStatus("query","return"),null==i||i(c,h),{err:c,response:h}}}class tm{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n,this.transmitter=new Zf(e,this.asyncConstructors,n),this.pubSub=new Xf(e,this.asyncConstructors,n),this.queries=new em(e,this.asyncConstructors,n)}async onReady(e){await this.asyncConstructors.ready(),null==e||e()}async onFailure(e){}addListener(e,t){return this.transmitter.addListener(e,t)}removeListener(e,t){return this.transmitter.removeListener(e,t)}transmit(e,t,n){return this.transmitter.transmit(e,t,n)}addResponder(e,t){this.queries.addResponder(e,t)}removeResponder(e){this.queries.removeResponder(e)}query(e,t,n,r){return this.queries.query(e,t,n,r)}subscribe(e,t){return this.pubSub.subscribe(e,t)}publish(e,t){return this.pubSub.publish(e,t)}addPubSubResponder(e,t,n,r){return this.pubSub.addPubSubResponder(e,t,n,r)}removePubSubResponder(e){return this.pubSub.removePubSubResponder(e)}unsubscribe(e){this.pubSub.unsubscribe(e)}trustedMessage(e){return this.pubSub.trustedMessage(e)}disconnectAll(){var e;null===(e=this.pubSub)||void 0===e||e.disconnectAll()}}class nm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.providers=[];const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"SearchClient",method:e,type:t,data:n})}async invokeProviderAction(e){console.warn("This method is deprecated")}async invokeItemAction(e,t){var n,r;this.logStatus("invokeItemAction","start",{item:e,action:t});const o=`${e.provider}.ActionHandler`,i=t.method?t.method:o,s=t.params?t.params:{item:e,action:t,windowName:null!==(r=null===(n=this.glue.windows.my())||void 0===n?void 0:n.id)&&void 0!==r?r:"Unknown Window"},{err:a}=await gg(()=>this.glue.interop.invoke(i,s,t.target));a&&this.logStatus("invokeItemAction","error",a),this.logStatus("invokeItemAction","return")}async search(e,t){if(this.logStatus("search","start",e),e.text&&""!==e.text)try{const n=await this.glue.search.query({search:e.text}),r=[];n.onError(({error:e})=>{this.logStatus("search","error",e),null==t||t(e)}),n.onResults(e=>{var n,o,i,s;r.push({data:e.results.map(({id:t,displayName:n,type:r,metadata:o,description:i,iconURL:s,action:a,secondaryActions:l})=>{var u,c;const d=(a?[a]:[]).concat(null!=l?l:[]);return{name:null!=n?n:t,type:r.name,score:1,description:i,icon:s?{imageType:"url",path:null!=s?s:""}:null,category:null!==(u=r.displayName)&&void 0!==u?u:r.name,actions:d,...o,provider:null===(c=e.provider)||void 0===c?void 0:c.name}}),provider:{displayName:null!==(o=null===(n=e.provider)||void 0===n?void 0:n.name.replace(Qg,""))&&void 0!==o?o:"Desktop",channel:null!==(s=null===(i=e.provider)||void 0===i?void 0:i.name)&&void 0!==s?s:"Desktop",providerActionCallback:!1,providerActionTitle:void 0}}),this.logStatus("search","return",{err:null,data:r}),null==t||t(null,r)})}catch(e){this.logStatus("search","error",e),null==t||t(e)}else null==t||t(null,[])}async unregister(e,t){this.logStatus("unregister","start",e),await this.asyncConstructors.ready(),await ag(this.providers,async({name:t,provider:n})=>{if(t===e.name){console.debug("FSBL.Clients.SearchClient.unregister removing",t);const e=`${Qg}${t}.ActionHandler`,{err:r}=await pg(()=>this.glue.interop.unregister(e));r&&console.warn("FSBL.Clients.SearchClient.unregister exception unregistering action handler",r),await n.unregister()}}),this.providers=this.providers.filter(({name:t})=>t!==e.name),this.logStatus("unregister","return"),null==t||t()}async register(e,t){this.logStatus("register","start",e),await this.asyncConstructors.ready(),(e.providerActionTitle||e.providerActionCallback)&&console.warn("Search Provider options 'providerActionTitle' and 'providerActionCallback' are deprecated.");const n=await(async(e,t)=>{const n=`${Qg}${t.name}`,r=`${n}.ActionHandler`,o=await e.search.registerProvider({name:n});return await pg(()=>e.interop.register(r,async e=>{console.debug("Action handler received",o.id,e);const n=t.itemActionCallback;n?n(e):console.warn("Action provider not found for",o.id,e)})),o.onQuery(e=>{t.searchCallback({text:e.search},(t,n)=>{const o=Array.isArray(n)?n:[n];t?e.error(t):(o.forEach(t=>{const{name:n,type:o,description:i,actions:s=[],...a}=t,l=s.map(e=>({name:e.name,method:r}));e.sendResult({type:{name:o},description:i,displayName:n,action:l.shift(),secondaryActions:l,metadata:{...a}})}),e.done())})}),{name:t.name,provider:o}})(this.glue,e);return this.providers.push(n),this.logStatus("register","return",{err:null,status:"success"}),null==t||t(null,{status:"success"}),{err:null,data:{status:"success"}}}}class rm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=this.asyncConstructors.addConstructor();e.then(e=>{this.glue=e,this.asyncConstructors.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"StorageClient",method:e,type:t,data:n})}async clearCache(e,t){this.logStatus("clearCache","start",t),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.clearCache",{...t}),e);return n&&this.logStatus("remove","error",n),this.logStatus("clearCache","return"),{err:n}}async remove(e,t){this.logStatus("remove","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.remove",e),t);return n&&this.logStatus("remove","error",n),this.logStatus("remove","return"),{err:n}}async keys(e,t){this.logStatus("keys","start",e),await this.asyncConstructors.ready();const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.keys",e),t);return n&&this.logStatus("keys","error",n),this.logStatus("keys","return",r),{err:n,data:r}}async getStandardized(e,t){this.logStatus("getStandardized","start",e),await this.asyncConstructors.ready();const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.get",e),t);return n&&this.logStatus("getStandardized","error",n),this.logStatus("getStandardized","return",r),{err:n,data:r}}async getMultiple(e,t){return this.logStatus("getMultiple","deprecated","Not Implemented"),{err:"get multiple is not implemented"}}async save(e,t){this.logStatus("save","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>{var t;return this.glue.interop.invoke("FSBL.Clients.StorageClient.save",{key:null!==(t=e.key)&&void 0!==t?t:e.field,value:e.value,topic:e.topic})},t);return n&&this.logStatus("save","error",n),this.logStatus("save","return"),{err:n}}async setUser(e,t){this.logStatus("setUser","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.setUser",e),t);return n&&this.logStatus("setUser","error",n),this.logStatus("setUser","return"),{err:n}}async get(e,t){this.logStatus("get","start",e);const n=await this.getStandardized(e,t);return this.logStatus("get","return",n),n.data}}class om{async initialize(e){var t,n,r,o,i,s,a;if(!this.glue.windows)return;this.windowIdentifier=await lg(this.glue);const l=null!=e?e:null===(t=this.windowIdentifier)||void 0===t?void 0:t.windowName,u=this.glue.windows.findById(l);if(!u)return void(globalThis.window&&this.loggerClient.warn("INVARIANT: WindowClient cannot find window",l));this.gdwin=u;const c=await(null===(n=this.gdwin)||void 0===n?void 0:n.getContext()),d=null!==(r=await Wg(this.gdwin))&&void 0!==r?r:{};this.spawnData=null!==(o=null==c?void 0:c["#finsemble-spawnData"])&&void 0!==o?o:{},this.options={customData:{...null==d?void 0:d.customProperties,...null===(a=null===(s=null===(i=null==d?void 0:d.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble,...this.spawnData,spawnData:this.spawnData}}}constructor(e,t,n,r){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.gate=new og;const o=t.addConstructor();this.loggerClient.debug("WindowClient Constructor"),this.options={customData:{}},e.then(async e=>{this.glue=e,this.initialize(r).finally(()=>{this.loggerClient.debug("WindowClient Initialized"),t.finishConstructor(o)})})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"WindowClient",method:e,type:t,data:n})}async showAtMousePosition(){var e,t,n,r,o,i;this.logStatus("showAtMousePosition","start"),await this.asyncConstructors.ready();const s=await this.glue.displays.getMousePosition(),a=await this.gdwin.getBounds();a.top=(null!==(e=null==s?void 0:s.y)&&void 0!==e?e:0)-(null!==(t=a.height)&&void 0!==t?t:0)+10,a.left=(null!==(n=null==s?void 0:s.x)&&void 0!==n?n:0)-(null!==(r=a.width)&&void 0!==r?r:0)/2,a.right=a.left+(null!==(o=a.width)&&void 0!==o?o:0),a.bottom=a.top+(null!==(i=a.height)&&void 0!==i?i:0),await this.gdwin.show(),await this.gdwin.moveResize(a),await this.gdwin.focus(),this.logStatus("showAtMousePosition","return")}async setWindowTitle(e){this.logStatus("setWindowTitle","start",{title:e}),await this.asyncConstructors.ready(),await this.gdwin.setTitle(e),this.logStatus("setWindowTitle","return")}setTaskbarIconOverlay(e){this.logStatus("setTaskbarIconOverlay","start",{url:e}),console.log("setTaskbarIconOverlay() is not implemented"),this.logStatus("setTaskbarIconOverlay","return")}setShape(e,t){console.log("WindowClient.setShape() is no longer supported.")}async getComponentState(e,t){this.logStatus("getComponentState","start",e),await this.asyncConstructors.ready();const n=(null==e?void 0:e.windowName)?this.glue.windows.findById(e.windowName):this.gdwin,r=await Cg(e,n);return this.logStatus("getComponentState","return",{err:null,data:r}),null==t||t(r.err,r.data),r}async setComponentState(e,t){return await this.gate.wait(async()=>this.setComponentStateInternal(e,t))}async setComponentStateInternal(e,t){this.logStatus("setComponentState","start",e),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await Ig(e,n);return this.logStatus("setComponentState","return",r),null==t||t(r.err,r.data),r}async setAlwaysOnTop(e,t){this.logStatus("setAlwaysOnTop","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.setOnTop(e),t);return this.logStatus("setAlwaysOnTop","return",{err:n}),{err:n}}async retrieveMonitorDimensions(e){this.logStatus("retrieveMonitorDimensions","start"),await this.asyncConstructors.ready();const t=await this.gdwin.getDisplay(),n={left:t.bounds.left*t.scaleFactor,top:t.bounds.top*t.scaleFactor,width:t.bounds.width,height:t.bounds.height};n.right=n.left+n.width,n.bottom=n.top+n.height,this.logStatus("retrieveMonitorDimensions","return",n),e(n)}async restore(e){this.logStatus("restore","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.restore(),e);return this.logStatus("restore","return",{err:t}),{err:t}}async removeFromTabCollection({windowNames:e}){this.logStatus("removeFromTabCollection","start",{windowNames:e}),await this.asyncConstructors.ready(),await sg(e,async e=>{const t=this.glue.windows.findById(e);await(null==t?void 0:t.detachTab({}))}),this.logStatus("removeFromTabCollection","return")}async removeComponentState(e,t){this.logStatus("removeComponentState","start",e),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await kg(e,n);return this.logStatus("removeComponentState","return",r),null==t||t(r.err,r.data),r}async promoteTab(e){this.logStatus("promoteTab","start",{windowName:e}),await this.asyncConstructors.ready();const t=this.glue.windows.findById(e);await(null==t?void 0:t.activate()),this.logStatus("promoteTab","return")}async minimize(e){this.logStatus("minimize","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.minimize(),e);return this.logStatus("minimize","return",{err:t}),{err:t}}async maximize(e){this.logStatus("maximize","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.maximize(),e);return this.logStatus("maximize","return",{err:t}),{err:t}}getWindowIdentifier(){return this.logStatus("getWindowIdentifier","start"),this.logStatus("getWindowIdentifier","return",this.windowIdentifier),this.windowIdentifier}getWindowBounds(){const e="WindowClient.getWindowBounds() is no longer supported. Please use getBounds()";throw console.log(e),new Error(e)}async getWindowTitle(e){this.logStatus("getWindowTitle","start",e),await this.asyncConstructors.ready();const t=e?this.glue.windows.findById(e):this.gdwin,n=null==t?void 0:t.getTitle();return this.logStatus("getWindowTitle","return",n),null!=n?n:"Unknown Window"}async getTabCollectionForWindow({windowName:e},t){var n,r;this.logStatus("getTabCollectionForWindow","start",{windowName:e}),await this.asyncConstructors.ready();const o=this.glue.windows.findById(e);if(!o){const t=`No window found matching id ${e}`;return this.logStatus("getTabCollectionForWindow","error",t),{err:t}}const i={id:o.tabGroupId,windows:o.tabs.map(e=>e.id),promotedWindowName:null!==(r=null===(n=o.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id)&&void 0!==r?r:""};return this.logStatus("getTabCollectionForWindow","return",{err:null,data:i}),null==t||t(null,i),{data:i,err:null}}async getTabCollection({id:e},t){var n;this.logStatus("getTabCollection","start",{id:e}),await this.asyncConstructors.ready();const r=await this.findGlueWindowInTabGroup(e);if(!r){const t=`No window found in tabGroup id ${e}`;return this.logStatus("getTabCollection","error",{err:t}),{err:t}}const o={windows:r.tabs.map(e=>e.id),promotedWindowName:null===(n=r.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id};return null==t||t(null,o),{data:o,err:null}}getSpawnData(){this.logStatus("getSpawnData","start");const e=this.spawnData;return this.logStatus("getSpawnData","return",e),e}async getPromotedTab({tabCollectionId:e},t){var n;this.logStatus("getPromotedTab","start",{tabCollectionId:e}),await this.asyncConstructors.ready();const r=await this.findGlueWindowInTabGroup(e);if(!r){const t=`No window found in tabGroup id ${e}`;return this.logStatus("getPromotedTab","error",{err:t}),{err:t}}const o=null===(n=r.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id;if(o)return this.logStatus("getPromotedTab","return",{err:null,data:o}),null==t||t(null,o),{err:null,data:o};{const n=`No promoted tab found for tab collection ${e}`;return this.logStatus("getPromotedTab","error",{err:n}),null==t||t(n),{err:n}}}async getMonitorInfo(e,t){await this.asyncConstructors.ready();const n=await this.gdwin.getDisplay(),r=qg(n);return r?{err:null,data:r}:{err:"Monitor not found. Check application.log"}}startMovingWindow(){console.log("WindowClient.startMovingWindow() is no longer supported")}stopMovingWindow(){console.log("WindowClient.stopMovingWindow() is no longer supported")}async getBounds(e){this.logStatus("getBounds","start"),await this.asyncConstructors.ready();const t=await this.gdwin.getBounds();return this.logStatus("getBounds","return",{err:null,data:t}),null==e||e(null,t),{err:null,data:t}}async formGroup(){this.logStatus("formGroup","start"),await Sg(this.glue,this.gdwin.id),this.logStatus("formGroup","return")}async fitToDOM(e,t){var n,r,o,i,s,a,l,u;this.logStatus("fitToDOM","start",e),await this.asyncConstructors.ready(),"function"==typeof e&&(t=e,e=null);const c=null!==(r=null===(n=null==e?void 0:e.padding)||void 0===n?void 0:n.height)&&void 0!==r?r:0,d=null!==(i=null===(o=null==e?void 0:e.padding)||void 0===o?void 0:o.width)&&void 0!==i?i:0,h=this.gdwin,p=await h.getBounds();if(!p)return this.logStatus("fitToDOM","return"),void(null==t||t());const g=await h.getDisplay(),f=null!==(s=g.workArea.height)&&void 0!==s?s:1/0,m=null!==(a=g.workArea.width)&&void 0!==a?a:1/0,y=Math.max(p.height-window.innerHeight,0),w=window.innerWidth-document.getElementsByTagName("html")[0].clientWidth,v=window.innerHeight-document.getElementsByTagName("html")[0].clientHeight?1:0,b=document.documentElement.offsetHeight+c+y+v,C=h.isVisible?document.documentElement.scrollWidth:p.width+d+w,S=Math.min(b,null!==(l=null==e?void 0:e.maxHeight)&&void 0!==l?l:b,f),I=Math.min(C,null!==(u=null==e?void 0:e.maxWidth)&&void 0!==u?u:C,m);p.width===I&&p.height===S||await h.moveResize({left:p.left,top:p.top,width:I,height:S}),this.logStatus("fitToDOM","return"),null==t||t()}async createTabCollection({windowNames:e,promotedTab:t}){var n;this.logStatus("createTabCollection","start",{windowNames:e,promotedTab:t}),await this.asyncConstructors.ready();const r=this.glue.windows.findById(null!==(n=e.shift())&&void 0!==n?n:"");await sg(e,async e=>{const n={};e===t&&(n.selected=!0),await(null==r?void 0:r.attachTab(e,n))}),this.logStatus("createTabCollection","return")}async close(e,t){this.logStatus("close","start"),e&&this.loggerClient.system.deprecated("The use of parameters in WindowClient.close() has been deprecated."),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.close(),t);return this.logStatus("close","return",{err:n}),{err:n}}async bringToFront(e){this.logStatus("bringToFront","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.show()),{err:n}=await pg(()=>this.gdwin.focus()),r=null!=t?t:n;return r&&this.logStatus("bringToFront","error",r),this.logStatus("bringToFront","return"),{err:r}}async addToTabCollection({windowNames:e,tabCollectionId:t,position:n,promotedTab:r}){this.logStatus("addToTabCollection","start",{windowNames:e,tabCollectionId:t,position:n,promotedTab:r}),await this.asyncConstructors.ready();const o=await this.findGlueWindowInTabGroup(t);o?(await sg(e,async e=>{const t={};e===r&&(t.selected=!0),n&&(t.index=n,n++),await o.attachTab(e,t)}),this.logStatus("addToTabCollection","return")):this.logStatus("addToTabCollection","return")}async findGlueWindowInTabGroup(e){return await this.asyncConstructors.ready(),this.glue.windows.list().find(t=>(null==t?void 0:t.tabGroupId)===e)}addListeners(){console.log("WindowClient.addListeners() is no longer supported")}}function im(...e){let t="";return e.forEach(e=>{t=`${t} ${e}`}),t.replace(/\s(.)/g,e=>e.toUpperCase()).replace(/\s/g,"").replace(/^(.)/,e=>e.toLowerCase())}function sm(e,t){const n=/\(\d+\)$/,r=e.replace(n,"").trim(),o=[...t,e].filter(e=>im(e).includes(im(r))).map(e=>{const t=e.match(n);return null===t?0:Number(t[0].slice(1,-1))}),i=Math.max(...o)+1;return`${r} (${i})`}const am=async(e,t,n)=>{const{err:r,data:o}=await pg(()=>e.layouts.getAll("Global"));if(r||!o)return n.error(r),!1;const i=o.map(e=>e.name);return i.includes(t)?sm(t,i):t};class lm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.debouncedUpdateLocalMembers=null,this.withoutChanges=null,this.handlers=[],this.activeWorkspace={version:"1.0.0",name:"Default workspace",type:"workspace",groups:{},windows:[]},this.workspaces=[];const r=t.addConstructor();this.loggerClient.debug("WorkspaceClient Constructor"),e.then(async e=>{this.glue=e,this.initialize().finally(()=>{this.loggerClient.debug("WorkspaceClient initialized"),t.finishConstructor(r)})}),this.minimizeAll=this.minimizeAll.bind(this),this.bringWindowsToFront=this.bringWindowsToFront.bind(this),this.autoArrange=this.autoArrange.bind(this)}async triggerWorkspaceEvent(e,t){const{err:n,data:r}=await Jg(this.glue,e,t);return n&&this.loggerClient.error("triggerWorkspaceEvent",e,t,n),{err:n,data:r}}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"WorkspaceClient",method:e,type:t,data:n})}async initialize(){const e=this.registerGlueEventHandlers(),t=this.updateLocalMembers();await eg().allSettled([e,t])}async updateGlobalLayouts(){const{err:e,data:t=[]}=await pg(()=>{var e;return null!==(e=this.glue.layouts.getAll("Global"))&&void 0!==e?e:[]});e&&this.loggerClient.error("WorkspaceClient.updateLocalMembers.getAll()",e),this.workspaces=t.map(e=>e.name)}async updateCurrentLayout(){const{err:e,data:t}=await pg(()=>this.glue.layouts.getCurrentLayout());if(e){if(e.toString().includes("Invocation timeout (30000 ms)"))return;this.loggerClient.error("WorkspaceClient.updateLocalMembers.getCurrentLayout()",e)}t&&(this.activeWorkspace=jg(t))}async updateLocalMembers(){return this.debouncedUpdateLocalMembers||(this.debouncedUpdateLocalMembers=(0,Qp.debounce)(async()=>{this.loggerClient.debug("WorkspaceClient updateLocalMembers");const e=this.updateCurrentLayout(),t=this.updateGlobalLayouts();await eg().allSettled([e,t])},1500)),await this.debouncedUpdateLocalMembers()}async registerGlueEventHandlers(){const e=this.glue.layouts.onAdded(()=>{this.updateLocalMembers()}),t=this.glue.layouts.onChanged(()=>{this.updateLocalMembers()}),n=this.glue.layouts.onRemoved(()=>{this.updateLocalMembers()}),r=this.glue.layouts.onRenamed(()=>{this.updateLocalMembers()}),o=this.glue.layouts.onRestored(()=>{this.updateLocalMembers()});await eg().allSettled([e,t,n,r,o])}async removeEventListener(e,t){this.logStatus("removeEventListener","start",{event:e}),await this.asyncConstructors.ready();const n=this.handlers.findIndex(n=>n.event===e&&n.handler===t);if(-1===n)return;const{uuid:r}=this.handlers[n];this.handlers.splice(n,1);const{err:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.removeEventListener",{event:e,id:r}));o&&this.logStatus("removeEventListener","error",o),this.glue.interop.unregister(r),this.logStatus("removeEventListener","return")}async addEventListener(e,t){this.logStatus("addEventListener","start",e),await this.asyncConstructors.ready();const n=Zp()();await this.glue.interop.register(n,ig(async e=>{let n=!1;const r=new Kp;if(t({data:e,wait:()=>{n=!0},done:e=>{r.resolve({action:"done",newData:e})},cancel:()=>{r.resolve({action:"cancel"})}}),n)return await r.promise})),this.handlers.push({event:e,handler:t,uuid:n});const{err:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.addEventListener",{event:e,uuid:n}));r&&this.logStatus("addEventListener","error",r),this.logStatus("addEventListener","return")}async autoArrange(e,t){this.logStatus("autoArrange","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.glue.windows.autoArrange());return this.logStatus("autoArrange","return",{err:n}),null==t||t(n),{err:n}}async minimizeAll(e,t){this.logStatus("minimizeAll","start",e),await this.asyncConstructors.ready();const n=await dg(this.glue,e,t);return this.logStatus("minimizeAll","return",n),n}async bringWindowsToFront(e,t){this.logStatus("bringWindowsToFront","start",e),await this.asyncConstructors.ready();const n=await cg(this.glue,e,t);return this.logStatus("bringWindowsToFront","return",n),n}async getActiveWorkspacePreUserStage(e){var t,n,r,o,i,s;const{err:a,data:l}=await pg(()=>this.glue.prefs.get("IO.Global.FinsemblePreferences"));a&&this.logStatus("getActiveWorkspace","error",a);const{err:u,data:c}=await pg(()=>this.glue.prefs.get("IO.Global.FinsembleLastWorkspace"));u&&this.logStatus("getActiveWorkspace","error",u);const{err:d,data:h}=await pg(()=>this.glue.contexts.get(tg));d&&this.logStatus("getActiveWorkspace","error",d);const p=null!==(s=null!==(o=null!==(n=null===(t=null==l?void 0:l.data)||void 0===t?void 0:t["finsemble.initialWorkspace"])&&void 0!==n?n:null===(r=null==h?void 0:h.finsemble)||void 0===r?void 0:r.initialWorkspace)&&void 0!==o?o:null===(i=null==c?void 0:c.data)||void 0===i?void 0:i.name)&&void 0!==s?s:"Default Workspace",{err:g,data:f}=await pg(()=>this.glue.layouts.get(p,"Global"));if(g&&this.logStatus("getActiveWorkspace","error",g),!f)return null;const m=jg(f);return null==e||e(null,{data:m}),{data:m}}async getActiveWorkspace(e,t){var n,r,o;if(this.logStatus("getActiveWorkspace","start"),await this.asyncConstructors.ready(),null===this.withoutChanges){const e=await this.glue.contexts.get(tg);this.withoutChanges=null!==(r=null===(n=null==e?void 0:e.iocd)||void 0===n?void 0:n.getActiveWorkspaceWithoutChanges)&&void 0!==r&&r}try{const n=await this.glue.layouts.getCurrentLayout();if(!n){const t=await this.getActiveWorkspacePreUserStage(e);if(t)return t}if(n&&(null!=t?t:this.withoutChanges)){const t=jg(n);return this.logStatus("getActiveWorkspace","return",{data:t}),null==e||e(null,t),{data:t}}const r=await Gg(this.glue,this.logStatus.bind(this),n),i=r?jg(r):{version:"1.0.0",name:"",type:"workspace",groups:{},windows:[],componentStates:{}};i.name.includes("#internal-tmp")&&(i.name="");const s={...i,name:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:i.name};return this.logStatus("getActiveWorkspace","return",{data:s}),null==e||e(null,s),{data:s}}catch(t){const n=t.toString();throw this.logStatus("getActiveWorkspace","error",n),null==e||e(n),t}}async getWorkspaces(e){this.logStatus("getWorkspaces","start"),await this.asyncConstructors.ready();const t=await this.glue.layouts.getAll("Global"),n=await(async e=>e.sort((e,t)=>{var n,r;const o=null===(n=e.metadata)||void 0===n?void 0:n["iop#position"],i=null===(r=t.metadata)||void 0===r?void 0:r["iop#position"];return void 0===o&&void 0!==i?1:void 0!==o&&void 0===i?-1:void 0===o&&void 0===i?e.name<t.name?-1:e.name>t.name?1:0:o<i?-1:o>i?1:0}))(t),r=n.map(e=>jg(e));return this.logStatus("getWorkspaces","return",r),null==e||e(null,r),r}getWorkspaceActions(e){this.logStatus("getWorkspaceActions","start");const t={NEW_WORKSPACE:"Finsemble.Workspace.NewWorkspace",SAVE:"Finsemble.Workspace.Save",RENAME:"Finsemble.Workspace.Rename",SAVE_AS:"Finsemble.Workspace.SaveAs",SWITCH_TO:"Finsemble.Workspace.SwitchTo",IMPORT:"Finsemble.Workspace.Import",EXPORT:"Finsemble.Workspace.Export",REMOVE:"Finsemble.Workspace.Remove",SAVE_GLOBAL_DATA:"Finsemble.Workspace.SaveGlobalData",SAVE_VIEW_DATA:"Finsemble.Workspace.SaveViewData",GET_GLOBAL_DATA:"Finsemble.Workspace.GetGlobalData",GET_VIEW_DATA:"Finsemble.Workspace.GetViewData",GET_WORKSPACES:"Finsemble.Workspace.GetWorkspaces",GET_WORKSPACE_NAMES:"Finsemble.Workspace.GetWorkspaceNames",SET_WORKSPACE_ORDER:"Finsemble.Workspace.SetWorkspaceOrder",GET_ACTIVE_WORKSPACE:"Finsemble.Workspace.GetActiveWorkspace",GET_ACTIVE_WORKSPACE_DIRTY:"Finsemble.Workspace.GetActiveWorkspaceDirty",GET_TEMPLATES:"Finsemble.Workspace.GetTemplates",IMPORT_TEMPLATE:"Finsemble.Workspace.ImportTemplate",EXPORT_TEMPLATE:"Finsemble.Workspace.ExportTemplate",REMOVE_TEMPLATE:"Finsemble.Workspace.RemoveTemplate",SET_WINDOW_STATE:"Finsemble.Workspace.SetWindowData",GET_WINDOW_STATE:"Finsemble.Workspace.GetWindowData",ADD_WINDOW:"WorkspaceService.addWindow",REMOVE_WINDOW:"WorkspaceService.removeWindow"};return this.logStatus("getWorkspaceActions","return",t),null==e||e(null,t),t}async getWorkspaceNames(e){var t;this.logStatus("getWorkspaceNames","start"),await this.asyncConstructors.ready();const{err:n,data:r}=await pg(()=>this.glue.layouts.getAll("Global")),o=n?`WorkspaceClient.getWorkspaceNames() ${n}`:null;o&&this.loggerClient.error(o);const i=null!==(t=null==r?void 0:r.map(e=>e.name))&&void 0!==t?t:[];return this.logStatus("getWorkspaceNames","return",i),null==e||e(o,i),i}async setWorkspaceOrder(e,t){await this.asyncConstructors.ready();const{workspaces:n}=e,{err:r,data:o}=await pg(()=>this.glue.layouts.getAll("Global"));if(r||!o)return this.loggerClient.error("WorkspaceClient.setWorkspaceOrder()",r),void(null==t||t(r));const i=o.map(e=>{var t;const r=n.findIndex(t=>t.name.name===e.name);return e.metadata=Vp()(null!==(t=e.metadata)&&void 0!==t?t:{},{"iop#position":r}),e});await this.glue.layouts.import(i),null==t||t(null),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.order",{workspaces:n.map(e=>e.name.name)}))}setWorkspaces(e,t){return this.setWorkspaceOrder(e,t)}async remove(e,t){this.logStatus("remove","start",e),await this.asyncConstructors.ready();const{workspace:n,name:r}=e,o=null!=r?r:null==n?void 0:n.name,{err:i}=o?await pg(()=>this.glue.layouts.remove("Global",o)):{err:null};this.logStatus("remove","return"),null==t||t(i),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.remove",{workspaces:[o]}))}async rename(e,t){this.logStatus("rename","start",e),await this.asyncConstructors.ready();const{oldName:n,newName:r}=e,o=await am(this.glue,r,this.loggerClient);if(!o)return void this.logStatus("rename","warn",`Can't get unique name for ${r}`);const{err:i,data:s}=await pg(()=>this.glue.layouts.get(n,"Global"));if(i&&this.loggerClient.error("WorkspaceClient.rename.get()",i),s){const{err:e}=await pg(()=>this.glue.layouts.rename(s,o));e&&this.loggerClient.error("WorkspaceClient.rename.rename()",e)}this.logStatus("rename","return"),await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.rename",{oldName:n,newName:o})),null==t||t(i)}async saveAs(e,t){if(this.logStatus("saveAs","start",e),await this.asyncConstructors.ready(),!e.force){const{err:n,data:r}=await pg(()=>this.glue.layouts.getAll("Global")),o=`WorkspaceClient:saveAs ${n}`;if(n||!r)return this.loggerClient.error(o),void(null==t||t(o));if(r.some(t=>t.name===e.name)){const n=`Layout ${e.name} already exists. Set force: true to overwrite`;return void(null==t||t(n))}}const{data:n}=await this.triggerWorkspaceEvent("save-requested",e.name);if(null==n?void 0:n.some(e=>"cancel"===(null==e?void 0:e.action)))return void(null==t||t(null));const{data:r}=await pg(()=>this.glue.layouts.getCurrentLayout()),{err:o}=await pg(()=>this.glue.layouts.save({name:e.name,type:"Global",setAsCurrent:!0,metadata:null==r?void 0:r.metadata}));o?(await this.triggerWorkspaceEvent("save-failed",e.name),this.loggerClient.error("WorkspaceClient.saveAs.save",o)):await this.triggerWorkspaceEvent("save-complete",e.name),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[e.name]})),this.logStatus("saveAs","return",e),null==t||t(o)}async save(e){this.logStatus("save","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await pg(()=>this.glue.layouts.getCurrentLayout());if(t&&this.logStatus("save","error",`getCurrentLayout: ${t}`),!n){const n=`No current layout. Use saveAs ${t}`;return this.logStatus("save","error",n),null==e||e(n),{err:n}}const{data:r}=await this.triggerWorkspaceEvent("save-requested",n.name);if(null==r?void 0:r.some(e=>"cancel"===(null==e?void 0:e.action)))return null==e||e(null),{};const{err:o}=await pg(()=>this.glue.layouts.save({name:n.name,type:"Global",setAsCurrent:!1,metadata:null==n?void 0:n.metadata}));return o?(await this.triggerWorkspaceEvent("save-failed",n.name),this.logStatus("save","error",`save: ${o}`)):await this.triggerWorkspaceEvent("save-complete",n.name),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[n.name]})),this.logStatus("save","return",{err:o}),null==e||e(o),{err:o}}async switchTo(e,t){this.logStatus("switchTo","start",e),await this.asyncConstructors.ready();const{err:n}=await(async(e,t)=>{const{data:n}=await pg(()=>e.layouts.getCurrentLayout());(null==n?void 0:n.name)&&await Jg(e,"close-requested",n.name);const{data:r}=await Jg(e,"load-requested",t);if(null==r?void 0:r.some(e=>"cancel"===(null==e?void 0:e.action)))return{err:null};let o=null;if(null==r?void 0:r.length){const t=[];r.forEach(e=>{e.newData&&t.push(e.newData)});const{err:n}=await pg(()=>e.layouts.import(t,"merge"));n&&(o=n)}const{data:i=[]}=await pg(()=>e.channels.all());await ag(i,async t=>pg(()=>e.channels.clearChannelData(t)));const{err:s}=await pg(()=>e.layouts.restore({name:t}));if(s)(null==n?void 0:n.name)&&Jg(e,"close-failed",n.name),Jg(e,"load-failed",t);else{(null==n?void 0:n.name)&&Jg(e,"close-complete",n.name),Jg(e,"load-complete",t);const{data:r}=await pg(()=>e.layouts.getCurrentLayout());await pg(()=>e.layouts.save({name:t,type:"Global",metadata:null==r?void 0:r.metadata})),await pg(()=>e.prefs.setFor("IO.Global.FinsembleLastWorkspace",{name:t}))}return gg(()=>e.interop.invoke("FSBL.Clients.WorkspaceClient.switchTo",{})),{err:o}})(this.glue,e.name);return n&&this.logStatus("switchTo","error",{err:n,message:"Error importing layout from workspace event"}),this.logStatus("switchTo","return",{err:n,data:void 0}),null==t||t(n),{data:void 0}}async isWorkspaceDirty(e){this.logStatus("isWorkspaceDirty","start"),await this.asyncConstructors.ready();const t=await Hg(this.glue,this.logStatus.bind(this));return null==e||e(null,t),t}async createWorkspace(e,t,n){this.logStatus("createWorkspace","start",{workspaceName:e,params:t}),await this.asyncConstructors.ready();const r=await am(this.glue,e,this.loggerClient);if(!r){const e={workspaceName:"An error occurred creating workspace"};return this.logStatus("createWorkspace","error",e),null==n||n("Cannot create unique name",e),e}const o={type:"Global",name:r,components:[]},{err:i,data:s}=await pg(()=>this.glue.layouts.import([o],"merge"));if(i||!s){const e=`WorkspaceClient.createWorkspace.import ${i}`,t={workspaceName:e};return this.logStatus("createWorkspace","error",e),null==n||n(e,t),t}const a="Success"!==s.status?s.status:null,l={workspaceName:r};return!1!==(null==t?void 0:t.switchAfterCreation)&&await this.switchTo({name:r}),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[r]})),this.logStatus("createWorkspace","return",{error:a,result:l}),null==n||n(a,l),l}async import(e,t){this.logStatus("import","start",e),await this.asyncConstructors.ready();const{workspaceJSONDefinition:n,force:r}=e,{err:o,data:i}=await pg(()=>this.glue.layouts.getAll("Global"));if(o||!i){const e=`WorkspaceClient.import:getAll() ${o}`;return console.error(e),this.logStatus("import","error",e),null==t||t(e,{}),{}}const s=(a=n,l=(e,t)=>{if(r)return[[e,t]];const n=i.map(e=>e.name);return[[n.includes(e)?sm(e,n):e,t]]},Object.fromEntries(Object.entries(a).flatMap(([e,t])=>l(e,t))));var a,l;const u=Object.entries(s).map(([e,t],n)=>Mg(e,t,n)),{err:c,data:d}=await pg(()=>this.glue.layouts.import(u,"merge"));if(c||!d){const e=`WorkspaceClient.import:getAll() ${c}`;return this.logStatus("import","error",e),null==t||t(e,{}),{}}const h=Object.fromEntries(Object.keys(s).map(e=>[e,Rg(e,d)]));return gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:u.map(e=>e.name)})),this.logStatus("import","return",h),null==t||t(null,h),h}async importWorkspace(e,t){return await this.asyncConstructors.ready(),this.import(e,t)}async export(e,t){this.logStatus("export","start",e),await this.asyncConstructors.ready();const{workspaceName:n}=e,{err:r,data:o}=await pg(()=>this.glue.layouts.get(n,"Global"));if(r&&this.logStatus("export","error",r),r||!o){const e=`Layout ${n} not found`;throw this.logStatus("export","error",e),null==t||t(e),new Error(e)}const i={[n]:jg(o)};return this.logStatus("export","return",i),null==t||t(null,i),i}async exportWorkspace(e,t){return this.export(e,t)}}class um{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"SystemManagerClient",method:e,type:t,data:n})}publishCheckpointState(){}async waitForBootStage(e,t,n){this.logStatus("waitForBootStage","start",{stage:e,when:t}),await this.asyncConstructors.ready();const r=`Finsemble:waitForBootStage:${Zp()()}`;await this.glue.interop.register(r,ig(async()=>{this.loggerClient.log(`waitForBootStage ${e}: received signal`),n()}));const{err:o}=await gg(()=>this.glue.interop.invoke("FSBL.SystemManagerClient.waitForBootStage",{channel:r,stage:e,when:t}));o&&this.logStatus("waitForBootStage","error",o.toString()),this.logStatus("waitForBootStage","return")}}class cm{constructor(e){this.gluePromise=e,this.frequencyMap={},this.gluePromise.then(e=>this.glue=e)}toast(e,t,n,r,o){var i,s,a,l;const u="ONCE-SINCE-STARTUP"===t?1:0,c=null!==(s=null!==(i=null==o?void 0:o.maxCount)&&void 0!==i?i:u)&&void 0!==s?s:0;c&&this.frequencyMap[n]>=c||(c&&(this.frequencyMap[n]=c),this.glue.notifications.raise({title:null!==(a=null!=e?e:n)&&void 0!==a?a:"",body:r,panelExpiry:(null!==(l=null==o?void 0:o.duration)&&void 0!==l?l:15e3)/1e3}))}alert(e,t,n,r,o){return this.toast(e,t,n,r,o)}}class dm{constructor(e,t,n){this.gluePromise=e,this.loggerClient=n,this.groupEventListener=null;const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,this.setupForeverListeners(),t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AuthenticationClient",method:e,type:t,data:n})}async checkIfBridgeIsRunning(){return this.glue.interop.methods().some(({name:e})=>"T42.BBG.IsLoggedIn"===e)}async setupForeverListeners(){try{(await this.glue.interop.subscribe("T42.BBG.GroupsChanged")).onData(e=>{this.groupEventListener&&this.groupEventListener(null,{data:{group:e.data}})})}catch(e){}}setEnabled(e,t){console.info("method 'setEnabled' has not been implemented.")}async checkConnection(e){if(this.logStatus("checkConnection","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.IsLoggedIn")),r=null==n?void 0:n.Result;this.logStatus("checkConnection","return",{isConnected:r}),e(t,r)}else e("Unable to connect",!1),this.logStatus("checkConnection","return",{isConnected:!1})}setConnectionEventListener(e){this.logStatus("setConnectionEventListener","deprecated","Not implemented"),console.info("method 'setConnectionEventListener' has not been implemented.")}removeConnectionEventListener(){this.logStatus("removeConnectionEventListener","deprecated","Not implemented"),console.info("method 'removeConnectionEventListener' has not been implemented.")}async runGetAllGroups(e){if(this.logStatus("runGetAllGroups","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetGroupsInfo"));this.logStatus("runGetAllGroups","return",null==n?void 0:n.groups),e(t,{status:!0,groups:null==n?void 0:n.groups})}else e("Unable to connect",null)}async runGetGroupContext(e,t){if(this.logStatus("runGetGroupContext","start"),await this.checkIfBridgeIsRunning()){const n={group:e},{err:r,data:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetGroupContext",n));this.logStatus("runGetGroupContext","return",null==o?void 0:o.result),t(r,{status:!0,group:null==o?void 0:o.result})}else t("Unable to connect",null)}async runSetGroupContext(e,t,n,r){if(this.logStatus("runSetGroupContext","start",{groupName:e,value:t,cookie:n}),await this.checkIfBridgeIsRunning()){const{err:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.SetGroupContext",{group:e,context:t,cookie:n}));this.logStatus("runSetGroupContext","return",{status:!0}),r(o,{status:!0})}else r("Unable to connect",null)}async setGroupEventListener(e){this.logStatus("setGroupEventListener","start"),this.groupEventListener=e,this.logStatus("setGroupEventListener","return")}removeGroupEventListener(){this.logStatus("removeGroupEventListener","start"),this.groupEventListener=null,this.logStatus("removeGroupEventListener","return")}async runGetAllWorksheets(e){if(this.logStatus("runGetAllWorksheets","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetWorksheets")),r=null==n?void 0:n.worksheets;this.logStatus("runGetAllWorksheets","return",r),e(t,{status:!0,worksheets:r})}else e("Unable to connect",null)}async runGetWorksheet(e,t){if(this.logStatus("runGetWorksheet","start"),await this.checkIfBridgeIsRunning()){const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetWorksheetSecurities",{worksheetId:e}));this.logStatus("runGetWorksheet","return",r),t(n,{status:!0,worksheet:r})}else t("Unable to connect",null)}async runCreateWorksheet(e,t,n){if(this.logStatus("runCreateWorksheet","start",{worksheetName:e,securities:t}),await this.checkIfBridgeIsRunning()){const r={name:e,securities:t},{err:o,data:i}=await gg(()=>this.glue.interop.invoke("T42.BBG.CreateWorksheet",r)),s=null==i?void 0:i.worksheet;this.logStatus("runCreateWorksheet","return",s),n(o,{status:!0,worksheet:s})}else n("Unable to connect",null)}async runReplaceWorksheet(e,t,n){if(this.logStatus("runReplaceWorksheet","start",{worksheetId:e,securities:t}),await this.checkIfBridgeIsRunning()){const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.SetWorksheetSecurities",{securities:t,worksheetId:e}));this.logStatus("runReplaceWorksheet","return",null==o?void 0:o.worksheet),n(r,{status:!0,worksheet:null==o?void 0:o.worksheet})}else n("Unable to connect",null)}async runBBGCommand(e,t,n,r,o){if(this.logStatus("runBBGCommand","start",{mnemonic:e,securities:t,panel:n,tails:r}),await this.checkIfBridgeIsRunning()){const{err:i}=await gg(()=>this.glue.interop.invoke("T42.BBG.RunFunction",{mnemonic:e,panel:n,securities:t,tails:r}));this.logStatus("runBBGCommand","return"),o(i,{status:!0})}else o("Unable to connect",null)}async runSecurityLookup(e,t){this.logStatus("runSecurityLookup","deprecated","Not Implemented"),await this.checkIfBridgeIsRunning()?console.info("method 'runSecurityLookup' has not been implemented."):t("Unable to connect",null)}}let hm="undefined"==typeof window?n.g:window,pm="undefined"==typeof window?n.g:window;"undefined"==typeof window?n.g:window;const gm={signatureString:"",signatureStringType:"unauthenticated",meta:{name:"Anonymous app",appId:"Anonymous appId"}},fm=e=>{const t=Symbol.for(`com.finsemble.singleton.${e}`);return Object.getOwnPropertySymbols(n.g).indexOf(t)>-1?n.g[t]:null},mm=(e,t,...r)=>{const o=fm(e);if(!o){const o=Symbol.for(`com.finsemble.singleton.${e}`);return n.g[o]=new t(...r),n.g[o]}return o},ym=`Unknown window-${Zp()()}`;class wm{constructor(){this.isReady=!1,this.onReadyListeners=[],this.currentStartupData={authenticationToken:gm,windowName:ym,webContentsName:ym}}static getInstance(){return wm.instance?wm.instance:wm.instance=mm("Startup",wm)}getStartupData(){return this.currentStartupData}setStartupData(e){this.currentStartupData=e}onReady(e){return new Promise(t=>{this.isReady?(e&&setTimeout(e,0),t()):this.onReadyListeners.push(()=>{e&&e(),t()})})}setReady(){this.isReady=!0,this.onReadyListeners.forEach(e=>{e()});try{hm.dispatchEvent&&hm.Event&&hm.dispatchEvent(new hm.Event("FSBLReady"))}catch(e){console.log(e.toString())}}}wm.instance=null;class vm{static createNew(e,t){fin.desktop.Window.createNew(e,t)}static getCurrent(){return fin.desktop.Window.getCurrent()}static wrap(e){if(!this.wrapCache[e]){const t=fin.desktop.Window.wrap(e);t.addEventListener("closed",()=>{delete this.wrapCache[e]}),this.wrapCache[e]=t}return this.wrapCache[e]}}vm.wrapCache={};class bm{static createNew(e,t){t("Cannot create freestanding windows")}static getCurrent(){const{windowName:e}=wm.getInstance().getStartupData();return{name:e,uuid:`${e}-uuid`,getOptions:e=>{null==e||e({})},addEventListener:()=>{},removeEventListener:()=>{},updateOptions:()=>{},close:()=>{},startMovingWindow:()=>{},stopMovingWindow:()=>{},isShowing:()=>{},bringToFront:()=>{},show:()=>{},hide:()=>{},setTaskbarIcon:()=>{}}}static wrap(){return this.getCurrent()}}class Cm{constructor(){return new fin.desktop.System.Clipboard}static writeText(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeText is deprecated"),fin.desktop.System.Clipboard.writeText(e,t,n,r)}static writeHTML(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeHTML is deprecated"),fin.desktop.System.Clipboard.writeHTML(e,t,n,r)}static writeRTF(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeRTF is deprecated"),fin.desktop.System.Clipboard.writeRTF(e,t,n,r)}static readText(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readText is deprecated"),fin.desktop.System.Clipboard.readText(e,t,n)}static readHTML(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readHTML is deprecated"),fin.desktop.System.Clipboard.readHTML(e,t,n)}static readRTF(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readRTF is deprecated"),fin.desktop.System.Clipboard.readRTF(e,t,n)}}class Sm{static get Application(){return{getCurrent:()=>(ry.deprecated("FSBL.System.Application is deprecated"),{restart:()=>{dy.transmit("Application.restart",{})},getWindow:()=>fin.desktop.Window,addEventListener:(e,t,n,r)=>{fin.desktop.Window.addEventListener(e,t,n,r)},close:(e,t,n)=>{fin.desktop.Window.close(e,t,n)},getChildWindows:(e,t)=>{null==e||e([fin.desktop.Window])},getGroups:(e,t)=>{null==e||e([])},getManifest:(e,t)=>{Sm.getManifest(e)},getParentUuid:(e,t)=>{null==e||e("Finsemble")},getInfo:(e,t)=>{Sm.getVersion(e)},getTrayIconInfo:(e,t)=>{null==e||e({})},isRunning:(e,t)=>{null==e||e(!0)},registerUser:(e,t,n,r)=>{null==n||n()},removeEventListener:(e,t,n,r)=>{fin.desktop.Window.removeEventListener(e,t,n,r)},removeTrayIcon:(e,t)=>{fin.desktop.Window.removeTrayIcon(e,t)},run:(e,t)=>{},scheduleRestart:(e,t)=>{null==e||e()},setTrayIcon:(e,t,n,r)=>{fin.desktop.Window.setTrayIcon(e,t,n,r)},terminate:(e,t)=>{Sm.terminate()},wait:(e,t)=>{null==e||e()},window:{name:fin.desktop.Window.name},uuid:"Finsemble"})}}static isFreestanding(){return"undefined"==typeof fin}static get Window(){return Sm.isFreestanding()?bm:vm}static get Notification(){return{send:e=>{fin.desktop.Notification.send(e)}}}static get Clipboard(){return Cm}static getManifest(e){return new Promise(t=>{fin.desktop.System.getManifest(n=>{null==e||e(n),t(n)})})}static async getMousePosition(e){return new Promise((t,n)=>{fin.desktop.System.getMousePosition(n=>{(n.left||0===n.left)&&(n.x=n.left),(n.top||0===n.top)&&(n.y=n.top),null==e||e(null,n),t(n)},t=>{null==e||e(t),n(t)})})}static async deleteAssets(e){return await fin.desktop.System.deleteAssets(e)}static getSDServerInfo(e=Function.prototype){return new Promise(t=>{fin.desktop.System.getSDServerInfo(n=>{t(n),e(n)})})}static getMonitorInfo(e){return new Promise(t=>{fin.desktop.System.getMonitorInfo(n=>{t(n),e&&e(n)})})}static isBrowserView(){return!Sm.isFreestanding()&&fin.isBrowserView()}static getViewId(){return ry.deprecated("FSBL.system.getViewId() is deprecated. Use FSBL.system.getWebContentsId()"),fin.getWebContentsId()}static getWebContentsId(){return fin.getWebContentsId()}static hasBrowserView(){return ry.deprecated("FSBL.system.hasBrowserView() is deprecated. Use FSBL.system.isTitlebarWindow()"),Sm.isTitlebarWindow()}static isTitlebarWindow(){return!Sm.isFreestanding()&&fin.isTitlebarWindow()}static get fin(){return fin||{}}static ready(e){return new Promise(t=>{fin.desktop.main(()=>{e&&e(),t()})})}static setTrayIcon(e,t){fin.desktop.System.setTrayIcon(e,t)}static getHostSpecs(e=Function.prototype){return new Promise(t=>{fin.desktop.System.getHostSpecs(n=>{t(n),e(n)})})}static get InterApplicationBus(){return fin.desktop.InterApplicationBus}static get launchExternalProcess(){return fin.desktop.System.launchExternalProcess}static get terminateExternalProcess(){return fin.desktop.System.terminateExternalProcess}static get exit(){return fin.desktop.System.exit}static async clearCache(e){return fin.desktop.System.clearCache(e)}static get showDeveloperTools(){return fin.desktop.System.showDeveloperTools}static get addEventListener(){return Sm.isFreestanding()?window.addEventListener:fin.desktop.System.addEventListener}static get removeEventListener(){return Sm.isFreestanding()?window.removeEventListener:fin.desktop.System.removeEventListener}static get addSelectClientCertificateListener(){return fin.desktop.System.addSelectClientCertificateListener}static get addCertificateErrorListener(){return fin.desktop.System.addCertificateErrorListener}static getFEAInfo(e){return new Promise(t=>{fin.desktop.System.getFEAInfo(n=>{null==e||e(n),t(n)})})}static get getVersion(){return fin.desktop.System.getVersion}static get getUpdateAvailable(){return fin.desktop.System.getUpdateAvailable}static get openUrlWithBrowser(){return fin.desktop.System.openUrlWithBrowser}static get getProcessList(){return fin.desktop.System.getProcessList}static get getProtocolString(){return fin.desktop.System.getProtocolString}static get hideSplashScreen(){return fin.desktop.System.hideSplashScreen}static notifyLoggerReady(){fin.desktop.System.notifyLoggerReady()}static updateCentralLoggerState(e){fin.desktop.System.updateCentralLoggerState(e)}static startupApplicationHandshake(){fin.desktop.System.startupApplicationHandshake&&fin.desktop.System.startupApplicationHandshake()}static terminate(){fin.desktop.System.terminate()}static restart(){fin.desktop.System.restart()}static getEnvironmentVariable(e,t){return new Promise(n=>{fin.desktop.System.getEnvironmentVariable(e,e=>{null==t||t(e),n(e)})})}}var Im;const km={navigationStart:Date.now()},Tm={now:()=>{var e;return hm.performance?null===(e=hm.performance)||void 0===e?void 0:e.now():Date.now()},timing:(null===(Im=hm.performance)||void 0===Im?void 0:Im.timing)?hm.performance.timing:km},xm=["microkernel","kernel","pre-authentication","authentication","appd-retrieval","system-preuser","preuser","preuser2","preuser3","preuser4","system-earlyuser","earlyuser","user"];function Am(e){return`systemManager.boot.status.${e}`}function Em(e,t){return`systemManager.checkpoint.${e}.${t}`}const Wm=new class{constructor(){this.startedElements={}}publishBootStatus(e,t,n,r){ry.system.debug("publishBootStatus",e,t,n),dy.publish(Am(e),{name:e,type:t,state:n,error:r})}waitForBootStage(e,t,n=Function.prototype){return new Promise((r,o)=>{ry.system.debug("SystemManagerClient.waitForBootStage entry",e,t);const i=xm.indexOf(e);"microkernel"===e&&"stageEntered"===t&&ry.system.error("Cannot wait on `stageEntered` for microkernel because router isn't up yet. So will instead wait for microkernel stage complete.");const s=dy.subscribe("systemManager.boot.stage",(a,l)=>{if(ry.system.debug("SystemManagerClient.waitForBootStage new stage",l.data.stage,s),a)ry.system.error("SystemManagerClient.waitForBootStage subscribe error",a),n(a),o(a);else if(-1===i)a="illegal stage argument",ry.system.debug("SystemManagerClient.waitForBootStage subscribe error",a,e),n(a),o(a);else{const o=xm.indexOf(l.data.stage);ry.system.debug("SystemManagerClient.waitForBootStage new stage",l.data,s),"stageEntered"===t&&o+1>=i?(ry.system.debug("SystemManagerClient.waitForBootStage stageEntered",e,s,n.name),n(),r(),dy.unsubscribe(s)):"stageCompleted"===t&&o>=i?(ry.system.debug("SystemManagerClient.waitForBootStage completed",e,s),n(),r(),dy.unsubscribe(s)):ry.system.debug(`SystemManagerClient.waitForBootStage else currentStageIndex=${o} stageIndex=${i} `,o,i,e,s)}})})}waitForStartup(e,t=Function.prototype){return new Promise((n,r)=>{if(this.startedElements[e])return void n();ry.system.debug(`SystemManagerClient.waitForStartup.${e}`,e);const o=dy.subscribe(Am(e),(i,s)=>{ry.system.debug("SystemManagerClient.waitForStartup subscribe",e,i,s),i?(ry.system.error("SystemManagerClient.waitForStartup subscribe error",i),t(i),this.startedElements[e]=!1,r(i)):s.data.name===e&&"completed"===s.data.state&&(ry.system.debug("SystemManagerClient.waitForStartup completed",e),this.startedElements[e]=!0,t(),n(),dy.unsubscribe(o))})})}publishCheckpointState(e,t,n){ry.system.debug("publishCheckpoint",e,t,n,Em(e,t)),dy.publish(Em(e,t),{windowName:e,checkpointName:t,state:n})}showSystemLog(){ry.system.debug("SystemManagerClient.showSystemLog"),dy.transmit("systemManager.showSystemlog",!0)}hideSystemLog(){ry.system.debug("SystemManagerClient.hideSystemLog"),dy.transmit("systemManager.hideSystemlog",!0)}systemLog(e,t){ry.system.debug("SystemManagerClient.systemLog",e,t),dy.transmit("systemManager.systemlog",{params:e,logMessage:t})}},Om=Wm,Dm=e=>{if(0===e.length)return"";let t=e[0].replace(".","$DOT$");if(1===e.length)return t;for(let n=1;n<e.length;n++)t=`${t}.${e[n].replace(".","$DOT$")}`;return t};class _m{constructor(){this.listeners={},this.subs={}}}let Pm=!1;const Rm=async()=>{Pm||(await Om.waitForStartup("configService"),Pm=!0)},Lm=()=>mm("ConfigClient",_m),Fm="Invalid path - MUST be a path array. e.g. for myObject.property use ['myObj', 'property']",Mm=(e,t)=>{var n;(null!==(n=Lm().listeners[e])&&void 0!==n?n:[]).forEach(n=>{oy.system.debug("ConfigClient.triggerListeners",e,t),n(null,{field:e,value:t})})},$m=(e,t)=>{if(e)oy.system.error("ConfigClient handleChanges() error",e);else{t.data.field||(t.data.field=null);const{field:e,storeData:n,value:r}=t.data;Mm(e||"configService",n||r)}},Nm=async e=>{const t=Lm();if(t.subs||(t.subs={}),!t.subs[e]){t.subs[e]=!0,Rm();const{err:n}=await dy.query("configService.addListener",e);n&&oy.system.error("Error adding listener to config service",n),await dy.subscribe(e,$m)}},jm=async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.getValue is deprecated. Use FSBL.Clients.ConfigClient.get() instead."),"string"==typeof e&&(e={field:e}),!e.field){const e="no field provided";return null==t||t(e),{err:e}}Rm();const{err:n,response:r}=await dy.query("configService.getValue",{field:e.field});return null==t||t(n,r.data),{err:n,data:r.data}},Bm=async(e,t,n)=>{var r;const o=Lm();let i=null;"function"==typeof e&&(t=e,e={field:null}),Array.isArray(e)?i=Dm(e):({field:i}=e);const s="configService"+(i?`.${i}`:"");o.listeners[s]=[t].concat(null!==(r=o.listeners[s])&&void 0!==r?r:[]),Nm(s),null==n||n()},qm=(e,t,n)=>{const r=Lm();let o=null;"function"==typeof e&&(n=t,t=e,e={field:o}),Array.isArray(e)?o=Dm(e):({field:o}=e);const i="configService"+(o?`.${o}`:"");if(r.listeners[i])for(let e=0;e<r.listeners[i].length;e++)if(r.listeners[i][e]===t)return r.listeners[i].splice(e,1),void(null==n||n(null,!0));null==n||n(null,!1)},Um={initialize(){oy.deprecated("There is no need to call ConfigClient.initialize() anymore.")},onReady:e=>{oy.system.deprecated("It is no longer necessary to call ConfigClient.onReady()"),null==e||e()},triggerListeners(e,t){oy.deprecated("Calling ConfigClient.triggerListeners() directly is not legal."),Mm(e,t)},handleChanges(e,t){oy.deprecated("It is illegal to call ConfigClient.handleChanges() directly."),$m(e,t)},async changeSub(e){oy.deprecated("Calling ConfigClient.changeSub() directly is not legal."),Nm(e)},addListener:Bm,addListeners:(e,t,n)=>{var r;const o=Lm();if(!Array.isArray(e))return oy.deprecated("configClient - addListeners() with an object instead of an array is deprecated. Please use addListener() instead."),Bm(e,t,n);const i="function"==typeof t?t:null;for(let t=0;t<e.length;t++){const n=e[t];let s="";"string"==typeof n?s=n:"object"==typeof n&&Array.isArray(n.field)?s=Dm(n.field):"object"==typeof n&&"string"==typeof n.field&&(s=n.field);const a="string"!=typeof n?n.listener:i;if(a){const e="configService"+(s?`.${s}`:"");o.listeners[e]=[a].concat(null!==(r=o.listeners[e])&&void 0!==r?r:[]),Nm(e)}}null==n||n()},getManifest:async e=>{Rm();const{err:t,response:n}=await dy.query("configService.getValues",{fields:null});return null==e||e(t,n.data),{err:t,data:n.data}},getPreferences:async e=>{await Om.waitForBootStage("authentication","stageCompleted");const{err:t,response:n}=await dy.query("PreferencesService.getPreferences",{});return oy.system.debug("PreferencesService.getPreferences response",n),null==e||e(t,n.data),{err:t,data:n.data}},getValue:jm,getValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.getValues is deprecated. Use FSBL.Clients.ConfigClient.getMultiple() instead."),"function"==typeof e&&(t=e,e=null),e&&!Array.isArray(e))return jm(e,t);Rm();const{err:n,response:r}=await dy.query("configService.getValues",{fields:e});return null==t||t(n,r.data),{err:n,data:r.data}},processAndSet:async(e,t)=>{if(oy.system.debug("ConfigClient.processAndSet",e),!e.overwrite&&e.replace){const e="cannot use replace option unless overwrite is also true";return oy.system.warn("ConfigClient.processAndSet:",e),null==t||t(e),{err:e}}{Rm();const{err:n,response:r}=await dy.query("configService.processAndSet",e);return null==t||t(n,r),{err:n,data:r.data}}},removeListener:qm,removeListeners:(e,t,n)=>{const r=Lm();if(!Array.isArray(e))return"function"==typeof e?qm({},e,n):e.field&&t&&qm(e,t,n),null==n?void 0:n(null,!0);const o="function"==typeof t?t:null;e.forEach(e=>{let t="";"string"==typeof e?t=e:"object"==typeof e&&Array.isArray(e.field)?t=Dm(e.field):"object"==typeof e&&"string"==typeof e.field&&(t=e.field);const n="string"!=typeof e?e.listener:o,i="configService"+(t?`.${t}`:"");r.listeners[i]=r.listeners[i].filter(e=>e!==n)}),null==n||n(null,!0)},removeValue:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.removeValue is deprecated. Use FSBL.Clients.ConfigClient.remove() instead."),"string"==typeof e&&(e={field:e}),!(null==e?void 0:e.field)){const e="No field provided";return null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.removeValue",e);return null==t||t(n),{err:n}},removeValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.removeValues is deprecated. Use FSBL.Clients.ConfigClient.removeMultiple() instead."),!e){const e="ConfigClient.removeValues. No params given";return oy.system.error(e),null==t||t(e),{err:e}}if(!Array.isArray(e)){const e="ConfigClient.removeValues. Params must be an array";return oy.system.error(e),null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.removeValues",e);return null==t||t(n),{err:n}},setPreference:async(e,t)=>{const{err:n,response:r}=await dy.query("PreferencesService.setPreference",e);return null==t||t(n,r.data),{err:n,data:r.data}},setValue:async(e,t)=>{oy.system.deprecated("FSBL.Clients.ConfigClient.setValue is deprecated. Use FSBL.Clients.ConfigClient.set() instead.");const n={field:e.field,value:e.value};Rm();const{err:r}=await dy.query("configService.setValue",n);return null==t||t(r),{err:r}},setValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.setValues is deprecated. Use FSBL.Clients.ConfigClient.setValues() instead."),!e){const e="ConfigClient.SetValues. No params given";return oy.system.error(e),null==t||t(e),{err:e}}if(!Array.isArray(e)){const e="ConfigClient.SetValues. Params must be an array";return oy.system.error(e),null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.setValues",e);return null==t||t(n),{err:n}},unsetPreference:async(e,t)=>{oy.system.debug("ConfigClient.unsetPreference",e);const{err:n,response:r}=await dy.query("PreferencesService.unsetPreference",e);return null==t||t(n,r.data),{err:n,data:r.data}},get:async(e,t)=>{if(null!==e&&!Array.isArray(e))return null==t||t(Fm),{err:Fm};Rm();const{err:n,response:r}=await dy.query("configService.getValue",e);return null==t||t(n,r.data),{err:n,data:r.data}},getMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.getValues",{fields:e.length?e:null});return null==t||t(n,r.data),{err:n,data:r.data}},set:async(e,t,n)=>{if(!Array.isArray(e))return null==n||n(Fm),{err:Fm};Rm();const r={field:e,value:t},{err:o,response:i}=await dy.query("configService.setValue",r);return null==n||n(o,i.data),{err:o,data:i.data}},setMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.setValues",e);return null==t||t(n,r.data),{err:n,data:r.data}},remove:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};Rm();const{err:n,response:r}=await dy.query("configService.removeValue",e);return null==t||t(n,r.data),{err:n,data:r.data}},removeMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.removeValues",e);return null==t||t(n,r.data),{err:n,data:r.data}}},zm=Um;var Gm=n(7350),Hm=n.n(Gm);const Vm={Error:!0,Warn:!0,Info:!0,Log:!0,Debug:!0,Verbose:!1,LocalOnly:!1};let Qm=5e3;const Jm=`NOTE: LOG ARG STRIPPED since greater than ${Qm/1e3}KB. Check origin's local Console to see output of the complete object.`,Km={console:{Error:!0,Warn:!0,Info:!0,Log:!0,Debug:!0,Verbose:!0,LocalOnly:!1},dev:Vm,system:Vm,perf:Vm},Ym=()=>{const{stack:e}=function(){try{throw Error("")}catch(e){return e}}();let t=6;e.includes("console.error")&&t++;const n=function(e,t,n){return e.split("\n",n).join("\n").length}(e,0,t);return`Log Stack: \n${e.substring(n).substr(1)}`},Zm=e=>{const t=Qm+1,n=[],r=[e];let o=0,i=0;for(;r.length&&i<=t;){i++;const e=r.pop();if("boolean"==typeof e)o+=4;else if("string"==typeof e)o+=2*e.length;else if("number"==typeof e)o+=8;else if("object"==typeof e&&-1===n.indexOf(e)){n.push(e);for(const t in e)r.push(e[t])}}return o},Xm=(e,t,n=0,r=1)=>{const o=Qm/1.5,i=t/2,s=i/2,a="*STRIPPED*",l=e=>{let t=Zm(e);e.length>0&&t>s&&(e[0]=Xm(e[0],i,n,r+1),e[1]=`${a} from size ${e.length}`,e.length=2)};let u=(0,Qp.cloneDeep)(e);if("object"!=typeof u)u=a,n+=Zm(u);else if(Array.isArray(u))l(u),n+=Zm(u);else{let e=Object.getOwnPropertyNames(u);for(let c=0;c<e.length;c++){let d=Zm(u[e[c]]);n>i&&d>100&&r>=3&&c>=1||n>o&&d>=10?u[e[c]]=a:d>s&&(Array.isArray(u[e[c]])?l(u[e[c]]):u[e[c]]=Xm(u[e[c]],t/1.2,n,r+1)),n+=Zm(u[e[c]])}}return u};class ey{constructor(){this.routerClient=null,this.viewId=null,this.isRegistering=!1,this.isRegistered=!1,this.calibratedTimeStampOffset=0,this.newCalibratedTimeStampOffset=0,this.filteredMessagesCounter=0,this.startupTime=0,this.loggerQueue=[],this.loggerClientName=Sm.Window.getCurrent().name,this.onLogStateChangeCallback=[],this.currentLogState=Km,this.skipLargeObjects=!0,this.setRouterClient=e=>{this.routerClient=e},this.system={error:(...e)=>{this.logIt("system","Error",e)},warn:(...e)=>{this.logIt("system","Warn",e)},info:(...e)=>{this.logIt("system","Info",e)},log:(...e)=>{this.logIt("system","Log",e)},debug:(...e)=>{this.logIt("system","Debug",e)},verbose:(...e)=>{this.logIt("system","Verbose",e)},deprecated:(...e)=>{this.logIt("system","Error",e)}},this.perf={error:(...e)=>{this.logIt("perf","Error",e)},warn:(...e)=>{this.logIt("perf","Warn",e)},info:(...e)=>{this.logIt("perf","Info",e)},log:(...e)=>{this.logIt("perf","Log",e)},debug:(...e)=>{this.logIt("perf","Debug",e)},verbose:(...e)=>{this.logIt("perf","Verbose",e)},deprecated:(...e)=>{this.logIt("perf","Error",e)}},this.console={error:(...e)=>{this.logIt("console","Error",e)},warn:(...e)=>{this.logIt("console","Warn",e)},info:(...e)=>{this.logIt("console","Info",e)},log:(...e)=>{this.logIt("console","Log",e)},debug:(...e)=>{this.logIt("console","Debug",e)},verbose:(...e)=>{this.logIt("console","Verbose",e)},deprecated:(...e)=>{this.logIt("console","Error",e)}};const e="routerService"===this.loggerClientName?100:125;this.transmitAndClearQueue=Hm()(()=>{var e;this.loggerQueue.length>0&&(null===(e=this.routerClient)||void 0===e||e.transmit("logger.service.logMessages",this.loggerQueue),this.loggerQueue=[])},e,{leading:!1})}updateQueueBasedOnState(e){const{loggerQueue:t,currentLogState:n,calibratedTimeStampOffset:r}=this;this.system.debug("Logger updateQueueBasedOnState",e,r,"QUEUE LENGTH",t.length,n),this.loggerQueue=t.flatMap(t=>{if(n[t.category][t.logType]){if(!n[t.category].LocalOnly)return e&&(t.logTimestamp=t.logTimestamp+r),[t];globalThis.console.log(t.category,t.logType,t.logTimestamp-Tm.timing.navigationStart,t.logData,"(Previously queued!)")}return[]})}onStateChanged(e){-1===this.onLogStateChangeCallback.indexOf(e)&&this.onLogStateChangeCallback.push(e)}setLogState(e,t){e&&e.dev&&(this.currentLogState=e,this.onLogStateChangeCallback.forEach(t=>{t(e)})),this.updateQueueBasedOnState(t)}addToQueue(e){const{loggerQueue:t}=this;if(t.length<2e4)t.push(e);else{globalThis.console.error("Logging Queue Overflowed! Dumping queue here then continuing",t.length);let e,n=0;for(;e=t.shift();)globalThis.console.log("Message "+n++,e);this.system.error("Logging Queue Overflowed! Dumping queue in client then continuing.")}}callStack(){return Ym()}setting(){return this.currentLogState}outputToConsole(e,t){var n;const r={Debug:globalThis.console.debug,Info:globalThis.console.info,Warn:globalThis.console.warn,Error:null!==(n=globalThis.console.unwrappedError)&&void 0!==n?n:globalThis.console.error,Log:globalThis.console.log,Verbose:globalThis.console.log};try{r[e](...t)}catch(e){r.Warn("Error outputting log to console",e,Ym())}}formatAndQueueMessage(e,t,n){var r;const o="forceObjectsToLogger"===n[0],i=n.flatMap(e=>{const t=Zm(e);if(!o&&t>Qm){if(this.outputToConsole("Warn",[`Message too large to send to the logger. Max message size:${Qm/1e3}KB`,`Approx message size: ${t/1e3}KB`,...n]),this.skipLargeObjects)return[`Log argument greater than ${Qm/1e3}KB. Check local Console to see output of the object.`];{const n=Xm(e,Qm),r=Zm(n);return r>Qm?[`LOG ARG STRIPPED but not logged here still greater than ${Qm/1e3}KB. Check local Console to see output of the object. (Tag:Logging-Drop)`]:[Jm,`OldSize=${t} (Tag:Logging-Strip) NewSize=${r}`,n]}}return e instanceof Error?[e.toString()]:"forceObjectsToLogger"===e?[]:[e]});let s=null;try{s=JSON.stringify(i)}catch(e){s=`*** Logger error can't JSON.stringify: ${Ym()}`}("Error"===t||"Warn"===t||"console"===e)&&!hm.runningInFSBLUnitTest&&this.outputToConsole(t,n);const a=null!==(r=this.viewId)&&void 0!==r?r:Sm.isBrowserView()&&Sm.getWebContentsId(),l={category:"console"===e?"system":e,logType:t,logClientName:a?`${this.loggerClientName}: view-${a}`:this.loggerClientName,logData:s,logTimestamp:Tm.timing.navigationStart+Tm.now()+this.calibratedTimeStampOffset};a&&(l.viewId=a),this.addToQueue(l),this.isRegistered&&this.transmitAndClearQueue()}logIt(e,t,n){var r;if(globalThis.glue42gd)globalThis.FSBL&&(null===(r=globalThis.FSBL.Clients.Logger)||void 0===r||r[t.toLowerCase()](...n));else if(this.currentLogState[e][t])if("Warn"!==t&&"Error"!==t||n.push(Ym()),this.currentLogState[e].LocalOnly){const r=t.toLowerCase();n.unshift(`${e} ${r} (${Tm.now()}):`),this.outputToConsole(t,n)}else this.formatAndQueueMessage(e,t,n)}error(...e){this.logIt("dev","Error",e)}warn(...e){this.logIt("dev","Warn",e)}info(...e){this.logIt("dev","Info",e)}log(...e){this.logIt("dev","Log",e)}debug(...e){this.logIt("dev","Debug",e)}verbose(...e){this.logIt("dev","Verbose",e)}deprecated(...e){this.logIt("dev","Error",e)}completeRegistration(e){zm.get(["finsemble","servicesConfig","logger"],(e,t)=>{var n,r;e||(this.skipLargeObjects=null!==(n=null==t?void 0:t.skipLargeObjects)&&void 0!==n?n:this.skipLargeObjects,Qm=null!==(r=null==t?void 0:t.maxLogMessageSize)&&void 0!==r?r:Qm)}),this.loggerQueue.forEach(e=>{this.viewId&&(e.viewId=this.viewId)}),this.isRegistered=!0,e?"routerService"!==this.loggerClientName?(this.calibratedTimeStampOffset=this.newCalibratedTimeStampOffset,this.setLogState(e,!0)):this.setLogState(e,!1):globalThis.console.error("Logger.startLogger() Initial state not received from logger service"),this.formatAndQueueMessage("system","Debug",["Logger Registered"]),this.transmitAndClearQueue()}registerWithLoggerService(){var e;const{windowName:t,webContentsName:n}=wm.getInstance().getStartupData();this.loggerClientName="undefined"!=typeof window&&window.top!==window?`${t}.Frame`:t;const r=`finsemble.logger.client.${this.loggerClientName}`;!this.viewId&&Sm.isBrowserView()&&(this.viewId=Sm.getWebContentsId()),this.system.debug("logger.service.registering",this.loggerClientName),Sm.Window.getCurrent().getOptions(async e=>{var o,i;const s=null===(i=null===(o=null==e?void 0:e.customData)||void 0===o?void 0:o.component)||void 0===i?void 0:i.centralLoggerNamePrefix;if(!this.routerClient)return;const{err:a,response:l}=await this.routerClient.query("logger.service.register",{clientName:this.loggerClientName,clientChannel:r,displayName:null!=n?n:t,windowName:t,viewId:this.viewId,centralLoggerNamePrefix:s});a?(globalThis.console.warn("Logger service not available. Trying to connect again in 750ms.",a),setTimeout(()=>{this.registerWithLoggerService()},750)):this.completeRegistration(l.data)}),null===(e=this.routerClient)||void 0===e||e.addListener(r,(e,t)=>{this.system.debug("logger.client.setLogState",t.data),this.setLogState(t.data,!1)})}unregisterClient(e,t){var n;this.system.debug("logger.service.unregister",this.loggerClientName,e,this.viewId),this.transmitAndClearQueue();const r=e||{clientName:this.loggerClientName,viewId:this.viewId};null===(n=this.routerClient)||void 0===n||n.query("logger.service.unregister",r,t)}async waitForServiceAndCalibrate(){var e;await Om.waitForStartup("loggerService"),this.system.debug("Logger onReady",this.loggerClientName),null===(e=this.routerClient)||void 0===e||e.calibrateTimeWithRouterService(e=>{this.newCalibratedTimeStampOffset=e,this.isRegistering||(this.isRegistering=!0,this.startupTime=performance.now()-this.startupTime,this.registerWithLoggerService())})}async start(e){this.routerClient=null!=e?e:hy,this.startupTime=performance.now(),await this.waitForServiceAndCalibrate(),Sm.isBrowserView()&&hm.addEventListener&&hm.addEventListener("beforeunload",()=>{this.unregisterClient()})}}const ty={error:(...e)=>mm("LoggerClient",ey).error(...e),warn:(...e)=>mm("LoggerClient",ey).warn(...e),info:(...e)=>mm("LoggerClient",ey).info(...e),log:(...e)=>mm("LoggerClient",ey).log(...e),debug:(...e)=>mm("LoggerClient",ey).debug(...e),verbose:(...e)=>mm("LoggerClient",ey).verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).deprecated(...e),start:e=>{mm("LoggerClient",ey).start(e)},channelFilter:e=>(e=>"logger.service.logMessages"===e||"Finsemble.heartbeat"===e)(e),setting:()=>mm("LoggerClient",ey).setting(),callStack:()=>mm("LoggerClient",ey).callStack(),unregisterClient:(e,t)=>{mm("LoggerClient",ey).unregisterClient(e,t)},setRouterClient:e=>{mm("LoggerClient",ey).setRouterClient(e)},onStateChanged(e){mm("LoggerClient",ey).onStateChanged(e)},system:{error:(...e)=>mm("LoggerClient",ey).system.error(...e),warn:(...e)=>mm("LoggerClient",ey).system.warn(...e),info:(...e)=>mm("LoggerClient",ey).system.info(...e),log:(...e)=>mm("LoggerClient",ey).system.log(...e),debug:(...e)=>mm("LoggerClient",ey).system.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).system.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).system.deprecated(...e)},perf:{error:(...e)=>mm("LoggerClient",ey).perf.error(...e),warn:(...e)=>mm("LoggerClient",ey).perf.warn(...e),info:(...e)=>mm("LoggerClient",ey).perf.info(...e),log:(...e)=>mm("LoggerClient",ey).perf.log(...e),debug:(...e)=>mm("LoggerClient",ey).perf.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).perf.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).perf.deprecated(...e)},console:{error:(...e)=>mm("LoggerClient",ey).console.error(...e),warn:(...e)=>mm("LoggerClient",ey).console.warn(...e),info:(...e)=>mm("LoggerClient",ey).console.info(...e),log:(...e)=>mm("LoggerClient",ey).console.log(...e),debug:(...e)=>mm("LoggerClient",ey).console.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).console.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).console.deprecated(...e)}},ny=(globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,ty),ry=ny,oy=ny,iy={},sy={activeTransports:{},liveTransport:null,setTransports(){sy.addTransport("SharedWorkerForCoreServices",iy.SharedWorkerForCoreServicesTransport),sy.addTransport("SharedWorker",iy.SharedWorkerTransport),sy.addTransport("IPCBus",iy.IPCTransport),sy.addTransport("FinsembleTransport",iy.FinsembleTransport)},addTransport(e,t){this.activeTransports[e]=t},getActiveTransports(e){const t=[],n=e=>{-1===t.indexOf(e)&&t.push(e)};return Sm.InterApplicationBus&&n("IPCBus"),n("FinsembleTransport"),SharedWorker&&(n("SharedWorker"),n("SharedWorkerForCoreServices")),n(e.sameDomainTransport),n(e.crossDomainTransport),oy.system.log("getActiveTransports",t),t},getTransport:(e,t,n,r,o,i)=>new Promise((s,a)=>{const l=sy.activeTransports[t];if(l)sy.liveTransport=new l(e,n,r,o,e=>{s(e)},i);else{const e=`routerTransport.getTransport() Unknown router transport name: ${t}`;oy.warn(e),a(e)}}),close(){sy.liveTransport&&(sy.liveTransport.close(),sy.liveTransport=null)}};iy.SharedWorkerForCoreServicesTransport=function(e,t,n,r,o){let i;this.send=function(e,t){1===arguments.length?(t=arguments[0],e=null):(e=arguments[0],t=arguments[1]),oy.system.verbose("SharedWorkerForCoreServicesTransport Outgoing Transport",t);try{i.port.postMessage([e,t])}catch(e){oy.system.error(`SharedWorkerForCoreServicesTransport: post message failed: ${JSON.stringify(e)}`,"Probable cause is sending illegal data type (e.g. function).")}},this.identifier=()=>"SharedWorkerForCoreServices";const s=e.transportSettings.SharedWorker&&e.transportSettings.SharedWorker.workerPath?e.transportSettings.SharedWorker.workerPath:`${e.routerDomainRoot}/routerSharedWorkerForCoreServices.js`;oy.console.log(`SharedWorkerForCoreServices Transport Initializing for ${n} using ${s}`),i=new SharedWorker(s,{name:"Finsemble",credentials:"include"}),i.port.onmessage=e=>{const n=e.data[0],r=e.data[1],o={transportID:this.identifier(),port:n};oy.system.verbose("SharedWorkerForCoreServicesTransport Incoming Transport",o,"Message",r),t(o,r)},i.onerror=e=>{oy.console.error(`SharedWorkerForCoreServicesTransport Transport Error ${JSON.stringify(e)}`)},i.port.start(),"RouterService"===n&&i.port.postMessage({data:"connect",source:"RouterService"}),this.close=()=>i.port.close(),null==o||o(this)},iy.SharedWorkerTransport=function(e,t,n,r,o){let i;this.send=function(e,t){1===arguments.length?(t=arguments[0],e=null):(e=arguments[0],t=arguments[1]),oy.system.verbose("SharedWorkerTransport Outgoing Transport",t);try{i.port.postMessage([e,t])}catch(e){oy.system.error(`SharedWorkerTransport: post message failed: ${JSON.stringify(e)}`,"Probable cause is sending illegal data type (e.g. function).")}},this.identifier=()=>"SharedWorker";const s=e.transportSettings.SharedWorker&&e.transportSettings.SharedWorker.workerPath?e.transportSettings.SharedWorker.workerPath:`${e.routerDomainRoot}/routerSharedWorker.js`;oy.console.log(`SharedWorker Transport Initializing for ${n} using ${s}`),i=new SharedWorker(s,{name:"Finsemble",credentials:"include"}),i.port.onmessage=e=>{const n=e.data[0],r=e.data[1],o={transportID:this.identifier(),port:n};oy.system.verbose("SharedWorkerTransport Incoming Transport",o,"Message",r),t(o,r)},i.onerror=e=>{oy.console.error(`SharedWorkerTransport Transport Error ${JSON.stringify(e)}`)},i.port.start(),"RouterService"===n&&i.port.postMessage({data:"connect",source:"RouterService"}),this.close=()=>i.port.close(),null==o||o(this)},iy.IPCTransport=function(e,t,n,r,o){this.send=function(e,t){let n;1===arguments.length?(n=r,t=arguments[0]):(n=e.name,t=arguments[1]),oy.system.verbose("IPCTransport Outgoing Transport",n,"Message",t),Sm.InterApplicationBus.publish(n,t,()=>{},()=>{})},this.identifier=()=>"IPCBus",oy.console.log(`IPCBus Transport Initializing for ${n}`);const i=Sm.InterApplicationBus.subscribe("*",n,e=>{const n={transportID:this.identifier(),name:e.header.origin};oy.system.verbose("IPCTransport Incoming Transport",n,"Message",e),t(n,e)},()=>{},e=>oy.console.error(`IPCBus Subscribe Failure: ${e}`));this.close=()=>Sm.InterApplicationBus.unsubscribe(i),null==o||o(this)},iy.FinsembleTransport=function(e,t,n,r,o,i){var s,a,l,u,c;const d=`${null!==(c=null!==(l=null===(a=null===(s=null==e?void 0:e.transportSettings)||void 0===s?void 0:s.FinsembleTransport)||void 0===a?void 0:a.serverAddress)&&void 0!==l?l:null===(u=null==e?void 0:e.transportSettings)||void 0===u?void 0:u.serverAddress)&&void 0!==c?c:"ws://127.0.0.1:3376"}/router`;let h,p,g=!0;const f=e=>{if("IAC_KeepaliveHandshake"===e)oy.system.verbose("FinsembleTransport Incoming Message","Message",e),oy.system.verbose("FinsembleTransport keepalive completed"),g=!0;else{const n={transportID:this.identifier(),client:e.clientMessage.header.origin};oy.system.verbose("FinsembleTransport Incoming Transport",n,"Message",e),t(n,e.clientMessage)}},m=()=>{oy.console.log(`FinsembleTransport Transport Initializing for ${n} using ${d} trying to connect to server`),d.startsWith("ws:")||d.startsWith("wss:")||oy.system.error(`Illegal WebSocket address "${d}" (Missing ws:// or wss:// ?)`),h=new hm.WebSocket(d),h.addEventListener("open",()=>{clearInterval(p),oy.console.log("FinsembleTransport connected to server"),h.send(JSON.stringify({dest:"IAC_SERVER",source:n})),"RouterService"!==n&&((()=>{const e=setInterval(()=>{g?(g=!1,h.send(JSON.stringify({dest:"IAC_KEEPALIVE_SERVER",source:n})),oy.system.verbose("FinsembleTransport keepalive sent")):(oy.console.error("FinsembleTransport keepalive handshake failed -- transport is essentially dead",5e3),clearInterval(e),i&&i())},5e3)})(),oy.console.log("FinsembleTransport keep-alive handshake started")),h.addEventListener("message",e=>{const t=JSON.parse(e.data);f(t.message)}),null==o||o(this)}),h.addEventListener("error",e=>{oy.system.error("FinsembleTransport websocket error",e),console.log(`Error connecting to websocket server ${d}`)}),h.addEventListener("close",e=>{oy.system.log("FinsembleTransport websocket close",e),console.log(`Websocket is closed with code ${e.code}`),1006===e.code&&(clearInterval(p),p=setInterval(m,1e4))})};this.send=function(e,t){let n,r;1===arguments.length?(n="ROUTER_SERVICE",r={clientMessage:t=arguments[0]}):(n="ROUTER_CLIENT",t=arguments[1],r={client:e.client,clientMessage:t}),oy.system.verbose("FinsembleTransport Outgoing Transport",n,"NewMessage",r),h.send(JSON.stringify({dest:n,message:r}))},this.identifier=()=>"FinsembleTransport",this.close=()=>{h.close()},p=setInterval(m,1e4),m()};const ay=sy;class ly{constructor(){this.alertOnceSinceStartUp={},this.alertCurrentCount={}}}function uy(e,t={}){if(null===e||"object"!=typeof e)return e;if(e.constructor==Date||e.constructor==RegExp||e.constructor==Function||e.constructor==String||e.constructor==Number||e.constructor==Boolean)return new e.constructor(e);t=t||new e.constructor;for(const n in e)t[n]=void 0===t[n]?uy(e[n],null):t[n];return t}class cy{constructor(){this.queue=[],this.started=!1,this.clientName="RouterClient.clientName not yet set",this.transport=null,this.isRouterReady=!1,this.isTransportFailed=!1,this.parentReadyCallbackQueue=[],this.parentFailureCallbackQueue=[],this.mapListeners={},this.mapQueryResponders={},this.mapPubSubResponders={},this.mapPubSubResponderState={},this.mapPubSubResponderRegEx={},this.pubsubListOfSubscribers={},this.mapSubscribersID={},this.mapSubscribersTopic={},this.mapQueryResponses={},this.mapQueryResponseTimeOut={}}onReadyCallBack(){for(ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient Ready"),this.isRouterReady=!0;this.parentReadyCallbackQueue.length>0;){ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient parentReady invoked");const e=this.parentReadyCallbackQueue.shift();null==e||e()}}sendToRouterService(e){this.transport?this.transport.send(e):(ny.system.info("RouterClient: Queuing message since router initialization not complete",e),this.queue.push(e))}originatedHere(e){return e.header.origin===this.clientName}invokeListeners(e){const{channel:t,origin:n}=e.header,r=this.mapListeners[t]||[];Array.isArray(r)&&0!==r.length?(e.originatedHere=()=>this.originatedHere(e),r.forEach(r=>{ny.channelFilter(t)||ny.system.info("RouterClient: incoming transmit","CHANNEL",t,"FROM",n,"MESSAGE",e),r(null,e)})):ny.system.log(`RouterClient: no listener for incoming transmit on channel ${t} from ${n}. Possibly the listener was removed while this message was in transit.`,e)}invokeResponder(e){const{channel:t,origin:n,queryID:r,error:o}=e.header;ny.system.info("RouterClient: incoming query","CHANNEL",t,"FROM",n,"QUERY MESSAGE",e);const i=(e,n)=>{ny.system.info("RouterClient: outgoing query response","CHANNEL",t,"RESPONSE DATA",n,"QUERY ID",r);let o={header:{origin:this.clientName,queryID:r,type:"queryResponse"},data:n};o.header.error=e?e.toString():null,this.sendToRouterService(o)},s=this.mapQueryResponders[t];if(void 0===s)e.header.logWhenNoResponder&&ny.system.warn(`RouterClient: No query responder defined on channel ${t} for incoming from ${n}.`,e);else if(o)ny.system.warn("RouterClient: queryResponder error",e),s(o),delete this.mapQueryResponders[t];else{const t={...e,originatedHere:()=>this.originatedHere(e),sendQueryResponse:(e,t)=>{i(e,t)}};s(null,t)}}invokeQueryResponse(e){var t;ny.system.info("RouterClient: incoming query response","CHANNEL",e.header.channel,"QUERY ID",e.header.queryID,"message",e);const{queryID:n}=e.header,r=this.mapQueryResponseTimeOut[n];delete this.mapQueryResponseTimeOut[n],r&&clearTimeout(r);const o=this.mapQueryResponses[n];o?(delete this.mapQueryResponses[n],o(null!==(t=e.header.error)&&void 0!==t?t:null,e)):ny.system.warn("Invariant: RouterClient: no handler found for incoming query response.",e)}invokeNotifyCallback(e){const{subscribeID:t,error:n}=e.header,r=this.mapSubscribersID[t];r?n?(ny.system.info("RouterClient: incoming PubSub notify error for subscriberID","SUBSCRIBER ID",t,"NOTIFY MESSAGE",e),r(n,e)):(e.originatedHere=()=>this.originatedHere(e),ny.system.info("RouterClient: incoming PubSub notify","SUBSCRIBER ID",t,"NOTIFY MESSAGE",e),r(null,e)):ny.system.info("RouterClient: no subscription handler defined for incoming notify for subscriberID. Possibly the subscription was removed while this publish was in transit.",t,e)}findResponder(e){const t=this.mapPubSubResponders[e];if(t)return t;for(const t in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[t].test(e))return this.mapPubSubResponders[t]}invokePublishEvent(e){const{topic:t}=e.header;let n=this.findResponder(t);if(n){const r=(e,n,r)=>{var o;n?ny.system.warn("RouterClient: incoming publish rejected by pubsub responder",n,r):(this.mapPubSubResponderState[t]=r,(null!==(o=this.pubsubListOfSubscribers[t])&&void 0!==o?o:[]).forEach(e=>{ny.system.info("RouterClient: sending pubsub notify","TOPIC",t,"NOTIFY DATA",r);const n={header:{origin:this.clientName,type:"notify",topic:t,subscribeID:e},data:r};this.sendToRouterService(n)}))};if(ny.system.info("RouterClient: incoming PubSub publish "+(n.publishCallback?"(publishCallback hook invoked)":""),"TOPIC",t,"PUBLISH MESSAGE",e),n.publishCallback){const t={...e,sendNotifyToAllSubscribers:(t,n)=>{r(e,t,n)}};n.publishCallback(null,t)}else r(e,null,e.data)}else ny.system.warn("RouterClient: no pubsub responder defined for incoming publish","TOPIC",t,"PUBLISH MESSAGE",e)}invokeSubscribeEvent(e){var t;const{topic:n,error:r}=e.header;ny.system.info("RouterClient: PubSub subscribe","TOPIC",n);let o=this.mapPubSubResponders[n];if(!o)for(const e in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[e].test(n)){o=this.mapPubSubResponders[e],this.mapPubSubResponderState[n]=null!==(t=this.mapPubSubResponderState[n])&&void 0!==t?t:this.mapPubSubResponderState[e];break}if(o)if(r)ny.system.warn(`RouterClient: pubsub error received from router service: ${r}`,e);else if(o.subscribeCallback){const t={...e,sendNotifyToSubscriber:(t,n)=>{this.sendNotifyToSubscriber(e,t,n)}};e.data=this.mapPubSubResponderState[n],o.subscribeCallback(null,t)}else this.sendNotifyToSubscriber(e,null,this.mapPubSubResponderState[n]);else ny.system.warn("RouterClient: no pubsub responder defined for incoming subscribe event",e)}invokeUnsubscribeEvent(e){const{topic:t,subscribeID:n}=e.header;let r=this.findResponder(t);if(!r)for(const e in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[e].test(t)){r=this.mapPubSubResponders[e];break}if(r)if(ny.system.info("RouterClient: incoming unsubscribe "+(r.unsubscribeCallback?"with unsubscribeCallback hook":""),"TOPIC",t,"UNSUBSCRIBE MESSAGE",e),r.unsubscribeCallback){const o={...e,removeSubscriber:()=>{this.removeSubscribers(t,n)}};r.unsubscribeCallback(null,o)}else this.removeSubscribers(t,n);else ny.system.warn("RouterClient: no pubsub responder defined for incoming unsubscribe event","TOPIC",t,"UNSUBSCRIBE MESSAGE",e)}sendNotifyToSubscriber(e,t,n){const{topic:r,subscribeID:o}=e.header;if(void 0!==n){let e={header:{origin:this.clientName,type:"notify",topic:r,subscribeID:o},data:n};t&&(e.header.error=t),this.sendToRouterService(e)}t?ny.system.warn("RouterClient: incoming subscription rejected by pubsub responder","TOPIC",r,"MESSAGE",this):(r in this.pubsubListOfSubscribers?this.pubsubListOfSubscribers[r].push(o):this.pubsubListOfSubscribers[r]=[o],ny.system.info("RouterClient: incoming subscription added","TOPIC",r,"MESSAGE"))}removeSubscribers(e,t){let n=!1;if(e in this.pubsubListOfSubscribers){const r=this.pubsubListOfSubscribers[e];for(let o=0;o<r.length;o++)if(t===r[o]){r.splice(o,1),0===r.length&&delete this.pubsubListOfSubscribers[e],n=!0,ny.system.info("RouterClient: PubSub removeListener","TOPIC",e,"FROM",t);break}}n||ny.system.warn(`RouterClient: tried to remove non-existent listener on ${e} from ${t}`)}routeIncomingMessage(e){const t=()=>{this.timeCalibrationHandler?this.timeCalibrationHandler(e):setTimeout(()=>{t()},10)};switch(ny.system.verbose("Incoming Message Type",e.header.type,e),e.header.type){case"transmit":this.invokeListeners(e);break;case"query":this.invokeResponder(e);break;case"queryResponse":this.invokeQueryResponse(e);break;case"notify":this.invokeNotifyCallback(e);break;case"publish":this.invokePublishEvent(e);break;case"subscribe":this.invokeSubscribeEvent(e);break;case"unsubscribe":this.invokeUnsubscribeEvent(e);break;case"timeCalibration":t();break;case"initialHandshakeResponse":this.handshakeHandler()}}asyncConnectToEventRouter(e,t,n){ny.system.debug(`Name of transport to establish: ${t}`);let r=null,o=0,i=!1,s=0,a=null;const l=()=>{const t=Number.MAX_SAFE_INTEGER;ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient: sendHandshake",o);const n={header:{origin:this.clientName,type:"initialHandshake"}};this.sendToRouterService(n),o++>t&&(()=>{if(clearInterval(r),s++,s<=3)ny.console.error("WINDOW LIFECYCLE:STARTUP:RouterClient: failure to connect to router service. Retrying...",s,e),null==a||a();else{const t="A cross domain transport has failed to connect. Cross domain components may not work. Please contact your administrator.";ny.console.error(t,e),((e,t,n,r,o)=>{const i=mm("Toast",ly);let s=!1;const a=`toast.${n}`,l=(o=o||{}).duration||864e5;switch(t){case"ONCE-SINCE-STARTUP":a in i.alertOnceSinceStartUp?s=!1:(s=!0,i.alertOnceSinceStartUp[a]=!0);break;case"MAX-COUNT":{let e=0;const t=o.maxCount||1;a in i.alertCurrentCount&&(e=i.alertCurrentCount[a]),i.alertCurrentCount[a]=++e,e<=t&&(s=!0);break}default:s=!0}if(ry.log("toast",e,s,t,n,r,o),s){const t={message:r,timeout:l,...o,devModeOnly:"devModeOnly"===e};t.title||"devModeOnly"!==e||(t.title="Finsemble Developer Notification"),Om.systemLog({notification:!0},`Notification: ${r}`),Sm.Notification.send(t)}})("dev","ONCE-SINCE-STARTUP","FSBL-Internal-Transport-Failure",t)}})()},u=()=>{if(!i){ny.system.debug(`WINDOW LIFECYCLE:STARTUP:RouterClient connected: Starting ${this.clientName} with transport ${this.transport.identifier()}`),i=!0,clearInterval(r);for(let e=0;e<this.queue.length;e++){ny.system.debug("RouterClient: releasing queued msg");const t=this.queue[e];this.transport.send({...t,header:{...t.header,origin:this.clientName}})}null==n||n()}},c=e=>{o=0,ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient:transport ready","TRANSPORT OBJECT",e),this.transport=e,this.handshakeHandler=u,l(),r=setInterval(l,1e3)},d=()=>{for(ny.system.error("RouterClient Transport Failed -- onFailure() callbacks invoked."),this.isTransportFailed=!0;this.parentFailureCallbackQueue.length>0;){ny.system.debug("RouterClient parentFailure invoked");const e=this.parentFailureCallbackQueue.shift();null==e||e()}};a=()=>{ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient:getClientTransport","ROUTER PARAMS:",e),ay.getTransport(e,t,(e,t)=>{t.header.lastClient=this.clientName,t.header.incomingTransportInfo=e,this.routeIncomingMessage(t)},this.clientName,"RouterService",d).then(c).catch(e=>{ny.console.error("RouterClient getTransport error",e)})},a()}addPubSubResponderCallBack(e,t,n,r){const o=e.toString();return!this.mapPubSubResponders[o]&&(e instanceof RegExp&&(this.mapPubSubResponderRegEx[o]=e,ny.system.info(`RouterClient: PubSub RegEx added for topic ${o}`)),this.mapPubSubResponders[o]={subscribeCallback:t,publishCallback:n,unsubscribeCallback:r},!0)}calibrateTimeWithRouterService(e){let t=0,n=0,r=1/0;const o={header:{origin:this.clientName,type:"timeCalibration"},clientBaseTime:[],serviceBaseTime:[]};this.timeCalibrationHandler=o=>{if(t++,t>5)(t=>{const{clientBaseTime:o,serviceBaseTime:i}=t;let s=0;for(let e=1;e<5;e++){const t=o[e-1],a=o[e]-t,l=i[e-1]-(t+a/2);a<r&&(r=a,n=l),s+=l,ny.system.debug("calibrationCalculation Intermediate Values","lastRRT",a,"lastOffset",l,"fastestOffset",n,"fastestRRT",r)}s/=4,ny.system.debug("RouterClient calibrationCalculation","Average Offset",s,"Chosen FastestOffset",n,t),e(n)})(o);else{o.clientBaseTime.push(Tm.timing.navigationStart+Tm.now());const e={header:{origin:this.clientName,type:"timeCalibration"},clientBaseTime:o.clientBaseTime,serviceBaseTime:o.serviceBaseTime};this.sendToRouterService(e)}},this.timeCalibrationHandler(o)}start(e){return new Promise(async t=>{if(this.started){const e="RouterClient.start() called twice. Ignoring second call.";return ny.system.warn(e),t(e)}this.started=!0,this.clientName=`RouterClient.${e.windowName}.${Zp()()}`;const n=`"RouterClient Check: connecting new client for ${this.clientName}`;ny.system.debug(n),console.debug(n),ay.setTransports(),this.asyncConnectToEventRouter(e,e.transportName,()=>{this.onReadyCallBack(),t(null)})})}disconnectFromService(){ny.system.info("RouterClient.disconnectFromService");const e={header:{origin:this.clientName,type:"disconnectFromService"}};this.sendToRouterService(e)}stop(){this.disconnectAll(),ay.close(),this.started=!1,this.disconnectFromService()}onReady(e){return new Promise(t=>{const n=()=>{e&&e(),t()};this.isRouterReady?n():this.parentReadyCallbackQueue.push(n)})}onFailure(e){return new Promise(t=>{const n=()=>{e&&e(),t()};this.isTransportFailed?n():this.parentFailureCallbackQueue.push(n)})}addListener(e,t){ny.system.info("RouterClient.addListener","CHANNEL",e);const n=this.mapListeners[e];if(n&&0!==n.length)n.some(e=>t===e)?ny.debug("RouterClient.addListener() Ignoring duplicate listener with identical callback",e,t):n.push(t);else{this.mapListeners[e]=[t];const n={header:{origin:this.clientName,type:"addListener",channel:e}};this.sendToRouterService(n)}return()=>{this.removeListener(e,t)}}transmit(e,t,n){ny.channelFilter(e)||ny.system.info("RouterClient.transmit","TO CHANNEL",e,"DATA",t);const r={header:{origin:this.clientName,type:"transmit",channel:e},data:t,options:n};this.sendToRouterService(r)}removeListener(e,t){if(ny.system.info("RouterClient.removeListener","CHANNEL",e,"EVENT HANDLER",t),!this.mapListeners[e])return ny.system.debug("Attempt to remove non existent listener",e,t),void console.log("Attempt to remove non existent listener",e,t);if(this.mapListeners[e]=this.mapListeners[e].flatMap(e=>e===t?[]:[e]),!this.mapListeners[e].length){delete this.mapListeners[e];const t={header:{origin:this.clientName,type:"removeListener",channel:e}};this.sendToRouterService(t)}}addResponder(e,t){if(ny.system.info("RouterClient.addResponder","CHANNEL",e),this.mapQueryResponders[e]){const n=`RouterClient.addResponder: Responder already locally defined for channel ${e}`;ny.system.warn(n),t(n)}else{this.mapQueryResponders[e]=t;const n={header:{origin:this.clientName,type:"addResponder",channel:e}};this.sendToRouterService(n)}}query(e,t,n,r){var o,i;const s=`${this.clientName}.${Zp()()}.${e}`,a=Tm.timing.navigationStart+Tm.now(),l=Tm.timing.navigationStart,u=Tm.now();ny.system.info("RouterClient.query","RESPONDER CHANNEL",e,"QUERY EVENT",t,"PARAMS",n,"QUERY ID",s,{timestamp:a,navstart:l,timenow:u});const c=null!=r?r:"function"==typeof n?n:null,d=null!==(o=null==n?void 0:n.timeout)&&void 0!==o?o:2e4,h=null===(i=null==n?void 0:n.logWhenNoResponder)||void 0===i||i;return new Promise(r=>{this.mapQueryResponses[s]=(e,t)=>{null==c||c(e,t),r({err:e,response:t})},!hm.runningInFSBLUnitTest&&d>0&&(this.mapQueryResponseTimeOut[s]=setTimeout(()=>{console.warn(`RouterClient: timeout after ${d} ms waiting on query response on channel ${e} for queryID ${s} from client ${this.clientName}`,"from event",t,"with params",n),delete this.mapQueryResponseTimeOut[s]},d));const o={header:{origin:this.clientName,type:"query",queryID:s,channel:e,logWhenNoResponder:h,timeout:d},data:t};this.sendToRouterService(o)})}removeResponder(e){if(ny.system.info("RouterClient.removeResponder","RESPONDER CHANNEL",e),this.mapQueryResponders[e]){delete this.mapQueryResponders[e];const t={header:{origin:this.clientName,type:"removeResponder",channel:e}};this.sendToRouterService(t)}}addPubSubResponder(e,t,n,r){let o,i;if(ny.system.info("RouterClient.addPubSubResponder","TOPIC",e,"INITIAL STATE",t,"PARAMS",n),void 0===(n=n||{}).subscribeCallback&&void 0===n.publishCallback&&void 0===n.unsubscribeCallback){t=t||{};const n={header:{origin:this.clientName,type:"addPubSubResponder",topic:e.toString(),handleOnServer:!0},data:t};this.sendToRouterService(n),i="success"}else if(this.addPubSubResponderCallBack(e,n.subscribeCallback,n.publishCallback,n.unsubscribeCallback)){t=t||{},this.mapPubSubResponderState[e.toString()]=uy(t);const n={header:{origin:this.clientName,type:"addPubSubResponder",topic:e.toString(),handleOnServer:!1},data:t};this.sendToRouterService(n),i="success"}else o=`RouterClient.addPubSubResponder: Responder already locally defined for topic ${e}`,ny.system.error(o);r&&r(o,i)}removePubSubResponder(e){ny.system.info("RouterClient.removePubSubResponder","TOPIC",e);const t=e.toString();if(this.mapPubSubResponders[t]){delete this.mapPubSubResponders[t],delete this.mapPubSubResponderState[t],delete this.mapPubSubResponderRegEx[t];const n={header:{origin:this.clientName,type:"removePubSubResponder",topic:e}};this.sendToRouterService(n)}else ny.system.warn(`RouterClient.removePubSubResponder failed: Could not find responder for topic ${e}`)}subscribe(e,t){ny.system.info("RouterClient.subscribe","TOPIC",e);const n=`${this.clientName}.${Zp()()}`;this.mapSubscribersID[n]=t,this.mapSubscribersTopic[n]=e;const r={header:{origin:this.clientName,type:"subscribe",subscribeID:n,topic:e}};return this.sendToRouterService(r),{subscribeID:n,topic:e}}publish(e,t){ny.system.info("RouterClient.publish","TOPIC",e,"EVENT",t);const n={header:{origin:this.clientName,type:"publish",topic:e},data:t};this.sendToRouterService(n)}unsubscribe(e){ny.system.info("RouterClient.unsubscribe","SUBSCRIBE ID",e);const{subscribeID:t}=e;if(this.mapSubscribersID[t]){delete this.mapSubscribersID[t],delete this.mapSubscribersTopic[t];const n={header:{origin:this.clientName,type:"unsubscribe",subscribeID:e.subscribeID,topic:e.topic}};this.sendToRouterService(n)}else ny.system.warn(`RouterClient.unsubscribe: Could not find subscribeID for topic ${e.topic}`)}trustedMessage(e){var t;return ny.system.debug("RouterClient.trustedMessage header",e.header),null===(t=e.header.originMetadata)||void 0===t?void 0:t.transportInfo.transportID.includes("SharedWorker")}disconnectAll(){ny.system.info("RouterClient.disconnectAll"),Object.keys(this.mapListeners).forEach(e=>{Array.from(new Set(this.mapListeners[e])).forEach(t=>{this.removeListener(e,t)})}),Object.keys(this.mapQueryResponders).forEach(e=>{this.removeResponder(e)}),Object.keys(this.mapPubSubResponders).forEach(e=>{this.removePubSubResponder(e)}),Object.keys(this.mapSubscribersID).forEach(e=>{const t=this.mapSubscribersTopic[e];this.unsubscribe({topic:t,subscribeID:e})})}}const dy={onReady:e=>(ny.system.deprecated("You no longer need to call RouterClient.onReady()"),mm("RouterClient",cy).onReady(e)),onFailure:e=>mm("RouterClient",cy).onFailure(e),addListener:(e,t)=>mm("RouterClient",cy).addListener(e,t),transmit:(e,t,n)=>{mm("RouterClient",cy).transmit(e,t,n)},removeListener:(e,t)=>{mm("RouterClient",cy).removeListener(e,t)},addResponder:(e,t)=>{mm("RouterClient",cy).addResponder(e,t)},query:(e,t,n,r)=>mm("RouterClient",cy).query(e,t,n,r),removeResponder:e=>{mm("RouterClient",cy).removeResponder(e)},addPubSubResponder:(e,t,n,r)=>{mm("RouterClient",cy).addPubSubResponder(e,t,n,r)},removePubSubResponder:e=>{mm("RouterClient",cy).removePubSubResponder(e)},subscribe:(e,t)=>mm("RouterClient",cy).subscribe(e,t),publish:(e,t)=>{mm("RouterClient",cy).publish(e,t)},unsubscribe:e=>{mm("RouterClient",cy).unsubscribe(e)},trustedMessage:e=>mm("RouterClient",cy).trustedMessage(e),disconnectAll:()=>{mm("RouterClient",cy).disconnectAll()},calibrateTimeWithRouterService:e=>{mm("RouterClient",cy).calibrateTimeWithRouterService(e)}},hy=dy,py={EVENTS:["title-changed","bringToFront","setBounds","alwaysOnTop","setOpacity"]},gy="Finsemble.Application.State",fy="Finsemble.ServiceManager.serviceInitializing",my="Finsemble.ServiceManager.serviceReady",yy="Finsemble.ServiceManager.serviceClosing",wy="Finsemble.ServiceManager.serviceClosed",vy=e=>`Finsemble.ServiceManager.queryReady.${e}`,by=e=>({authenticationClient:"authenticationService",configClient:"configService",distributedStoreClient:"dataStoreService",hotkeyClient:"hotkeysService",linkerClient:"linkerService",logger:"loggerService",searchClient:"searchService",storageClient:"storageService",windowClient:"windowService",workspaceClient:"workspaceService"}[e]),Cy="Finsemble.State.Services";var Sy;!function(e){e[e.NORMAL=0]="NORMAL",e[e.MINIMIZED_WAS_NORMAL=1]="MINIMIZED_WAS_NORMAL",e[e.MAXIMIZED=2]="MAXIMIZED",e[e.MINIMIZED_WAS_MAXIMIZED=3]="MINIMIZED_WAS_MAXIMIZED"}(Sy||(Sy={}));const Iy="Finsemble.Service.Start",ky="Finsemble.Service.Stop",Ty="Finsemble.Event.Interrupt",xy=["close-requested","closed","close-complete","_container-close-handlers"],Ay={DELAYABLE_EVENTS:["close-requested","closed","close-complete","_container-close-handlers"],CANCELABLE_EVENTS:["close-requested"]},Ey={DELAYABLE_EVENTS:["load-requested","close-requested","save-requested"],CANCELABLE_EVENTS:["close-requested"],CLEAN_SHUTDOWN:"Finsemble.Workspace.cleanShutdown",WORKSPACE_UPDATED:"Finsemble.WorkspaceService.update",RELOAD_GROUPS:"Finsemble.WorkspaceService.reloadGroups",STORAGE_TOPIC:"finsemble.workspace",CACHE_STORAGE_TOPIC:"finsemble.workspace.cache",ALL_WORKSPACES:"finsemble.allWorkspaces",ACTIVE_WORKSPACE:"activeWorkspace",LAST_USED_WORKSPACE_TOPIC:"finsemble",LAST_USED_WORKSPACE_NAME:"finsemble.lastUsedWorkspace.name",LAST_USED_WORKSPACE:"finsemble.lastUsedWorkspace",INITIAL_WORKSPACE_PREFERENCE:"finsemble.initialWorkspace",PUBLISH_REASONS:{INIT:"workspace:initialization",LOAD_DATA_RETRIEVED:"workspace:load:dataRetrieved",LOAD_FINISHED:"workspace:load:finished",WINDOW_REMOVED:"window:remove",WINDOW_ADDED:"window:add",LOAD_STARTED:"workspace:load:start",WORKSPACE_REMOVED:"Workspace:remove",WORKSPACE_RENAMED:"rename",SWITCHTO_TERMINATED:"workspace:switchTo:terminated",NEW_WORKSPACE:"new workspace",SAVE_AS:"APPLICATION LIFECYCLE:WORKSPACE LIFECYCLE:SaveAs:Workspace:Save As"},API_CHANNELS:{NEW_WORKSPACE:"Finsemble.Workspace.NewWorkspace",SAVE:"Finsemble.Workspace.Save",RENAME:"Finsemble.Workspace.Rename",SAVE_AS:"Finsemble.Workspace.SaveAs",SWITCH_TO:"Finsemble.Workspace.SwitchTo",IMPORT:"Finsemble.Workspace.Import",EXPORT:"Finsemble.Workspace.Export",REMOVE:"Finsemble.Workspace.Remove",SAVE_GLOBAL_DATA:"Finsemble.Workspace.SaveGlobalData",SAVE_VIEW_DATA:"Finsemble.Workspace.SaveViewData",GET_GLOBAL_DATA:"Finsemble.Workspace.GetGlobalData",GET_VIEW_DATA:"Finsemble.Workspace.GetViewData",GET_WORKSPACES:"Finsemble.Workspace.GetWorkspaces",GET_WORKSPACE_NAMES:"Finsemble.Workspace.GetWorkspaceNames",SET_WORKSPACE_ORDER:"Finsemble.Workspace.SetWorkspaceOrder",GET_ACTIVE_WORKSPACE:"Finsemble.Workspace.GetActiveWorkspace",GET_ACTIVE_WORKSPACE_DIRTY:"Finsemble.Workspace.GetActiveWorkspaceDirty",GET_TEMPLATES:"Finsemble.Workspace.GetTemplates",IMPORT_TEMPLATE:"Finsemble.Workspace.ImportTemplate",EXPORT_TEMPLATE:"Finsemble.Workspace.ExportTemplate",REMOVE_TEMPLATE:"Finsemble.Workspace.RemoveTemplate",SET_WINDOW_STATE:"Finsemble.Workspace.SetWindowData",GET_WINDOW_STATE:"Finsemble.Workspace.GetWindowData",ADD_WINDOW:"WorkspaceService.addWindow",REMOVE_WINDOW:"WorkspaceService.removeWindow",GET_MANY_WINDOW_STATES:"Finsemble.Workspace.GetWindowDataMultiple",SETUP_INITIAL_WORKSPACE:"Finsemble.Workspace.SetupInitialWorkspace"},DEFAULT_WINDOW_PROPS:["name","componentType","windowType","alwaysOnTop","autoShow","minWidth","minHeight","maxWidth","maxHeight","resizable","maximizable","minimizable","opacity","windowState","left","top","width","height","right","bottom","defaultLeft","defaultTop","defaultWidth","defaultHeight","defaultRight","defaultBottom","monitorInfo","icon","cachedBounds","showTaskbarIcon","isEvergreen","launchGroupComponentData","allowAutoArrange"],ADDITIONAL_WINDOW_PROPS:{WebWindow:["url","fullscreen","frame","backgroundColor","transparent","waitForPageLoad","affinity","appUUID"],NativeWindow:["path","alias","arguments","argumentsAsQueryString","isWPF"]}},Wy={REMOTE_FOCUS:"WindowService.remoteFocus",SET_ALWAYS_ON_TOP:"WindowService-Request-setAlwaysOnTop",IS_ALWAYS_ON_TOP:"WindowService-Request-isAlwaysOnTop"},Oy="finsemble.componentStateStorage",Dy="Finsemble.WindowService.HeartbeatTimeout",_y={WINDOW_CLOSED:"LauncherService.WindowClosed"},Py={AERO_KEY:"aero_key",SYSTEM_RESTORED:"system_restored"},Ry=class{constructor(t,n){var r;this.allowDelay=!1,this.delayed=!1,this.allowCancel=!1,this.canceled=!1,this.completed=!1,this.event=t.event,this.source=t.source,this.sourceType=t.sourceType,this.listenerGuid=t.listenerGuid,e[this.sourceType.toUpperCase()]&&e[this.sourceType.toUpperCase()].DELAYABLE_EVENTS.includes(this.event)&&(this.allowDelay=!0),e[this.sourceType.toUpperCase()]&&e[this.sourceType.toUpperCase()].CANCELABLE_EVENTS.includes(this.event)&&(this.allowCancel=!0),this.handler=t.handler,this.queryMessage=n,this.guid=null===(r=null==n?void 0:n.data)||void 0===r?void 0:r.guid,this.internalHandler()}async internalHandler(){var e,t;this.data=null===(t=null===(e=this.queryMessage)||void 0===e?void 0:e.data)||void 0===t?void 0:t.data,this.handler&&await this.handler(this),this.delayed||this.canceled||this.completed||this.done()}cancel(){this.allowCancel&&(this.canceled=!0,this.done())}wait(){var e;this.allowDelay?(this.delayed=!0,null===(e=this.queryMessage)||void 0===e||e.sendQueryResponse(null,{wait:!0})):this.done()}done(e){var t;this.completed=!0,this.delayed?dy.transmit(`Finsemble.Listener.Done.${this.guid}.${this.listenerGuid}`,{canceled:this.canceled,data:e}):null===(t=this.queryMessage)||void 0===t||t.sendQueryResponse(null,{canceled:this.canceled,data:e})}},Ly=class{constructor(e){var t;this.eventList=[],this.cleanedUp=!1,this.openResponders=[],this.closedHandlersExecuted=0,this.handlers=[],this.closeFinalHandler=null,this.name=e.name,this.thisWindowName=window.name,this.sourceType=null!==(t=e.sourceType)&&void 0!==t?t:"undefined",window.addEventListener("beforeunload",()=>{this.cleanup()}),this.currentWindow=Sm.Window.getCurrent()}addListener(e,t){return this.addEventListener(e,t)}removeListener(e,t){return this.removeEventListener(e,t)}closeFinal(e){this.closeFinalHandler=e;const t=`${this.name}_public_${Date.now()}_${Math.random()}`;dy.transmit(`Finsemble.RegisterInterruptibleEvent.${this.name}`,{event:"closed",listenerGuid:t,windowName:this.thisWindowName});const n=(...e)=>{this.howManyClosedHandlers()||(this.closeFinalHandler&&this.closeFinalHandler(...e),this.closeFinalHandler=null)},r=`Finsemble.Interrupt.${t}`;dy.addResponder(r,(e,r)=>{new Ry({source:this.name,sourceType:this.sourceType,listenerGuid:t,handler:n,event:"closed"},r)}),this.openResponders.push(r)}howManyClosedHandlers(){return this.handlers.filter(e=>"closed"===e.event).length}addEventListener(e,t){ry.system.debug("PublicEventManager.addEventListener:",e);const n=`${this.name}_public_${Date.now()}_${Math.random()}`,r="closed"!==e?t:(...e)=>{t(...e),this.closedHandlersExecuted++,this.closedHandlersExecuted===this.howManyClosedHandlers()&&this.closeFinalHandler&&(this.closeFinalHandler(),this.closeFinalHandler=null)};this.handlers.push({event:e,handler:r,listenerGuid:n}),dy.transmit(`Finsemble.RegisterInterruptibleEvent.${this.name}`,{event:e,listenerGuid:n,windowName:this.thisWindowName});const o=`Finsemble.Interrupt.${n}`;return dy.addResponder(o,(t,o)=>{new Ry({source:this.name,sourceType:this.sourceType,listenerGuid:n,handler:r,event:e},o)}),this.openResponders.push(o),"close-requested"===e&&this.currentWindow.addListener("close-requested",r),()=>{this.removeEventListener(e,t)}}removeEventListener(e,t,n=!0){if(ry.system.debug("PublicEventManager.removeEventListener:",e),this.cleanedUp)return;const r=this.handlers.findIndex(n=>n.event===e&&n.handler===t);if(-1===r)return void(n&&ry.system.warn(`PublicEventManager.removeEventListener() attempt to remove unregistered event "${e}"`));const{listenerGuid:o}=this.handlers[r];dy.transmit(`Finsemble.UnregisterInterruptibleEvent.${this.name}`,{event:e,listenerGuid:o,windowName:this.thisWindowName}),dy.removeResponder(`Finsemble.Interrupt.${o}`),"close-requested"===e&&this.currentWindow.removeListener("close-requested",t),this.handlers.splice(r,1)}cleanup(){this.cleanedUp=!0,this.handlers=[],this.openResponders.forEach(e=>{dy.removeResponder(e)})}};function Fy(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map(function(e){return"'"+e+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function My(e){return!!e&&!!e[kw]}function $y(e){var t;return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Tw}(e)||Array.isArray(e)||!!e[Iw]||!!(null===(t=e.constructor)||void 0===t?void 0:t[Iw])||Gy(e)||Hy(e))}function Ny(e){return My(e)||Fy(23,e),e[kw].t}function jy(e,t,n){void 0===n&&(n=!1),0===By(e)?(n?Object.keys:xw)(e).forEach(function(r){n&&"symbol"==typeof r||t(r,e[r],e)}):e.forEach(function(n,r){return t(r,n,e)})}function By(e){var t=e[kw];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:Gy(e)?2:Hy(e)?3:0}function qy(e,t){return 2===By(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Uy(e,t,n){var r=By(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function zy(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function Gy(e){return vw&&e instanceof Map}function Hy(e){return bw&&e instanceof Set}function Vy(e){return e.o||e.t}function Qy(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Aw(e);delete t[kw];for(var n=xw(t),r=0;r<n.length;r++){var o=n[r],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function Jy(e,t){return void 0===t&&(t=!1),Yy(e)||My(e)||!$y(e)||(By(e)>1&&(e.set=e.add=e.clear=e.delete=Ky),Object.freeze(e),t&&jy(e,function(e,t){return Jy(t,!0)},!0)),e}function Ky(){Fy(2)}function Yy(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function Zy(e){var t=Ew[e];return t||Fy(18,e),t}function Xy(){return yw}function ew(e,t){t&&(Zy("Patches"),e.u=[],e.s=[],e.v=t)}function tw(e){nw(e),e.p.forEach(ow),e.p=null}function nw(e){e===yw&&(yw=e.l)}function rw(e){return yw={p:[],l:yw,h:e,m:!0,_:0}}function ow(e){var t=e[kw];0===t.i||1===t.i?t.j():t.g=!0}function iw(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.O||Zy("ES5").S(t,e,r),r?(n[kw].P&&(tw(t),Fy(4)),$y(e)&&(e=sw(t,e),t.l||lw(t,e)),t.u&&Zy("Patches").M(n[kw].t,e,t.u,t.s)):e=sw(t,n,[]),tw(t),t.u&&t.v(t.u,t.s),e!==Sw?e:void 0}function sw(e,t,n){if(Yy(t))return t;var r=t[kw];if(!r)return jy(t,function(o,i){return aw(e,r,t,o,i,n)},!0),t;if(r.A!==e)return t;if(!r.P)return lw(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var o=4===r.i||5===r.i?r.o=Qy(r.k):r.o,i=o,s=!1;3===r.i&&(i=new Set(o),o.clear(),s=!0),jy(i,function(t,i){return aw(e,r,o,t,i,n,s)}),lw(e,o,!1),n&&e.u&&Zy("Patches").N(r,n,e.u,e.s)}return r.o}function aw(e,t,n,r,o,i,s){if(My(o)){var a=sw(e,o,i&&t&&3!==t.i&&!qy(t.R,r)?i.concat(r):void 0);if(Uy(n,r,a),!My(a))return;e.m=!1}else s&&n.add(o);if($y(o)&&!Yy(o)){if(!e.h.D&&e._<1)return;sw(e,o),t&&t.A.l||lw(e,o)}}function lw(e,t,n){void 0===n&&(n=!1),!e.l&&e.h.D&&e.m&&Jy(t,n)}function uw(e,t){var n=e[kw];return(n?Vy(n):e)[t]}function cw(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function dw(e){e.P||(e.P=!0,e.l&&dw(e.l))}function hw(e){e.o||(e.o=Qy(e.t))}function pw(e,t,n){var r=Gy(t)?Zy("MapSet").F(t,n):Hy(t)?Zy("MapSet").T(t,n):e.O?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:Xy(),P:!1,I:!1,R:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=r,i=Ww;n&&(o=[r],i=Ow);var s=Proxy.revocable(o,i),a=s.revoke,l=s.proxy;return r.k=l,r.j=a,l}(t,n):Zy("ES5").J(t,n);return(n?n.A:Xy()).p.push(r),r}function gw(e){return My(e)||Fy(22,e),function e(t){if(!$y(t))return t;var n,r=t[kw],o=By(t);if(r){if(!r.P&&(r.i<4||!Zy("ES5").K(r)))return r.t;r.I=!0,n=fw(t,o),r.I=!1}else n=fw(t,o);return jy(n,function(t,o){r&&function(e,t){return 2===By(e)?e.get(t):e[t]}(r.t,t)===o||Uy(n,t,e(o))}),3===o?new Set(n):n}(e)}function fw(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Qy(e)}var mw,yw,ww="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),vw="undefined"!=typeof Map,bw="undefined"!=typeof Set,Cw="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Sw=ww?Symbol.for("immer-nothing"):((mw={})["immer-nothing"]=!0,mw),Iw=ww?Symbol.for("immer-draftable"):"__$immer_draftable",kw=ww?Symbol.for("immer-state"):"__$immer_state",Tw=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),xw="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Aw=Object.getOwnPropertyDescriptors||function(e){var t={};return xw(e).forEach(function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)}),t},Ew={},Ww={get:function(e,t){if(t===kw)return e;var n=Vy(e);if(!qy(n,t))return function(e,t,n){var r,o=cw(t,n);return o?"value"in o?o.value:null===(r=o.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!$y(r)?r:r===uw(e.t,t)?(hw(e),e.o[t]=pw(e.A.h,r,e)):r},has:function(e,t){return t in Vy(e)},ownKeys:function(e){return Reflect.ownKeys(Vy(e))},set:function(e,t,n){var r=cw(Vy(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var o=uw(Vy(e),t),i=null==o?void 0:o[kw];if(i&&i.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(zy(n,o)&&(void 0!==n||qy(e.t,t)))return!0;hw(e),dw(e)}return e.o[t]===n&&(void 0!==n||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==uw(e.t,t)||t in e.t?(e.R[t]=!1,hw(e),dw(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=Vy(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){Fy(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Fy(12)}},Ow={};jy(Ww,function(e,t){Ow[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Ow.deleteProperty=function(e,t){return Ow.set.call(this,e,t,void 0)},Ow.set=function(e,t,n){return Ww.set.call(this,e[0],t,n,e[0])};var Dw=function(){function e(e){var t=this;this.O=Cw,this.D=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var o=n;n=e;var i=t;return function(e){var t=this;void 0===e&&(e=o);for(var r=arguments.length,s=Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return i.produce(e,function(e){var r;return(r=n).call.apply(r,[t,e].concat(s))})}}var s;if("function"!=typeof n&&Fy(6),void 0!==r&&"function"!=typeof r&&Fy(7),$y(e)){var a=rw(t),l=pw(t,e,void 0),u=!0;try{s=n(l),u=!1}finally{u?tw(a):nw(a)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then(function(e){return ew(a,r),iw(e,a)},function(e){throw tw(a),e}):(ew(a,r),iw(s,a))}if(!e||"object"!=typeof e){if(void 0===(s=n(e))&&(s=e),s===Sw&&(s=void 0),t.D&&Jy(s,!0),r){var c=[],d=[];Zy("Patches").M(e,s,c,d),r(c,d)}return s}Fy(21,e)},this.produceWithPatches=function(e,n){if("function"==typeof e)return function(n){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return t.produceWithPatches(n,function(t){return e.apply(void 0,[t].concat(o))})};var r,o,i=t.produce(e,n,function(e,t){r=e,o=t});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(function(e){return[e,r,o]}):[i,r,o]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){$y(e)||Fy(8),My(e)&&(e=gw(e));var t=rw(this),n=pw(this,e,void 0);return n[kw].C=!0,nw(t),n},t.finishDraft=function(e,t){var n=(e&&e[kw]).A;return ew(n,t),iw(void 0,n)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!Cw&&Fy(20),this.O=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var o=Zy("Patches").$;return My(e)?o(e,t):this.produce(e,function(e){return o(e,t)})},e}(),_w=new Dw;function Pw(e){return Pw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pw(e)}function Rw(e,t,n){return(t=function(e){var t=function(e){if("object"!=Pw(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Pw(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Pw(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lw(Object(n),!0).forEach(function(t){Rw(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lw(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mw(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}_w.produce,_w.produceWithPatches.bind(_w),_w.setAutoFreeze.bind(_w),_w.setUseProxies.bind(_w),_w.applyPatches.bind(_w),_w.createDraft.bind(_w),_w.finishDraft.bind(_w);var $w="function"==typeof Symbol&&Symbol.observable||"@@observable",Nw=function(){return Math.random().toString(36).substring(7).split("").join(".")},jw={INIT:"@@redux/INIT"+Nw(),REPLACE:"@@redux/REPLACE"+Nw(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Nw()}};function Bw(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(Mw(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(Mw(1));return n(Bw)(e,t)}if("function"!=typeof e)throw new Error(Mw(2));var o=e,i=t,s=[],a=s,l=!1;function u(){a===s&&(a=s.slice())}function c(){if(l)throw new Error(Mw(3));return i}function d(e){if("function"!=typeof e)throw new Error(Mw(4));if(l)throw new Error(Mw(5));var t=!0;return u(),a.push(e),function(){if(t){if(l)throw new Error(Mw(6));t=!1,u();var n=a.indexOf(e);a.splice(n,1),s=null}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error(Mw(7));if(void 0===e.type)throw new Error(Mw(8));if(l)throw new Error(Mw(9));try{l=!0,i=o(i,e)}finally{l=!1}for(var t=s=a,n=0;n<t.length;n++)(0,t[n])();return e}return h({type:jw.INIT}),(r={dispatch:h,subscribe:d,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error(Mw(10));o=e,h({type:jw.REPLACE})}})[$w]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(Mw(11));function n(){e.next&&e.next(c())}return n(),{unsubscribe:t(n)}}})[$w]=function(){return this},e},r}function qw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function Uw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error(Mw(15))},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return r=qw.apply(void 0,i)(n.dispatch),Fw(Fw({},n),{},{dispatch:r})}}}function zw(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}var Gw=zw();Gw.withExtraArgument=zw;const Hw=Gw;var Vw,Qw=(Vw=function(e,t){return Vw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Vw(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Vw(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Jw=function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e},Kw=Object.defineProperty,Yw=Object.defineProperties,Zw=Object.getOwnPropertyDescriptors,Xw=Object.getOwnPropertySymbols,ev=Object.prototype.hasOwnProperty,tv=Object.prototype.propertyIsEnumerable,nv=function(e,t,n){return t in e?Kw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},rv=function(e,t){for(var n in t||(t={}))ev.call(t,n)&&nv(e,n,t[n]);if(Xw)for(var r=0,o=Xw(t);r<o.length;r++)n=o[r],tv.call(t,n)&&nv(e,n,t[n]);return e},ov=function(e,t){return Yw(e,Zw(t))},iv="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?qw:qw.apply(null,arguments)};"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;var sv=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return Qw(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Jw([void 0],e[0].concat(this)))):new(t.bind.apply(t,Jw([void 0],e.concat(this))))},t}(Array),av=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return Qw(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Jw([void 0],e[0].concat(this)))):new(t.bind.apply(t,Jw([void 0],e.concat(this))))},t}(Array);function lv(e){var t,n=function(e){return function(e){void 0===e&&(e={});var t=e.thunk,n=void 0===t||t,r=(e.immutableCheck,e.serializableCheck,new sv);return n&&(function(e){return"boolean"==typeof e}(n)?r.push(Hw):r.push(Hw.withExtraArgument(n.extraArgument))),r}(e)},r=e||{},o=r.reducer,i=void 0===o?void 0:o,s=r.middleware,a=void 0===s?n():s,l=r.devTools,u=void 0===l||l,c=r.preloadedState,d=void 0===c?void 0:c,h=r.enhancers,p=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!function(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var n=t;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];"function"==typeof e[o]&&(n[o]=e[o])}var i,s=Object.keys(n);try{!function(e){Object.keys(e).forEach(function(t){var n=e[t];if(void 0===n(void 0,{type:jw.INIT}))throw new Error(Mw(12));if(void 0===n(void 0,{type:jw.PROBE_UNKNOWN_ACTION()}))throw new Error(Mw(13))})}(n)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},a=0;a<s.length;a++){var l=s[a],u=n[l],c=e[l],d=u(c,t);if(void 0===d)throw t&&t.type,new Error(Mw(14));o[l]=d,r=r||d!==c}return(r=r||s.length!==Object.keys(e).length)?o:e}}(i)}var g=a;"function"==typeof g&&(g=g(n));var f=Uw.apply(void 0,g),m=qw;u&&(m=iv(rv({trace:!1},"object"==typeof u&&u)));var y=new av(f),w=y;return Array.isArray(p)?w=Jw([f],p):"function"==typeof p&&(w=p(y)),Bw(t,d,m.apply(void 0,w))}function uv(e,t){function n(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(t){var o=t.apply(void 0,n);if(!o)throw new Error("prepareAction did not return an object");return rv(rv({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:n[0]}}return n.toString=function(){return""+e},n.type=e,n.match=function(t){return t.type===e},n}var cv=["name","message","stack","code"],dv=function(e,t){this.payload=e,this.meta=t},hv=function(e,t){this.payload=e,this.meta=t},pv=function(e){if("object"==typeof e&&null!==e){for(var t={},n=0,r=cv;n<r.length;n++){var o=r[n];"string"==typeof e[o]&&(t[o]=e[o])}return t}return{message:String(e)}};function gv(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}!function(){function e(e,t,n){var r=uv(e+"/fulfilled",function(e,t,n,r){return{payload:e,meta:ov(rv({},r||{}),{arg:n,requestId:t,requestStatus:"fulfilled"})}}),o=uv(e+"/pending",function(e,t,n){return{payload:void 0,meta:ov(rv({},n||{}),{arg:t,requestId:e,requestStatus:"pending"})}}),i=uv(e+"/rejected",function(e,t,r,o,i){return{payload:o,error:(n&&n.serializeError||pv)(e||"Rejected"),meta:ov(rv({},i||{}),{arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===(null==e?void 0:e.name),condition:"ConditionError"===(null==e?void 0:e.name)})}}),s="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign(function(e){return function(a,l,u){var c,d=(null==n?void 0:n.idGenerator)?n.idGenerator(e):function(e){void 0===e&&(e=21);for(var t="",n=e;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t}(),h=new s;function p(e){c=e,h.abort()}var g=function(){return s=this,g=null,f=function(){var s,g,f,m,y,w;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(v){switch(v.label){case 0:return v.trys.push([0,4,,5]),null===(b=m=null==(s=null==n?void 0:n.condition)?void 0:s.call(n,e,{getState:l,extra:u}))||"object"!=typeof b||"function"!=typeof b.then?[3,2]:[4,m];case 1:m=v.sent(),v.label=2;case 2:if(!1===m||h.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=new Promise(function(e,t){return h.signal.addEventListener("abort",function(){return t({name:"AbortError",message:c||"Aborted"})})}),a(o(d,e,null==(g=null==n?void 0:n.getPendingMeta)?void 0:g.call(n,{requestId:d,arg:e},{getState:l,extra:u}))),[4,Promise.race([y,Promise.resolve(t(e,{dispatch:a,getState:l,extra:u,requestId:d,signal:h.signal,abort:p,rejectWithValue:function(e,t){return new dv(e,t)},fulfillWithValue:function(e,t){return new hv(e,t)}})).then(function(t){if(t instanceof dv)throw t;return t instanceof hv?r(t.payload,d,e,t.meta):r(t,d,e)})])];case 3:return f=v.sent(),[3,5];case 4:return w=v.sent(),f=w instanceof dv?i(null,d,e,w.payload,w.meta):i(w,d,e),[3,5];case 5:return n&&!n.dispatchConditionRejection&&i.match(f)&&f.meta.condition||a(f),[2,f]}var b})},new Promise(function(e,t){var n=function(e){try{o(f.next(e))}catch(e){t(e)}},r=function(e){try{o(f.throw(e))}catch(e){t(e)}},o=function(t){return t.done?e(t.value):Promise.resolve(t.value).then(n,r)};o((f=f.apply(s,g)).next())});var s,g,f}();return Object.assign(g,{abort:p,requestId:d,arg:e,unwrap:function(){return g.then(gv)}})}},{pending:o,rejected:i,fulfilled:r,typePrefix:e})}e.withTypes=function(){return e}}(),Object.assign;var fv="listenerMiddleware";uv(fv+"/add"),uv(fv+"/removeAll"),uv(fv+"/remove"),"function"==typeof queueMicrotask&&queueMicrotask.bind("undefined"!=typeof window?window:void 0!==n.g?n.g:globalThis);"undefined"!=typeof window&&window.requestAnimationFrame&&window.requestAnimationFrame,function(){function e(e,t){var n=o[e];return n?n.enumerable=t:o[e]=n={configurable:!0,enumerable:t,get:function(){var t=this[kw];return Ww.get(t,e)},set:function(t){var n=this[kw];Ww.set(n,e,t)}},n}function t(e){for(var t=e.length-1;t>=0;t--){var o=e[t][kw];if(!o.P)switch(o.i){case 5:r(o)&&dw(o);break;case 4:n(o)&&dw(o)}}}function n(e){for(var t=e.t,n=e.k,r=xw(n),o=r.length-1;o>=0;o--){var i=r[o];if(i!==kw){var s=t[i];if(void 0===s&&!qy(t,i))return!0;var a=n[i],l=a&&a[kw];if(l?l.t!==s:!zy(a,s))return!0}}var u=!!t[kw];return r.length!==xw(t).length+(u?0:1)}function r(e){var t=e.k;if(t.length!==e.t.length)return!0;var n=Object.getOwnPropertyDescriptor(t,t.length-1);if(n&&!n.get)return!0;for(var r=0;r<t.length;r++)if(!t.hasOwnProperty(r))return!0;return!1}var o={};!function(e,t){Ew[e]||(Ew[e]=t)}("ES5",{J:function(t,n){var r=Array.isArray(t),o=function(t,n){if(t){for(var r=Array(n.length),o=0;o<n.length;o++)Object.defineProperty(r,""+o,e(o,!0));return r}var i=Aw(n);delete i[kw];for(var s=xw(i),a=0;a<s.length;a++){var l=s[a];i[l]=e(l,t||!!i[l].enumerable)}return Object.create(Object.getPrototypeOf(n),i)}(r,t),i={i:r?5:4,A:n?n.A:Xy(),P:!1,I:!1,R:{},l:n,t,k:o,o:null,g:!1,C:!1};return Object.defineProperty(o,kw,{value:i,writable:!0}),o},S:function(e,n,o){o?My(n)&&n[kw].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var n=t[kw];if(n){var o=n.t,i=n.k,s=n.R,a=n.i;if(4===a)jy(i,function(t){t!==kw&&(void 0!==o[t]||qy(o,t)?s[t]||e(i[t]):(s[t]=!0,dw(n)))}),jy(o,function(e){void 0!==i[e]||qy(i,e)||(s[e]=!1,dw(n))});else if(5===a){if(r(n)&&(dw(n),s.length=!0),i.length<o.length)for(var l=i.length;l<o.length;l++)s[l]=!1;else for(var u=o.length;u<i.length;u++)s[u]=!0;for(var c=Math.min(i.length,o.length),d=0;d<c;d++)i.hasOwnProperty(d)||(s[d]=!0),void 0===s[d]&&e(i[d])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):r(e)}})}();const mv={windows:{},dragging:null,tabCollections:{},useDOMBasedMovement:!0,closingTabs:null},yv={clone:uv("windowTitleBar/clone"),close:uv("windowTitleBar/close"),closeTab:uv("windowTitleBar/closeTab"),disableDOMBasedMovement:uv("windowTitleBar/disableDOMBasedMovement"),setMaximize:uv("windowTitleBar/maximize"),minimize:uv("windowTitleBar/minimize"),promoteTab:uv("windowTitleBar/promoteTab"),register:uv("windowTitleBar/register"),removeFromTabCollection:uv("windowTitleBar/removeFromTabCollection"),scroll:uv("windowTitleBar/scrollTabCollection"),setAlwaysOnTop:uv("windowTitleBar/setAlwaysOnTop"),setGrouped:uv("windowTitleBar/setGrouped"),setUserDefinedTitle:uv("windowTitleBar/setUserDefinedTitle"),setDraggingStatus:uv("windowTitlebar/setDraggingStatus"),stopDragging:uv("windowTitlebar/stopDragging"),shiftPromotedTab:uv("windowTitleBar/shiftPromotedTab"),setClosingTabStatus:uv("windowTitleBar/setClosingTabStatus"),removeClosingTabs:uv("windowTitleBar/removeClosingTabs"),createTabCollection:uv("api/createTabCollection"),addTabsToTabCollection:uv("api/addTabsToTabCollection"),removeTabsFromTabCollection:uv("api/removeTabsFromTabCollection"),showScrim:uv("ux/showScrim"),hideScrim:uv("ux/hideScrim"),setScrimSafetyTimeout:uv("ux/setScrimSafetyTimeout"),addLaunchData:uv("main/addLaunchData"),dockingOperation:uv("main/dockingOperation"),loadWorkspace:uv("main/loadWorkspace"),setEmulatedMaximization:uv("main/setEmulatedMaximization"),enableDND:uv("main/enableDND"),loadUserDefinedTitle:uv("main/loadUserDefinedTitle"),saveSpawnTabTitleToWorkspace:uv("main/saveSpawnTabTitleToWorkspace"),setDocumentTitle:uv("main/updatedDocumentTitle"),setAPITitle:uv("main/updatedAPITitle"),updateGroupedWindows:uv("main/updateGroupedWindows"),windowEvent:uv("main/windowEvent"),updateMaximizedBounds:uv("main/updateMaximizedBounds"),workspaceClosing:uv("main/workspaceClosing"),setTabCollectionForEvergreen:uv("main/setTabCollectionForEvergreen"),updateEvergreenAfterWorkspaceLoading:uv("main/updateEvergreenAfterWorkspaceLoading"),createDefaultWindowTitleBar:uv("main/createDefaultWindowTitleBar")};var wv;function vv(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Array.prototype.concat;var bv=Symbol("isCmd"),Cv=(Symbol("dispatch"),Symbol("getState"),"NONE");Object.freeze((vv(wv={},bv,!0),vv(wv,"type",Cv),vv(wv,"simulate",function(){return null}),wv));const Sv=({server:e,slice:t,dispatchOnly:n})=>r=>(o,i)=>{const s=r((e,t)=>("@@finsemble/updateState"===t.type&&(e=t.newState),{...o(e,t)}),i),a={...s,dispatch:t=>(ry.system.debug(`Interop.remote.${t.type}`,s,t),"@@finsemble/updateState"==t.type?s.dispatch(t):t.type?dy.query(e,t):t.then&&t.then(s.dispatch),t)},l=`reduxSlice:${t}:${Date.now()}_${Math.random()}`;return dy.addListener(l,(e,t)=>{if(!e&&t){const e={type:"@@finsemble/updateState",newState:null==t?void 0:t.data};a.dispatch(e)}}),n||dy.query(e,{"@@finsemble/action":"subscribe","@@finsemble/slice":t,"@@finsemble/routerChannel":l},()=>{}),a},Iv=e=>e;var kv=n(8055),Tv=n.n(kv);class xv{constructor(e){var t;this.onLoadHandler=e=>{(null==e?void 0:e.viewId)===this.id&&this.subscriptions.forEach(e=>null==e?void 0:e())},this.win=e.win,this.id=e.id,this.subscriptions=[],this.isVisible=null===(t=e.visible)||void 0===t||t}async remove(e=Function.prototype){this.subscriptions.length>0&&Sm.removeEventListener("browserView-content-loaded",this.onLoadHandler),await this.win.removeBrowserView(this,e)}async setBounds(e,t=Function.prototype){await this.win.setViewBounds({view:this,bounds:e},t)}async bringToFront(e=Function.prototype){await this.win.bringViewToFront(this,e)}async showView(e=Function.prototype){this.isVisible=!0,await this.win.showBrowserView(this,e)}async hideView(e=Function.prototype){this.isVisible=!1,await this.win.hideBrowserView(this,e)}onContentLoaded(e=Function.prototype){this.subscriptions.push(e),1===this.subscriptions.length&&Sm.addEventListener("browserView-content-loaded",this.onLoadHandler)}}class Av extends Ly{constructor(e){super({name:e.name,sourceType:"Window"}),this.types={},this.wrapState=e.wrapState||"initializing",this.componentState={},this.windowState=Sy.NORMAL,this.type=null,this.windowType=null,this.bounds={},this.guid=`${Date.now()}_${Math.random()}`,this.WINDOWSTATE=Sy,this.windowOptions={},this.doConstruction(e),this.componentKey=Ev("activeWorkspace",this.name,this.name),this.windowKey=Ev("activeWorkspace",this.name),Av.bindFunctions(this)}standardizeEventName(e){switch(e){case"bounds-set":case"stoppedMoving":return"bounds-change-end";case"startedMoving":return"bounds-change-start";case"bringToFront":return"broughtToFront";default:return e}}addEventListener(e,t){return e=this.standardizeEventName(e),super.addEventListener(e,t)}removeEventListener(e,t,n=!1){if("closed"!==e||!pm.finsembleWindow||this.name!==pm.finsembleWindow.name)return e=this.standardizeEventName(e),super.removeEventListener(e,t,n)}windowServiceChannelName(e){return`WindowService-Request-${e}`}eventChannelName(e){return`WindowService-Event-${this.name||this.windowName}-${e}`}doConstruction(e){if(e.setWindowType||e.windowType||(e.windowType="WebWindow"),e.windowType)return e.setWindowType=e.windowType,delete e.windowType,new Av(e);if(e)for(const t in e)this[t]=e[t];this.name||(this.name=e.windowName),this.windowType=this.setWindowType}static registerType(e,t){const n=Av;n.types||(n.types={}),n.types[e]=t}static bindFunctions(e){e.eventChannelName=e.eventChannelName.bind(e),e.windowServiceChannelName=e.windowServiceChannelName.bind(e),e.handleWrapRemoveRequest=e.handleWrapRemoveRequest.bind(e),e.reload=e.reload.bind(e)}static async createWrapFromUUIDAndName(e,t){var n;const{uuid:r,windowType:o}=t;if(!1!==t.waitForReady)try{await Av._windowReady(e),t.wrapState="ready"}catch(e){return{err:e}}ry.system.debug("WRAP LIFECYCLE:",e,"All information for wrap passed in, creating wrap locally");const i=Av.cache[e];return i?(ry.system.debug("WRAP LIFECYCLE:",e,"Window found in the cache, returning without going to the Launcher"),{data:i}):{data:(await Av._createWrap({...t,windowIdentifier:null!==(n=t.windowIdentifier)&&void 0!==n?n:{uuid:r,name:e,windowName:e,windowType:o}})).wrap}}static getInstance(e,t){var n;const r=Sm.Window.getCurrent().name,o=null!==(n=null==(e=Tv()(e))?void 0:e.windowName)&&void 0!==n?n:null==e?void 0:e.name;return new Promise(async(n,i)=>{if(!o){const e='"name" is a required param';return null==t||t(e),void i(e)}e.windowName=o;let s=Av.cache[o];if(s)return ry.system.debug("WRAP LIFECYCLE:",o,"Window found in the cache, returning without going to the Launcher"),null==t||t(null,s),void n({wrap:s});if(e.name){const{err:r,data:s}=await Av.createWrapFromUUIDAndName(o,e);return r||!s?(null==t||t(r),void i(r)):(null==t||t(null,s),void n({wrap:s}))}if(!1!==e.waitForReady)try{await Av._windowReady(o),e.wrapState="ready"}catch(a){return null==t||t(a,null),void i(a)}const{err:a,response:l}=await dy.query("WindowService-Request-getWindowIdentifier",{windowName:o,requester:r});if(a)return ry.system.error(a),null==t||t(a,null),void i(a);if(s=Av.cache[o],s)return ry.system.debug("WRAP LIFECYCLE:",e.name,"Information received from launcher, but wrap exists in cache. Returning cached wrap."),null==t||t(null,s),void n({wrap:s});ry.system.debug("WRAP LIFECYCLE:",o,"Information received from launcher. Creating wrap.");const{identifier:u}=l.data;u.windowName&&(u.name=u.windowName),e.retrievedIdentifier=u,({wrap:s}=await Av._createWrap(e)),l.data.descriptor&&(s.descriptor=l.data.descriptor),null==t||t(null,s),n({wrap:s})})}static _createWrap(e){return new Promise(async t=>{const n=e.retrievedIdentifier||e.windowIdentifier;(e.setWindowType||n.windowType)&&"WebApplication"!==n.windowType||(n.windowType="WebWindow");let r={...n};r=Object.assign(r,e),r.setWindowType=r.windowType,delete r.windowType,ry.system.debug("WRAP LIFECYCLE: Placing wrap into the local cache.",n.windowName);let o=new Av(r);Av.cache[n.windowName]=o,o.windowType=n.windowType,o.identifier=n,o.closeFinal(o.handleWrapRemoveRequest),o.addEventListener("maximized",async()=>{o.windowState=Sy.MAXIMIZED,o.windowOptions.windowState=Sy.MAXIMIZED;const{data:e}=await o.getBounds();e&&(o.windowOptions.left=e.left,o.windowOptions.top=e.top,o.windowOptions.height=e.height,o.windowOptions.width=e.width,o.windowOptions.right=e.right,o.windowOptions.bottom=e.bottom,o.windowOptions.opacity=1,o.saveCompleteWindowState(o.windowOptions))}),o.addEventListener("minimized",()=>{o.windowState===Sy.MAXIMIZED?(o.windowState=Sy.MINIMIZED_WAS_MAXIMIZED,o.windowOptions.windowState=Sy.MINIMIZED_WAS_MAXIMIZED):o.windowState===Sy.NORMAL?(o.windowState=Sy.MINIMIZED_WAS_NORMAL,o.windowOptions.windowState=Sy.MINIMIZED_WAS_NORMAL):ry.system.warn("Invalid window state received listening to window minimize",o.windowState)}),o.addEventListener("restored",()=>{o.windowState=Sy.NORMAL,o.windowOptions.windowState=Sy.NORMAL});const i=dy.subscribe(`Finsemble.Component.State.${n.windowName}`,(e,t)=>{if(e)ry.system.error("Finsemble component state change error",e);else{const{state:e}=t.data;o.wrapState=e,dy.unsubscribe(i)}});t({wrap:o})})}static _getRemoveWrapChannel(e){return`${Sm.Window.getCurrent().name}.removeWrap.${e}`}async handleWrapRemoveRequest(e){e&&e.wait(),ry.system.debug("WRAP Destructor. Removing cached window",this.name,"in ",window.name),this.removeListeners&&this.removeListeners(),this.cleanupRouter(),this.cleanup(),this.name!==pm.name&&this.name&&delete Av.cache[this.name],e&&e.done()}static closeAllWraps(){Object.values(Av.cache).forEach(e=>{e.handleWrapRemoveRequest()})}cleanupRouter(){const e=Av._getRemoveWrapChannel(this.name);dy.removeResponder(e)}onReady(e){return new Promise(t=>{if("ready"===this.wrapState)return null==e||e(),void t();this.addEventListener("ready",()=>{null==e||e(),t()})})}queryWindowService(e,t,n=Function.prototype){return"function"==typeof t&&(n=t,t={}),t={...t,windowIdentifier:this.identifier},ry.setting().system.Debug&&(t.callstack=ry.callStack()),new Promise(async(r,o)=>{var i;if("close"!==e&&"ready"!==this.wrapState)return await this.onReady(),this.wrapState="ready",void r(await this.queryWindowService(e,t));ry.system.debug("FinsembleWindow.queryWindowService",this.windowServiceChannelName(e),t);const{err:s,response:a}=await dy.query(this.windowServiceChannelName(e),t);let l=null!==(i=a.data)&&void 0!==i?i:null;if(s){if(ry.system.debug(`WindowService.${e}: failed`,s),console.debug(`WindowService.${e}: failed`,s),"getComponentState"!==e&&"Not found"!==s)return void o(s)}else ry.system.debug(`${this.windowServiceChannelName(e)} successful`,l),console.debug(`${this.windowServiceChannelName(e)} successful`,l);r(l),n(s,l)})}minimize(e=null,t){return new Promise(n=>{this.queryWindowService("minimize",e,e=>{null==t||t(e),n({err:e})})})}maximize(e=null,t){return new Promise(n=>{this.getBounds((r,o)=>{r||!o?ry.system.warn(`Error getting bounds, cached bounds will not be set: ${r}`):this.updateOptions({options:{left:o.left,top:o.top,width:o.width,height:o.height}}),this.queryWindowService("maximize",e,e=>{null==t||t(e),n({err:e})})})})}restore(e=null,t){return new Promise(n=>{this.queryWindowService("restore",e,e=>{null==t||t(e),n({err:e})})})}blur(e=null,t){return new Promise(n=>{this.queryWindowService("blur",e,e=>{null==t||t(e),n({err:e})})})}focus(e=null,t){return new Promise(n=>{this.queryWindowService("focus",e,e=>{null==t||t(e),n({err:e})})})}bringToFront(e=null,t){return new Promise(n=>{this.queryWindowService("bringToFront",e,e=>{null==t||t(e),n({err:e})})})}setAlwaysOnTop(e={alwaysOnTop:!0},t){return new Promise(n=>{this.queryWindowService("setAlwaysOnTop",e,e=>{null==t||t(e),n({err:e})})})}isAlwaysOnTop(e={},t){this.queryWindowService("isAlwaysOnTop",e,t)}isShowing(e={},t){this.queryWindowService("isShowing",e,t)}setIgnoreMouseEvents(e,t,n=Function.prototype){const r={ignore:new Boolean(e).valueOf(),options:new Boolean(t).valueOf()?t:{forward:!1}};this.queryWindowService("setIgnoreMouseEvents",r,n)}setShape(e,t=Function.prototype){this.queryWindowService("setShape",e,t)}async addBrowserView(e,t=Function.prototype){const n=await this.queryWindowService("addBrowserView",e,t);return new xv({id:n,win:this,visible:null==e?void 0:e.visible})}async removeBrowserView(e,t=Function.prototype){await this.queryWindowService("removeBrowserView",{viewId:e.id},t)}async bringViewToFront(e,t=Function.prototype){await this.queryWindowService("bringViewToFront",{viewId:e.id},t)}async showBrowserView(e,t=Function.prototype){await this.queryWindowService("showBrowserView",{viewId:e.id},t)}async hideBrowserView(e,t=Function.prototype){await this.queryWindowService("hideBrowserView",{viewId:e.id},t)}async setViewBounds(e,t=Function.prototype){await this.queryWindowService("setViewBounds",{viewId:e.view.id,bounds:e.bounds},t)}setBounds(e={bounds:{}},t){return new Promise(n=>{"function"==typeof e||e.bounds||(e={bounds:e}),this.queryWindowService("setBounds",e,e=>{null==t||t(e),n({err:e})})})}getBounds(e,t){return new Promise(n=>{const r="function"==typeof e?e:t;this.queryWindowService("getBounds",{},(e,t)=>{null==r||r(e,t),n({err:e,data:t})})})}updateOptions(e,t=Function.prototype){this.queryWindowService("updateOptions",e,t)}hide(e={},t){return new Promise(n=>{this.queryWindowService("hide",e,(e,r)=>{null==t||t(e,r),n({err:e})})})}reload(e={},t=Function.prototype){this.queryWindowService("reload",e,t)}show(e={},t){return new Promise(n=>{this.queryWindowService("show",e,(e,r)=>{null==t||t(e,r),n({err:e})})})}showAt(e={},t=Function.prototype){this.queryWindowService("showAt",e,t)}close(e={},t){return new Promise(n=>{ry.system.debug("WRAP CLOSE. Public close initiated for",this.name,e),this.queryWindowService("close",e,e=>{ry.system.debug("WRAP CLOSE. Public close initiated for",this.name),null==t||t(e),n({err:e})})})}animate(e={},t=Function.prototype){this.queryWindowService("animate",e,t)}registerWithDocking(e={},t){this.onReady(()=>{dy.query("DockingService.registerWindow",e,t)})}showNativeOpenDialog(e={},t){this.queryWindowService("showNativeOpenDialog",e,t)}unRegisterWithDocking(){dy.transmit("DockingService.deregisterWindow",{name:this.windowName})}initializeWindow({manageWindowMovement:e,identifier:t},n=Function.prototype){const r=()=>{dy.publish(`Finsemble.${this.windowName}.componentReady`,{name:this.windowName}),n()};e?this.registerWithDocking(t,r):r()}wrapReady(){dy.publish(`Finsemble.${this.windowName}.wrapReady`,{name:this.windowName,state:"open"})}setOpacity(e,t=Function.prototype){this.queryWindowService("setOpacity",e,t)}startTabTileMonitoring(e={}){ry.system.debug("FinsembleWindow.startTabTileMonitoring",e),dy.transmit("TabTile.startTabTile",{params:e})}stopTabTileMonitoring(e={},t=Function.prototype){ry.system.debug("FinsembleWindow.stopTabTileMonitoring",e),dy.query("TabTile.stopTabTile",{params:e},function(e,n){e?ry.system.warn("TabTile.stopTabTile: query failed",e):ry.system.debug("TabTile.stopTabTile results",n.data);const r=n.data;t?t(e,r,this.defaultStopTrackingAction):this.defaultTabTileAction(r)})}defaultTabTileAction(e){const t=this;switch(ry.system.debug("FinsembleWindow.defaultTabTileAction",e),e.stoppedLocation){case"OutsideWindow":case"TabSection":break;case"InsideWindow":e.tileGroupId?t.Group.addWindow(this.identifier,e.tileGroupId,e.dropCoordinates):t.Group.createGroup(function(n){t.Group.addWindow(this.identifier,n,e.dropCoordinates,{startingWindowIdentifier:e.droppedOnWindowIdentifier})});break;default:ry.system.error("stopTracking returned an unknown stoppedLocation result",e)}}mergeBounds(e){e.right=e.left+e.width;const t={left:e.left,right:e.right,width:e.width,top:e.top,bottom:e.top+e.height,height:e.height},n={defaultLeft:e.left,defaultWidth:e.width,defaultTop:e.top,defaultHeight:e.height};Object.assign(this.windowOptions,t),Object.assign(this.windowOptions,n),this.windowOptions.bounds=t}startMove(e={}){ry.system.debug("FinsembleWindow.startMove",e),e.windowIdentifier=this.identifier,dy.transmit(this.eventChannelName("startedMoving"),{})}stopMove(e={}){ry.system.debug("FinsembleWindow.stopMove",e),e.windowIdentifier=this.identifier,dy.transmit(this.eventChannelName("stoppedMoving"),{})}getMonitor(e){dy.query("DockingService.getMonitorForWindow",{windowIdentifier:this.identifier},(t,n)=>n?e(n.data):e())}getComponentState(e,t){return new Promise(n=>{this.queryWindowService("getComponentState",e,(e,r)=>{null==t||t(e,r),n({err:e,data:r})})})}getWindowState(e,t){this.queryWindowService("getWindowState",e,t)}setComponentState(e,t=()=>{}){this.queryWindowService("setComponentState",e,t)}removeComponentState(e,t=()=>{}){this.queryWindowService("removeComponentState",e,t)}setWindowState(e,t=()=>{}){this.queryWindowService("setWindowState",e,t)}saveCompleteWindowState(e={},t=Function.prototype){this.queryWindowService("saveCompleteWindowState",e,t)}cancelTabTileMonitoring(e={}){ry.system.debug("FinsembleWindow.cancelTabTileMonitoring",e),dy.transmit("TabTile.cancelTabTile",{params:e})}setTitle(e){(({singletonName:e,server:t,slice:r,emptyStore:o,dispatchOnly:i=!1})=>((e,t,...r)=>{const o=fm(e);if(!o){const o=Symbol.for(`com.finsemble.singleton.${e}`);return n.g[o]=t(...r),n.g[o]}return o})(e,()=>(({server:e,slice:t,emptyStore:n,dispatchOnly:r=!1})=>lv({preloadedState:n,reducer:Iv,enhancers:[Sv({server:e,slice:t,dispatchOnly:r})]}))({server:t,slice:r,emptyStore:o,dispatchOnly:i})))({singletonName:"WindowClient::setWindowTitle",server:"@@finsemble/remoteRedux/WindowServiceStore",slice:"windowTitleBar",emptyStore:mv,dispatchOnly:!0}).dispatch(yv.setAPITitle({title:e}))}getOptions(e){return new Promise(t=>{this.queryWindowService("getOptions",{},(n,r)=>{null==e||e(n,r),t({err:n,data:r})})})}formGroup(){dy.transmit("DockingService.formGroup",{windowName:this.name})}ejectFromGroup(){dy.query("DockingService.leaveGroup",{name:this.name},()=>{})}}function Ev(...e){let t="";for(let n=0;n<e.length;n++)t=`${t} ${e[n]}`;return t.replace(/\s(.)/g,e=>e.toUpperCase()).replace(/\s/g,"").replace(/^(.)/,e=>e.toLowerCase())}Av.WINDOWSTATE=Sy,Av.wrap=Av.getInstance,Av.cache={},Av._windowReady=function(e){let t;return ry.system.debug(`windowServiceReady: ${e} starting`),new Promise(async n=>{ry.system.debug(`windowServiceReady: ${e} waiting`),t=dy.subscribe(`Finsemble.Component.State.${e}`,(r,o)=>{const{state:i}=o.data;switch(ry.system.debug(`windowServiceReady: ${e} state change: ${i}`),i){case"ready":case"reloading":case"closing":ry.system.debug(`windowServiceReady: ${e} ${i}`),dy.unsubscribe(t),n()}})})},n(4383),n(2404),n(9132);let Wv,Ov,{fdc3:Dv}=pm,_v=null;const Pv=async()=>{var e,t,n;if(null!==_v)return _v;const r=await Wv.contexts.get(tg),o=null===(e=null==r?void 0:r.iocd)||void 0===e?void 0:e.persistFDC3Context,i=await Wg(Wv.windows.my()),s=null===(t=null==i?void 0:i.customProperties)||void 0===t?void 0:t.persistFDC3Context;return _v=null===(n=null!=s?s:o)||void 0===n||n,Ov.debug("FDC3 context persistence enabled?",_v),_v},Rv=async e=>{var t;if(!e)return;if(!await Pv())return;const n=`#finsemble-persistedContext-${e.type}`;Ov.debug("Persisting FDC3 context",n,e),await(null===(t=Wv.windows.my())||void 0===t?void 0:t.updateContext({[n]:e}))},Lv=async(e,t)=>{var n,r,o,i;if(!await Pv())return;const s=null!==(r=await(null===(n=Wv.windows.my())||void 0===n?void 0:n.getContext()))&&void 0!==r?r:{},a=`#finsemble-persistedContext-${e}`,l=null!==(o=s[a])&&void 0!==o?o:null===(i=s["#finsemble-componentState"])||void 0===i?void 0:i[a];l&&Ov.debug("Restoring FDC3 context",a,l),l&&await t(l)},Fv=[],Mv=()=>{if(!globalThis.fdc3)return void console.log("No fdc3 object found on global path. Skipping monkey patch.");const e=Dv.addContextListener,t=Dv.broadcast,n=Dv.addIntentListener,r=Dv.raiseIntent,o=Dv.open,i=Dv.getUserChannels;Dv.addContextListener=async(t,n)=>{(Ov||console).log("intercepted addContextListener",t),n||(n=t,t=null);const r=null!=n?n:t,o=(e,t)=>(Rv(e),r(e,t));return"string"==typeof t&&(Wv?await Lv(t,r):Fv.push(()=>{Lv(t,r)})),n?await e(t,o):await e(o)},Dv.broadcast=async e=>{if(Wv)return Rv(e),await t(e);Fv.push(()=>{Dv.broadcast(e)})},Dv.addIntentListener=async(e,t)=>await n(e,async(e,n)=>(Rv(e),await t(e,n))),Dv.leaveChannel=async e=>{var t;Wv&&await Wv.channels.leave(null===(t=Wv.windows.my())||void 0===t?void 0:t.id,e)},Dv.getCurrentChannels=async()=>{var e;if(!Wv)return null;const t=null!==(e=Wv.channels.current())&&void 0!==e?e:"",n=t?t.split("+++"):[];return(await Dv.getUserChannels()).filter(e=>n.includes(e.id))};const s=async e=>{let t=e;const n="string"==typeof e?e:(null==e?void 0:e.name)?e.name:void 0;if(n){const e=(await Wv.appManager.applications()).find(e=>{var t,r;return(null===(r=null===(t=e.userProperties)||void 0===t?void 0:t.appd)||void 0===r?void 0:r.name)===n});e&&(t={appId:e.name})}return t};Dv.getSystemChannels=async()=>(await i()).sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:0),Dv.getUserChannels=async()=>(await i()).sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:0),Dv.raiseIntent=async(e,t,n)=>r(e,t,await s(n)),Dv.open=async(e,t)=>o(await s(e),t)},$v=(e,t)=>{globalThis.fdc3&&(Wv=e,Ov=t,Ov.debug("Monkey patching fdc3. Queued broadcasts:",Fv.length),Fv.forEach(e=>{e()}))},Nv=(new Date).getTime();if(globalThis.window){console.debug("FSBL preload running");const e=null===globalThis||void 0===globalThis?void 0:globalThis.glue42gd;e&&(e.gwURL=e.gwURL.replace("localhost","127.0.0.1"))}const jv={appManager:"full",layouts:{mode:"full",autoSaveWindowContext:["Workspace","Global"]},windows:!0,bus:!0,channels:!0,contexts:!0,libraries:[pc,Gp]},Bv=(e,t)=>{Mv();const n=new Kp,r=e(null!=t?t:jv),o=new Dg,i=new $f(r,o),s=new tm(r,o,i);i.initialize(s),Zg.setStaticInstances(r,i);const a=new Df(r,o,i),l=new ef(r,o,s,i),u=new kf(r,o,i),c=new Zg(r,o),d=new om(r,o,i),h=new rm(r,o,i),p=new tf(r,o,i,s,h),g=new Pf(r,o,i),f=new lm(r,o,i),m=new df(r,o,s,i),y=new yf(r,o,s,l,u,i),w={addEventListener:async(e,t)=>{"onReady"===e&&(await n.promise,t())},Clients:{AppsClient:l,AuthenticationClient:p,DialogManager:y,SearchClient:new nm(r,o,i),RouterClient:s,WorkspaceClient:f,ConfigClient:m,LauncherClient:l,WindowClient:d,DistributedStoreClient:u,StorageClient:h,HotkeyClient:new Ff(r,o,i),NotificationClient:new Yf(r,o,i),Logger:i,BloombergBridgeClient:new dm(r,o,i)},SystemManagerClient:new um(r,o,i),getFSBLInfo:async e=>{const t=await g.getFEAInfo(),n={FSBLVersion:t["io.Connect Desktop"],gitHash:"","io.Connect Desktop":t["io.Connect Desktop"],"@interopio/desktop":t["@interopio/desktop"],Electron:t.Electron,FEA:t.FEA,isDevLaunch:!1,isDevMode:!1,sddEnabled:!1};return null==e||e(n),n},UserNotification:new cm(r),componentType:"",publishReady:()=>{r.then(async e=>{const{err:t}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"signal-app-ready"}));t&&console.error("Error occurred signaling ready",t)})},restartApplication:async e=>new Promise(t=>{r.then(n=>{(async(e,t,n,r)=>{await Vg(e,t,n,!0,r)||await e.appManager.restart({autoSave:!1,showDialog:!1})})(n,y.open.bind(y),f.save.bind(f),e).then(t)})}),shutdownApplication:()=>{r.then(e=>{(async(e,t,n)=>{await Vg(e,t,n,!1,void 0)||await e.appManager.exit({autoSave:!1,showDialog:!1})})(e,y.open.bind(y),f.save.bind(f))})},onShutdown:()=>{},System:g,glue:r,version:"0.0.1",FinsembleWindow:Zg};return console.debug("FSBL preload: Glue API initializing"),i.debug("FSBL preload: Glue API initializing"),r.then(async e=>{var t,r,a,l,u,c,d,h,g,f,m,y;if(console.debug("FSBL preload: Glue API ready"),i.debug("FSBL preload: Glue API ready"),"Toolbar"===(null===(t=e.windows.my())||void 0===t?void 0:t.name)){const{err:t}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"signal-app-ready"}));t&&console.error("Error occurred signaling Toolbar ready",t)}await Promise.all([o.ready()]),i.debug("FSBL preload: All clients are ready"),globalThis.iop=null!==(r=globalThis.iop)&&void 0!==r?r:e;const v=null===(u=null===(l=null===(a=e.windows)||void 0===a?void 0:a.my())||void 0===l?void 0:l.application)||void 0===u?void 0:u.type;v&&(w.componentType=v),null===(d=null===(c=e.windows)||void 0===c?void 0:c.my())||void 0===d||d.onRefreshing(async t=>{var n;const r=await e.contexts.get(tg);!1===(null===(n=null==r?void 0:r["finsemble-electron-adapter"])||void 0===n?void 0:n.reloadWindowHotkey)&&t()}),null===(g=null===(h=e.windows)||void 0===h?void 0:h.my())||void 0===g||g.onFocusChanged(e=>{e.isFocused?document.documentElement.classList.add("desktop-active"):document.documentElement.classList.remove("desktop-active")}),"sso-application"===(null===(m=null===(f=e.windows)||void 0===f?void 0:f.my())||void 0===m?void 0:m.name)&&(e.interop.register("Finsemble.Clients.AuthenticationClient.publishAuthorization.backChannel",ig(async(e,t)=>{console.debug("Received backChannel credentials from application",t.applicationName),p.publishAuthorization(null==e?void 0:e.user,null==e?void 0:e.credentials)})),(async e=>{var t;const n=await Wg(e.windows.my());(null==n?void 0:n.details.hidden)&&(null===(t=e.windows.my())||void 0===t||t.hide())})(e),s.publish("AuthorizationState",{state:"starting"}).then(()=>{s.publish("AuthorizationState",{state:"waiting"})})),(async e=>{var t;const n=await(async e=>{var t,n,r;if(!e.windows)return!1;const o=await Wg(e.windows.my());return!!(null===(t=null==o?void 0:o.customProperties)||void 0===t?void 0:t.component)||"(Menu) "===(null===(n=e.windows.my())||void 0===n?void 0:n.name.substring(0,7))||["custom-tray","finsemble-decorator-window","web-group-application"].includes(null===(r=globalThis.glue42gd)||void 0===r?void 0:r.applicationName)})(e);if(!n)return;const r=await e.contexts.get(tg);(e=>{if(e){const o=Zp()(),i=`${r=e,"/"===r.slice(-1)?r:`${r}/`}assets/css/theme.css?${o}`,s=document.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("type","text/css"),s.setAttribute("href",i),n=s,(t=document.body).firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}var t,n,r})(null===(t=null==r?void 0:r.finsemble)||void 0===t?void 0:t.documentRoot),(async e=>{let t=null;if(!e.themes)return;const n=e=>{var n,r;const o=document.getElementsByTagName("html");t&&(null===(n=o[0])||void 0===n||n.classList.remove(t.name)),t=e,null===(r=o[0])||void 0===r||r.classList.add(t.name)};t=await e.themes.getCurrent(),n(t),e.themes.onChanged(e=>{n(e)})})(e)})(e),$v(e,i),i.debug(`FSBL preload ready ${(new Date).getTime()-Nv}ms`),n.resolve();const b=new Event("FSBLReady");null===(y=globalThis.dispatchEvent)||void 0===y||y.call(globalThis,b),Wg(e.windows.my()).then(t=>{(null==t?void 0:t.details.backgroundThrottling)&&(async e=>{const t=e.windows.my();if(!t)return;const{id:n,name:r}=t;setInterval(async()=>{const{err:t}=await gg(()=>e.interop.invoke("Finsemble.heartbeat",{type:"component",windowName:`${r}:${n}`,componentType:"finsemble",isBrowserView:!0}));t&&console.error("Error occurred sending heartbeat",t)},1e4)})(e)})}),{FSBL:w,finsembleWindow:c,fin:a}};if("undefined"!=typeof window){const e=window.Glue;if(e){const t=Bv(e);Object.keys(t).forEach(e=>{window[e]=t[e]}),console.debug("FSBL preload loaded")}}})(),{}})());
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolyfillPreload=t():e.PolyfillPreload=t()}(this,()=>(()=>{var e={2:(e,t,n)=>{var r=n(2199),o=n(4664),i=n(5950);e.exports=function(e){return r(e,i,o)}},79:(e,t,n)=>{var r=n(3702),o=n(80),i=n(4739),s=n(8655),a=n(1175);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},80:(e,t,n)=>{var r=n(6025),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():o.call(t,n,1),--this.size,0))}},104:(e,t,n)=>{var r=n(3661);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},124:(e,t,n)=>{var r=n(9325);e.exports=function(){return r.Date.now()}},181:e=>{e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},270:(e,t,n)=>{var r=n(7068),o=n(346);e.exports=function e(t,n,i,s,a){return t===n||(null==t||null==n||!o(t)&&!o(n)?t!=t&&n!=n:r(t,n,i,s,e,a))}},289:(e,t,n)=>{var r=n(2651);e.exports=function(e){return r(this,e).get(e)}},294:e=>{e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},317:e=>{e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},346:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},361:e=>{var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},392:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},575:()=>{},631:(e,t,n)=>{var r=n(8077),o=n(9326);e.exports=function(e,t){return null!=e&&o(e,t,r)}},659:(e,t,n)=>{var r=n(1873),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},689:(e,t,n)=>{var r=n(2),o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,i,s,a){var l=1&n,u=r(e),c=u.length;if(c!=r(t).length&&!l)return!1;for(var d=c;d--;){var h=u[d];if(!(l?h in t:o.call(t,h)))return!1}var p=a.get(e),g=a.get(t);if(p&&g)return p==t&&g==e;var f=!0;a.set(e,t),a.set(t,e);for(var m=l;++d<c;){var y=e[h=u[d]],w=t[h];if(i)var v=l?i(w,y,h,t,e,a):i(y,w,h,e,t,a);if(!(void 0===v?y===w||s(y,w,n,i,a):v)){f=!1;break}m||(m="constructor"==h)}if(f&&!m){var b=e.constructor,C=t.constructor;b==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof C&&C instanceof C||(f=!1)}return a.delete(e),a.delete(t),f}},695:(e,t,n)=>{var r=n(8096),o=n(2428),i=n(6449),s=n(3656),a=n(361),l=n(7167),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),c=!n&&o(e),d=!n&&!c&&s(e),h=!n&&!c&&!d&&l(e),p=n||c||d||h,g=p?r(e.length,String):[],f=g.length;for(var m in e)!t&&!u.call(e,m)||p&&("length"==m||d&&("offset"==m||"parent"==m)||h&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||a(m,f))||g.push(m);return g}},938:e=>{e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},945:(e,t,n)=>{var r=n(79),o=n(8223),i=n(3661);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},1033:e=>{e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},1042:(e,t,n)=>{var r=n(6110)(Object,"create");e.exports=r},1175:(e,t,n)=>{var r=n(6025);e.exports=function(e,t){var n=this.__data__,o=r(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}},1380:e=>{e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},1420:(e,t,n)=>{var r=n(79);e.exports=function(){this.__data__=new r,this.size=0}},1459:e=>{e.exports=function(e){return this.__data__.has(e)}},1549:(e,t,n)=>{var r=n(2032),o=n(3862),i=n(6721),s=n(2749),a=n(5749);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},1769:(e,t,n)=>{var r=n(6449),o=n(8586),i=n(1802),s=n(3222);e.exports=function(e,t){return r(e)?e:o(e,t)?[e]:i(s(e))}},1791:(e,t,n)=>{var r=n(6547),o=n(3360);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var a=-1,l=t.length;++a<l;){var u=t[a],c=i?i(n[u],e[u],u,n,e):void 0;void 0===c&&(c=e[u]),s?o(n,u,c):r(n,u,c)}return n}},1800:e=>{var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},1802:(e,t,n)=>{var r=n(2224),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,function(e,n,r,o){t.push(r?o.replace(i,"$1"):n||e)}),t});e.exports=s},1811:e=>{var t=Date.now;e.exports=function(e){var n=0,r=0;return function(){var o=t(),i=16-(o-r);if(r=o,i>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}},1873:(e,t,n)=>{var r=n(9325).Symbol;e.exports=r},1882:(e,t,n)=>{var r=n(2552),o=n(3805);e.exports=function(e){if(!o(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1961:(e,t,n)=>{var r=n(9653);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},1986:(e,t,n)=>{var r=n(1873),o=n(7828),i=n(5288),s=n(5911),a=n(317),l=n(4247),u=r?r.prototype:void 0,c=u?u.valueOf:void 0;e.exports=function(e,t,n,r,u,d,h){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!d(new o(e),new o(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return i(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var p=a;case"[object Set]":var g=1&r;if(p||(p=l),e.size!=t.size&&!g)return!1;var f=h.get(e);if(f)return f==t;r|=2,h.set(e,t);var m=s(p(e),p(t),r,u,d,h);return h.delete(e),m;case"[object Symbol]":if(c)return c.call(e)==c.call(t)}return!1}},2032:(e,t,n)=>{var r=n(1042);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},2199:(e,t,n)=>{var r=n(4528),o=n(6449);e.exports=function(e,t,n){var i=t(e);return o(e)?i:r(i,n(e))}},2224:(e,t,n)=>{var r=n(104);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},2271:(e,t,n)=>{var r=n(1791),o=n(4664);e.exports=function(e,t){return r(e,o(e),t)}},2404:(e,t,n)=>{var r=n(270);e.exports=function(e,t){return r(e,t)}},2428:(e,t,n)=>{var r=n(7534),o=n(346),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,l=r(function(){return arguments}())?r:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=l},2543:function(e,t,n){var r;e=n.nmd(e),function(){var o,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,u=128,c=1/0,d=9007199254740991,h=NaN,p=4294967295,g=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],f="[object Arguments]",m="[object Array]",y="[object Boolean]",w="[object Date]",v="[object Error]",b="[object Function]",C="[object GeneratorFunction]",S="[object Map]",I="[object Number]",k="[object Object]",T="[object Promise]",x="[object RegExp]",A="[object Set]",E="[object String]",W="[object Symbol]",O="[object WeakMap]",D="[object ArrayBuffer]",_="[object DataView]",P="[object Float32Array]",R="[object Float64Array]",L="[object Int8Array]",F="[object Int16Array]",M="[object Int32Array]",$="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",B="[object Uint32Array]",q=/\b__p \+= '';/g,U=/\b(__p \+=) '' \+/g,z=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,V=RegExp(G.source),Q=RegExp(H.source),J=/<%-([\s\S]+?)%>/g,K=/<%([\s\S]+?)%>/g,Y=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,X=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,oe=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,pe=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,fe=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ye=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ce="\\ud800-\\udfff",Se="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ie="\\u2700-\\u27bf",ke="a-z\\xdf-\\xf6\\xf8-\\xff",Te="A-Z\\xc0-\\xd6\\xd8-\\xde",xe="\\ufe0e\\ufe0f",Ae="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ee="["+Ce+"]",We="["+Ae+"]",Oe="["+Se+"]",De="\\d+",_e="["+Ie+"]",Pe="["+ke+"]",Re="[^"+Ce+Ae+De+Ie+ke+Te+"]",Le="\\ud83c[\\udffb-\\udfff]",Fe="[^"+Ce+"]",Me="(?:\\ud83c[\\udde6-\\uddff]){2}",$e="[\\ud800-\\udbff][\\udc00-\\udfff]",Ne="["+Te+"]",je="\\u200d",Be="(?:"+Pe+"|"+Re+")",qe="(?:"+Ne+"|"+Re+")",Ue="(?:['’](?:d|ll|m|re|s|t|ve))?",ze="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ge="(?:"+Oe+"|"+Le+")?",He="["+xe+"]?",Ve=He+Ge+"(?:"+je+"(?:"+[Fe,Me,$e].join("|")+")"+He+Ge+")*",Qe="(?:"+[_e,Me,$e].join("|")+")"+Ve,Je="(?:"+[Fe+Oe+"?",Oe,Me,$e,Ee].join("|")+")",Ke=RegExp("['’]","g"),Ye=RegExp(Oe,"g"),Ze=RegExp(Le+"(?="+Le+")|"+Je+Ve,"g"),Xe=RegExp([Ne+"?"+Pe+"+"+Ue+"(?="+[We,Ne,"$"].join("|")+")",qe+"+"+ze+"(?="+[We,Ne+Be,"$"].join("|")+")",Ne+"?"+Be+"+"+Ue,Ne+"+"+ze,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",De,Qe].join("|"),"g"),et=RegExp("["+je+Ce+Se+xe+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rt=-1,ot={};ot[P]=ot[R]=ot[L]=ot[F]=ot[M]=ot[$]=ot[N]=ot[j]=ot[B]=!0,ot[f]=ot[m]=ot[D]=ot[y]=ot[_]=ot[w]=ot[v]=ot[b]=ot[S]=ot[I]=ot[k]=ot[x]=ot[A]=ot[E]=ot[O]=!1;var it={};it[f]=it[m]=it[D]=it[_]=it[y]=it[w]=it[P]=it[R]=it[L]=it[F]=it[M]=it[S]=it[I]=it[k]=it[x]=it[A]=it[E]=it[W]=it[$]=it[N]=it[j]=it[B]=!0,it[v]=it[b]=it[O]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,lt=parseInt,ut="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ct="object"==typeof self&&self&&self.Object===Object&&self,dt=ut||ct||Function("return this")(),ht=t&&!t.nodeType&&t,pt=ht&&e&&!e.nodeType&&e,gt=pt&&pt.exports===ht,ft=gt&&ut.process,mt=function(){try{return pt&&pt.require&&pt.require("util").types||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),yt=mt&&mt.isArrayBuffer,wt=mt&&mt.isDate,vt=mt&&mt.isMap,bt=mt&&mt.isRegExp,Ct=mt&&mt.isSet,St=mt&&mt.isTypedArray;function It(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function kt(e,t,n,r){for(var o=-1,i=null==e?0:e.length;++o<i;){var s=e[o];t(r,s,n(s),e)}return r}function Tt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function xt(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function At(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Et(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}function Wt(e,t){return!(null==e||!e.length)&&Nt(e,t,0)>-1}function Ot(e,t,n){for(var r=-1,o=null==e?0:e.length;++r<o;)if(n(t,e[r]))return!0;return!1}function Dt(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}function _t(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}function Pt(e,t,n,r){var o=-1,i=null==e?0:e.length;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function Rt(e,t,n,r){var o=null==e?0:e.length;for(r&&o&&(n=e[--o]);o--;)n=t(n,e[o],o,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Ft=Ut("length");function Mt(e,t,n){var r;return n(e,function(e,n,o){if(t(e,n,o))return r=n,!1}),r}function $t(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i<o;)if(t(e[i],i,e))return i;return-1}function Nt(e,t,n){return t==t?function(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}(e,t,n):$t(e,Bt,n)}function jt(e,t,n,r){for(var o=n-1,i=e.length;++o<i;)if(r(e[o],t))return o;return-1}function Bt(e){return e!=e}function qt(e,t){var n=null==e?0:e.length;return n?Ht(e,t)/n:h}function Ut(e){return function(t){return null==t?o:t[e]}}function zt(e){return function(t){return null==e?o:e[t]}}function Gt(e,t,n,r,o){return o(e,function(e,o,i){n=r?(r=!1,e):t(n,e,o,i)}),n}function Ht(e,t){for(var n,r=-1,i=e.length;++r<i;){var s=t(e[r]);s!==o&&(n=n===o?s:n+s)}return n}function Vt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Qt(e){return e?e.slice(0,hn(e)+1).replace(re,""):e}function Jt(e){return function(t){return e(t)}}function Kt(e,t){return Dt(t,function(t){return e[t]})}function Yt(e,t){return e.has(t)}function Zt(e,t){for(var n=-1,r=e.length;++n<r&&Nt(t,e[n],0)>-1;);return n}function Xt(e,t){for(var n=e.length;n--&&Nt(t,e[n],0)>-1;);return n}var en=zt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tn=zt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function nn(e){return"\\"+st[e]}function rn(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function sn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,r=e.length,o=0,i=[];++n<r;){var s=e[n];s!==t&&s!==a||(e[n]=a,i[o++]=n)}return i}function ln(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function un(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function cn(e){return rn(e)?function(e){for(var t=Ze.lastIndex=0;Ze.test(e);)++t;return t}(e):Ft(e)}function dn(e){return rn(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var pn=zt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),gn=function e(t){var n,r=(t=null==t?dt:gn.defaults(dt.Object(),t,gn.pick(dt,nt))).Array,oe=t.Date,Ce=t.Error,Se=t.Function,Ie=t.Math,ke=t.Object,Te=t.RegExp,xe=t.String,Ae=t.TypeError,Ee=r.prototype,We=Se.prototype,Oe=ke.prototype,De=t["__core-js_shared__"],_e=We.toString,Pe=Oe.hasOwnProperty,Re=0,Le=(n=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Fe=Oe.toString,Me=_e.call(ke),$e=dt._,Ne=Te("^"+_e.call(Pe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),je=gt?t.Buffer:o,Be=t.Symbol,qe=t.Uint8Array,Ue=je?je.allocUnsafe:o,ze=sn(ke.getPrototypeOf,ke),Ge=ke.create,He=Oe.propertyIsEnumerable,Ve=Ee.splice,Qe=Be?Be.isConcatSpreadable:o,Je=Be?Be.iterator:o,Ze=Be?Be.toStringTag:o,et=function(){try{var e=ui(ke,"defineProperty");return e({},"",{}),e}catch(e){}}(),st=t.clearTimeout!==dt.clearTimeout&&t.clearTimeout,ut=oe&&oe.now!==dt.Date.now&&oe.now,ct=t.setTimeout!==dt.setTimeout&&t.setTimeout,ht=Ie.ceil,pt=Ie.floor,ft=ke.getOwnPropertySymbols,mt=je?je.isBuffer:o,Ft=t.isFinite,zt=Ee.join,fn=sn(ke.keys,ke),mn=Ie.max,yn=Ie.min,wn=oe.now,vn=t.parseInt,bn=Ie.random,Cn=Ee.reverse,Sn=ui(t,"DataView"),In=ui(t,"Map"),kn=ui(t,"Promise"),Tn=ui(t,"Set"),xn=ui(t,"WeakMap"),An=ui(ke,"create"),En=xn&&new xn,Wn={},On=Mi(Sn),Dn=Mi(In),_n=Mi(kn),Pn=Mi(Tn),Rn=Mi(xn),Ln=Be?Be.prototype:o,Fn=Ln?Ln.valueOf:o,Mn=Ln?Ln.toString:o;function $n(e){if(ea(e)&&!Us(e)&&!(e instanceof qn)){if(e instanceof Bn)return e;if(Pe.call(e,"__wrapped__"))return $i(e)}return new Bn(e)}var Nn=function(){function e(){}return function(t){if(!Xs(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=o,n}}();function jn(){}function Bn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=o}function qn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Un(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function zn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Gn;++t<n;)this.add(e[t])}function Vn(e){var t=this.__data__=new zn(e);this.size=t.size}function Qn(e,t){var n=Us(e),r=!n&&qs(e),o=!n&&!r&&Vs(e),i=!n&&!r&&!o&&la(e),s=n||r||o||i,a=s?Vt(e.length,xe):[],l=a.length;for(var u in e)!t&&!Pe.call(e,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||mi(u,l))||a.push(u);return a}function Jn(e){var t=e.length;return t?e[Gr(0,t-1)]:o}function Kn(e,t){return _i(Ao(e),ir(t,0,e.length))}function Yn(e){return _i(Ao(e))}function Zn(e,t,n){(n!==o&&!Ns(e[t],n)||n===o&&!(t in e))&&rr(e,t,n)}function Xn(e,t,n){var r=e[t];Pe.call(e,t)&&Ns(r,n)&&(n!==o||t in e)||rr(e,t,n)}function er(e,t){for(var n=e.length;n--;)if(Ns(e[n][0],t))return n;return-1}function tr(e,t,n,r){return cr(e,function(e,o,i){t(r,e,n(e),i)}),r}function nr(e,t){return e&&Eo(t,Oa(t),e)}function rr(e,t,n){"__proto__"==t&&et?et(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function or(e,t){for(var n=-1,i=t.length,s=r(i),a=null==e;++n<i;)s[n]=a?o:Ta(e,t[n]);return s}function ir(e,t,n){return e==e&&(n!==o&&(e=e<=n?e:n),t!==o&&(e=e>=t?e:t)),e}function sr(e,t,n,r,i,s){var a,l=1&t,u=2&t,c=4&t;if(n&&(a=i?n(e,r,i,s):n(e)),a!==o)return a;if(!Xs(e))return e;var d=Us(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Pe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ao(e,a)}else{var h=hi(e),p=h==b||h==C;if(Vs(e))return Co(e,l);if(h==k||h==f||p&&!i){if(a=u||p?{}:gi(e),!l)return u?function(e,t){return Eo(e,di(e),t)}(e,function(e,t){return e&&Eo(t,Da(t),e)}(a,e)):function(e,t){return Eo(e,ci(e),t)}(e,nr(a,e))}else{if(!it[h])return i?e:{};a=function(e,t,n){var r,o=e.constructor;switch(t){case D:return So(e);case y:case w:return new o(+e);case _:return function(e,t){var n=t?So(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case P:case R:case L:case F:case M:case $:case N:case j:case B:return Io(e,n);case S:return new o;case I:case E:return new o(e);case x:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new o;case W:return r=e,Fn?ke(Fn.call(r)):{}}}(e,h,l)}}s||(s=new Vn);var g=s.get(e);if(g)return g;s.set(e,a),ia(e)?e.forEach(function(r){a.add(sr(r,t,n,r,e,s))}):ta(e)&&e.forEach(function(r,o){a.set(o,sr(r,t,n,o,e,s))});var m=d?o:(c?u?ni:ti:u?Da:Oa)(e);return Tt(m||e,function(r,o){m&&(r=e[o=r]),Xn(a,o,sr(r,t,n,o,e,s))}),a}function ar(e,t,n){var r=n.length;if(null==e)return!r;for(e=ke(e);r--;){var i=n[r],s=t[i],a=e[i];if(a===o&&!(i in e)||!s(a))return!1}return!0}function lr(e,t,n){if("function"!=typeof e)throw new Ae(i);return Ei(function(){e.apply(o,n)},t)}function ur(e,t,n,r){var o=-1,i=Wt,s=!0,a=e.length,l=[],u=t.length;if(!a)return l;n&&(t=Dt(t,Jt(n))),r?(i=Ot,s=!1):t.length>=200&&(i=Yt,s=!1,t=new Hn(t));e:for(;++o<a;){var c=e[o],d=null==n?c:n(c);if(c=r||0!==c?c:0,s&&d==d){for(var h=u;h--;)if(t[h]===d)continue e;l.push(c)}else i(t,d,r)||l.push(c)}return l}$n.templateSettings={escape:J,evaluate:K,interpolate:Y,variable:"",imports:{_:$n}},$n.prototype=jn.prototype,$n.prototype.constructor=$n,Bn.prototype=Nn(jn.prototype),Bn.prototype.constructor=Bn,qn.prototype=Nn(jn.prototype),qn.prototype.constructor=qn,Un.prototype.clear=function(){this.__data__=An?An(null):{},this.size=0},Un.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Un.prototype.get=function(e){var t=this.__data__;if(An){var n=t[e];return n===s?o:n}return Pe.call(t,e)?t[e]:o},Un.prototype.has=function(e){var t=this.__data__;return An?t[e]!==o:Pe.call(t,e)},Un.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=An&&t===o?s:t,this},zn.prototype.clear=function(){this.__data__=[],this.size=0},zn.prototype.delete=function(e){var t=this.__data__,n=er(t,e);return!(n<0||(n==t.length-1?t.pop():Ve.call(t,n,1),--this.size,0))},zn.prototype.get=function(e){var t=this.__data__,n=er(t,e);return n<0?o:t[n][1]},zn.prototype.has=function(e){return er(this.__data__,e)>-1},zn.prototype.set=function(e,t){var n=this.__data__,r=er(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Un,map:new(In||zn),string:new Un}},Gn.prototype.delete=function(e){var t=ai(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return ai(this,e).get(e)},Gn.prototype.has=function(e){return ai(this,e).has(e)},Gn.prototype.set=function(e,t){var n=ai(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Hn.prototype.add=Hn.prototype.push=function(e){return this.__data__.set(e,s),this},Hn.prototype.has=function(e){return this.__data__.has(e)},Vn.prototype.clear=function(){this.__data__=new zn,this.size=0},Vn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Vn.prototype.get=function(e){return this.__data__.get(e)},Vn.prototype.has=function(e){return this.__data__.has(e)},Vn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof zn){var r=n.__data__;if(!In||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(e,t),this.size=n.size,this};var cr=Do(wr),dr=Do(vr,!0);function hr(e,t){var n=!0;return cr(e,function(e,r,o){return n=!!t(e,r,o)}),n}function pr(e,t,n){for(var r=-1,i=e.length;++r<i;){var s=e[r],a=t(s);if(null!=a&&(l===o?a==a&&!aa(a):n(a,l)))var l=a,u=s}return u}function gr(e,t){var n=[];return cr(e,function(e,r,o){t(e,r,o)&&n.push(e)}),n}function fr(e,t,n,r,o){var i=-1,s=e.length;for(n||(n=fi),o||(o=[]);++i<s;){var a=e[i];t>0&&n(a)?t>1?fr(a,t-1,n,r,o):_t(o,a):r||(o[o.length]=a)}return o}var mr=_o(),yr=_o(!0);function wr(e,t){return e&&mr(e,t,Oa)}function vr(e,t){return e&&yr(e,t,Oa)}function br(e,t){return Et(t,function(t){return Ks(e[t])})}function Cr(e,t){for(var n=0,r=(t=yo(t,e)).length;null!=e&&n<r;)e=e[Fi(t[n++])];return n&&n==r?e:o}function Sr(e,t,n){var r=t(e);return Us(e)?r:_t(r,n(e))}function Ir(e){return null==e?e===o?"[object Undefined]":"[object Null]":Ze&&Ze in ke(e)?function(e){var t=Pe.call(e,Ze),n=e[Ze];try{e[Ze]=o;var r=!0}catch(e){}var i=Fe.call(e);return r&&(t?e[Ze]=n:delete e[Ze]),i}(e):function(e){return Fe.call(e)}(e)}function kr(e,t){return e>t}function Tr(e,t){return null!=e&&Pe.call(e,t)}function xr(e,t){return null!=e&&t in ke(e)}function Ar(e,t,n){for(var i=n?Ot:Wt,s=e[0].length,a=e.length,l=a,u=r(a),c=1/0,d=[];l--;){var h=e[l];l&&t&&(h=Dt(h,Jt(t))),c=yn(h.length,c),u[l]=!n&&(t||s>=120&&h.length>=120)?new Hn(l&&h):o}h=e[0];var p=-1,g=u[0];e:for(;++p<s&&d.length<c;){var f=h[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(g?Yt(g,m):i(d,m,n))){for(l=a;--l;){var y=u[l];if(!(y?Yt(y,m):i(e[l],m,n)))continue e}g&&g.push(m),d.push(f)}}return d}function Er(e,t,n){var r=null==(e=Ti(e,t=yo(t,e)))?e:e[Fi(Ji(t))];return null==r?o:It(r,e,n)}function Wr(e){return ea(e)&&Ir(e)==f}function Or(e,t,n,r,i){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,r,i,s){var a=Us(e),l=Us(t),u=a?m:hi(e),c=l?m:hi(t),d=(u=u==f?k:u)==k,h=(c=c==f?k:c)==k,p=u==c;if(p&&Vs(e)){if(!Vs(t))return!1;a=!0,d=!1}if(p&&!d)return s||(s=new Vn),a||la(e)?Xo(e,t,n,r,i,s):function(e,t,n,r,o,i,s){switch(n){case _:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case D:return!(e.byteLength!=t.byteLength||!i(new qe(e),new qe(t)));case y:case w:case I:return Ns(+e,+t);case v:return e.name==t.name&&e.message==t.message;case x:case E:return e==t+"";case S:var a=on;case A:var l=1&r;if(a||(a=ln),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var c=Xo(a(e),a(t),r,o,i,s);return s.delete(e),c;case W:if(Fn)return Fn.call(e)==Fn.call(t)}return!1}(e,t,u,n,r,i,s);if(!(1&n)){var g=d&&Pe.call(e,"__wrapped__"),b=h&&Pe.call(t,"__wrapped__");if(g||b){var C=g?e.value():e,T=b?t.value():t;return s||(s=new Vn),i(C,T,n,r,s)}}return!!p&&(s||(s=new Vn),function(e,t,n,r,i,s){var a=1&n,l=ti(e),u=l.length;if(u!=ti(t).length&&!a)return!1;for(var c=u;c--;){var d=l[c];if(!(a?d in t:Pe.call(t,d)))return!1}var h=s.get(e),p=s.get(t);if(h&&p)return h==t&&p==e;var g=!0;s.set(e,t),s.set(t,e);for(var f=a;++c<u;){var m=e[d=l[c]],y=t[d];if(r)var w=a?r(y,m,d,t,e,s):r(m,y,d,e,t,s);if(!(w===o?m===y||i(m,y,n,r,s):w)){g=!1;break}f||(f="constructor"==d)}if(g&&!f){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(g=!1)}return s.delete(e),s.delete(t),g}(e,t,n,r,i,s))}(e,t,n,r,Or,i))}function Dr(e,t,n,r){var i=n.length,s=i,a=!r;if(null==e)return!s;for(e=ke(e);i--;){var l=n[i];if(a&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++i<s;){var u=(l=n[i])[0],c=e[u],d=l[1];if(a&&l[2]){if(c===o&&!(u in e))return!1}else{var h=new Vn;if(r)var p=r(c,d,u,e,t,h);if(!(p===o?Or(d,c,3,r,h):p))return!1}}return!0}function _r(e){return!(!Xs(e)||(t=e,Le&&Le in t))&&(Ks(e)?Ne:fe).test(Mi(e));var t}function Pr(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Us(e)?$r(e[0],e[1]):Mr(e):dl(e)}function Rr(e){if(!Ci(e))return fn(e);var t=[];for(var n in ke(e))Pe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Lr(e,t){return e<t}function Fr(e,t){var n=-1,o=Gs(e)?r(e.length):[];return cr(e,function(e,r,i){o[++n]=t(e,r,i)}),o}function Mr(e){var t=li(e);return 1==t.length&&t[0][2]?Ii(t[0][0],t[0][1]):function(n){return n===e||Dr(n,e,t)}}function $r(e,t){return wi(e)&&Si(t)?Ii(Fi(e),t):function(n){var r=Ta(n,e);return r===o&&r===t?xa(n,e):Or(t,r,3)}}function Nr(e,t,n,r,i){e!==t&&mr(t,function(s,a){if(i||(i=new Vn),Xs(s))!function(e,t,n,r,i,s,a){var l=xi(e,n),u=xi(t,n),c=a.get(u);if(c)Zn(e,n,c);else{var d=s?s(l,u,n+"",e,t,a):o,h=d===o;if(h){var p=Us(u),g=!p&&Vs(u),f=!p&&!g&&la(u);d=u,p||g||f?Us(l)?d=l:Hs(l)?d=Ao(l):g?(h=!1,d=Co(u,!0)):f?(h=!1,d=Io(u,!0)):d=[]:ra(u)||qs(u)?(d=l,qs(l)?d=ma(l):Xs(l)&&!Ks(l)||(d=gi(u))):h=!1}h&&(a.set(u,d),i(d,u,r,s,a),a.delete(u)),Zn(e,n,d)}}(e,t,a,n,Nr,r,i);else{var l=r?r(xi(e,a),s,a+"",e,t,i):o;l===o&&(l=s),Zn(e,a,l)}},Da)}function jr(e,t){var n=e.length;if(n)return mi(t+=t<0?n:0,n)?e[t]:o}function Br(e,t,n){t=t.length?Dt(t,function(e){return Us(e)?function(t){return Cr(t,1===e.length?e[0]:e)}:e}):[nl];var r=-1;t=Dt(t,Jt(si()));var o=Fr(e,function(e,n,o){var i=Dt(t,function(t){return t(e)});return{criteria:i,index:++r,value:e}});return function(e){var t=e.length;for(e.sort(function(e,t){return function(e,t,n){for(var r=-1,o=e.criteria,i=t.criteria,s=o.length,a=n.length;++r<s;){var l=ko(o[r],i[r]);if(l)return r>=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)});t--;)e[t]=e[t].value;return e}(o)}function qr(e,t,n){for(var r=-1,o=t.length,i={};++r<o;){var s=t[r],a=Cr(e,s);n(a,s)&&Kr(i,yo(s,e),a)}return i}function Ur(e,t,n,r){var o=r?jt:Nt,i=-1,s=t.length,a=e;for(e===t&&(t=Ao(t)),n&&(a=Dt(e,Jt(n)));++i<s;)for(var l=0,u=t[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==e&&Ve.call(a,l,1),Ve.call(e,l,1);return e}function zr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var o=t[n];if(n==r||o!==i){var i=o;mi(o)?Ve.call(e,o,1):lo(e,o)}}return e}function Gr(e,t){return e+pt(bn()*(t-e+1))}function Hr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Vr(e,t){return Wi(ki(e,t,nl),e+"")}function Qr(e){return Jn(Na(e))}function Jr(e,t){var n=Na(e);return _i(n,ir(t,0,n.length))}function Kr(e,t,n,r){if(!Xs(e))return e;for(var i=-1,s=(t=yo(t,e)).length,a=s-1,l=e;null!=l&&++i<s;){var u=Fi(t[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return e;if(i!=a){var d=l[u];(c=r?r(d,u,l):o)===o&&(c=Xs(d)?d:mi(t[i+1])?[]:{})}Xn(l,u,c),l=l[u]}return e}var Yr=En?function(e,t){return En.set(e,t),e}:nl,Zr=et?function(e,t){return et(e,"toString",{configurable:!0,enumerable:!1,value:Xa(t),writable:!0})}:nl;function Xr(e){return _i(Na(e))}function eo(e,t,n){var o=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=r(i);++o<i;)s[o]=e[o+t];return s}function to(e,t){var n;return cr(e,function(e,r,o){return!(n=t(e,r,o))}),!!n}function no(e,t,n){var r=0,o=null==e?r:e.length;if("number"==typeof t&&t==t&&o<=2147483647){for(;r<o;){var i=r+o>>>1,s=e[i];null!==s&&!aa(s)&&(n?s<=t:s<t)?r=i+1:o=i}return o}return ro(e,t,nl,n)}function ro(e,t,n,r){var i=0,s=null==e?0:e.length;if(0===s)return 0;for(var a=(t=n(t))!=t,l=null===t,u=aa(t),c=t===o;i<s;){var d=pt((i+s)/2),h=n(e[d]),p=h!==o,g=null===h,f=h==h,m=aa(h);if(a)var y=r||f;else y=c?f&&(r||p):l?f&&p&&(r||!g):u?f&&p&&!g&&(r||!m):!g&&!m&&(r?h<=t:h<t);y?i=d+1:s=d}return yn(s,4294967294)}function oo(e,t){for(var n=-1,r=e.length,o=0,i=[];++n<r;){var s=e[n],a=t?t(s):s;if(!n||!Ns(a,l)){var l=a;i[o++]=0===s?0:s}}return i}function io(e){return"number"==typeof e?e:aa(e)?h:+e}function so(e){if("string"==typeof e)return e;if(Us(e))return Dt(e,so)+"";if(aa(e))return Mn?Mn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ao(e,t,n){var r=-1,o=Wt,i=e.length,s=!0,a=[],l=a;if(n)s=!1,o=Ot;else if(i>=200){var u=t?null:Vo(e);if(u)return ln(u);s=!1,o=Yt,l=new Hn}else l=t?[]:a;e:for(;++r<i;){var c=e[r],d=t?t(c):c;if(c=n||0!==c?c:0,s&&d==d){for(var h=l.length;h--;)if(l[h]===d)continue e;t&&l.push(d),a.push(c)}else o(l,d,n)||(l!==a&&l.push(d),a.push(c))}return a}function lo(e,t){return null==(e=Ti(e,t=yo(t,e)))||delete e[Fi(Ji(t))]}function uo(e,t,n,r){return Kr(e,t,n(Cr(e,t)),r)}function co(e,t,n,r){for(var o=e.length,i=r?o:-1;(r?i--:++i<o)&&t(e[i],i,e););return n?eo(e,r?0:i,r?i+1:o):eo(e,r?i+1:0,r?o:i)}function ho(e,t){var n=e;return n instanceof qn&&(n=n.value()),Pt(t,function(e,t){return t.func.apply(t.thisArg,_t([e],t.args))},n)}function po(e,t,n){var o=e.length;if(o<2)return o?ao(e[0]):[];for(var i=-1,s=r(o);++i<o;)for(var a=e[i],l=-1;++l<o;)l!=i&&(s[i]=ur(s[i]||a,e[l],t,n));return ao(fr(s,1),t,n)}function go(e,t,n){for(var r=-1,i=e.length,s=t.length,a={};++r<i;){var l=r<s?t[r]:o;n(a,e[r],l)}return a}function fo(e){return Hs(e)?e:[]}function mo(e){return"function"==typeof e?e:nl}function yo(e,t){return Us(e)?e:wi(e,t)?[e]:Li(ya(e))}var wo=Vr;function vo(e,t,n){var r=e.length;return n=n===o?r:n,!t&&n>=r?e:eo(e,t,n)}var bo=st||function(e){return dt.clearTimeout(e)};function Co(e,t){if(t)return e.slice();var n=e.length,r=Ue?Ue(n):new e.constructor(n);return e.copy(r),r}function So(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function Io(e,t){var n=t?So(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ko(e,t){if(e!==t){var n=e!==o,r=null===e,i=e==e,s=aa(e),a=t!==o,l=null===t,u=t==t,c=aa(t);if(!l&&!c&&!s&&e>t||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&e<t||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(e,t,n,o){for(var i=-1,s=e.length,a=n.length,l=-1,u=t.length,c=mn(s-a,0),d=r(u+c),h=!o;++l<u;)d[l]=t[l];for(;++i<a;)(h||i<s)&&(d[n[i]]=e[i]);for(;c--;)d[l++]=e[i++];return d}function xo(e,t,n,o){for(var i=-1,s=e.length,a=-1,l=n.length,u=-1,c=t.length,d=mn(s-l,0),h=r(d+c),p=!o;++i<d;)h[i]=e[i];for(var g=i;++u<c;)h[g+u]=t[u];for(;++a<l;)(p||i<s)&&(h[g+n[a]]=e[i++]);return h}function Ao(e,t){var n=-1,o=e.length;for(t||(t=r(o));++n<o;)t[n]=e[n];return t}function Eo(e,t,n,r){var i=!n;n||(n={});for(var s=-1,a=t.length;++s<a;){var l=t[s],u=r?r(n[l],e[l],l,n,e):o;u===o&&(u=e[l]),i?rr(n,l,u):Xn(n,l,u)}return n}function Wo(e,t){return function(n,r){var o=Us(n)?kt:tr,i=t?t():{};return o(n,e,si(r,2),i)}}function Oo(e){return Vr(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:o,a=i>2?n[2]:o;for(s=e.length>3&&"function"==typeof s?(i--,s):o,a&&yi(n[0],n[1],a)&&(s=i<3?o:s,i=1),t=ke(t);++r<i;){var l=n[r];l&&e(t,l,r,s)}return t})}function Do(e,t){return function(n,r){if(null==n)return n;if(!Gs(n))return e(n,r);for(var o=n.length,i=t?o:-1,s=ke(n);(t?i--:++i<o)&&!1!==r(s[i],i,s););return n}}function _o(e){return function(t,n,r){for(var o=-1,i=ke(t),s=r(t),a=s.length;a--;){var l=s[e?a:++o];if(!1===n(i[l],l,i))break}return t}}function Po(e){return function(t){var n=rn(t=ya(t))?dn(t):o,r=n?n[0]:t.charAt(0),i=n?vo(n,1).join(""):t.slice(1);return r[e]()+i}}function Ro(e){return function(t){return Pt(Ka(qa(t).replace(Ke,"")),e,"")}}function Lo(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Nn(e.prototype),r=e.apply(n,t);return Xs(r)?r:n}}function Fo(e){return function(t,n,r){var i=ke(t);if(!Gs(t)){var s=si(n,3);t=Oa(t),n=function(e){return s(i[e],e,i)}}var a=e(t,n,r);return a>-1?i[s?t[a]:a]:o}}function Mo(e){return ei(function(t){var n=t.length,r=n,s=Bn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(i);if(s&&!l&&"wrapper"==oi(a))var l=new Bn([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=t[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var e=arguments,r=e[0];if(l&&1==e.length&&Us(r))return l.plant(r).value();for(var o=0,i=n?t[o].apply(this,e):r;++o<n;)i=t[o].call(this,i);return i}})}function $o(e,t,n,i,s,a,l,c,d,h){var p=t&u,g=1&t,f=2&t,m=24&t,y=512&t,w=f?o:Lo(e);return function u(){for(var v=arguments.length,b=r(v),C=v;C--;)b[C]=arguments[C];if(m)var S=ii(u),I=function(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}(b,S);if(i&&(b=To(b,i,s,m)),a&&(b=xo(b,a,l,m)),v-=I,m&&v<h){var k=an(b,S);return Go(e,t,$o,u.placeholder,n,b,k,c,d,h-v)}var T=g?n:this,x=f?T[e]:e;return v=b.length,c?b=function(e,t){for(var n=e.length,r=yn(t.length,n),i=Ao(e);r--;){var s=t[r];e[r]=mi(s,n)?i[s]:o}return e}(b,c):y&&v>1&&b.reverse(),p&&d<v&&(b.length=d),this&&this!==dt&&this instanceof u&&(x=w||Lo(x)),x.apply(T,b)}}function No(e,t){return function(n,r){return function(e,t,n,r){return wr(e,function(e,o,i){t(r,n(e),o,i)}),r}(n,e,t(r),{})}}function jo(e,t){return function(n,r){var i;if(n===o&&r===o)return t;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=so(n),r=so(r)):(n=io(n),r=io(r)),i=e(n,r)}return i}}function Bo(e){return ei(function(t){return t=Dt(t,Jt(si())),Vr(function(n){var r=this;return e(t,function(e){return It(e,r,n)})})})}function qo(e,t){var n=(t=t===o?" ":so(t)).length;if(n<2)return n?Hr(t,e):t;var r=Hr(t,ht(e/cn(t)));return rn(t)?vo(dn(r),0,e).join(""):r.slice(0,e)}function Uo(e){return function(t,n,i){return i&&"number"!=typeof i&&yi(t,n,i)&&(n=i=o),t=ha(t),n===o?(n=t,t=0):n=ha(n),function(e,t,n,o){for(var i=-1,s=mn(ht((t-e)/(n||1)),0),a=r(s);s--;)a[o?s:++i]=e,e+=n;return a}(t,n,i=i===o?t<n?1:-1:ha(i),e)}}function zo(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=fa(t),n=fa(n)),e(t,n)}}function Go(e,t,n,r,i,s,a,u,c,d){var h=8&t;t|=h?l:64,4&(t&=~(h?64:l))||(t&=-4);var p=[e,t,i,h?s:o,h?a:o,h?o:s,h?o:a,u,c,d],g=n.apply(o,p);return vi(e)&&Ai(g,p),g.placeholder=r,Oi(g,e,t)}function Ho(e){var t=Ie[e];return function(e,n){if(e=fa(e),(n=null==n?0:yn(pa(n),292))&&Ft(e)){var r=(ya(e)+"e").split("e");return+((r=(ya(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Vo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(e){return new Tn(e)}:al;function Qo(e){return function(t){var n=hi(t);return n==S?on(t):n==A?un(t):function(e,t){return Dt(t,function(t){return[t,e[t]]})}(t,e(t))}}function Jo(e,t,n,s,c,d,h,p){var g=2&t;if(!g&&"function"!=typeof e)throw new Ae(i);var f=s?s.length:0;if(f||(t&=-97,s=c=o),h=h===o?h:mn(pa(h),0),p=p===o?p:pa(p),f-=c?c.length:0,64&t){var m=s,y=c;s=c=o}var w=g?o:ri(e),v=[e,t,n,s,c,m,y,d,h,p];if(w&&function(e,t){var n=e[1],r=t[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&256==n&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!i&&!s)return e;1&r&&(e[2]=t[2],o|=1&n?0:4);var l=t[3];if(l){var c=e[3];e[3]=c?To(c,l,t[4]):l,e[4]=c?an(e[3],a):t[4]}(l=t[5])&&(c=e[5],e[5]=c?xo(c,l,t[6]):l,e[6]=c?an(e[5],a):t[6]),(l=t[7])&&(e[7]=l),r&u&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=o}(v,w),e=v[0],t=v[1],n=v[2],s=v[3],c=v[4],!(p=v[9]=v[9]===o?g?0:e.length:mn(v[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)b=8==t||16==t?function(e,t,n){var i=Lo(e);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var d=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=d.length)<n?Go(e,t,$o,s.placeholder,o,l,d,o,o,n-a):It(this&&this!==dt&&this instanceof s?i:e,this,l)}}(e,t,p):t!=l&&33!=t||c.length?$o.apply(o,v):function(e,t,n,o){var i=1&t,s=Lo(e);return function t(){for(var a=-1,l=arguments.length,u=-1,c=o.length,d=r(c+l),h=this&&this!==dt&&this instanceof t?s:e;++u<c;)d[u]=o[u];for(;l--;)d[u++]=arguments[++a];return It(h,i?n:this,d)}}(e,t,n,s);else var b=function(e,t,n){var r=1&t,o=Lo(e);return function t(){return(this&&this!==dt&&this instanceof t?o:e).apply(r?n:this,arguments)}}(e,t,n);return Oi((w?Yr:Ai)(b,v),e,t)}function Ko(e,t,n,r){return e===o||Ns(e,Oe[n])&&!Pe.call(r,n)?t:e}function Yo(e,t,n,r,i,s){return Xs(e)&&Xs(t)&&(s.set(t,e),Nr(e,t,o,Yo,s),s.delete(t)),e}function Zo(e){return ra(e)?o:e}function Xo(e,t,n,r,i,s){var a=1&n,l=e.length,u=t.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(e),d=s.get(t);if(c&&d)return c==t&&d==e;var h=-1,p=!0,g=2&n?new Hn:o;for(s.set(e,t),s.set(t,e);++h<l;){var f=e[h],m=t[h];if(r)var y=a?r(m,f,h,t,e,s):r(f,m,h,e,t,s);if(y!==o){if(y)continue;p=!1;break}if(g){if(!Lt(t,function(e,t){if(!Yt(g,t)&&(f===e||i(f,e,n,r,s)))return g.push(t)})){p=!1;break}}else if(f!==m&&!i(f,m,n,r,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function ei(e){return Wi(ki(e,o,zi),e+"")}function ti(e){return Sr(e,Oa,ci)}function ni(e){return Sr(e,Da,di)}var ri=En?function(e){return En.get(e)}:al;function oi(e){for(var t=e.name+"",n=Wn[t],r=Pe.call(Wn,t)?n.length:0;r--;){var o=n[r],i=o.func;if(null==i||i==e)return o.name}return t}function ii(e){return(Pe.call($n,"placeholder")?$n:e).placeholder}function si(){var e=$n.iteratee||rl;return e=e===rl?Pr:e,arguments.length?e(arguments[0],arguments[1]):e}function ai(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function li(e){for(var t=Oa(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,Si(o)]}return t}function ui(e,t){var n=function(e,t){return null==e?o:e[t]}(e,t);return _r(n)?n:o}var ci=ft?function(e){return null==e?[]:(e=ke(e),Et(ft(e),function(t){return He.call(e,t)}))}:gl,di=ft?function(e){for(var t=[];e;)_t(t,ci(e)),e=ze(e);return t}:gl,hi=Ir;function pi(e,t,n){for(var r=-1,o=(t=yo(t,e)).length,i=!1;++r<o;){var s=Fi(t[r]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++r!=o?i:!!(o=null==e?0:e.length)&&Zs(o)&&mi(s,o)&&(Us(e)||qs(e))}function gi(e){return"function"!=typeof e.constructor||Ci(e)?{}:Nn(ze(e))}function fi(e){return Us(e)||qs(e)||!!(Qe&&e&&e[Qe])}function mi(e,t){var n=typeof e;return!!(t=null==t?d:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function yi(e,t,n){if(!Xs(n))return!1;var r=typeof t;return!!("number"==r?Gs(n)&&mi(t,n.length):"string"==r&&t in n)&&Ns(n[t],e)}function wi(e,t){if(Us(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!aa(e))||X.test(e)||!Z.test(e)||null!=t&&e in ke(t)}function vi(e){var t=oi(e),n=$n[t];if("function"!=typeof n||!(t in qn.prototype))return!1;if(e===n)return!0;var r=ri(n);return!!r&&e===r[0]}(Sn&&hi(new Sn(new ArrayBuffer(1)))!=_||In&&hi(new In)!=S||kn&&hi(kn.resolve())!=T||Tn&&hi(new Tn)!=A||xn&&hi(new xn)!=O)&&(hi=function(e){var t=Ir(e),n=t==k?e.constructor:o,r=n?Mi(n):"";if(r)switch(r){case On:return _;case Dn:return S;case _n:return T;case Pn:return A;case Rn:return O}return t});var bi=De?Ks:fl;function Ci(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function Si(e){return e==e&&!Xs(e)}function Ii(e,t){return function(n){return null!=n&&n[e]===t&&(t!==o||e in ke(n))}}function ki(e,t,n){return t=mn(t===o?e.length-1:t,0),function(){for(var o=arguments,i=-1,s=mn(o.length-t,0),a=r(s);++i<s;)a[i]=o[t+i];i=-1;for(var l=r(t+1);++i<t;)l[i]=o[i];return l[t]=n(a),It(e,this,l)}}function Ti(e,t){return t.length<2?e:Cr(e,eo(t,0,-1))}function xi(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ai=Di(Yr),Ei=ct||function(e,t){return dt.setTimeout(e,t)},Wi=Di(Zr);function Oi(e,t,n){var r=t+"";return Wi(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return Tt(g,function(n){var r="_."+n[0];t&n[1]&&!Wt(e,r)&&e.push(r)}),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Di(e){var t=0,n=0;return function(){var r=wn(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(o,arguments)}}function _i(e,t){var n=-1,r=e.length,i=r-1;for(t=t===o?r:t;++n<t;){var s=Gr(n,i),a=e[s];e[s]=e[n],e[n]=a}return e.length=t,e}var Pi,Ri,Li=(Pi=Ps(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,function(e,n,r,o){t.push(r?o.replace(ce,"$1"):n||e)}),t},function(e){return 500===Ri.size&&Ri.clear(),e}),Ri=Pi.cache,Pi);function Fi(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Mi(e){if(null!=e){try{return _e.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $i(e){if(e instanceof qn)return e.clone();var t=new Bn(e.__wrapped__,e.__chain__);return t.__actions__=Ao(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ni=Vr(function(e,t){return Hs(e)?ur(e,fr(t,1,Hs,!0)):[]}),ji=Vr(function(e,t){var n=Ji(t);return Hs(n)&&(n=o),Hs(e)?ur(e,fr(t,1,Hs,!0),si(n,2)):[]}),Bi=Vr(function(e,t){var n=Ji(t);return Hs(n)&&(n=o),Hs(e)?ur(e,fr(t,1,Hs,!0),o,n):[]});function qi(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=mn(r+o,0)),$t(e,si(t,3),o)}function Ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r-1;return n!==o&&(i=pa(n),i=n<0?mn(r+i,0):yn(i,r-1)),$t(e,si(t,3),i,!0)}function zi(e){return null!=e&&e.length?fr(e,1):[]}function Gi(e){return e&&e.length?e[0]:o}var Hi=Vr(function(e){var t=Dt(e,fo);return t.length&&t[0]===e[0]?Ar(t):[]}),Vi=Vr(function(e){var t=Ji(e),n=Dt(e,fo);return t===Ji(n)?t=o:n.pop(),n.length&&n[0]===e[0]?Ar(n,si(t,2)):[]}),Qi=Vr(function(e){var t=Ji(e),n=Dt(e,fo);return(t="function"==typeof t?t:o)&&n.pop(),n.length&&n[0]===e[0]?Ar(n,o,t):[]});function Ji(e){var t=null==e?0:e.length;return t?e[t-1]:o}var Ki=Vr(Yi);function Yi(e,t){return e&&e.length&&t&&t.length?Ur(e,t):e}var Zi=ei(function(e,t){var n=null==e?0:e.length,r=or(e,t);return zr(e,Dt(t,function(e){return mi(e,n)?+e:e}).sort(ko)),r});function Xi(e){return null==e?e:Cn.call(e)}var es=Vr(function(e){return ao(fr(e,1,Hs,!0))}),ts=Vr(function(e){var t=Ji(e);return Hs(t)&&(t=o),ao(fr(e,1,Hs,!0),si(t,2))}),ns=Vr(function(e){var t=Ji(e);return t="function"==typeof t?t:o,ao(fr(e,1,Hs,!0),o,t)});function rs(e){if(!e||!e.length)return[];var t=0;return e=Et(e,function(e){if(Hs(e))return t=mn(e.length,t),!0}),Vt(t,function(t){return Dt(e,Ut(t))})}function os(e,t){if(!e||!e.length)return[];var n=rs(e);return null==t?n:Dt(n,function(e){return It(t,o,e)})}var is=Vr(function(e,t){return Hs(e)?ur(e,t):[]}),ss=Vr(function(e){return po(Et(e,Hs))}),as=Vr(function(e){var t=Ji(e);return Hs(t)&&(t=o),po(Et(e,Hs),si(t,2))}),ls=Vr(function(e){var t=Ji(e);return t="function"==typeof t?t:o,po(Et(e,Hs),o,t)}),us=Vr(rs),cs=Vr(function(e){var t=e.length,n=t>1?e[t-1]:o;return n="function"==typeof n?(e.pop(),n):o,os(e,n)});function ds(e){var t=$n(e);return t.__chain__=!0,t}function hs(e,t){return t(e)}var ps=ei(function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof qn&&mi(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:hs,args:[i],thisArg:o}),new Bn(r,this.__chain__).thru(function(e){return t&&!e.length&&e.push(o),e})):this.thru(i)}),gs=Wo(function(e,t,n){Pe.call(e,n)?++e[n]:rr(e,n,1)}),fs=Fo(qi),ms=Fo(Ui);function ys(e,t){return(Us(e)?Tt:cr)(e,si(t,3))}function ws(e,t){return(Us(e)?xt:dr)(e,si(t,3))}var vs=Wo(function(e,t,n){Pe.call(e,n)?e[n].push(t):rr(e,n,[t])}),bs=Vr(function(e,t,n){var o=-1,i="function"==typeof t,s=Gs(e)?r(e.length):[];return cr(e,function(e){s[++o]=i?It(t,e,n):Er(e,t,n)}),s}),Cs=Wo(function(e,t,n){rr(e,n,t)});function Ss(e,t){return(Us(e)?Dt:Fr)(e,si(t,3))}var Is=Wo(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),ks=Vr(function(e,t){if(null==e)return[];var n=t.length;return n>1&&yi(e,t[0],t[1])?t=[]:n>2&&yi(t[0],t[1],t[2])&&(t=[t[0]]),Br(e,fr(t,1),[])}),Ts=ut||function(){return dt.Date.now()};function xs(e,t,n){return t=n?o:t,t=e&&null==t?e.length:t,Jo(e,u,o,o,o,o,t)}function As(e,t){var n;if("function"!=typeof t)throw new Ae(i);return e=pa(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=o),n}}var Es=Vr(function(e,t,n){var r=1;if(n.length){var o=an(n,ii(Es));r|=l}return Jo(e,r,t,n,o)}),Ws=Vr(function(e,t,n){var r=3;if(n.length){var o=an(n,ii(Ws));r|=l}return Jo(t,r,e,n,o)});function Os(e,t,n){var r,s,a,l,u,c,d=0,h=!1,p=!1,g=!0;if("function"!=typeof e)throw new Ae(i);function f(t){var n=r,i=s;return r=s=o,d=t,l=e.apply(i,n)}function m(e){var n=e-c;return c===o||n>=t||n<0||p&&e-d>=a}function y(){var e=Ts();if(m(e))return w(e);u=Ei(y,function(e){var n=t-(e-c);return p?yn(n,a-(e-d)):n}(e))}function w(e){return u=o,g&&r?f(e):(r=s=o,l)}function v(){var e=Ts(),n=m(e);if(r=arguments,s=this,c=e,n){if(u===o)return function(e){return d=e,u=Ei(y,t),h?f(e):l}(c);if(p)return bo(u),u=Ei(y,t),f(c)}return u===o&&(u=Ei(y,t)),l}return t=fa(t)||0,Xs(n)&&(h=!!n.leading,a=(p="maxWait"in n)?mn(fa(n.maxWait)||0,t):a,g="trailing"in n?!!n.trailing:g),v.cancel=function(){u!==o&&bo(u),d=0,r=c=s=u=o},v.flush=function(){return u===o?l:w(Ts())},v}var Ds=Vr(function(e,t){return lr(e,1,t)}),_s=Vr(function(e,t,n){return lr(e,fa(t)||0,n)});function Ps(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(i);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Ps.Cache||Gn),n}function Rs(e){if("function"!=typeof e)throw new Ae(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ps.Cache=Gn;var Ls=wo(function(e,t){var n=(t=1==t.length&&Us(t[0])?Dt(t[0],Jt(si())):Dt(fr(t,1),Jt(si()))).length;return Vr(function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=t[o].call(this,r[o]);return It(e,this,r)})}),Fs=Vr(function(e,t){var n=an(t,ii(Fs));return Jo(e,l,o,t,n)}),Ms=Vr(function(e,t){var n=an(t,ii(Ms));return Jo(e,64,o,t,n)}),$s=ei(function(e,t){return Jo(e,256,o,o,o,t)});function Ns(e,t){return e===t||e!=e&&t!=t}var js=zo(kr),Bs=zo(function(e,t){return e>=t}),qs=Wr(function(){return arguments}())?Wr:function(e){return ea(e)&&Pe.call(e,"callee")&&!He.call(e,"callee")},Us=r.isArray,zs=yt?Jt(yt):function(e){return ea(e)&&Ir(e)==D};function Gs(e){return null!=e&&Zs(e.length)&&!Ks(e)}function Hs(e){return ea(e)&&Gs(e)}var Vs=mt||fl,Qs=wt?Jt(wt):function(e){return ea(e)&&Ir(e)==w};function Js(e){if(!ea(e))return!1;var t=Ir(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!ra(e)}function Ks(e){if(!Xs(e))return!1;var t=Ir(e);return t==b||t==C||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==pa(e)}function Zs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function Xs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=vt?Jt(vt):function(e){return ea(e)&&hi(e)==S};function na(e){return"number"==typeof e||ea(e)&&Ir(e)==I}function ra(e){if(!ea(e)||Ir(e)!=k)return!1;var t=ze(e);if(null===t)return!0;var n=Pe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&_e.call(n)==Me}var oa=bt?Jt(bt):function(e){return ea(e)&&Ir(e)==x},ia=Ct?Jt(Ct):function(e){return ea(e)&&hi(e)==A};function sa(e){return"string"==typeof e||!Us(e)&&ea(e)&&Ir(e)==E}function aa(e){return"symbol"==typeof e||ea(e)&&Ir(e)==W}var la=St?Jt(St):function(e){return ea(e)&&Zs(e.length)&&!!ot[Ir(e)]},ua=zo(Lr),ca=zo(function(e,t){return e<=t});function da(e){if(!e)return[];if(Gs(e))return sa(e)?dn(e):Ao(e);if(Je&&e[Je])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Je]());var t=hi(e);return(t==S?on:t==A?ln:Na)(e)}function ha(e){return e?(e=fa(e))===c||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=ha(e),n=t%1;return t==t?n?t-n:t:0}function ga(e){return e?ir(pa(e),0,p):0}function fa(e){if("number"==typeof e)return e;if(aa(e))return h;if(Xs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Xs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var n=ge.test(e);return n||me.test(e)?lt(e.slice(2),n?2:8):pe.test(e)?h:+e}function ma(e){return Eo(e,Da(e))}function ya(e){return null==e?"":so(e)}var wa=Oo(function(e,t){if(Ci(t)||Gs(t))Eo(t,Oa(t),e);else for(var n in t)Pe.call(t,n)&&Xn(e,n,t[n])}),va=Oo(function(e,t){Eo(t,Da(t),e)}),ba=Oo(function(e,t,n,r){Eo(t,Da(t),e,r)}),Ca=Oo(function(e,t,n,r){Eo(t,Oa(t),e,r)}),Sa=ei(or),Ia=Vr(function(e,t){e=ke(e);var n=-1,r=t.length,i=r>2?t[2]:o;for(i&&yi(t[0],t[1],i)&&(r=1);++n<r;)for(var s=t[n],a=Da(s),l=-1,u=a.length;++l<u;){var c=a[l],d=e[c];(d===o||Ns(d,Oe[c])&&!Pe.call(e,c))&&(e[c]=s[c])}return e}),ka=Vr(function(e){return e.push(o,Yo),It(Pa,o,e)});function Ta(e,t,n){var r=null==e?o:Cr(e,t);return r===o?n:r}function xa(e,t){return null!=e&&pi(e,t,xr)}var Aa=No(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Fe.call(t)),e[t]=n},Xa(nl)),Ea=No(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Fe.call(t)),Pe.call(e,t)?e[t].push(n):e[t]=[n]},si),Wa=Vr(Er);function Oa(e){return Gs(e)?Qn(e):Rr(e)}function Da(e){return Gs(e)?Qn(e,!0):function(e){if(!Xs(e))return function(e){var t=[];if(null!=e)for(var n in ke(e))t.push(n);return t}(e);var t=Ci(e),n=[];for(var r in e)("constructor"!=r||!t&&Pe.call(e,r))&&n.push(r);return n}(e)}var _a=Oo(function(e,t,n){Nr(e,t,n)}),Pa=Oo(function(e,t,n,r){Nr(e,t,n,r)}),Ra=ei(function(e,t){var n={};if(null==e)return n;var r=!1;t=Dt(t,function(t){return t=yo(t,e),r||(r=t.length>1),t}),Eo(e,ni(e),n),r&&(n=sr(n,7,Zo));for(var o=t.length;o--;)lo(n,t[o]);return n}),La=ei(function(e,t){return null==e?{}:function(e,t){return qr(e,t,function(t,n){return xa(e,n)})}(e,t)});function Fa(e,t){if(null==e)return{};var n=Dt(ni(e),function(e){return[e]});return t=si(t),qr(e,n,function(e,n){return t(e,n[0])})}var Ma=Qo(Oa),$a=Qo(Da);function Na(e){return null==e?[]:Kt(e,Oa(e))}var ja=Ro(function(e,t,n){return t=t.toLowerCase(),e+(n?Ba(t):t)});function Ba(e){return Ja(ya(e).toLowerCase())}function qa(e){return(e=ya(e))&&e.replace(we,en).replace(Ye,"")}var Ua=Ro(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),za=Ro(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),Ga=Po("toLowerCase"),Ha=Ro(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),Va=Ro(function(e,t,n){return e+(n?" ":"")+Ja(t)}),Qa=Ro(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ja=Po("toUpperCase");function Ka(e,t,n){return e=ya(e),(t=n?o:t)===o?function(e){return tt.test(e)}(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ya=Vr(function(e,t){try{return It(e,o,t)}catch(e){return Js(e)?e:new Ce(e)}}),Za=ei(function(e,t){return Tt(t,function(t){t=Fi(t),rr(e,t,Es(e[t],e))}),e});function Xa(e){return function(){return e}}var el=Mo(),tl=Mo(!0);function nl(e){return e}function rl(e){return Pr("function"==typeof e?e:sr(e,1))}var ol=Vr(function(e,t){return function(n){return Er(n,e,t)}}),il=Vr(function(e,t){return function(n){return Er(e,n,t)}});function sl(e,t,n){var r=Oa(t),o=br(t,r);null!=n||Xs(t)&&(o.length||!r.length)||(n=t,t=e,e=this,o=br(t,Oa(t)));var i=!(Xs(n)&&"chain"in n&&!n.chain),s=Ks(e);return Tt(o,function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(i||t){var n=e(this.__wrapped__);return(n.__actions__=Ao(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_t([this.value()],arguments))})}),e}function al(){}var ll=Bo(Dt),ul=Bo(At),cl=Bo(Lt);function dl(e){return wi(e)?Ut(Fi(e)):function(e){return function(t){return Cr(t,e)}}(e)}var hl=Uo(),pl=Uo(!0);function gl(){return[]}function fl(){return!1}var ml,yl=jo(function(e,t){return e+t},0),wl=Ho("ceil"),vl=jo(function(e,t){return e/t},1),bl=Ho("floor"),Cl=jo(function(e,t){return e*t},1),Sl=Ho("round"),Il=jo(function(e,t){return e-t},0);return $n.after=function(e,t){if("function"!=typeof t)throw new Ae(i);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},$n.ary=xs,$n.assign=wa,$n.assignIn=va,$n.assignInWith=ba,$n.assignWith=Ca,$n.at=Sa,$n.before=As,$n.bind=Es,$n.bindAll=Za,$n.bindKey=Ws,$n.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Us(e)?e:[e]},$n.chain=ds,$n.chunk=function(e,t,n){t=(n?yi(e,t,n):t===o)?1:mn(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,l=r(ht(i/t));s<i;)l[a++]=eo(e,s,s+=t);return l},$n.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,o=[];++t<n;){var i=e[t];i&&(o[r++]=i)}return o},$n.concat=function(){var e=arguments.length;if(!e)return[];for(var t=r(e-1),n=arguments[0],o=e;o--;)t[o-1]=arguments[o];return _t(Us(n)?Ao(n):[n],fr(t,1))},$n.cond=function(e){var t=null==e?0:e.length,n=si();return e=t?Dt(e,function(e){if("function"!=typeof e[1])throw new Ae(i);return[n(e[0]),e[1]]}):[],Vr(function(n){for(var r=-1;++r<t;){var o=e[r];if(It(o[0],this,n))return It(o[1],this,n)}})},$n.conforms=function(e){return function(e){var t=Oa(e);return function(n){return ar(n,e,t)}}(sr(e,1))},$n.constant=Xa,$n.countBy=gs,$n.create=function(e,t){var n=Nn(e);return null==t?n:nr(n,t)},$n.curry=function e(t,n,r){var i=Jo(t,8,o,o,o,o,o,n=r?o:n);return i.placeholder=e.placeholder,i},$n.curryRight=function e(t,n,r){var i=Jo(t,16,o,o,o,o,o,n=r?o:n);return i.placeholder=e.placeholder,i},$n.debounce=Os,$n.defaults=Ia,$n.defaultsDeep=ka,$n.defer=Ds,$n.delay=_s,$n.difference=Ni,$n.differenceBy=ji,$n.differenceWith=Bi,$n.drop=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,(t=n||t===o?1:pa(t))<0?0:t,r):[]},$n.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,0,(t=r-(t=n||t===o?1:pa(t)))<0?0:t):[]},$n.dropRightWhile=function(e,t){return e&&e.length?co(e,si(t,3),!0,!0):[]},$n.dropWhile=function(e,t){return e&&e.length?co(e,si(t,3),!0):[]},$n.fill=function(e,t,n,r){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&yi(e,t,n)&&(n=0,r=i),function(e,t,n,r){var i=e.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:pa(r))<0&&(r+=i),r=n>r?0:ga(r);n<r;)e[n++]=t;return e}(e,t,n,r)):[]},$n.filter=function(e,t){return(Us(e)?Et:gr)(e,si(t,3))},$n.flatMap=function(e,t){return fr(Ss(e,t),1)},$n.flatMapDeep=function(e,t){return fr(Ss(e,t),c)},$n.flatMapDepth=function(e,t,n){return n=n===o?1:pa(n),fr(Ss(e,t),n)},$n.flatten=zi,$n.flattenDeep=function(e){return null!=e&&e.length?fr(e,c):[]},$n.flattenDepth=function(e,t){return null!=e&&e.length?fr(e,t=t===o?1:pa(t)):[]},$n.flip=function(e){return Jo(e,512)},$n.flow=el,$n.flowRight=tl,$n.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var o=e[t];r[o[0]]=o[1]}return r},$n.functions=function(e){return null==e?[]:br(e,Oa(e))},$n.functionsIn=function(e){return null==e?[]:br(e,Da(e))},$n.groupBy=vs,$n.initial=function(e){return null!=e&&e.length?eo(e,0,-1):[]},$n.intersection=Hi,$n.intersectionBy=Vi,$n.intersectionWith=Qi,$n.invert=Aa,$n.invertBy=Ea,$n.invokeMap=bs,$n.iteratee=rl,$n.keyBy=Cs,$n.keys=Oa,$n.keysIn=Da,$n.map=Ss,$n.mapKeys=function(e,t){var n={};return t=si(t,3),wr(e,function(e,r,o){rr(n,t(e,r,o),e)}),n},$n.mapValues=function(e,t){var n={};return t=si(t,3),wr(e,function(e,r,o){rr(n,r,t(e,r,o))}),n},$n.matches=function(e){return Mr(sr(e,1))},$n.matchesProperty=function(e,t){return $r(e,sr(t,1))},$n.memoize=Ps,$n.merge=_a,$n.mergeWith=Pa,$n.method=ol,$n.methodOf=il,$n.mixin=sl,$n.negate=Rs,$n.nthArg=function(e){return e=pa(e),Vr(function(t){return jr(t,e)})},$n.omit=Ra,$n.omitBy=function(e,t){return Fa(e,Rs(si(t)))},$n.once=function(e){return As(2,e)},$n.orderBy=function(e,t,n,r){return null==e?[]:(Us(t)||(t=null==t?[]:[t]),Us(n=r?o:n)||(n=null==n?[]:[n]),Br(e,t,n))},$n.over=ll,$n.overArgs=Ls,$n.overEvery=ul,$n.overSome=cl,$n.partial=Fs,$n.partialRight=Ms,$n.partition=Is,$n.pick=La,$n.pickBy=Fa,$n.property=dl,$n.propertyOf=function(e){return function(t){return null==e?o:Cr(e,t)}},$n.pull=Ki,$n.pullAll=Yi,$n.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Ur(e,t,si(n,2)):e},$n.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Ur(e,t,o,n):e},$n.pullAt=Zi,$n.range=hl,$n.rangeRight=pl,$n.rearg=$s,$n.reject=function(e,t){return(Us(e)?Et:gr)(e,Rs(si(t,3)))},$n.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,o=[],i=e.length;for(t=si(t,3);++r<i;){var s=e[r];t(s,r,e)&&(n.push(s),o.push(r))}return zr(e,o),n},$n.rest=function(e,t){if("function"!=typeof e)throw new Ae(i);return Vr(e,t=t===o?t:pa(t))},$n.reverse=Xi,$n.sampleSize=function(e,t,n){return t=(n?yi(e,t,n):t===o)?1:pa(t),(Us(e)?Kn:Jr)(e,t)},$n.set=function(e,t,n){return null==e?e:Kr(e,t,n)},$n.setWith=function(e,t,n,r){return r="function"==typeof r?r:o,null==e?e:Kr(e,t,n,r)},$n.shuffle=function(e){return(Us(e)?Yn:Xr)(e)},$n.slice=function(e,t,n){var r=null==e?0:e.length;return r?(n&&"number"!=typeof n&&yi(e,t,n)?(t=0,n=r):(t=null==t?0:pa(t),n=n===o?r:pa(n)),eo(e,t,n)):[]},$n.sortBy=ks,$n.sortedUniq=function(e){return e&&e.length?oo(e):[]},$n.sortedUniqBy=function(e,t){return e&&e.length?oo(e,si(t,2)):[]},$n.split=function(e,t,n){return n&&"number"!=typeof n&&yi(e,t,n)&&(t=n=o),(n=n===o?p:n>>>0)?(e=ya(e))&&("string"==typeof t||null!=t&&!oa(t))&&!(t=so(t))&&rn(e)?vo(dn(e),0,n):e.split(t,n):[]},$n.spread=function(e,t){if("function"!=typeof e)throw new Ae(i);return t=null==t?0:mn(pa(t),0),Vr(function(n){var r=n[t],o=vo(n,0,t);return r&&_t(o,r),It(e,this,o)})},$n.tail=function(e){var t=null==e?0:e.length;return t?eo(e,1,t):[]},$n.take=function(e,t,n){return e&&e.length?eo(e,0,(t=n||t===o?1:pa(t))<0?0:t):[]},$n.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?eo(e,(t=r-(t=n||t===o?1:pa(t)))<0?0:t,r):[]},$n.takeRightWhile=function(e,t){return e&&e.length?co(e,si(t,3),!1,!0):[]},$n.takeWhile=function(e,t){return e&&e.length?co(e,si(t,3)):[]},$n.tap=function(e,t){return t(e),e},$n.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new Ae(i);return Xs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Os(e,t,{leading:r,maxWait:t,trailing:o})},$n.thru=hs,$n.toArray=da,$n.toPairs=Ma,$n.toPairsIn=$a,$n.toPath=function(e){return Us(e)?Dt(e,Fi):aa(e)?[e]:Ao(Li(ya(e)))},$n.toPlainObject=ma,$n.transform=function(e,t,n){var r=Us(e),o=r||Vs(e)||la(e);if(t=si(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Xs(e)&&Ks(i)?Nn(ze(e)):{}}return(o?Tt:wr)(e,function(e,r,o){return t(n,e,r,o)}),n},$n.unary=function(e){return xs(e,1)},$n.union=es,$n.unionBy=ts,$n.unionWith=ns,$n.uniq=function(e){return e&&e.length?ao(e):[]},$n.uniqBy=function(e,t){return e&&e.length?ao(e,si(t,2)):[]},$n.uniqWith=function(e,t){return t="function"==typeof t?t:o,e&&e.length?ao(e,o,t):[]},$n.unset=function(e,t){return null==e||lo(e,t)},$n.unzip=rs,$n.unzipWith=os,$n.update=function(e,t,n){return null==e?e:uo(e,t,mo(n))},$n.updateWith=function(e,t,n,r){return r="function"==typeof r?r:o,null==e?e:uo(e,t,mo(n),r)},$n.values=Na,$n.valuesIn=function(e){return null==e?[]:Kt(e,Da(e))},$n.without=is,$n.words=Ka,$n.wrap=function(e,t){return Fs(mo(t),e)},$n.xor=ss,$n.xorBy=as,$n.xorWith=ls,$n.zip=us,$n.zipObject=function(e,t){return go(e||[],t||[],Xn)},$n.zipObjectDeep=function(e,t){return go(e||[],t||[],Kr)},$n.zipWith=cs,$n.entries=Ma,$n.entriesIn=$a,$n.extend=va,$n.extendWith=ba,sl($n,$n),$n.add=yl,$n.attempt=Ya,$n.camelCase=ja,$n.capitalize=Ba,$n.ceil=wl,$n.clamp=function(e,t,n){return n===o&&(n=t,t=o),n!==o&&(n=(n=fa(n))==n?n:0),t!==o&&(t=(t=fa(t))==t?t:0),ir(fa(e),t,n)},$n.clone=function(e){return sr(e,4)},$n.cloneDeep=function(e){return sr(e,5)},$n.cloneDeepWith=function(e,t){return sr(e,5,t="function"==typeof t?t:o)},$n.cloneWith=function(e,t){return sr(e,4,t="function"==typeof t?t:o)},$n.conformsTo=function(e,t){return null==t||ar(e,t,Oa(t))},$n.deburr=qa,$n.defaultTo=function(e,t){return null==e||e!=e?t:e},$n.divide=vl,$n.endsWith=function(e,t,n){e=ya(e),t=so(t);var r=e.length,i=n=n===o?r:ir(pa(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},$n.eq=Ns,$n.escape=function(e){return(e=ya(e))&&Q.test(e)?e.replace(H,tn):e},$n.escapeRegExp=function(e){return(e=ya(e))&&ne.test(e)?e.replace(te,"\\$&"):e},$n.every=function(e,t,n){var r=Us(e)?At:hr;return n&&yi(e,t,n)&&(t=o),r(e,si(t,3))},$n.find=fs,$n.findIndex=qi,$n.findKey=function(e,t){return Mt(e,si(t,3),wr)},$n.findLast=ms,$n.findLastIndex=Ui,$n.findLastKey=function(e,t){return Mt(e,si(t,3),vr)},$n.floor=bl,$n.forEach=ys,$n.forEachRight=ws,$n.forIn=function(e,t){return null==e?e:mr(e,si(t,3),Da)},$n.forInRight=function(e,t){return null==e?e:yr(e,si(t,3),Da)},$n.forOwn=function(e,t){return e&&wr(e,si(t,3))},$n.forOwnRight=function(e,t){return e&&vr(e,si(t,3))},$n.get=Ta,$n.gt=js,$n.gte=Bs,$n.has=function(e,t){return null!=e&&pi(e,t,Tr)},$n.hasIn=xa,$n.head=Gi,$n.identity=nl,$n.includes=function(e,t,n,r){e=Gs(e)?e:Na(e),n=n&&!r?pa(n):0;var o=e.length;return n<0&&(n=mn(o+n,0)),sa(e)?n<=o&&e.indexOf(t,n)>-1:!!o&&Nt(e,t,n)>-1},$n.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=null==n?0:pa(n);return o<0&&(o=mn(r+o,0)),Nt(e,t,o)},$n.inRange=function(e,t,n){return t=ha(t),n===o?(n=t,t=0):n=ha(n),function(e,t,n){return e>=yn(t,n)&&e<mn(t,n)}(e=fa(e),t,n)},$n.invoke=Wa,$n.isArguments=qs,$n.isArray=Us,$n.isArrayBuffer=zs,$n.isArrayLike=Gs,$n.isArrayLikeObject=Hs,$n.isBoolean=function(e){return!0===e||!1===e||ea(e)&&Ir(e)==y},$n.isBuffer=Vs,$n.isDate=Qs,$n.isElement=function(e){return ea(e)&&1===e.nodeType&&!ra(e)},$n.isEmpty=function(e){if(null==e)return!0;if(Gs(e)&&(Us(e)||"string"==typeof e||"function"==typeof e.splice||Vs(e)||la(e)||qs(e)))return!e.length;var t=hi(e);if(t==S||t==A)return!e.size;if(Ci(e))return!Rr(e).length;for(var n in e)if(Pe.call(e,n))return!1;return!0},$n.isEqual=function(e,t){return Or(e,t)},$n.isEqualWith=function(e,t,n){var r=(n="function"==typeof n?n:o)?n(e,t):o;return r===o?Or(e,t,o,n):!!r},$n.isError=Js,$n.isFinite=function(e){return"number"==typeof e&&Ft(e)},$n.isFunction=Ks,$n.isInteger=Ys,$n.isLength=Zs,$n.isMap=ta,$n.isMatch=function(e,t){return e===t||Dr(e,t,li(t))},$n.isMatchWith=function(e,t,n){return n="function"==typeof n?n:o,Dr(e,t,li(t),n)},$n.isNaN=function(e){return na(e)&&e!=+e},$n.isNative=function(e){if(bi(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return _r(e)},$n.isNil=function(e){return null==e},$n.isNull=function(e){return null===e},$n.isNumber=na,$n.isObject=Xs,$n.isObjectLike=ea,$n.isPlainObject=ra,$n.isRegExp=oa,$n.isSafeInteger=function(e){return Ys(e)&&e>=-9007199254740991&&e<=d},$n.isSet=ia,$n.isString=sa,$n.isSymbol=aa,$n.isTypedArray=la,$n.isUndefined=function(e){return e===o},$n.isWeakMap=function(e){return ea(e)&&hi(e)==O},$n.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==Ir(e)},$n.join=function(e,t){return null==e?"":zt.call(e,t)},$n.kebabCase=Ua,$n.last=Ji,$n.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=pa(n))<0?mn(r+i,0):yn(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):$t(e,Bt,i,!0)},$n.lowerCase=za,$n.lowerFirst=Ga,$n.lt=ua,$n.lte=ca,$n.max=function(e){return e&&e.length?pr(e,nl,kr):o},$n.maxBy=function(e,t){return e&&e.length?pr(e,si(t,2),kr):o},$n.mean=function(e){return qt(e,nl)},$n.meanBy=function(e,t){return qt(e,si(t,2))},$n.min=function(e){return e&&e.length?pr(e,nl,Lr):o},$n.minBy=function(e,t){return e&&e.length?pr(e,si(t,2),Lr):o},$n.stubArray=gl,$n.stubFalse=fl,$n.stubObject=function(){return{}},$n.stubString=function(){return""},$n.stubTrue=function(){return!0},$n.multiply=Cl,$n.nth=function(e,t){return e&&e.length?jr(e,pa(t)):o},$n.noConflict=function(){return dt._===this&&(dt._=$e),this},$n.noop=al,$n.now=Ts,$n.pad=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return qo(pt(o),n)+e+qo(ht(o),n)},$n.padEnd=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;return t&&r<t?e+qo(t-r,n):e},$n.padStart=function(e,t,n){e=ya(e);var r=(t=pa(t))?cn(e):0;return t&&r<t?qo(t-r,n)+e:e},$n.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),vn(ya(e).replace(re,""),t||0)},$n.random=function(e,t,n){if(n&&"boolean"!=typeof n&&yi(e,t,n)&&(t=n=o),n===o&&("boolean"==typeof t?(n=t,t=o):"boolean"==typeof e&&(n=e,e=o)),e===o&&t===o?(e=0,t=1):(e=ha(e),t===o?(t=e,e=0):t=ha(t)),e>t){var r=e;e=t,t=r}if(n||e%1||t%1){var i=bn();return yn(e+i*(t-e+at("1e-"+((i+"").length-1))),t)}return Gr(e,t)},$n.reduce=function(e,t,n){var r=Us(e)?Pt:Gt,o=arguments.length<3;return r(e,si(t,4),n,o,cr)},$n.reduceRight=function(e,t,n){var r=Us(e)?Rt:Gt,o=arguments.length<3;return r(e,si(t,4),n,o,dr)},$n.repeat=function(e,t,n){return t=(n?yi(e,t,n):t===o)?1:pa(t),Hr(ya(e),t)},$n.replace=function(){var e=arguments,t=ya(e[0]);return e.length<3?t:t.replace(e[1],e[2])},$n.result=function(e,t,n){var r=-1,i=(t=yo(t,e)).length;for(i||(i=1,e=o);++r<i;){var s=null==e?o:e[Fi(t[r])];s===o&&(r=i,s=n),e=Ks(s)?s.call(e):s}return e},$n.round=Sl,$n.runInContext=e,$n.sample=function(e){return(Us(e)?Jn:Qr)(e)},$n.size=function(e){if(null==e)return 0;if(Gs(e))return sa(e)?cn(e):e.length;var t=hi(e);return t==S||t==A?e.size:Rr(e).length},$n.snakeCase=Ha,$n.some=function(e,t,n){var r=Us(e)?Lt:to;return n&&yi(e,t,n)&&(t=o),r(e,si(t,3))},$n.sortedIndex=function(e,t){return no(e,t)},$n.sortedIndexBy=function(e,t,n){return ro(e,t,si(n,2))},$n.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=no(e,t);if(r<n&&Ns(e[r],t))return r}return-1},$n.sortedLastIndex=function(e,t){return no(e,t,!0)},$n.sortedLastIndexBy=function(e,t,n){return ro(e,t,si(n,2),!0)},$n.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=no(e,t,!0)-1;if(Ns(e[n],t))return n}return-1},$n.startCase=Va,$n.startsWith=function(e,t,n){return e=ya(e),n=null==n?0:ir(pa(n),0,e.length),t=so(t),e.slice(n,n+t.length)==t},$n.subtract=Il,$n.sum=function(e){return e&&e.length?Ht(e,nl):0},$n.sumBy=function(e,t){return e&&e.length?Ht(e,si(t,2)):0},$n.template=function(e,t,n){var r=$n.templateSettings;n&&yi(e,t,n)&&(t=o),e=ya(e),t=ba({},t,r,Ko);var i,s,a=ba({},t.imports,r.imports,Ko),l=Oa(a),u=Kt(a,l),c=0,d=t.interpolate||ve,h="__p += '",p=Te((t.escape||ve).source+"|"+d.source+"|"+(d===Y?de:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),g="//# sourceURL="+(Pe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(p,function(t,n,r,o,a,l){return r||(r=o),h+=e.slice(c,l).replace(be,nn),n&&(i=!0,h+="' +\n__e("+n+") +\n'"),a&&(s=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=l+t.length,t}),h+="';\n";var f=Pe.call(t,"variable")&&t.variable;if(f){if(ue.test(f))throw new Ce("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(s?h.replace(q,""):h).replace(U,"$1").replace(z,"$1;"),h="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=Ya(function(){return Se(l,g+"return "+h).apply(o,u)});if(m.source=h,Js(m))throw m;return m},$n.times=function(e,t){if((e=pa(e))<1||e>d)return[];var n=p,r=yn(e,p);t=si(t),e-=p;for(var o=Vt(r,t);++n<e;)t(n);return o},$n.toFinite=ha,$n.toInteger=pa,$n.toLength=ga,$n.toLower=function(e){return ya(e).toLowerCase()},$n.toNumber=fa,$n.toSafeInteger=function(e){return e?ir(pa(e),-9007199254740991,d):0===e?e:0},$n.toString=ya,$n.toUpper=function(e){return ya(e).toUpperCase()},$n.trim=function(e,t,n){if((e=ya(e))&&(n||t===o))return Qt(e);if(!e||!(t=so(t)))return e;var r=dn(e),i=dn(t);return vo(r,Zt(r,i),Xt(r,i)+1).join("")},$n.trimEnd=function(e,t,n){if((e=ya(e))&&(n||t===o))return e.slice(0,hn(e)+1);if(!e||!(t=so(t)))return e;var r=dn(e);return vo(r,0,Xt(r,dn(t))+1).join("")},$n.trimStart=function(e,t,n){if((e=ya(e))&&(n||t===o))return e.replace(re,"");if(!e||!(t=so(t)))return e;var r=dn(e);return vo(r,Zt(r,dn(t))).join("")},$n.truncate=function(e,t){var n=30,r="...";if(Xs(t)){var i="separator"in t?t.separator:i;n="length"in t?pa(t.length):n,r="omission"in t?so(t.omission):r}var s=(e=ya(e)).length;if(rn(e)){var a=dn(e);s=a.length}if(n>=s)return e;var l=n-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):e.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(e.slice(l).search(i)){var c,d=u;for(i.global||(i=Te(i.source,ya(he.exec(i))+"g")),i.lastIndex=0;c=i.exec(d);)var h=c.index;u=u.slice(0,h===o?l:h)}}else if(e.indexOf(so(i),l)!=l){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+r},$n.unescape=function(e){return(e=ya(e))&&V.test(e)?e.replace(G,pn):e},$n.uniqueId=function(e){var t=++Re;return ya(e)+t},$n.upperCase=Qa,$n.upperFirst=Ja,$n.each=ys,$n.eachRight=ws,$n.first=Gi,sl($n,(ml={},wr($n,function(e,t){Pe.call($n.prototype,t)||(ml[t]=e)}),ml),{chain:!1}),$n.VERSION="4.17.21",Tt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){$n[e].placeholder=$n}),Tt(["drop","take"],function(e,t){qn.prototype[e]=function(n){n=n===o?1:mn(pa(n),0);var r=this.__filtered__&&!t?new qn(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,p),type:e+(r.__dir__<0?"Right":"")}),r},qn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Tt(["filter","map","takeWhile"],function(e,t){var n=t+1,r=1==n||3==n;qn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:si(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),Tt(["head","last"],function(e,t){var n="take"+(t?"Right":"");qn.prototype[e]=function(){return this[n](1).value()[0]}}),Tt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");qn.prototype[e]=function(){return this.__filtered__?new qn(this):this[n](1)}}),qn.prototype.compact=function(){return this.filter(nl)},qn.prototype.find=function(e){return this.filter(e).head()},qn.prototype.findLast=function(e){return this.reverse().find(e)},qn.prototype.invokeMap=Vr(function(e,t){return"function"==typeof e?new qn(this):this.map(function(n){return Er(n,e,t)})}),qn.prototype.reject=function(e){return this.filter(Rs(si(e)))},qn.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new qn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==o&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},qn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},qn.prototype.toArray=function(){return this.take(p)},wr(qn.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=$n[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);i&&($n.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof qn,u=a[0],c=l||Us(t),d=function(e){var t=i.apply($n,_t([e],a));return r&&h?t[0]:t};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var h=this.__chain__,p=!!this.__actions__.length,g=s&&!h,f=l&&!p;if(!s&&c){t=f?t:new qn(this);var m=e.apply(t,a);return m.__actions__.push({func:hs,args:[d],thisArg:o}),new Bn(m,h)}return g&&f?e.apply(this,a):(m=this.thru(d),g?r?m.value()[0]:m.value():m)})}),Tt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Ee[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);$n.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(Us(o)?o:[],e)}return this[n](function(n){return t.apply(Us(n)?n:[],e)})}}),wr(qn.prototype,function(e,t){var n=$n[t];if(n){var r=n.name+"";Pe.call(Wn,r)||(Wn[r]=[]),Wn[r].push({name:t,func:n})}}),Wn[$o(o,2).name]=[{name:"wrapper",func:o}],qn.prototype.clone=function(){var e=new qn(this.__wrapped__);return e.__actions__=Ao(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ao(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ao(this.__views__),e},qn.prototype.reverse=function(){if(this.__filtered__){var e=new qn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},qn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Us(e),r=t<0,o=n?e.length:0,i=function(e,t,n){for(var r=-1,o=n.length;++r<o;){var i=n[r],s=i.size;switch(i.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=yn(t,e+s);break;case"takeRight":e=mn(e,t-s)}}return{start:e,end:t}}(0,o,this.__views__),s=i.start,a=i.end,l=a-s,u=r?a:s-1,c=this.__iteratees__,d=c.length,h=0,p=yn(l,this.__takeCount__);if(!n||!r&&o==l&&p==l)return ho(e,this.__actions__);var g=[];e:for(;l--&&h<p;){for(var f=-1,m=e[u+=t];++f<d;){var y=c[f],w=y.iteratee,v=y.type,b=w(m);if(2==v)m=b;else if(!b){if(1==v)continue e;break e}}g[h++]=m}return g},$n.prototype.at=ps,$n.prototype.chain=function(){return ds(this)},$n.prototype.commit=function(){return new Bn(this.value(),this.__chain__)},$n.prototype.next=function(){this.__values__===o&&(this.__values__=da(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?o:this.__values__[this.__index__++]}},$n.prototype.plant=function(e){for(var t,n=this;n instanceof jn;){var r=$i(n);r.__index__=0,r.__values__=o,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},$n.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof qn){var t=e;return this.__actions__.length&&(t=new qn(this)),(t=t.reverse()).__actions__.push({func:hs,args:[Xi],thisArg:o}),new Bn(t,this.__chain__)}return this.thru(Xi)},$n.prototype.toJSON=$n.prototype.valueOf=$n.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},$n.prototype.first=$n.prototype.head,Je&&($n.prototype[Je]=function(){return this}),$n}();dt._=gn,(r=function(){return gn}.call(t,n,t,e))===o||(e.exports=r)}.call(this)},2552:(e,t,n)=>{var r=n(1873),o=n(659),i=n(9350),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},2651:(e,t,n)=>{var r=n(4218);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},2749:(e,t,n)=>{var r=n(1042),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:o.call(t,e)}},2804:(e,t,n)=>{var r=n(6110)(n(9325),"Promise");e.exports=r},2865:(e,t,n)=>{var r=n(9570),o=n(1811)(r);e.exports=o},2903:(e,t,n)=>{var r=n(3805),o=n(5527),i=n(181),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=o(e),n=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&n.push(a);return n}},2949:(e,t,n)=>{var r=n(2651);e.exports=function(e,t){var n=r(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this}},3007:e=>{e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},3040:(e,t,n)=>{var r=n(1549),o=n(79),i=n(8223);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},3120:(e,t,n)=>{var r=n(4528),o=n(5891);e.exports=function e(t,n,i,s,a){var l=-1,u=t.length;for(i||(i=o),a||(a=[]);++l<u;){var c=t[l];n>0&&i(c)?n>1?e(c,n-1,i,s,a):r(a,c):s||(a[a.length]=c)}return a}},3170:(e,t,n)=>{var r=n(6547),o=n(1769),i=n(361),s=n(3805),a=n(7797);e.exports=function(e,t,n,l){if(!s(e))return e;for(var u=-1,c=(t=o(t,e)).length,d=c-1,h=e;null!=h&&++u<c;){var p=a(t[u]),g=n;if("__proto__"===p||"constructor"===p||"prototype"===p)return e;if(u!=d){var f=h[p];void 0===(g=l?l(f,p,h):void 0)&&(g=s(f)?f:i(t[u+1])?[]:{})}r(h,p,g),h=h[p]}return e}},3201:e=>{var t=/\w*$/;e.exports=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}},3222:(e,t,n)=>{var r=n(7556);e.exports=function(e){return null==e?"":r(e)}},3243:(e,t,n)=>{var r=n(6110),o=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},3290:(e,t,n)=>{e=n.nmd(e);var r=n(9325),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=a?a(n):new e.constructor(n);return e.copy(r),r}},3345:e=>{e.exports=function(){return[]}},3349:(e,t,n)=>{var r=n(2199),o=n(6375),i=n(7241);e.exports=function(e){return r(e,i,o)}},3360:(e,t,n)=>{var r=n(3243);e.exports=function(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},3488:e=>{e.exports=function(e){return e}},3605:e=>{e.exports=function(e){return this.__data__.get(e)}},3650:(e,t,n)=>{var r=n(4335)(Object.keys,Object);e.exports=r},3656:(e,t,n)=>{e=n.nmd(e);var r=n(9325),o=n(9935),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?r.Buffer:void 0,l=(a?a.isBuffer:void 0)||o;e.exports=l},3661:(e,t,n)=>{var r=n(3040),o=n(7670),i=n(289),s=n(4509),a=n(2949);function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=r,l.prototype.delete=o,l.prototype.get=i,l.prototype.has=s,l.prototype.set=a,e.exports=l},3702:e=>{e.exports=function(){this.__data__=[],this.size=0}},3729:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},3736:(e,t,n)=>{var r=n(1873),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},3805:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},3838:(e,t,n)=>{var r=n(1791),o=n(7241);e.exports=function(e,t){return e&&r(t,o(t),e)}},3862:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},4128:(e,t,n)=>{var r=n(1800),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},4218:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4247:e=>{e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4248:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},4335:e=>{e.exports=function(e,t){return function(n){return e(t(n))}}},4342:(e,t,n)=>{"use strict";!function(){var t,r,o,i=0,s=[];for(r=0;r<256;r++)s[r]=(r+256).toString(16).substr(1);function a(){var e=((!t||i+16>l.BUFFER_SIZE)&&(i=0,t=l.randomBytes(l.BUFFER_SIZE)),t.slice(i,i+=16));return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function l(){var e=a();return s[e[0]]+s[e[1]]+s[e[2]]+s[e[3]]+"-"+s[e[4]]+s[e[5]]+"-"+s[e[6]]+s[e[7]]+"-"+s[e[8]]+s[e[9]]+"-"+s[e[10]]+s[e[11]]+s[e[12]]+s[e[13]]+s[e[14]]+s[e[15]]}l.BUFFER_SIZE=4096,l.bin=a,l.clearBuffer=function(){t=null,i=0},l.test=function(e){return"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},"undefined"!=typeof crypto?o=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(o=window.msCrypto),o=o||n(575),e.exports=l,l.randomBytes=function(){if(o){if(o.randomBytes)return o.randomBytes;if(o.getRandomValues)return"function"!=typeof Uint8Array.prototype.slice?function(e){var t=new Uint8Array(e);return o.getRandomValues(t),Array.from(t)}:function(e){var t=new Uint8Array(e);return o.getRandomValues(t),t}}return function(e){var t,n=[];for(t=0;t<e;t++)n.push(Math.floor(256*Math.random()));return n}}()}()},4383:(e,t,n)=>{var r=n(6001),o=n(8816)(function(e,t){return null==e?{}:r(e,t)});e.exports=o},4394:(e,t,n)=>{var r=n(2552),o=n(346);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},4509:(e,t,n)=>{var r=n(2651);e.exports=function(e){return r(this,e).has(e)}},4528:e=>{e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},4664:(e,t,n)=>{var r=n(9770),o=n(3345),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:o;e.exports=a},4733:(e,t,n)=>{var r=n(1791),o=n(5950);e.exports=function(e,t){return e&&r(t,o(t),e)}},4739:(e,t,n)=>{var r=n(6025);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},4744:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map(function(e){return r(e,n)})}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function a(e,n,l){(l=l||{}).arrayMerge=l.arrayMerge||o,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=r;var u=Array.isArray(n);return u===Array.isArray(e)?u?l.arrayMerge(e,n,l):function(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach(function(t){o[t]=r(e[t],n)}),i(t).forEach(function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return a;var n=t.customMerge(e);return"function"==typeof n?n:a}(i,n)(e[i],t[i],n):o[i]=r(t[i],n))}),o}(e,n,l):r(n,l)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return a(e,n,t)},{})};var l=a;e.exports=l},4840:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},4894:(e,t,n)=>{var r=n(1882),o=n(294);e.exports=function(e){return null!=e&&o(e.length)&&!r(e)}},4901:(e,t,n)=>{var r=n(2552),o=n(294),i=n(346),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!s[r(e)]}},4932:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},5083:(e,t,n)=>{var r=n(1882),o=n(7296),i=n(3805),s=n(7473),a=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,c=l.toString,d=u.hasOwnProperty,h=RegExp("^"+c.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(r(e)?h:a).test(s(e))}},5288:e=>{e.exports=function(e,t){return e===t||e!=e&&t!=t}},5481:(e,t,n)=>{var r=n(9325)["__core-js_shared__"];e.exports=r},5527:e=>{var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},5529:(e,t,n)=>{var r=n(9344),o=n(8879),i=n(5527);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:r(o(e))}},5580:(e,t,n)=>{var r=n(6110)(n(9325),"DataView");e.exports=r},5749:(e,t,n)=>{var r=n(1042);e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},5861:(e,t,n)=>{var r=n(5580),o=n(8223),i=n(2804),s=n(6545),a=n(8303),l=n(2552),u=n(7473),c="[object Map]",d="[object Promise]",h="[object Set]",p="[object WeakMap]",g="[object DataView]",f=u(r),m=u(o),y=u(i),w=u(s),v=u(a),b=l;(r&&b(new r(new ArrayBuffer(1)))!=g||o&&b(new o)!=c||i&&b(i.resolve())!=d||s&&b(new s)!=h||a&&b(new a)!=p)&&(b=function(e){var t=l(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case f:return g;case m:return c;case y:return d;case w:return h;case v:return p}return t}),e.exports=b},5891:(e,t,n)=>{var r=n(1873),o=n(2428),i=n(6449),s=r?r.isConcatSpreadable:void 0;e.exports=function(e){return i(e)||o(e)||!!(s&&e&&e[s])}},5911:(e,t,n)=>{var r=n(8859),o=n(4248),i=n(9219);e.exports=function(e,t,n,s,a,l){var u=1&n,c=e.length,d=t.length;if(c!=d&&!(u&&d>c))return!1;var h=l.get(e),p=l.get(t);if(h&&p)return h==t&&p==e;var g=-1,f=!0,m=2&n?new r:void 0;for(l.set(e,t),l.set(t,e);++g<c;){var y=e[g],w=t[g];if(s)var v=u?s(w,y,g,t,e,l):s(y,w,g,e,t,l);if(void 0!==v){if(v)continue;f=!1;break}if(m){if(!o(t,function(e,t){if(!i(m,t)&&(y===e||a(y,e,n,s,l)))return m.push(t)})){f=!1;break}}else if(y!==w&&!a(y,w,n,s,l)){f=!1;break}}return l.delete(e),l.delete(t),f}},5950:(e,t,n)=>{var r=n(695),o=n(8984),i=n(4894);e.exports=function(e){return i(e)?r(e):o(e)}},5970:(e,t,n)=>{var r=n(3120);e.exports=function(e){return null!=e&&e.length?r(e,1):[]}},6001:(e,t,n)=>{var r=n(7420),o=n(631);e.exports=function(e,t){return r(e,t,function(t,n){return o(e,n)})}},6009:(e,t,n)=>{e=n.nmd(e);var r=n(4840),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o&&r.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a},6025:(e,t,n)=>{var r=n(5288);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},6038:(e,t,n)=>{var r=n(5861),o=n(346);e.exports=function(e){return o(e)&&"[object Set]"==r(e)}},6110:(e,t,n)=>{var r=n(5083),o=n(392);e.exports=function(e,t){var n=o(e,t);return r(n)?n:void 0}},6169:(e,t,n)=>{var r=n(9653);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}},6189:e=>{var t=Object.prototype.hasOwnProperty;e.exports=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r}},6375:(e,t,n)=>{var r=n(4528),o=n(8879),i=n(4664),s=n(3345),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)r(t,i(e)),e=o(e);return t}:s;e.exports=a},6449:e=>{var t=Array.isArray;e.exports=t},6545:(e,t,n)=>{var r=n(6110)(n(9325),"Set");e.exports=r},6547:(e,t,n)=>{var r=n(3360),o=n(5288),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&o(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},6721:(e,t,n)=>{var r=n(1042),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(t,e)?t[e]:void 0}},6757:(e,t,n)=>{var r=n(1033),o=Math.max;e.exports=function(e,t,n){return t=o(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,a=o(i.length-t,0),l=Array(a);++s<a;)l[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(l),r(e,this,u)}}},7068:(e,t,n)=>{var r=n(7217),o=n(5911),i=n(1986),s=n(689),a=n(5861),l=n(6449),u=n(3656),c=n(7167),d="[object Arguments]",h="[object Array]",p="[object Object]",g=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,f,m,y){var w=l(e),v=l(t),b=w?h:a(e),C=v?h:a(t),S=(b=b==d?p:b)==p,I=(C=C==d?p:C)==p,k=b==C;if(k&&u(e)){if(!u(t))return!1;w=!0,S=!1}if(k&&!S)return y||(y=new r),w||c(e)?o(e,t,n,f,m,y):i(e,t,b,n,f,m,y);if(!(1&n)){var T=S&&g.call(e,"__wrapped__"),x=I&&g.call(t,"__wrapped__");if(T||x){var A=T?e.value():e,E=x?t.value():t;return y||(y=new r),m(A,E,n,f,y)}}return!!k&&(y||(y=new r),s(e,t,n,f,m,y))}},7167:(e,t,n)=>{var r=n(4901),o=n(7301),i=n(6009),s=i&&i.isTypedArray,a=s?o(s):r;e.exports=a},7199:(e,t,n)=>{var r=n(9653),o=n(6169),i=n(3201),s=n(3736),a=n(1961);e.exports=function(e,t,n){var l=e.constructor;switch(t){case"[object ArrayBuffer]":return r(e);case"[object Boolean]":case"[object Date]":return new l(+e);case"[object DataView]":return o(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(e,n);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},7217:(e,t,n)=>{var r=n(79),o=n(1420),i=n(938),s=n(3605),a=n(9817),l=n(945);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=l,e.exports=u},7241:(e,t,n)=>{var r=n(695),o=n(2903),i=n(4894);e.exports=function(e){return i(e)?r(e,!0):o(e)}},7296:(e,t,n)=>{var r,o=n(5481),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!i&&i in e}},7301:e=>{e.exports=function(e){return function(t){return e(t)}}},7334:e=>{e.exports=function(e){return function(){return e}}},7350:(e,t,n)=>{var r=n(8221),o=n(3805);e.exports=function(e,t,n){var i=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return o(n)&&(i="leading"in n?!!n.leading:i,s="trailing"in n?!!n.trailing:s),r(e,t,{leading:i,maxWait:t,trailing:s})}},7420:(e,t,n)=>{var r=n(7422),o=n(3170),i=n(1769);e.exports=function(e,t,n){for(var s=-1,a=t.length,l={};++s<a;){var u=t[s],c=r(e,u);n(c,u)&&o(l,i(u,e),c)}return l}},7422:(e,t,n)=>{var r=n(1769),o=n(7797);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[o(t[n++])];return n&&n==i?e:void 0}},7473:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},7534:(e,t,n)=>{var r=n(2552),o=n(346);e.exports=function(e){return o(e)&&"[object Arguments]"==r(e)}},7556:(e,t,n)=>{var r=n(1873),o=n(4932),i=n(6449),s=n(4394),a=r?r.prototype:void 0,l=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return l?l.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}},7670:(e,t,n)=>{var r=n(2651);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},7730:(e,t,n)=>{var r=n(9172),o=n(7301),i=n(6009),s=i&&i.isMap,a=s?o(s):r;e.exports=a},7797:(e,t,n)=>{var r=n(4394);e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7828:(e,t,n)=>{var r=n(9325).Uint8Array;e.exports=r},8055:(e,t,n)=>{var r=n(9999);e.exports=function(e){return r(e,5)}},8077:e=>{e.exports=function(e,t){return null!=e&&t in Object(e)}},8096:e=>{e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},8221:(e,t,n)=>{var r=n(3805),o=n(124),i=n(9374),s=Math.max,a=Math.min;e.exports=function(e,t,n){var l,u,c,d,h,p,g=0,f=!1,m=!1,y=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=l,r=u;return l=u=void 0,g=t,d=e.apply(r,n)}function v(e){var n=e-p;return void 0===p||n>=t||n<0||m&&e-g>=c}function b(){var e=o();if(v(e))return C(e);h=setTimeout(b,function(e){var n=t-(e-p);return m?a(n,c-(e-g)):n}(e))}function C(e){return h=void 0,y&&l?w(e):(l=u=void 0,d)}function S(){var e=o(),n=v(e);if(l=arguments,u=this,p=e,n){if(void 0===h)return function(e){return g=e,h=setTimeout(b,t),f?w(e):d}(p);if(m)return clearTimeout(h),h=setTimeout(b,t),w(p)}return void 0===h&&(h=setTimeout(b,t)),d}return t=i(t)||0,r(n)&&(f=!!n.leading,c=(m="maxWait"in n)?s(i(n.maxWait)||0,t):c,y="trailing"in n?!!n.trailing:y),S.cancel=function(){void 0!==h&&clearTimeout(h),g=0,l=p=u=h=void 0},S.flush=function(){return void 0===h?d:C(o())},S}},8223:(e,t,n)=>{var r=n(6110)(n(9325),"Map");e.exports=r},8303:(e,t,n)=>{var r=n(6110)(n(9325),"WeakMap");e.exports=r},8440:(e,t,n)=>{var r=n(6038),o=n(7301),i=n(6009),s=i&&i.isSet,a=s?o(s):r;e.exports=a},8586:(e,t,n)=>{var r=n(6449),o=n(4394),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8655:(e,t,n)=>{var r=n(6025);e.exports=function(e){return r(this.__data__,e)>-1}},8816:(e,t,n)=>{var r=n(5970),o=n(6757),i=n(2865);e.exports=function(e){return i(o(e,void 0,r),e+"")}},8859:(e,t,n)=>{var r=n(3661),o=n(1380),i=n(1459);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=o,s.prototype.has=i,e.exports=s},8879:(e,t,n)=>{var r=n(4335)(Object.getPrototypeOf,Object);e.exports=r},8948:(e,t,n)=>{var r=n(1791),o=n(6375);e.exports=function(e,t){return r(e,o(e),t)}},8984:(e,t,n)=>{var r=n(5527),o=n(3650),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))i.call(e,n)&&"constructor"!=n&&t.push(n);return t}},9031:e=>{"use strict";function t(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,r){r||(r={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof r.unknown&&(o.unknownFn=r.unknown),"boolean"==typeof r.boolean&&r.boolean?o.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach(function(e){o.bools[e]=!0});var i={};function s(e){return i[e].some(function(e){return o.bools[e]})}Object.keys(r.alias||{}).forEach(function(e){i[e]=[].concat(r.alias[e]),i[e].forEach(function(t){i[t]=[e].concat(i[e].filter(function(e){return t!==e}))})}),[].concat(r.string).filter(Boolean).forEach(function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach(function(e){o.strings[e]=!0})});var a=r.default||{},l={_:[]};function u(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var l=t[t.length-1];n(i,l)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[l]||o.bools[l]||"boolean"==typeof i[l]?i[l]=r:Array.isArray(i[l])?i[l].push(r):i[l]=[i[l],r])}function c(e,n,r){if(!r||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,r)||!1!==o.unknownFn(r)){var s=!o.strings[e]&&t(n)?Number(n):n;u(l,e.split("."),s),(i[e]||[]).forEach(function(e){u(l,e.split("."),s)})}}Object.keys(o.bools).forEach(function(e){c(e,void 0!==a[e]&&a[e])});var d=[];-1!==e.indexOf("--")&&(d=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var h=0;h<e.length;h++){var p,g,f=e[h];if(/^--.+=/.test(f)){var m=f.match(/^--([^=]+)=([\s\S]*)$/);p=m[1];var y=m[2];o.bools[p]&&(y="false"!==y),c(p,y,f)}else if(/^--no-.+/.test(f))c(p=f.match(/^--no-(.+)/)[1],!1,f);else if(/^--.+/.test(f))p=f.match(/^--(.+)/)[1],void 0===(g=e[h+1])||/^(-|--)[^-]/.test(g)||o.bools[p]||o.allBools||i[p]&&s(p)?/^(true|false)$/.test(g)?(c(p,"true"===g,f),h+=1):c(p,!o.strings[p]||"",f):(c(p,g,f),h+=1);else if(/^-[^-]+/.test(f)){for(var w=f.slice(1,-1).split(""),v=!1,b=0;b<w.length;b++)if("-"!==(g=f.slice(b+2))){if(/[A-Za-z]/.test(w[b])&&"="===g[0]){c(w[b],g.slice(1),f),v=!0;break}if(/[A-Za-z]/.test(w[b])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(g)){c(w[b],g,f),v=!0;break}if(w[b+1]&&w[b+1].match(/\W/)){c(w[b],f.slice(b+2),f),v=!0;break}c(w[b],!o.strings[w[b]]||"",f)}else c(w[b],g,f);p=f.slice(-1)[0],v||"-"===p||(!e[h+1]||/^(-|--)[^-]/.test(e[h+1])||o.bools[p]||i[p]&&s(p)?e[h+1]&&/^(true|false)$/.test(e[h+1])?(c(p,"true"===e[h+1],f),h+=1):c(p,!o.strings[p]||"",f):(c(p,e[h+1],f),h+=1))}else if(o.unknownFn&&!1===o.unknownFn(f)||l._.push(o.strings._||!t(f)?f:Number(f)),r.stopEarly){l._.push.apply(l._,e.slice(h+1));break}}return Object.keys(a).forEach(function(e){var t,n,r;t=l,n=e.split("."),r=t,n.slice(0,-1).forEach(function(e){r=r[e]||{}}),n[n.length-1]in r||(u(l,e.split("."),a[e]),(i[e]||[]).forEach(function(t){u(l,t.split("."),a[e])}))}),r["--"]?l["--"]=d.slice():d.forEach(function(e){l._.push(e)}),l}},9132:(e,t,n)=>{var r=n(270);e.exports=function(e,t,n){var o=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===o?r(e,t,void 0,n):!!o}},9172:(e,t,n)=>{var r=n(5861),o=n(346);e.exports=function(e){return o(e)&&"[object Map]"==r(e)}},9219:e=>{e.exports=function(e,t){return e.has(t)}},9325:(e,t,n)=>{var r=n(4840),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},9326:(e,t,n)=>{var r=n(1769),o=n(2428),i=n(6449),s=n(361),a=n(294),l=n(7797);e.exports=function(e,t,n){for(var u=-1,c=(t=r(t,e)).length,d=!1;++u<c;){var h=l(t[u]);if(!(d=null!=e&&n(e,h)))break;e=e[h]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&a(c)&&s(h,c)&&(i(e)||o(e))}},9344:(e,t,n)=>{var r=n(3805),o=Object.create,i=function(){function e(){}return function(t){if(!r(t))return{};if(o)return o(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();e.exports=i},9350:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},9374:(e,t,n)=>{var r=n(4128),o=n(3805),i=n(4394),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||l.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},9570:(e,t,n)=>{var r=n(7334),o=n(3243),i=n(3488),s=o?function(e,t){return o(e,"toString",{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},9653:(e,t,n)=>{var r=n(7828);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},9770:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}},9817:e=>{e.exports=function(e){return this.__data__.has(e)}},9935:e=>{e.exports=function(){return!1}},9999:(e,t,n)=>{var r=n(7217),o=n(3729),i=n(6547),s=n(4733),a=n(3838),l=n(3290),u=n(3007),c=n(2271),d=n(8948),h=n(2),p=n(3349),g=n(5861),f=n(6189),m=n(7199),y=n(5529),w=n(6449),v=n(3656),b=n(7730),C=n(3805),S=n(8440),I=n(5950),k=n(7241),T="[object Arguments]",x="[object Function]",A="[object Object]",E={};E[T]=E["[object Array]"]=E["[object ArrayBuffer]"]=E["[object DataView]"]=E["[object Boolean]"]=E["[object Date]"]=E["[object Float32Array]"]=E["[object Float64Array]"]=E["[object Int8Array]"]=E["[object Int16Array]"]=E["[object Int32Array]"]=E["[object Map]"]=E["[object Number]"]=E[A]=E["[object RegExp]"]=E["[object Set]"]=E["[object String]"]=E["[object Symbol]"]=E["[object Uint8Array]"]=E["[object Uint8ClampedArray]"]=E["[object Uint16Array]"]=E["[object Uint32Array]"]=!0,E["[object Error]"]=E[x]=E["[object WeakMap]"]=!1,e.exports=function e(t,n,W,O,D,_){var P,R=1&n,L=2&n,F=4&n;if(W&&(P=D?W(t,O,D,_):W(t)),void 0!==P)return P;if(!C(t))return t;var M=w(t);if(M){if(P=f(t),!R)return u(t,P)}else{var $=g(t),N=$==x||"[object GeneratorFunction]"==$;if(v(t))return l(t,R);if($==A||$==T||N&&!D){if(P=L||N?{}:y(t),!R)return L?d(t,a(P,t)):c(t,s(P,t))}else{if(!E[$])return D?t:{};P=m(t,$,R)}}_||(_=new r);var j=_.get(t);if(j)return j;_.set(t,P),S(t)?t.forEach(function(r){P.add(e(r,n,W,r,t,_))}):b(t)&&t.forEach(function(r,o){P.set(o,e(r,n,W,o,t,_))});var B=M?void 0:(F?L?p:h:L?k:I)(t);return o(B||t,function(r,o){B&&(r=t[o=r]),i(P,o,e(r,n,W,o,t,_))}),P}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e={};n.r(e),n.d(e,{APPLICATION_STATE_CHANNEL:()=>gy,CLIENT_SERVER_MAPPING:()=>by,COMPONENT_STATE_STORAGE_TOPIC:()=>Oy,EVENT_INTERRUPT_CHANNEL:()=>Ty,HEARTBEAT_TIMEOUT_CHANNEL:()=>Dy,INTERRUPTIBLE_EVENTS:()=>xy,LAUNCHER_SERVICE:()=>_y,MOVE_REASON:()=>Py,SERVICES_STATE_CHANNEL:()=>Cy,SERVICE_CLOSED_CHANNEL:()=>wy,SERVICE_CLOSING_CHANNEL:()=>yy,SERVICE_INITIALIZING_CHANNEL:()=>fy,SERVICE_QUERY_READY_CHANNEL:()=>vy,SERVICE_READY_CHANNEL:()=>my,SERVICE_START_CHANNEL:()=>Iy,SERVICE_STOP_CHANNEL:()=>ky,WINDOW:()=>Ay,WINDOWSTATE:()=>Sy,WINDOW_SERVICE_REQUESTS:()=>Wy,WORKSPACE:()=>Ey,WRAPPERS:()=>py});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var i,s,a=Object.prototype.toString,l=function(e){var t=a.call(e),n="[object Arguments]"===t;return n||(n="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===a.call(e.callee)),n},u=Array.prototype.slice,c=l,d=Object.keys,h=d?function(e){return d(e)}:function(){if(s)return i;var e;if(s=1,!Object.keys){var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=l,o=Object.prototype.propertyIsEnumerable,a=!o.call({toString:null},"toString"),u=o.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=function(e){var t=e.constructor;return t&&t.prototype===e},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!h["$"+e]&&t.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{d(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();e=function(e){var o=null!==e&&"object"==typeof e,i="[object Function]"===n.call(e),s=r(e),l=o&&"[object String]"===n.call(e),h=[];if(!o&&!i&&!s)throw new TypeError("Object.keys called on a non-object");var g=u&&i;if(l&&e.length>0&&!t.call(e,0))for(var f=0;f<e.length;++f)h.push(String(f));if(s&&e.length>0)for(var m=0;m<e.length;++m)h.push(String(m));else for(var y in e)g&&"prototype"===y||!t.call(e,y)||h.push(String(y));if(a)for(var w=function(e){if("undefined"==typeof window||!p)return d(e);try{return d(e)}catch(e){return!1}}(e),v=0;v<c.length;++v)w&&"constructor"===c[v]||!t.call(e,c[v])||h.push(c[v]);return h}}return i=e}(),p=Object.keys;h.shim=function(){if(Object.keys){var e=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);e||(Object.keys=function(e){return c(e)?p(u.call(e)):p(e)})}else Object.keys=h;return Object.keys||h};var g,f,m=h,y=Error,w=EvalError,v=RangeError,b=ReferenceError,C=SyntaxError,S=TypeError,I=URIError;function k(){return f?g:(f=1,g=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0})}var T,x="undefined"!=typeof Symbol&&Symbol,A=k(),E=function(){return"function"==typeof x&&"function"==typeof Symbol&&"symbol"==typeof x("foo")&&"symbol"==typeof Symbol("bar")&&A()},W={__proto__:null,foo:{}},O=Object,D=Object.prototype.toString,_=Math.max,P=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var o=0;o<t.length;o+=1)n[o+e.length]=t[o];return n},R=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==D.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var n,r=function(e){for(var t=[],n=1,r=0;n<e.length;n+=1,r+=1)t[r]=e[n];return t}(arguments),o=_(0,t.length-r.length),i=[],s=0;s<o;s++)i[s]="$"+s;if(n=Function("binder","return function ("+function(e){for(var t="",n=0;n<e.length;n+=1)t+=e[n],n+1<e.length&&(t+=",");return t}(i)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var o=t.apply(this,P(r,arguments));return Object(o)===o?o:this}return t.apply(e,P(r,arguments))}),t.prototype){var a=function(){};a.prototype=t.prototype,n.prototype=new a,a.prototype=null}return n},L=Function.prototype.call,F=Object.prototype.hasOwnProperty,M=R.call(L,F),$=y,N=w,j=v,B=b,q=C,U=S,z=I,G=Function,H=function(e){try{return G('"use strict"; return ('+e+").constructor;")()}catch(e){}},V=Object.getOwnPropertyDescriptor;if(V)try{V({},"")}catch(Ny){V=null}var Q=function(){throw new U},J=V?function(){try{return Q}catch(e){try{return V(arguments,"callee").get}catch(e){return Q}}}():Q,K=E(),Y={__proto__:W}.foo===W.foo&&!(W instanceof O),Z=Object.getPrototypeOf||(Y?function(e){return e.__proto__}:null),X={},ee="undefined"!=typeof Uint8Array&&Z?Z(Uint8Array):T,te={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?T:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?T:ArrayBuffer,"%ArrayIteratorPrototype%":K&&Z?Z([][Symbol.iterator]()):T,"%AsyncFromSyncIteratorPrototype%":T,"%AsyncFunction%":X,"%AsyncGenerator%":X,"%AsyncGeneratorFunction%":X,"%AsyncIteratorPrototype%":X,"%Atomics%":"undefined"==typeof Atomics?T:Atomics,"%BigInt%":"undefined"==typeof BigInt?T:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?T:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?T:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?T:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":$,"%eval%":eval,"%EvalError%":N,"%Float32Array%":"undefined"==typeof Float32Array?T:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?T:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?T:FinalizationRegistry,"%Function%":G,"%GeneratorFunction%":X,"%Int8Array%":"undefined"==typeof Int8Array?T:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?T:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?T:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":K&&Z?Z(Z([][Symbol.iterator]())):T,"%JSON%":"object"==typeof JSON?JSON:T,"%Map%":"undefined"==typeof Map?T:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&K&&Z?Z((new Map)[Symbol.iterator]()):T,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?T:Promise,"%Proxy%":"undefined"==typeof Proxy?T:Proxy,"%RangeError%":j,"%ReferenceError%":B,"%Reflect%":"undefined"==typeof Reflect?T:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?T:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&K&&Z?Z((new Set)[Symbol.iterator]()):T,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?T:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":K&&Z?Z(""[Symbol.iterator]()):T,"%Symbol%":K?Symbol:T,"%SyntaxError%":q,"%ThrowTypeError%":J,"%TypedArray%":ee,"%TypeError%":U,"%Uint8Array%":"undefined"==typeof Uint8Array?T:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?T:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?T:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?T:Uint32Array,"%URIError%":z,"%WeakMap%":"undefined"==typeof WeakMap?T:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?T:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?T:WeakSet};if(Z)try{null.error}catch(Ny){var ne=Z(Z(Ny));te["%Error.prototype%"]=ne}var re,oe,ie=function e(t){var n;if("%AsyncFunction%"===t)n=H("async function () {}");else if("%GeneratorFunction%"===t)n=H("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=H("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&Z&&(n=Z(o.prototype))}return te[t]=n,n},se={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=R,le=M,ue=ae.call(Function.call,Array.prototype.concat),ce=ae.call(Function.apply,Array.prototype.splice),de=ae.call(Function.call,String.prototype.replace),he=ae.call(Function.call,String.prototype.slice),pe=ae.call(Function.call,RegExp.prototype.exec),ge=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,fe=/\\(\\)?/g,me=function(e,t){var n,r=e;if(le(se,r)&&(r="%"+(n=se[r])[0]+"%"),le(te,r)){var o=te[r];if(o===X&&(o=ie(r)),void 0===o&&!t)throw new U("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:o}}throw new q("intrinsic "+e+" does not exist!")},ye=function(e,t){if("string"!=typeof e||0===e.length)throw new U("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new U('"allowMissing" argument must be a boolean');if(null===pe(/^%?[^%]*%?$/,e))throw new q("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=he(e,0,1),n=he(e,-1);if("%"===t&&"%"!==n)throw new q("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new q("invalid intrinsic syntax, expected opening `%`");var r=[];return de(e,ge,function(e,t,n,o){r[r.length]=n?de(o,fe,"$1"):t||e}),r}(e),r=n.length>0?n[0]:"",o=me("%"+r+"%",t),i=o.name,s=o.value,a=!1,l=o.alias;l&&(r=l[0],ce(n,ue([0,1],l)));for(var u=1,c=!0;u<n.length;u+=1){var d=n[u],h=he(d,0,1),p=he(d,-1);if(('"'===h||"'"===h||"`"===h||'"'===p||"'"===p||"`"===p)&&h!==p)throw new q("property names with quotes must have matching quotes");if("constructor"!==d&&c||(a=!0),le(te,i="%"+(r+="."+d)+"%"))s=te[i];else if(null!=s){if(!(d in s)){if(!t)throw new U("base intrinsic for "+e+" exists, but the property is not available.");return}if(V&&u+1>=n.length){var g=V(s,d);s=(c=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:s[d]}else c=le(s,d),s=s[d];c&&!a&&(te[i]=s)}}return s};function we(){if(oe)return re;oe=1;var e=ye("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return re=e}var ve=ye("%Object.getOwnPropertyDescriptor%",!0);if(ve)try{ve([],"length")}catch(Ny){ve=null}var be=ve,Ce=we(),Se=C,Ie=S,ke=be,Te=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new Ie("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new Ie("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new Ie("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new Ie("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new Ie("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new Ie("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ke&&ke(e,t);if(Ce)Ce(e,t,{configurable:null===i&&a?a.configurable:!i,enumerable:null===r&&a?a.enumerable:!r,value:n,writable:null===o&&a?a.writable:!o});else{if(!s&&(r||o||i))throw new Se("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}},xe=we(),Ae=function(){return!!xe};Ae.hasArrayLengthDefineBug=function(){if(!xe)return null;try{return 1!==xe([],"length",{value:1}).length}catch(e){return!0}};var Ee=Ae,We=m,Oe="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),De=Object.prototype.toString,_e=Array.prototype.concat,Pe=Te,Re=Ee(),Le=function(e,t,n,r){if(t in e)if(!0===r){if(e[t]===n)return}else if("function"!=typeof(o=r)||"[object Function]"!==De.call(o)||!r())return;var o;Re?Pe(e,t,n,!0):Pe(e,t,n)},Fe=function(e,t){var n=arguments.length>2?arguments[2]:{},r=We(t);Oe&&(r=_e.call(r,Object.getOwnPropertySymbols(t)));for(var o=0;o<r.length;o+=1)Le(e,r[o],t[r[o]],n[r[o]])};Fe.supportsDescriptors=!!Re;var Me=Fe,$e={exports:{}},Ne=ye,je=Te,Be=Ee(),qe=be,Ue=S,ze=Ne("%Math.floor%"),Ge=function(e,t){if("function"!=typeof e)throw new Ue("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||ze(t)!==t)throw new Ue("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,o=!0;if("length"in e&&qe){var i=qe(e,"length");i&&!i.configurable&&(r=!1),i&&!i.writable&&(o=!1)}return(r||o||!n)&&(Be?je(e,"length",t,!0,!0):je(e,"length",t)),e};!function(e){var t=R,n=ye,r=Ge,o=S,i=n("%Function.prototype.apply%"),s=n("%Function.prototype.call%"),a=n("%Reflect.apply%",!0)||t.call(s,i),l=we(),u=n("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var n=a(t,s,arguments);return r(n,1+u(0,e.length-(arguments.length-1)),!0)};var c=function(){return a(t,i,arguments)};l?l(e.exports,"apply",{value:c}):e.exports.apply=c}($e);var He=$e.exports,Ve=ye,Qe=He,Je=Qe(Ve("String.prototype.indexOf")),Ke=function(e,t){var n=Ve(e,!!t);return"function"==typeof n&&Je(e,".prototype.")>-1?Qe(n):n},Ye=m,Ze=k()(),Xe=Ke,et=Object,tt=Xe("Array.prototype.push"),nt=Xe("Object.prototype.propertyIsEnumerable"),rt=Ze?Object.getOwnPropertySymbols:null,ot=function(e,t){if(null==e)throw new TypeError("target must be an object");var n=et(e);if(1===arguments.length)return n;for(var r=1;r<arguments.length;++r){var o=et(arguments[r]),i=Ye(o),s=Ze&&(Object.getOwnPropertySymbols||rt);if(s)for(var a=s(o),l=0;l<a.length;++l){var u=a[l];nt(o,u)&&tt(i,u)}for(var c=0;c<i.length;++c){var d=i[c];if(nt(o,d)){var h=o[d];n[d]=h}}}return n},it=ot,st=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),n={},r=0;r<t.length;++r)n[t[r]]=t[r];var o=Object.assign({},n),i="";for(var s in o)i+=s;return e!==i}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}return!1}()?it:Object.assign:it},at=Me,lt=st,ut=Me,ct=ot,dt=st,ht=He.apply(dt()),pt=function(e,t){return ht(Object,arguments)};ut(pt,{getPolyfill:dt,implementation:ct,shim:function(){var e=lt();return at(Object,{assign:e},{assign:function(){return Object.assign!==e}}),e}});var gt=pt,ft=function(){return"string"==typeof function(){}.name},mt=Object.getOwnPropertyDescriptor;if(mt)try{mt([],"length")}catch(Ny){mt=null}ft.functionsHaveConfigurableNames=function(){if(!ft()||!mt)return!1;var e=mt(function(){},"name");return!!e&&!!e.configurable};var yt=Function.prototype.bind;ft.boundFunctionsHaveNames=function(){return ft()&&"function"==typeof yt&&""!==function(){}.bind().name};var wt=ft,vt=Te,bt=Ee(),Ct=wt.functionsHaveConfigurableNames(),St=S,It=S,kt=Object,Tt=function(e,t){if("function"!=typeof e)throw new St("`fn` is not a function");return arguments.length>2&&!!arguments[2]&&!Ct||(bt?vt(e,"name",t,!0,!0):vt(e,"name",t)),e}(function(){if(null==this||this!==kt(this))throw new It("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),xt=Tt,At=Me.supportsDescriptors,Et=Object.getOwnPropertyDescriptor,Wt=function(){if(At&&"gim"===/a/gim.flags){var e=Et(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"boolean"==typeof RegExp.prototype.dotAll&&"boolean"==typeof RegExp.prototype.hasIndices){var t="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(n,"sticky",{get:function(){t+="y"}}),"dy"===t)return e.get}}return xt},Ot=Me.supportsDescriptors,Dt=Wt,_t=Object.getOwnPropertyDescriptor,Pt=Object.defineProperty,Rt=TypeError,Lt=Object.getPrototypeOf,Ft=/a/,Mt=Me,$t=Tt,Nt=Wt,jt=He(Nt());Mt(jt,{getPolyfill:Nt,implementation:$t,shim:function(){if(!Ot||!Lt)throw new Rt("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=Dt(),t=Lt(Ft),n=_t(t,"flags");return n&&n.get===e||Pt(t,"flags",{configurable:!0,enumerable:!1,get:e}),e}});var Bt=jt,qt={exports:{}},Ut=k(),zt=function(){return Ut()&&!!Symbol.toStringTag},Gt=zt(),Ht=Ke("Object.prototype.toString"),Vt=function(e){return!(Gt&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===Ht(e)},Qt=function(e){return!!Vt(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==Ht(e)&&"[object Function]"===Ht(e.callee)},Jt=function(){return Vt(arguments)}();Vt.isLegacyArguments=Qt;var Kt=Jt?Vt:Qt,Yt=o(Object.freeze({__proto__:null,default:{}})),Zt="function"==typeof Map&&Map.prototype,Xt=Object.getOwnPropertyDescriptor&&Zt?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,en=Zt&&Xt&&"function"==typeof Xt.get?Xt.get:null,tn=Zt&&Map.prototype.forEach,nn="function"==typeof Set&&Set.prototype,rn=Object.getOwnPropertyDescriptor&&nn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,on=nn&&rn&&"function"==typeof rn.get?rn.get:null,sn=nn&&Set.prototype.forEach,an="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,ln="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,un="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,cn=Boolean.prototype.valueOf,dn=Object.prototype.toString,hn=Function.prototype.toString,pn=String.prototype.match,gn=String.prototype.slice,fn=String.prototype.replace,mn=String.prototype.toUpperCase,yn=String.prototype.toLowerCase,wn=RegExp.prototype.test,vn=Array.prototype.concat,bn=Array.prototype.join,Cn=Array.prototype.slice,Sn=Math.floor,In="function"==typeof BigInt?BigInt.prototype.valueOf:null,kn=Object.getOwnPropertySymbols,Tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,xn="function"==typeof Symbol&&"object"==typeof Symbol.iterator,An="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,En=Object.prototype.propertyIsEnumerable,Wn=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function On(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||wn.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Sn(-e):Sn(e);if(r!==e){var o=String(r),i=gn.call(t,o.length+1);return fn.call(o,n,"$&_")+"."+fn.call(fn.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fn.call(t,n,"$&_")}var Dn=Yt,_n=Dn.custom,Pn=$n(_n)?_n:null;function Rn(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Ln(e){return fn.call(String(e),/"/g,"&quot;")}function Fn(e){return!("[object Array]"!==Bn(e)||An&&"object"==typeof e&&An in e)}function Mn(e){return!("[object RegExp]"!==Bn(e)||An&&"object"==typeof e&&An in e)}function $n(e){if(xn)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Tn)return!1;try{return Tn.call(e),!0}catch(e){}return!1}var Nn=Object.prototype.hasOwnProperty||function(e){return e in this};function jn(e,t){return Nn.call(e,t)}function Bn(e){return dn.call(e)}function qn(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function Un(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Un(gn.call(e,0,t.maxStringLength),t)+r}return Rn(fn.call(fn.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,zn),"single",t)}function zn(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+mn.call(t.toString(16))}function Gn(e){return"Object("+e+")"}function Hn(e){return e+" { ? }"}function Vn(e,t,n,r){return e+" ("+t+") {"+(r?Qn(n,r):bn.call(n,", "))+"}"}function Qn(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+bn.call(e,","+n)+"\n"+t.prev}function Jn(e,t){var n=Fn(e),r=[];if(n){r.length=e.length;for(var o=0;o<e.length;o++)r[o]=jn(e,o)?t(e[o],e):""}var i,s="function"==typeof kn?kn(e):[];if(xn){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var l in e)jn(e,l)&&(n&&String(Number(l))===l&&l<e.length||xn&&i["$"+l]instanceof Symbol||(wn.call(/[^\w$]/,l)?r.push(t(l,e)+": "+t(e[l],e)):r.push(l+": "+t(e[l],e))));if("function"==typeof kn)for(var u=0;u<s.length;u++)En.call(e,s[u])&&r.push("["+t(s[u])+"]: "+t(e[s[u]],e));return r}var Kn=ye,Yn=Ke,Zn=function e(n,r,o,i){var s=r||{};if(jn(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(jn(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!jn(s,"customInspect")||s.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(jn(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(jn(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var l=s.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return Un(n,s);if("number"==typeof n){if(0===n)return 1/0/n>0?"0":"-0";var u=String(n);return l?On(n,u):u}if("bigint"==typeof n){var c=String(n)+"n";return l?On(n,c):c}var d=void 0===s.depth?5:s.depth;if(void 0===o&&(o=0),o>=d&&d>0&&"object"==typeof n)return Fn(n)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=bn.call(Array(e.indent+1)," ")}return{base:n,prev:bn.call(Array(t+1),n)}}(s,o);if(void 0===i)i=[];else if(qn(i,n)>=0)return"[Circular]";function p(t,n,r){if(n&&(i=Cn.call(i)).push(n),r){var a={depth:s.depth};return jn(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,o+1,i)}return e(t,s,o+1,i)}if("function"==typeof n&&!Mn(n)){var g=function(e){if(e.name)return e.name;var t=pn.call(hn.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(n),f=Jn(n,p);return"[Function"+(g?": "+g:" (anonymous)")+"]"+(f.length>0?" { "+bn.call(f,", ")+" }":"")}if($n(n)){var m=xn?fn.call(String(n),/^(Symbol\(.*\))_[^)]*$/,"$1"):Tn.call(n);return"object"!=typeof n||xn?m:Gn(m)}if(function(e){return!(!e||"object"!=typeof e)&&("undefined"!=typeof HTMLElement&&e instanceof HTMLElement||"string"==typeof e.nodeName&&"function"==typeof e.getAttribute)}(n)){for(var y="<"+yn.call(String(n.nodeName)),w=n.attributes||[],v=0;v<w.length;v++)y+=" "+w[v].name+"="+Rn(Ln(w[v].value),"double",s);return y+=">",n.childNodes&&n.childNodes.length&&(y+="..."),y+"</"+yn.call(String(n.nodeName))+">"}if(Fn(n)){if(0===n.length)return"[]";var b=Jn(n,p);return h&&!function(e){for(var t=0;t<e.length;t++)if(qn(e[t],"\n")>=0)return!1;return!0}(b)?"["+Qn(b,h)+"]":"[ "+bn.call(b,", ")+" ]"}if(function(e){return!("[object Error]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n)){var C=Jn(n,p);return"cause"in Error.prototype||!("cause"in n)||En.call(n,"cause")?0===C.length?"["+String(n)+"]":"{ ["+String(n)+"] "+bn.call(C,", ")+" }":"{ ["+String(n)+"] "+bn.call(vn.call("[cause]: "+p(n.cause),C),", ")+" }"}if("object"==typeof n&&a){if(Pn&&"function"==typeof n[Pn]&&Dn)return Dn(n,{depth:d-o});if("symbol"!==a&&"function"==typeof n.inspect)return n.inspect()}if(function(e){if(!en||!e||"object"!=typeof e)return!1;try{en.call(e);try{on.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(n)){var S=[];return tn&&tn.call(n,function(e,t){S.push(p(t,n,!0)+" => "+p(e,n))}),Vn("Map",en.call(n),S,h)}if(function(e){if(!on||!e||"object"!=typeof e)return!1;try{on.call(e);try{en.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(n)){var I=[];return sn&&sn.call(n,function(e){I.push(p(e,n))}),Vn("Set",on.call(n),I,h)}if(function(e){if(!an||!e||"object"!=typeof e)return!1;try{an.call(e,an);try{ln.call(e,ln)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(n))return Hn("WeakMap");if(function(e){if(!ln||!e||"object"!=typeof e)return!1;try{ln.call(e,ln);try{an.call(e,an)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(n))return Hn("WeakSet");if(function(e){if(!un||!e||"object"!=typeof e)return!1;try{return un.call(e),!0}catch(e){}return!1}(n))return Hn("WeakRef");if(function(e){return!("[object Number]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(p(Number(n)));if(function(e){if(!e||"object"!=typeof e||!In)return!1;try{return In.call(e),!0}catch(e){}return!1}(n))return Gn(p(In.call(n)));if(function(e){return!("[object Boolean]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(cn.call(n));if(function(e){return!("[object String]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n))return Gn(p(String(n)));if("undefined"!=typeof window&&n===window)return"{ [object Window] }";if(n===t)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==Bn(e)||An&&"object"==typeof e&&An in e)}(n)&&!Mn(n)){var k=Jn(n,p),T=Wn?Wn(n)===Object.prototype:n instanceof Object||n.constructor===Object,x=n instanceof Object?"":"null prototype",A=!T&&An&&Object(n)===n&&An in n?gn.call(Bn(n),8,-1):x?"Object":"",E=(T||"function"!=typeof n.constructor?"":n.constructor.name?n.constructor.name+" ":"")+(A||x?"["+bn.call(vn.call([],A||[],x||[]),": ")+"] ":"");return 0===k.length?E+"{}":h?E+"{"+Qn(k,h)+"}":E+"{ "+bn.call(k,", ")+" }"}return String(n)},Xn=S,er=Kn("%WeakMap%",!0),tr=Kn("%Map%",!0),nr=Yn("WeakMap.prototype.get",!0),rr=Yn("WeakMap.prototype.set",!0),or=Yn("WeakMap.prototype.has",!0),ir=Yn("Map.prototype.get",!0),sr=Yn("Map.prototype.set",!0),ar=Yn("Map.prototype.has",!0),lr=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ur=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new Xn("Side channel does not contain "+Zn(e))},get:function(r){if(er&&r&&("object"==typeof r||"function"==typeof r)){if(e)return nr(e,r)}else if(tr){if(t)return ir(t,r)}else if(n)return function(e,t){var n=lr(e,t);return n&&n.value}(n,r)},has:function(r){if(er&&r&&("object"==typeof r||"function"==typeof r)){if(e)return or(e,r)}else if(tr){if(t)return ar(t,r)}else if(n)return function(e,t){return!!lr(e,t)}(n,r);return!1},set:function(r,o){er&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new er),rr(e,r,o)):tr?(t||(t=new tr),sr(t,r,o)):(n||(n={key:{},next:null}),function(e,t,n){var r=lr(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,o))}};return r},cr=M,dr=ur(),hr=S,pr={assert:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");if(dr.assert(e),!pr.has(e,t))throw new hr("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var n=dr.get(e);return n&&n["$"+t]},has:function(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var n=dr.get(e);return!!n&&cr(n,"$"+t)},set:function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new hr("`O` is not an object");if("string"!=typeof t)throw new hr("`slot` must be a string");var r=dr.get(e);r||(r={},dr.set(e,r)),r["$"+t]=n}};Object.freeze&&Object.freeze(pr);var gr,fr=pr,mr=SyntaxError,yr="object"==typeof StopIteration?StopIteration:null,wr={}.toString,vr=Array.isArray||function(e){return"[object Array]"==wr.call(e)},br=String.prototype.valueOf,Cr=Object.prototype.toString,Sr=zt(),Ir=function(e){return"string"==typeof e||"object"==typeof e&&(Sr?function(e){try{return br.call(e),!0}catch(e){return!1}}(e):"[object String]"===Cr.call(e))},kr="function"==typeof Map&&Map.prototype?Map:null,Tr="function"==typeof Set&&Set.prototype?Set:null;kr||(gr=function(e){return!1});var xr=kr?Map.prototype.has:null,Ar=Tr?Set.prototype.has:null;gr||xr||(gr=function(e){return!1});var Er,Wr=gr||function(e){if(!e||"object"!=typeof e)return!1;try{if(xr.call(e),Ar)try{Ar.call(e)}catch(e){return!0}return e instanceof kr}catch(e){}return!1},Or="function"==typeof Map&&Map.prototype?Map:null,Dr="function"==typeof Set&&Set.prototype?Set:null;Dr||(Er=function(e){return!1});var _r=Or?Map.prototype.has:null,Pr=Dr?Set.prototype.has:null;Er||Pr||(Er=function(e){return!1});var Rr=Er||function(e){if(!e||"object"!=typeof e)return!1;try{if(Pr.call(e),_r)try{_r.call(e)}catch(e){return!0}return e instanceof Dr}catch(e){}return!1},Lr=Kt,Fr=function(e){if(!yr)throw new mr("this environment lacks StopIteration");fr.set(e,"[[Done]]",!1);var t={next:function(){var e=fr.get(this,"[[Iterator]]"),t=fr.get(e,"[[Done]]");try{return{done:t,value:t?void 0:e.next()}}catch(t){if(fr.set(e,"[[Done]]",!0),t!==yr)throw t;return{done:!0,value:void 0}}}};return fr.set(t,"[[Iterator]]",e),t};if(E()||k()()){var Mr=Symbol.iterator;qt.exports=function(e){return null!=e&&void 0!==e[Mr]?e[Mr]():Lr(e)?Array.prototype[Mr].call(e):void 0}}else{var $r=vr,Nr=Ir,jr=ye,Br=jr("%Map%",!0),qr=jr("%Set%",!0),Ur=Ke,zr=Ur("Array.prototype.push"),Gr=Ur("String.prototype.charCodeAt"),Hr=Ur("String.prototype.slice"),Vr=function(e){var t=0;return{next:function(){var n,r=t>=e.length;return r||(n=e[t],t+=1),{done:r,value:n}}}},Qr=function(e,t){if($r(e)||Lr(e))return Vr(e);if(Nr(e)){var n=0;return{next:function(){var t=function(e,t){if(t+1>=e.length)return t+1;var n=Gr(e,t);if(n<55296||n>56319)return t+1;var r=Gr(e,t+1);return r<56320||r>57343?t+1:t+2}(e,n),r=Hr(e,n,t);return n=t,{done:t>e.length,value:r}}}}return t&&void 0!==e["_es6-shim iterator_"]?e["_es6-shim iterator_"]():void 0};if(Br||qr){var Jr=Wr,Kr=Rr,Yr=Ur("Map.prototype.forEach",!0),Zr=Ur("Set.prototype.forEach",!0);if("undefined"==typeof process||!process.versions||!process.versions.node)var Xr=Ur("Map.prototype.iterator",!0),eo=Ur("Set.prototype.iterator",!0);var to=Ur("Map.prototype.@@iterator",!0)||Ur("Map.prototype._es6-shim iterator_",!0),no=Ur("Set.prototype.@@iterator",!0)||Ur("Set.prototype._es6-shim iterator_",!0);qt.exports=function(e){return function(e){if(Jr(e)){if(Xr)return Fr(Xr(e));if(to)return to(e);if(Yr){var t=[];return Yr(e,function(e,n){zr(t,[n,e])}),Vr(t)}}if(Kr(e)){if(eo)return Fr(eo(e));if(no)return no(e);if(Zr){var n=[];return Zr(e,function(e){zr(n,e)}),Vr(n)}}}(e)||Qr(e)}}else qt.exports=function(e){if(null!=e)return Qr(e,!0)}}var ro=qt.exports,oo=function(e){return e!=e},io=function(e,t){return 0===e&&0===t?1/e==1/t:e===t||!(!oo(e)||!oo(t))},so=io,ao=function(){return"function"==typeof Object.is?Object.is:so},lo=ao,uo=Me,co=Me,ho=io,po=ao,go=He(po(),Object);co(go,{getPolyfill:po,implementation:ho,shim:function(){var e=lo();return uo(Object,{is:e},{is:function(){return Object.is!==e}}),e}});var fo,mo,yo,wo,vo=go,bo=He,Co=Ke,So=ye("%ArrayBuffer%",!0),Io=Co("ArrayBuffer.prototype.byteLength",!0),ko=Co("Object.prototype.toString"),To=!!So&&!Io&&new So(0).slice,xo=!!To&&bo(To),Ao=Io||xo?function(e){if(!e||"object"!=typeof e)return!1;try{return Io?Io(e):xo(e,0),!0}catch(e){return!1}}:So?function(e){return"[object ArrayBuffer]"===ko(e)}:function(e){return!1},Eo=Date.prototype.getDay,Wo=Object.prototype.toString,Oo=zt(),Do=Ke,_o=zt();if(_o){fo=Do("Object.prototype.hasOwnProperty"),mo=Do("RegExp.prototype.exec"),yo={};var Po=function(){throw yo};wo={toString:Po,valueOf:Po},"symbol"==typeof Symbol.toPrimitive&&(wo[Symbol.toPrimitive]=Po)}var Ro=Do("Object.prototype.toString"),Lo=Object.getOwnPropertyDescriptor,Fo=_o?function(e){if(!e||"object"!=typeof e)return!1;var t=Lo(e,"lastIndex");if(!t||!fo(t,"value"))return!1;try{mo(e,wo)}catch(e){return e===yo}}:function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Ro(e)},Mo=Ke("SharedArrayBuffer.prototype.byteLength",!0),$o=Mo?function(e){if(!e||"object"!=typeof e)return!1;try{return Mo(e),!0}catch(e){return!1}}:function(e){return!1},No=Number.prototype.toString,jo=Object.prototype.toString,Bo=zt(),qo=Ke,Uo=qo("Boolean.prototype.toString"),zo=qo("Object.prototype.toString"),Go=zt(),Ho={exports:{}},Vo=Object.prototype.toString;if(E()){var Qo=Symbol.prototype.toString,Jo=/^Symbol\(.*\)$/;Ho.exports=function(e){if("symbol"==typeof e)return!0;if("[object Symbol]"!==Vo.call(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&Jo.test(Qo.call(e))}(e)}catch(e){return!1}}}else Ho.exports=function(e){return!1};var Ko=Ho.exports,Yo={exports:{}},Zo="undefined"!=typeof BigInt&&BigInt;if("function"==typeof Zo&&"function"==typeof BigInt&&"bigint"==typeof Zo(42)&&"bigint"==typeof BigInt(42)){var Xo=BigInt.prototype.valueOf;Yo.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return Xo.call(e),!0}catch(e){}return!1}(e))}}else Yo.exports=function(e){return!1};var ei,ti=Yo.exports,ni=Ir,ri=Ko,oi=ti,ii="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,si="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;ii||(ei=function(e){return!1});var ai=ii?ii.prototype.has:null,li=si?si.prototype.has:null;ei||ai||(ei=function(e){return!1});var ui=ei||function(e){if(!e||"object"!=typeof e)return!1;try{if(ai.call(e,ai),li)try{li.call(e,li)}catch(e){return!0}return e instanceof ii}catch(e){}return!1},ci={exports:{}},di=Ke,hi=ye("%WeakSet%",!0),pi=di("WeakSet.prototype.has",!0);if(pi){var gi=di("WeakMap.prototype.has",!0);ci.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(pi(e,pi),gi)try{gi(e,gi)}catch(e){return!0}return e instanceof hi}catch(e){}return!1}}else ci.exports=function(e){return!1};var fi,mi,yi=ci.exports,wi=Wr,vi=Rr,bi=ui,Ci=yi,Si=Function.prototype.toString,Ii="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Ii&&"function"==typeof Object.defineProperty)try{fi=Object.defineProperty({},"length",{get:function(){throw mi}}),mi={},Ii(function(){throw 42},null,fi)}catch(Xy){Xy!==mi&&(Ii=null)}else Ii=null;var ki=/^\s*class\b/,Ti=function(e){try{var t=Si.call(e);return ki.test(t)}catch(e){return!1}},xi=function(e){try{return!Ti(e)&&(Si.call(e),!0)}catch(e){return!1}},Ai=Object.prototype.toString,Ei="function"==typeof Symbol&&!!Symbol.toStringTag,Wi=!(0 in[,]),Oi=function(){return!1};if("object"==typeof document){var Di=document.all;Ai.call(Di)===Ai.call(document.all)&&(Oi=function(e){if((Wi||!e)&&(void 0===e||"object"==typeof e))try{var t=Ai.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var _i=Ii?function(e){if(Oi(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Ii(e,null,fi)}catch(e){if(e!==mi)return!1}return!Ti(e)&&xi(e)}:function(e){if(Oi(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Ei)return xi(e);if(Ti(e))return!1;var t=Ai.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&xi(e)},Pi=_i,Ri=Object.prototype.toString,Li=Object.prototype.hasOwnProperty,Fi=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],Mi="undefined"==typeof globalThis?t:globalThis,$i=function(e,t,n){if(!Pi(t))throw new TypeError("iterator must be a function");var r;arguments.length>=3&&(r=n),"[object Array]"===Ri.call(e)?function(e,t,n){for(var r=0,o=e.length;r<o;r++)Li.call(e,r)&&(null==n?t(e[r],r,e):t.call(n,e[r],r,e))}(e,t,r):"string"==typeof e?function(e,t,n){for(var r=0,o=e.length;r<o;r++)null==n?t(e.charAt(r),r,e):t.call(n,e.charAt(r),r,e)}(e,t,r):function(e,t,n){for(var r in e)Li.call(e,r)&&(null==n?t(e[r],r,e):t.call(n,e[r],r,e))}(e,t,r)},Ni=He,ji=Ke,Bi=be,qi=ji("Object.prototype.toString"),Ui=zt(),zi="undefined"==typeof globalThis?t:globalThis,Gi=function(){for(var e=[],t=0;t<Fi.length;t++)"function"==typeof Mi[Fi[t]]&&(e[e.length]=Fi[t]);return e}(),Hi=ji("String.prototype.slice"),Vi=Object.getPrototypeOf,Qi=ji("Array.prototype.indexOf",!0)||function(e,t){for(var n=0;n<e.length;n+=1)if(e[n]===t)return n;return-1},Ji={__proto__:null};$i(Gi,Ui&&Bi&&Vi?function(e){var t=new zi[e];if(Symbol.toStringTag in t){var n=Vi(t),r=Bi(n,Symbol.toStringTag);if(!r){var o=Vi(n);r=Bi(o,Symbol.toStringTag)}Ji["$"+e]=Ni(r.get)}}:function(e){var t=new zi[e],n=t.slice||t.set;n&&(Ji["$"+e]=Ni(n))});var Ki=Ke("ArrayBuffer.prototype.byteLength",!0),Yi=Ao,Zi=gt,Xi=Ke,es=Bt,ts=ye,ns=ro,rs=ur,os=vo,is=Kt,ss=vr,as=Ao,ls=function(e){return"object"==typeof e&&null!==e&&(Oo?function(e){try{return Eo.call(e),!0}catch(e){return!1}}(e):"[object Date]"===Wo.call(e))},us=Fo,cs=$o,ds=m,hs=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:ni(e)?"String":function(e){return"number"==typeof e||"object"==typeof e&&(Bo?function(e){try{return No.call(e),!0}catch(e){return!1}}(e):"[object Number]"===jo.call(e))}(e)?"Number":function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(Go&&Symbol.toStringTag in e?function(e){try{return Uo(e),!0}catch(e){return!1}}(e):"[object Boolean]"===zo(e))}(e)?"Boolean":ri(e)?"Symbol":oi(e)?"BigInt":void 0},ps=function(e){if(e&&"object"==typeof e){if(wi(e))return"Map";if(vi(e))return"Set";if(bi(e))return"WeakMap";if(Ci(e))return"WeakSet"}return!1},gs=function(e){if(!e||"object"!=typeof e)return!1;if(!Ui){var t=Hi(qi(e),8,-1);return Qi(Gi,t)>-1?t:"Object"===t&&function(e){var t=!1;return $i(Ji,function(n,r){if(!t)try{n(e),t=Hi(r,1)}catch(e){}}),t}(e)}return Bi?function(e){var t=!1;return $i(Ji,function(n,r){if(!t)try{"$"+n(e)===r&&(t=Hi(r,1))}catch(e){}}),t}(e):null},fs=function(e){return Yi(e)?Ki?Ki(e):e.byteLength:NaN},ms=Xi("SharedArrayBuffer.prototype.byteLength",!0),ys=Xi("Date.prototype.getTime"),ws=Object.getPrototypeOf,vs=Xi("Object.prototype.toString"),bs=ts("%Set%",!0),Cs=Xi("Map.prototype.has",!0),Ss=Xi("Map.prototype.get",!0),Is=Xi("Map.prototype.size",!0),ks=Xi("Set.prototype.add",!0),Ts=Xi("Set.prototype.delete",!0),xs=Xi("Set.prototype.has",!0),As=Xi("Set.prototype.size",!0);function Es(e,t,n,r){for(var o,i=ns(e);(o=i.next())&&!o.done;)if(Ps(t,o.value,n,r))return Ts(e,o.value),!0;return!1}function Ws(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Os(e,t,n,r,o,i){var s=Ws(n);if(null!=s)return s;var a=Ss(t,s),l=Zi({},o,{strict:!1});return!(void 0===a&&!Cs(t,s)||!Ps(r,a,l,i))&&!Cs(e,s)&&Ps(r,a,l,i)}function Ds(e,t,n){var r=Ws(n);return null!=r?r:xs(t,r)&&!xs(e,r)}function _s(e,t,n,r,o,i){for(var s,a,l=ns(e);(s=l.next())&&!s.done;)if(Ps(n,a=s.value,o,i)&&Ps(r,Ss(t,a),o,i))return Ts(e,a),!0;return!1}function Ps(e,t,n,r){var o=n||{};if(o.strict?os(e,t):e===t)return!0;if(hs(e)!==hs(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return o.strict?os(e,t):e==t;var i,s=r.has(e),a=r.has(t);if(s&&a){if(r.get(e)===r.get(t))return!0}else i={};return s||r.set(e,i),a||r.set(t,i),function(e,t,n,r){var o,i;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(vs(e)!==vs(t))return!1;if(is(e)!==is(t))return!1;if(ss(e)!==ss(t))return!1;var s=e instanceof Error,a=t instanceof Error;if(s!==a)return!1;if((s||a)&&(e.name!==t.name||e.message!==t.message))return!1;var l=us(e),u=us(t);if(l!==u)return!1;if((l||u)&&(e.source!==t.source||es(e)!==es(t)))return!1;var c=ls(e),d=ls(t);if(c!==d)return!1;if((c||d)&&ys(e)!==ys(t))return!1;if(n.strict&&ws&&ws(e)!==ws(t))return!1;var h=gs(e),p=gs(t);if(h!==p)return!1;if(h||p){if(e.length!==t.length)return!1;for(o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var g=Rs(e),f=Rs(t);if(g!==f)return!1;if(g||f){if(e.length!==t.length)return!1;for(o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var m=as(e),y=as(t);if(m!==y)return!1;if(m||y)return fs(e)===fs(t)&&"function"==typeof Uint8Array&&Ps(new Uint8Array(e),new Uint8Array(t),n,r);var w=cs(e),v=cs(t);if(w!==v)return!1;if(w||v)return ms(e)===ms(t)&&"function"==typeof Uint8Array&&Ps(new Uint8Array(e),new Uint8Array(t),n,r);if(typeof e!=typeof t)return!1;var b=ds(e),C=ds(t);if(b.length!==C.length)return!1;for(b.sort(),C.sort(),o=b.length-1;o>=0;o--)if(b[o]!=C[o])return!1;for(o=b.length-1;o>=0;o--)if(!Ps(e[i=b[o]],t[i],n,r))return!1;var S=ps(e),I=ps(t);return S===I&&("Set"===S||"Set"===I?function(e,t,n,r){if(As(e)!==As(t))return!1;for(var o,i,s,a=ns(e),l=ns(t);(o=a.next())&&!o.done;)if(o.value&&"object"==typeof o.value)s||(s=new bs),ks(s,o.value);else if(!xs(t,o.value)){if(n.strict)return!1;if(!Ds(e,t,o.value))return!1;s||(s=new bs),ks(s,o.value)}if(s){for(;(i=l.next())&&!i.done;)if(i.value&&"object"==typeof i.value){if(!Es(s,i.value,n.strict,r))return!1}else if(!n.strict&&!xs(e,i.value)&&!Es(s,i.value,n.strict,r))return!1;return 0===As(s)}return!0}(e,t,n,r):"Map"!==S||function(e,t,n,r){if(Is(e)!==Is(t))return!1;for(var o,i,s,a,l,u,c=ns(e),d=ns(t);(o=c.next())&&!o.done;)if(a=o.value[0],l=o.value[1],a&&"object"==typeof a)s||(s=new bs),ks(s,a);else if(void 0===(u=Ss(t,a))&&!Cs(t,a)||!Ps(l,u,n,r)){if(n.strict)return!1;if(!Os(e,t,a,l,n,r))return!1;s||(s=new bs),ks(s,a)}if(s){for(;(i=d.next())&&!i.done;)if(a=i.value[0],u=i.value[1],a&&"object"==typeof a){if(!_s(s,e,a,u,n,r))return!1}else if(!(n.strict||e.has(a)&&Ps(Ss(e,a),u,n,r)||_s(s,e,a,u,Zi({},n,{strict:!1}),r)))return!1;return 0===As(s)}return!0}(e,t,n,r))}(e,t,o,r)}function Rs(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length||"function"!=typeof e.copy||"function"!=typeof e.slice||e.length>0&&"number"!=typeof e[0]||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}var Ls=function(e,t,n){return Ps(e,t,n,rs())},Fs=r(Ls);let Ms=(e=21)=>{let t="",n=e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t};const $s=e=>"object"==typeof e&&!Array.isArray(e)&&0!==Object.keys(e).length,Ns=e=>({unsubscribe(){e?"function"==typeof e?e():e.then(e=>e()).catch(console.error):console.error("Failed to unsubscribe!")}}),js=(e,t,n)=>new Promise((r,o)=>{const i=setTimeout(()=>{o(n||`Promise timeout hit: ${t}`)},t);e().then(e=>{clearTimeout(i),r(e)}).catch(e=>{clearTimeout(i),o(e)})}),Bs=()=>Ms(),qs=["name","title","version","customProperties","icon","caption","type"],Us=["appId","name","type","details","version","title","tooltip","lang","description","categories","icons","screenshots","contactEmail","moreInfo","publisher","customConfig","hostManifests","interop","localizedVersions"];var zs=function(e){return{ok:!0,result:e}},Gs=function(e){return{ok:!1,error:e}},Hs=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:zs(e(t.result,n.result))},Vs=function(e,t){return!0===t.ok?t:Gs(e(t.error))},Qs=function(){return Qs=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Qs.apply(this,arguments)};function Js(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Js(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Js(e[r[n]],t[r[n]]))return!1}return!0}}var Ks=function(e){return Array.isArray(e)},Ys=function(e){return"object"==typeof e&&null!==e&&!Ks(e)},Zs=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},Xs=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},ea=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Qs({at:e+(n||"")},r)},ta=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return Vs(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?zs(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?zs(e):Gs({message:Zs("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?zs(e):Gs({message:Zs("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?zs(e):Gs({message:Zs("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Js(e,t)?zs(t):Gs({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Ys(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?Gs({message:"the key '"+r+"' is required but was not present"}):Gs(ea("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return zs(n)}return Ys(e)?zs(e):Gs({message:Zs("an object",e)})})},e.array=function(t){return new e(function(e){return Ks(e)&&t?e.reduce(function(e,n,r){return Hs(function(e,t){return e.concat([t])},e,function(e,n){return Vs(function(e){return ea("["+n+"]",e)},t.decode(e))}(n,r))},zs([])):Ks(e)?zs(e):Gs({message:Zs("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ks(e)){if(e.length!==t.length)return Gs({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return Gs(ea("["+r+"]",o.error));n[r]=o.result}return zs(n)}return Gs({message:Zs("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return Hs(Object.assign,t,n.decode(e))},zs({}))})},e.anyJson=function(){return new e(function(e){return zs(e)})},e.unknownJson=function(){return new e(function(e){return zs(e)})},e.dict=function(t){return new e(function(e){if(Ys(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return Gs(ea("."+r,o.error));n[r]=o.result}return zs(n)}return Gs({message:Zs("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?zs(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return Gs({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return zs(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return Gs({at:Xs(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Ys(r))return Gs({at:Xs(t.slice(0,o+1)),message:Zs("an object",r)});if("number"==typeof t[o]&&!Ks(r))return Gs({at:Xs(t.slice(0,o+1)),message:Zs("an array",r)});r=r[t[o]]}return Vs(function(e){return void 0===r?{at:Xs(t),message:"path does not exist"}:ea(Xs(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return zs(t)})},e.fail=function(t){return new e(function(e){return Gs({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),na=ta.string,ra=ta.number,oa=ta.boolean,ia=ta.anyJson;ta.unknownJson;var sa=ta.constant,aa=ta.object,la=ta.array;ta.tuple;var ua=ta.dict,ca=ta.optional,da=ta.oneOf;ta.union,ta.intersection,ta.withDefault,ta.valueAt,ta.succeed,ta.fail,ta.lazy;const ha=na().where(e=>e.length>0,"Expected a non-empty string"),pa=ra().where(e=>e>=0,"Expected a non-negative number"),ga=aa({name:ha,displayName:ca(na()),contexts:ca(la(na())),customConfig:ca(aa())}),fa=da(sa("web"),sa("native"),sa("citrix"),sa("onlineNative"),sa("other")),ma=aa({url:ha}),ya=aa({src:ha,size:ca(ha),type:ca(ha)}),wa=aa({src:ha,size:ca(ha),type:ca(ha),label:ca(ha)}),va=aa({contexts:la(ha),displayName:ca(ha),resultType:ca(ha),customConfig:ca(ia())}),ba=aa({listensFor:ca(ua(va)),raises:ca(ua(la(ha)))}),Ca=aa({broadcasts:ca(la(ha)),listensFor:ca(la(ha))}),Sa=aa({name:ha,description:ca(ha),broadcasts:ca(la(ha)),listensFor:ca(la(ha))}),Ia=aa({intents:ca(ba),userChannels:ca(Ca),appChannels:ca(la(Sa))}),ka=aa({url:ca(ha),top:ca(ra()),left:ca(ra()),width:ca(pa),height:ca(pa)}),Ta=aa({name:ca(ha),type:ca(ha.where(e=>"window"===e,"Expected a value of window")),title:ca(ha),version:ca(ha),customProperties:ca(ia()),icon:ca(na()),caption:ca(na()),details:ca(ka),intents:ca(la(ga)),hidden:ca(oa())}),xa=aa({name:ha,appId:ha,title:ca(ha),version:ca(ha),manifest:ha,manifestType:ha,tooltip:ca(ha),description:ca(ha),contactEmail:ca(ha),supportEmail:ca(ha),publisher:ca(ha),images:ca(la(aa({url:ca(ha)}))),icons:ca(la(aa({icon:ca(ha)}))),customConfig:ia(),intents:ca(la(ga))}),Aa=aa({appId:ca(ha),name:ca(ha),details:ca(ma),version:ca(ha),title:ca(ha),tooltip:ca(ha),lang:ca(ha),description:ca(ha),categories:ca(la(ha)),icons:ca(la(ya)),screenshots:ca(la(wa)),contactEmail:ca(ha),supportEmail:ca(ha),moreInfo:ca(ha),publisher:ca(ha),customConfig:ca(la(ia())),hostManifests:ca(ia()),interop:ca(Ia)}),Ea=aa({appId:ha,name:ha,type:fa,details:ma,version:ca(ha),title:ca(ha),tooltip:ca(ha),lang:ca(ha),description:ca(ha),categories:ca(la(ha)),icons:ca(la(ya)),screenshots:ca(la(wa)),contactEmail:ca(ha),supportEmail:ca(ha),moreInfo:ca(ha),publisher:ca(ha),customConfig:ca(la(ia())),hostManifests:ca(ia()),interop:ca(Ia),localizedVersions:ca(ua(Aa))}),Wa=da(xa,Ea),Oa=e=>`${e.kind} at ${e.at}: ${JSON.stringify(e.input)}. Reason - ${e.message}`;class Da{fdc3ToDesktopDefinitionType={web:"window",native:"exe",citrix:"citrix",onlineNative:"clickonce",other:"window"};toApi(){return{isFdc3Definition:this.isFdc3Definition.bind(this),parseToBrowserBaseAppData:this.parseToBrowserBaseAppData.bind(this),parseToDesktopAppConfig:this.parseToDesktopAppConfig.bind(this)}}isFdc3Definition(e){const t=Wa.run(e);return t.ok?e.appId&&e.details?{isFdc3:!0,version:"2.0"}:e.manifest?{isFdc3:!0,version:"1.2"}:{isFdc3:!1,reason:"The passed definition is not FDC3"}:{isFdc3:!1,reason:Oa(t.error)}}parseToBrowserBaseAppData(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const r=Wa.run(e);if(!r.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(r.error)}`);const o=this.getUserPropertiesFromDefinition(e,n),i={url:this.getUrl(e,n)},s={name:e.appId,type:"window",createOptions:i,userProperties:{...o,intents:"1.2"===n?o.intents:this.getIntentsFromV2AppDefinition(e),details:i},title:e.title,version:e.version,icon:this.getIconFromDefinition(e,n),caption:e.description,fdc3:"2.0"===n?{...e,definitionVersion:"2.0"}:void 0},a=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!a)return s;const l=Ta.run(a);if(!l.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(l.error)}`);return Object.keys(l.result).length?this.mergeBaseAppDataWithGlueManifest(s,l.result):s}parseToDesktopAppConfig(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const r=Wa.run(e);if(!r.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Oa(r.error)}`);if("1.2"===n){const t=e;return{name:t.appId,type:"window",details:{url:this.getUrl(e,n)},version:t.version,title:t.title,tooltip:t.tooltip,caption:t.description,icon:t.icons?.[0].icon,intents:t.intents,customProperties:{manifestType:t.manifestType,images:t.images,contactEmail:t.contactEmail,supportEmail:t.supportEmail,publisher:t.publisher,icons:t.icons,customConfig:t.customConfig}}}const o=e,i={name:o.appId,type:this.fdc3ToDesktopDefinitionType[o.type],details:o.details,version:o.version,title:o.title,tooltip:o.tooltip,caption:o.description,icon:this.getIconFromDefinition(o,"2.0"),intents:this.getIntentsFromV2AppDefinition(o),fdc3:{...o,definitionVersion:"2.0"}},s=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!s)return i;if("object"!=typeof s||Array.isArray(s))throw new Error(`Invalid '${e.hostManifests.ioConnect?"hostManifests.ioConnect":"hostManifests['Glue42']"}' key`);return this.mergeDesktopConfigWithGlueManifest(i,s)}getUserPropertiesFromDefinition(e,t){return"1.2"===t?Object.fromEntries(Object.entries(e).filter(([e])=>!qs.includes(e))):Object.fromEntries(Object.entries(e).filter(([e])=>!qs.includes(e)&&!Us.includes(e)))}getUrl(e,t){let n;if("1.2"===t){const t=JSON.parse(e.manifest);n=t.details?.url||t.url}else n=e.details?.url;if(!n||"string"!=typeof n)throw new Error(`Invalid FDC3 ${t} definition. Provide valid 'url' under '${"1.2"===t?"manifest":"details"}' key`);return n}getIntentsFromV2AppDefinition(e){const t=e.interop?.intents?.listensFor;if(t)return Object.entries(t).map(e=>{const[t,n]=e;return{name:t,...n}})}getIconFromDefinition(e,t){return"1.2"===t?e.icons?.find(e=>e.icon)?.icon||void 0:e.icons?.find(e=>e.src)?.src||void 0}mergeBaseAppDataWithGlueManifest(e,t){let n=e;if(t.details){const r={...e.createOptions,...t.details};n.createOptions=r,n.userProperties.details=r}return Array.isArray(t.intents)&&(n.userProperties.intents=(n.userProperties.intents||[]).concat(t.intents)),n={...n,...t},delete n.details,delete n.intents,n}mergeDesktopConfigWithGlueManifest(e,t){const n=Object.assign({},e,t,{details:{...e.details,...t.details}});return Array.isArray(t.intents)&&(n.intents=(e.intents||[]).concat(t.intents)),n}}const _a={common:{nonEmptyStringDecoder:ha,nonNegativeNumberDecoder:pa},fdc3:{allDefinitionsDecoder:Wa,v1DefinitionDecoder:xa,v2DefinitionDecoder:Ea}};var Pa;!function(e){e.USER_CANCELLED="User Closed Intents Resolver UI without choosing a handler",e.CALLER_NOT_DEFINED="Caller Id is not defined",e.TIMEOUT_HIT="Timeout hit",e.INTENT_NOT_FOUND="Cannot find Intent",e.HANDLER_NOT_FOUND="Cannot find Intent Handler",e.TARGET_INSTANCE_UNAVAILABLE="Cannot start Target Instance",e.INTENT_DELIVERY_FAILED="Target Instance did not add a listener",e.RESOLVER_UNAVAILABLE="Intents Resolver UI unavailable",e.RESOLVER_TIMEOUT="User did not choose a handler",e.INVALID_RESOLVER_RESPONSE="Intents Resolver UI returned invalid response",e.INTENT_HANDLER_REJECTION="Intent Handler function processing the raised intent threw an error or rejected the promise it returned"}(Pa||(Pa={}));const Ra=new class{_fdc3;_decoders=_a;_errors={intents:Pa};get fdc3(){return this._fdc3||(this._fdc3=(new Da).toApi()),this._fdc3}get decoders(){return this._decoders}get errors(){return this._errors}};Ra.fdc3,Ra.decoders;const La=Ra.errors;var Fa,Ma;!function(e){e.Context="Context",e.Channel="Channel"}(Fa||(Fa={})),function(e){e.User="user",e.App="app",e.Private="private"}(Ma||(Ma={}));const $a=["id","type","broadcast","addContextListener","getCurrentContext"],Na=["type"],ja=["contexts","channels","interop","intents","appManager","windows"],Ba=La.intents,qa="FDC3.Collaborate",Ua="___privateFDC3Channel___";var za;!function(e){e.ListenerAdded="listenerAdded",e.OnAddContextListener="onAddContextListener",e.OnUnsubscribe="onUnsubscribe",e.OnDisconnect="onDisconnect"}(za||(za={}));var Ga=function(e){return{ok:!0,result:e}},Ha=function(e){return{ok:!1,error:e}},Va=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:Ga(e(t.result,n.result))},Qa=function(e,t){return!0===t.ok?t:Ha(e(t.error))},Ja=function(){return Ja=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ja.apply(this,arguments)};function Ka(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Ka(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Ka(e[r[n]],t[r[n]]))return!1}return!0}}var Ya=function(e){return Array.isArray(e)},Za=function(e){return"object"==typeof e&&null!==e&&!Ya(e)},Xa=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},el=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},tl=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Ja({at:e+(n||"")},r)},nl=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return Qa(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?Ga(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?Ga(e):Ha({message:Xa("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?Ga(e):Ha({message:Xa("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?Ga(e):Ha({message:Xa("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Ka(e,t)?Ga(t):Ha({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Za(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?Ha({message:"the key '"+r+"' is required but was not present"}):Ha(tl("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return Ga(n)}return Za(e)?Ga(e):Ha({message:Xa("an object",e)})})},e.array=function(t){return new e(function(e){return Ya(e)&&t?e.reduce(function(e,n,r){return Va(function(e,t){return e.concat([t])},e,function(e,n){return Qa(function(e){return tl("["+n+"]",e)},t.decode(e))}(n,r))},Ga([])):Ya(e)?Ga(e):Ha({message:Xa("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ya(e)){if(e.length!==t.length)return Ha({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return Ha(tl("["+r+"]",o.error));n[r]=o.result}return Ga(n)}return Ha({message:Xa("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return Va(Object.assign,t,n.decode(e))},Ga({}))})},e.anyJson=function(){return new e(function(e){return Ga(e)})},e.unknownJson=function(){return new e(function(e){return Ga(e)})},e.dict=function(t){return new e(function(e){if(Za(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return Ha(tl("."+r,o.error));n[r]=o.result}return Ga(n)}return Ha({message:Xa("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?Ga(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return Ha({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return Ga(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return Ha({at:el(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Za(r))return Ha({at:el(t.slice(0,o+1)),message:Xa("an object",r)});if("number"==typeof t[o]&&!Ya(r))return Ha({at:el(t.slice(0,o+1)),message:Xa("an array",r)});r=r[t[o]]}return Qa(function(e){return void 0===r?{at:el(t),message:"path does not exist"}:tl(el(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return Ga(t)})},e.fail=function(t){return new e(function(e){return Ha({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),rl=nl.string,ol=nl.number;nl.boolean;var il=nl.anyJson;nl.unknownJson;var sl=nl.constant,al=nl.object,ll=nl.array;nl.tuple,nl.dict;var ul=nl.optional,cl=nl.oneOf;nl.union,nl.intersection,nl.withDefault,nl.valueAt,nl.succeed,nl.fail,nl.lazy;const dl=rl().where(e=>e.length>0,"Expected a non-empty string");ol().where(e=>e>=0,"Expected a non-negative number");const hl=al({src:dl,size:ul(rl()),type:ul(rl())}),pl=al({src:dl,size:ul(rl()),type:ul(rl()),label:ul(rl())});al({appId:dl,instanceId:ul(rl()),name:ul(rl()),version:ul(rl()),title:ul(rl()),tooltip:ul(rl()),description:ul(rl()),icons:ul(ll(hl)),images:ul(ll(pl))});const gl=al({appId:dl,instanceId:ul(rl())}),fl=cl(dl,gl),ml=al({type:dl,name:ul(dl),id:ul(il())}),yl=ul(ml),wl=ul(gl),vl=ul(fl),bl=ul(dl),Cl=cl(sl("joinPrivateChannel"),sl("publishOnPrivateChannel"),sl("addedContextListenerOnPrivateChannel"),sl("removedContextListenerOnPrivateChannel"),sl("disconnectedFromPrivateChannel"),sl("startupContextOpened")),Sl=al({channelId:ul(dl),contextType:ul(dl),payload:ul(ml)}),Il=al({action:Cl,correlationId:dl,collaborationObject:ul(Sl)}),kl=al({fdc3:al({collaborationId:dl,openApp:al({appId:dl,instanceId:dl}),context:al({contextType:ul(rl()),payload:ml})})});al({channelId:ul(dl)});class Tl{channelsParser;channelsStateStore;glue;_logger;glueInitPromise;resolveGluePromise;rejectGluePromise;defaultGluePromiseTimeout=12e4;constructor(e,t){this.channelsParser=e,this.channelsStateStore=t}get gluePromise(){return this.glueInitPromise.then(this.initializeLogger.bind(this))}initialize(e){this.glue=e,this.resolveGluePromise()}initializeFailed(e){this.rejectGluePromise(e)}createGluePromise(){this.glueInitPromise=js(()=>new Promise((e,t)=>{this.resolveGluePromise=e,this.rejectGluePromise=t}),this.defaultGluePromiseTimeout,`Timeout of ${this.defaultGluePromiseTimeout}ms waiting for Glue to initialize`)}get logger(){return this._logger}validateGlue(e){if("object"!=typeof e||Array.isArray(e))return{isValid:!1,error:{message:"Glue is not a valid object"}};const t=Object.keys(e),n=ja.filter(e=>!t.includes(e));return n.length?{isValid:!1,error:{message:`Fdc3 cannot initialize correctly - Glue is missing the following ${n.length>1?"properties":"property"}: ${n.join(", ")}`}}:{isValid:!0}}interopInstance(){return this.glue.interop.instance}getApplication(e){return this.glue.appManager.application(e)}getApplicationInstances(e){return this.glue.appManager.instances().filter(t=>t.application.name===e)}getAppInstanceById(e){return this.glue.appManager.instances().find(t=>t.id===e)}async findIntents(e){return this.glue.intents.find(e)}async raiseIntent(e){return this.glue.intents.raise(e)}doesFilterHandlersExist(){return!!this.glue.intents.filterHandlers}async filterHandlers(e){if(!this.glue.intents.filterHandlers)throw new Error("Intents method 'filterHandlers' does not exist");return this.glue.intents.filterHandlers(e)}doesGetIntentsExist(){return!!this.glue.intents.getIntents}getIntents(e){if(!this.glue.intents.getIntents)throw new Error("Intents method 'getIntents' does not exist");return this.glue.intents.getIntents(e)}async getMyWindowContext(){const e=this.getMyWindow();if(e)return e.getContext()}addIntentListener(e,t){return this.glue.intents.register?this.glue.intents.register(e,t):this.glue.intents.addIntentListener(e,t)}getAllContexts(){return this.glue.contexts.all()}async getContext(e){return this.glue.contexts.get(e)}async updateContext(e,t){return this.glue.contexts.update(e,t)}async updateContextWithLatestFdc3Type(e,t){const{path:n,value:r}=this.channelsParser.parseFDC3ContextToGlueContexts(t),o={path:"latest_fdc3_type",value:this.channelsParser.mapFDC3TypeToChannelsDelimiter(t.type)};await this.contextsSetPaths(e,[{path:`data.${n}`,value:r},o])}async channelsUpdate(e,t){return this.glue.channels.publish(e,t)}getChannelsMode(){return this.glue.channels.mode}async getMyChannels(){return this.glue.channels.getMyChannels?this.glue.channels.getMyChannels():[await this.glue.channels.getMy()]}async joinChannel(e){return this.glue.channels.join(e)}async leaveChannel(e){return this.glue.channels.leave(e)}getCurrentChannel(){if(!this.glue.channels.myChannels)return this.glue.channels.my();const e=this.glue.channels.myChannels();return e[e.length-1]}async getIoChannelNameByFDC3ChannelId(e){const t=await this.listAllChannels();return t.find(t=>t.meta.fdc3?.id===e)?.name}async getFDC3ChannelIdByIoChannelName(e){const t=(await this.listAllChannels()).filter(e=>e.meta.fdc3),n=t.find(t=>t.name===e);return n?.meta.fdc3.id}getMyChannel(){return this.glue.channels.getMy()}setOnChannelChanged(e){return this.glue.channels.onChannelsChanged?this.glue.channels.onChannelsChanged(t=>{const n=t[t.length-1];e(n)}):this.glue.channels.changed(e)}async getAllChannels(){return this.glue.channels.all()}async listAllChannels(){return this.glue.channels.list()}async getChannel(e){return this.glue.channels.get(e)}getMyWindow(){const e=this.glue.windows.my();return $s(e)?e:void 0}getMyInteropInstance(){return this.glue.interop.instance}getGlueVersion(){return this.glue?.version}registerOnInstanceStopped(e){return this.glue.appManager.onInstanceStopped(e)}async unregisterMethod(e){return this.glue.interop.unregister(e)}invokeSystemMethod(e,t){return Il.runWithException(e),this.glue.interop.invoke(qa,e,{instance:t})}registerMethod(e,t){return this.glue.interop.register(e,t)}getInteropMethods(e){return this.glue.interop.methods(e)}legacyChannelsSubscribe(e,t){const n={replayed:!1};return this.glue.channels.subscribe(async(r,o,i)=>{if(this.isUpdateFromMe(i)||!o||!o.latest_fdc3_type)return;const s=await this.getFDC3ChannelIdByIoChannelName(o.name);if(n.replayed)return this.parseDataAndInvokeSubscribeCallback({callback:e,contextData:o,metadata:this.getContextMetadata(i),contextType:t,channelId:s});this.invokePreviouslyBroadcastedData({callback:e,contextData:o,metadata:this.getContextMetadata(i),contextType:t,channelId:s}),n.replayed=!0})}channelsSubscribe(e,t){const n={replayed:!1};let r;return this.glue.channels.subscribe(async(o,i,s)=>{if(this.isUpdateFromMe(s)||!i||!o.fdc3)return;const a=await this.getFDC3ChannelIdByIoChannelName(i.name);if(t&&o.fdc3.type!==t&&!n.replayed)return this.invokePreviouslyBroadcastedData({callback:e,contextData:i,metadata:this.getContextMetadata(s),contextType:t,channelId:a}),n.replayed=!0,void(r=o.fdc3);r&&Fs(r,o.fdc3,{strict:!0})||(e(o.fdc3,this.getContextMetadata(s),a),n.replayed=!0,r=o.fdc3)})}contextsSubscribe(e,t){const n={replayed:!1};return this.glue.contexts.subscribe(e,(e,r,o,i,s)=>{this.isUpdateFromMe(s?.updaterId)||this.checkIfShouldInvokeInitialReplay(n,e)&&this.parseDataAndInvokeSubscribeCallback({callback:t,contextData:e,metadata:this.getContextMetadata(s?.updaterId)})})}getInteropServers(e){return this.glue.interop.servers(e)}initSubLogger(e){return this.logger?.subLogger(e)}getPrefs(e){return this.glue.prefs.get(e)}async checkIsFdc3DataWrappingSupported(){const e=window.glue42core||window.iobrowser,t=e?"T42.Web.Client.Control":"T42.Channels.Command",n=this.glue.interop.servers().find(e=>e.instance===this.glue.interop.instance.instance);if(!n)return!1;if(!n.getMethods().some(e=>e.name===t))return!1;const r=e?{domain:"system",operation:"isFdc3DataWrappingSupported"}:{command:"isFdc3DataWrappingSupported"};try{return(await this.glue.interop.invoke(t,r,{instance:this.interopInstance().instance})).returned.isSupported}catch(e){return!1}}invokePreviouslyBroadcastedData({callback:e,contextData:t,metadata:n,contextType:r,channelId:o}){const i=r||this.channelsParser.mapChannelsDelimiterToFDC3Type(t.latest_fdc3_type),s=this.getLatestBroadcastedDataByContextType(t,i);s&&e(s,n,o)}isUpdateFromMe(e){return this.glue.interop.instance.peerId===e}getContextMetadata(e){const t=this.glue.interop.servers().find(t=>t.peerId===e);if(t)return{source:{appId:t.applicationName,instanceId:t.instance}}}initializeLogger(){this._logger=this.glue.logger}parseDataAndInvokeSubscribeCallback({callback:e,contextData:t,metadata:n,contextType:r,channelId:o}){if(!r)return void e(this.channelsParser.parseContextsDataToInitialFDC3Data({data:t.data,latest_fdc3_type:t.latest_fdc3_type}),n,o);if(this.channelsParser.mapChannelsDelimiterToFDC3Type(t.latest_fdc3_type)!==r)return;const i=this.getLatestBroadcastedDataByContextType(t,r);i&&e(i,n,o)}getLatestBroadcastedDataByContextType(e,t){let n;return Object.entries(e.data).forEach(([e,r])=>{if(!this.channelsParser.isFdc3DataKey(e))return;const o=this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(e);o===t&&(n={type:o,...r})}),n}checkIfShouldInvokeInitialReplay(e,t){return e.replayed?!!t.latest_fdc3_type:(e.replayed=!0,!1)}async contextsSetPaths(e,t){await this.glue.contexts.setPaths(e,t)}}const xl="Glue42";class Al{fireFdc3Ready(){const e=new Event("fdc3Ready");window.dispatchEvent(e)}fireNotifyStarted(){this.send("notifyStarted")}fireRequestGlue(){this.send("requestGlue")}send(e,t){const n=new CustomEvent(xl,{detail:{glue42:{event:e,message:t}}});window.dispatchEvent(n)}}var El,Wl,Ol,Dl,_l;!function(e){e.AppNotFound="AppNotFound",e.ErrorOnLaunch="ErrorOnLaunch",e.AppTimeout="AppTimeout",e.ResolverUnavailable="ResolverUnavailable",e.MalformedContext="MalformedContext",e.DesktopAgentNotFound="DesktopAgentNotFound"}(El||(El={})),function(e){e.NoAppsFound="NoAppsFound",e.ResolverUnavailable="ResolverUnavailable",e.UserCancelled="UserCancelledResolution",e.ResolverTimeout="ResolverTimeout",e.TargetAppUnavailable="TargetAppUnavailable",e.TargetInstanceUnavailable="TargetInstanceUnavailable",e.IntentDeliveryFailed="IntentDeliveryFailed",e.MalformedContext="MalformedContext",e.DesktopAgentNotFound="DesktopAgentNotFound"}(Wl||(Wl={})),function(e){e.NoResultReturned="NoResultReturned",e.IntentHandlerRejected="IntentHandlerRejected"}(Ol||(Ol={})),function(e){e.NoChannelFound="NoChannelFound",e.AccessDenied="AccessDenied",e.CreationFailed="CreationFailed",e.MalformedContext="MalformedContext"}(Dl||(Dl={})),function(e){e.ResponseTimedOut="ResponseToBridgeTimedOut",e.AgentDisconnected="AgentDisconnected",e.NotConnectedToBridge="NotConnectedToBridge",e.MalformedMessage="MalformedMessage"}(_l||(_l={})),"function"==typeof SuppressedError&&SuppressedError;var Pl=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}("fdc3.action","fdc3.chart","fdc3.chat.initSettings","fdc3.chat.message","fdc3.chat.room","fdc3.chat.searchCriteria","fdc3.contact","fdc3.contactList","fdc3.country","fdc3.currency","fdc3.email","fdc3.instrument","fdc3.instrumentList","fdc3.interaction","fdc3.message","fdc3.organization","fdc3.portfolio","fdc3.position","fdc3.nothing","fdc3.timeRange","fdc3.transactionResult","fdc3.valuation");new Set(Pl);var Rl,Ll,Fl=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}("CreateInteraction","SendChatMessage","StartCall","StartChat","StartEmail","ViewAnalysis","ViewChat","ViewChart","ViewContact","ViewHoldings","ViewInstrument","ViewInteractions","ViewMessages","ViewNews","ViewOrders","ViewProfile","ViewQuote","ViewResearch");new Set(Fl),function(e){e.Chart="fdc3.chart",e.ChatInitSettings="fdc3.chat.initSettings",e.ChatRoom="fdc3.chat.room",e.Contact="fdc3.contact",e.ContactList="fdc3.contactList",e.Country="fdc3.country",e.Currency="fdc3.currency",e.Email="fdc3.email",e.Instrument="fdc3.instrument",e.InstrumentList="fdc3.instrumentList",e.Interaction="fdc3.interaction",e.Nothing="fdc3.nothing",e.Organization="fdc3.organization",e.Portfolio="fdc3.portfolio",e.Position="fdc3.position",e.ChatSearchCriteria="fdc3.chat.searchCriteria",e.TimeRange="fdc3.timeRange",e.TransactionResult="fdc3.transactionResult",e.Valuation="fdc3.valuation"}(Rl||(Rl={})),function(e){e.CreateInteraction="CreateInteraction",e.SendChatMessage="SendChatMessage",e.StartCall="StartCall",e.StartChat="StartChat",e.StartEmail="StartEmail",e.ViewAnalysis="ViewAnalysis",e.ViewChat="ViewChat",e.ViewChart="ViewChart",e.ViewContact="ViewContact",e.ViewHoldings="ViewHoldings",e.ViewInstrument="ViewInstrument",e.ViewInteractions="ViewInteractions",e.ViewMessages="ViewMessages",e.ViewNews="ViewNews",e.ViewOrders="ViewOrders",e.ViewProfile="ViewProfile",e.ViewQuote="ViewQuote",e.ViewResearch="ViewResearch"}(Ll||(Ll={}));class Ml{intentsController;applicationController;channelsController;constructor(e,t,n){this.intentsController=e,this.applicationController=t,this.channelsController=n}toApi(){return{getStartupContext:this.getStartupContext.bind(this),addContextListener:this.addContextListener.bind(this),addIntentListener:this.addIntentListener.bind(this),broadcast:this.broadcast.bind(this),createPrivateChannel:this.createPrivateChannel.bind(this),findInstances:this.findInstances.bind(this),findIntent:this.findIntent.bind(this),findIntentsByContext:this.findIntentsByContext.bind(this),getAppMetadata:this.getAppMetadata.bind(this),getCurrentChannel:this.getCurrentChannel.bind(this),getInfo:this.getInfo.bind(this),getOrCreateChannel:this.getOrCreateChannel.bind(this),getSystemChannels:this.getSystemChannels.bind(this),getUserChannels:this.getSystemChannels.bind(this),joinChannel:this.joinChannel.bind(this),joinUserChannel:this.joinUserChannel.bind(this),leaveCurrentChannel:this.leaveCurrentChannel.bind(this),open:this.open.bind(this),raiseIntent:this.raiseIntent.bind(this),raiseIntentForContext:this.raiseIntentForContext.bind(this),getCurrentChannels:this.getCurrentChannels.bind(this),leaveChannel:this.leaveChannel.bind(this),leaveCurrentChannels:this.leaveCurrentChannels.bind(this)}}async open(e,t){if(fl.runWithException(e),!yl.run(t).ok)throw new Error(El.MalformedContext);return this.applicationController.open({commandId:Bs(),target:e,context:t})}async findInstances(e){return gl.runWithException(e),this.applicationController.findInstances({commandId:Bs(),appIdentifier:e})}async getAppMetadata(e){return gl.runWithException(e),this.applicationController.getAppMetadata({commandId:Bs(),appIdentifier:e})}async getInfo(){return this.applicationController.getInfo({commandId:Bs()})}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e)}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:e})}const n=bl.runWithException(e);if("function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n})}async findIntent(e,t,n){dl.runWithException(e);const r=yl.run(t);if(!r.ok)throw new Error(Wl.MalformedContext);return bl.runWithException(n),this.intentsController.findIntent({commandId:Bs(),intent:e,context:r.result,resultType:n})}async findIntentsByContext(e,t){const n=ml.run(e);if(!n.ok)throw new Error(Wl.MalformedContext);return bl.runWithException(t),this.intentsController.findIntentsByContext({commandId:Bs(),context:n.result,resultType:t})}async raiseIntent(e,t,n){if(dl.runWithException(e),!ml.run(t).ok)throw new Error(Wl.MalformedContext);return vl.runWithException(n),this.intentsController.raiseIntent({commandId:Bs(),intent:e,context:t,target:n})}async raiseIntentForContext(e,t){if(!ml.run(e).ok)throw new Error(Wl.MalformedContext);return wl.runWithException(t),this.intentsController.raiseIntentForContext({commandId:Bs(),context:e,target:t})}async addIntentListener(e,t){if(dl.runWithException(e),"function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.intentsController.addIntentListener({commandId:Bs(),intent:e,handler:t})}async getStartupContext(){return this.channelsController.getStartupContext()}async getOrCreateChannel(e){return dl.runWithException(e),this.channelsController.getOrCreateChannel({commandId:Bs(),channelId:e})}async getSystemChannels(){return this.channelsController.getUserChannels(Bs())}async joinChannel(e){return dl.runWithException(e),this.channelsController.joinUserChannel({commandId:Bs(),channelId:e})}async joinUserChannel(e){return dl.runWithException(e),this.channelsController.joinUserChannel({commandId:Bs(),channelId:e})}async getCurrentChannel(){return this.channelsController.getCurrentChannel(Bs())}async leaveCurrentChannel(){return this.channelsController.leaveCurrentChannel(Bs())}async createPrivateChannel(){return this.channelsController.createPrivateChannel(Bs())}async getCurrentChannels(){return this.channelsController.getCurrentChannels(Bs())}async leaveChannel(e){return dl.runWithException(e),this.channelsController.leave(Bs(),{channelId:e})}async leaveCurrentChannels(){return this.channelsController.leave(Bs())}}class $l{channelsController;id;type=Ma.App;constructor(e,t){this.channelsController=e,this.id=t}toApi(){return{id:this.id,type:this.type,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this)}}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e,this.id)}async getCurrentContext(e){return bl.runWithException(e),this.channelsController.getContextForChannel({commandId:Bs(),channelId:this.id,contextType:e})}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:e,channelId:this.id})}const n=bl.runWithException(e);if("function"!=typeof t)throw new Error("Please provide the handler as a function!");return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n,channelId:this.id})}}class Nl{fdc3Delimiter="&";channelsFdc3DataPrefix="fdc3_";mapChannelNameToContextName(e){return`___channel___${e}`}parseContextsDataToInitialFDC3Data(e){const{data:t,latest_fdc3_type:n}=e;return{type:this.mapChannelsDelimiterToFDC3Type(n),...t[`${this.channelsFdc3DataPrefix}${n}`]}}revertGlueParsedTypeToInitialFDC3Type(e){const t=e.replace(this.channelsFdc3DataPrefix,"");return this.mapChannelsDelimiterToFDC3Type(t)}parseFDC3ContextToGlueContexts(e){const{type:t,...n}=e,r=this.mapFDC3TypeToChannelsDelimiter(t);return{path:`${this.channelsFdc3DataPrefix}${r}`,value:n}}mapFDC3TypeToChannelsDelimiter(e){return e.split(".").join(this.fdc3Delimiter)}isFdc3DataKey(e){return!!e.startsWith(this.channelsFdc3DataPrefix)}mapChannelsDelimiterToFDC3Type(e){return e.split(this.fdc3Delimiter).join(".")}}class jl{channelsController;id;type=Ma.User;displayMetadata;constructor(e,t){this.channelsController=e,this.id=t.meta.fdc3?t.meta.fdc3.id:t.name,this.displayMetadata={name:t.name,color:t.meta.color}}toApi(){return{id:this.id,type:this.type,displayMetadata:this.displayMetadata,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this)}}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);return this.channelsController.broadcast(Bs(),e,this.id)}async getCurrentContext(e){return bl.run(e),this.channelsController.getContextForChannel({commandId:Bs(),channelId:this.id,contextType:e})}async addContextListener(e,t){if(1===arguments.length){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};return this.channelsController.addContextListener({commandId:Bs(),handler:e,channelId:this.id})}const n=bl.runWithException(e);if("function"!=typeof t)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof t};return this.channelsController.addContextListener({commandId:Bs(),handler:t,contextType:n,channelId:this.id})}}const Bl=e=>({id:e.id,type:e.type,displayMetadata:e.displayMetadata}),ql=(e,t)=>(n,r,o)=>{t?n.type===t&&e(n,r,o):e(n,r,o)};class Ul{glueController;channelsController;channelsFactory;glueEventsController;_logger;ioToFDC3ErrorsDict={[Ba.USER_CANCELLED]:Wl.UserCancelled,[Ba.TIMEOUT_HIT]:Wl.IntentDeliveryFailed,[Ba.TARGET_INSTANCE_UNAVAILABLE]:Wl.TargetInstanceUnavailable,[Ba.RESOLVER_UNAVAILABLE]:Wl.ResolverUnavailable,[Ba.RESOLVER_TIMEOUT]:Wl.ResolverTimeout,[Ba.INVALID_RESOLVER_RESPONSE]:Wl.IntentDeliveryFailed,[Ba.INTENT_NOT_FOUND]:Wl.NoAppsFound,[Ba.INTENT_DELIVERY_FAILED]:Wl.IntentDeliveryFailed,[Ba.HANDLER_NOT_FOUND]:Wl.NoAppsFound,[Ba.CALLER_NOT_DEFINED]:Wl.IntentDeliveryFailed,[Ba.INTENT_HANDLER_REJECTION]:Ol.IntentHandlerRejected};constructor(e,t,n,r){this.glueController=e,this.channelsController=t,this.channelsFactory=n,this.glueEventsController=r}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.intents.controller")),this._logger}async findIntent({commandId:e,intent:t,context:n,resultType:r}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findIntent() invoked for intent ${t} with contextType ${n?.type} and resultType ${r}`);const o=await this.glueController.findIntents({name:t});if(!o.length)throw{message:Wl.NoAppsFound,reason:`There are no apps handling the passed intent ${t}`};const i=o.find(e=>e.name===t);if(!i)throw{message:Wl.NoAppsFound,reason:`There are no apps handling the passed intent ${t}`};if(!n&&!r)return this.convertGlue42IntentToFDC3Intent(i);const s=n&&"fdc3.nothing"===n.type?void 0:n?.type,a=this.getGlueIntentWithFilteredHandlers(i,{contextType:s,resultType:r});if(!a.handlers.length)throw{message:Wl.NoAppsFound,reason:`No apps handling intent ${t} with contextType ${n?.type} and resultType ${r}`};return this.convertGlue42IntentToFDC3Intent(a)}async findIntentsByContext({commandId:e,context:t,resultType:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findIntentsByContext() invoked for context type ${t.type} and resultType ${n}`);const r=await this.glueController.findIntents({contextType:t.type,resultType:n});if(!r.length)throw{message:Wl.NoAppsFound,reason:`No apps registering intent with contextType ${t.type} ${n?`and resultType ${n}`:""}`};return this.logger?.info(`[${e}] - parsing glue intents to fdc3 intents and returning`),r.map(e=>{const r=this.getGlueIntentWithFilteredHandlers(e,{contextType:t.type,resultType:n});return this.convertGlue42IntentToFDC3Intent(r)})}async raiseIntent({commandId:e,intent:t,context:n,target:r}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - raiseIntent() invoked for intent ${t} with contextType: ${n.type} and target: ${r}`);const o={type:n.type,data:{...n}},i=(await this.glueController.findIntents({name:t})).find(e=>e.name===t);if(!i)throw{message:Wl.NoAppsFound,reason:`There's no app registering an intent '${t}'`};if(!r){const s=this.filterGlueIntentHandlers({commandId:e,intent:i,context:n,target:r});return this.logger?.info(`[${e}] - raising intent ${t} with contextType ${n.type} and handlers ${s.handlers.map(e=>e.applicationName&&e.instanceId)}`),this.invokeRaiseIntent(e,{intent:t,context:o,handlers:s.handlers})}if(r?.instanceId)return this.logger?.info(`[${e}] - raising intent ${t} with contextType ${n.type} to target instance of app ${r.appId} and id ${r.instanceId}`),this.invokeRaiseIntent(e,{intent:t,context:o,target:{instance:r.instanceId}});const s="string"==typeof r?r:r.appId;return this.invokeRaiseIntent(e,{intent:t,context:o,target:{app:s}})}async raiseIntentForContext({commandId:e,context:t,target:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - raiseIntentForContext() invoked with contextType ${t.type} and target ${n}`);const r=this.glueController.doesFilterHandlersExist(),o=this.glueController.doesGetIntentsExist(),i=await this.checkForRememberedIntentHandlerForContext(t.type),s={type:t.type,data:{...t}};if(i)return this.invokeRaiseIntent(e,{context:s,intent:i.intent});if(!r||!o||n)return this.legacyRaiseIntentForContext({commandId:e,context:t,target:n});const a=this.glueController.filterHandlers({contextTypes:[t.type]}).catch(e=>{throw this.parseIoToFdc3Error(e)}),{handlers:l}=await a;if(!l.length){const n=`${Wl.NoAppsFound} - Cannot find Intent Handlers for intents with context type ${t.type}`;throw this._logger?.warn(`[${e}] - ${n}`),new Error(Wl.NoAppsFound)}if(l.length>1)return this.legacyRaiseIntentForContext({commandId:e,context:t,target:n});const u=l[0],{intents:c}=await this.glueController.getIntents(u),d=c.find(e=>e.contextTypes?.includes(t.type));if(!d)throw this.logger?.warn(`[${e}] - ${Wl.IntentDeliveryFailed} - There's no valid intent for handler ${JSON.stringify(u)} and context type ${t.type}`),new Error(Wl.IntentDeliveryFailed);return this.invokeRaiseIntent(e,{intent:d.intent,context:s,target:{app:u.applicationName,instance:u.instanceId}})}async addIntentListener({commandId:e,intent:t,handler:n}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - addIntentListener() invoked for intent ${t}`);const r=this.getWrappedIntentHandler(n);return this.glueController.addIntentListener(t,r)}async checkForRememberedIntentHandlerForContext(e){let t;try{t=await this.glueController.getPrefs()}catch(e){return void this._logger?.warn(`Cannot get prefs due to the following error: ${e}`)}const n=t.data?.intents;if(!n)return;const r=Object.entries(n).find(([t,n])=>n.filter?.contextTypes?.includes(e));if(!r)return;const[o,i]=r;return{intent:o,handler:i.handler}}filterGlueIntentHandlers({commandId:e,intent:t,context:n,target:r}){let o;return o=this.filterIntentHandlersByContext(t,n),r?(this.logger?.log(`[${e}] - filtering handlers by target (${JSON.stringify(r)}) for intent ${t.name}`),o=this.filterIntentHandlersByTarget({intent:t,target:r,commandId:e}),o):(this.logger?.info(`[${e}] - There's no passed target, intent handlers are filtered only by context type`),o)}filterIntentHandlersByTarget({intent:e,target:t,commandId:n}){const r="string"==typeof t?t:t.appId,o="string"==typeof t?void 0:t.instanceId;this.logger?.info(`[${n}] - Checking if application with name ${r} exists`);const i=this.glueController.getApplication(r),s=this.serverInstanceAsIntentHandler(e.name);if(!(i||"string"!=typeof t&&t.instanceId&&s.length))throw{message:Wl.TargetAppUnavailable,reason:`There's no app with appId ${r}`};this.logger?.info(`[${n}] - target app ${r} found. Filtering handlers by applicationName: ${r}`);const a=e.handlers.filter(e=>e.applicationName===r);if(!a.length)throw{message:Wl.NoAppsFound,reason:`Intent ${e.name} exists but there's no app with appId ${r} registering it`};if(!o)return this.logger?.log(`[${n}] - returning all handlers for intent ${e.name} and target: ${JSON.stringify(t)}`),{name:e.name,handlers:a};if(!(i?i.instances.find(e=>e.id===o):s.find(e=>e.instance===o)))throw{message:Wl.TargetInstanceUnavailable,reason:`There's no instance with id ${o} of the passed app ${r}`};this.logger?.info(`[${n}] - Filtering handlers by instanceId: ${o}`);const l=a.filter(e=>e.instanceId===o);if(!l.length)throw{message:Wl.IntentDeliveryFailed,reason:`There's no instance with id ${o} of app ${r} registering intent ${e.name}`};return{name:e.name,handlers:l}}serverInstanceAsIntentHandler(e){const t=`Tick42.FDC3.Intents.${e}`;return this.glueController.getInteropServers({name:t})}filterIntentHandlersByContext(e,t){const n=this.getGlueIntentWithFilteredHandlers(e,{contextType:t.type});if(!n.handlers.length)throw{message:Wl.NoAppsFound,reason:`There's no app registering an intent with the passed context type ${t.type}`};return n}async getResult(e,t){this.logger?.info(`[${e}] - getResult() of IntentResolution invoked`);const{result:n}=t;if(n.fdc3error)throw n.fdc3error;if(!n||"object"!=typeof n||Array.isArray(n)||$s(n)&&!n.fdc3intentContext&&!n.fdc3intentChannel&&!n.fdc3error)throw this.logger?.warn(`[${e}] - ${Ol.NoResultReturned} - The intent handler exited without returning a valid result - a promise resolving to a Context, Channel object or void`),new Error(Ol.NoResultReturned);if(!$s(n))return;if(!n.fdc3intentChannel&&!n.fdc3intentContext)return n;if(n.fdc3intentContext)return n.fdc3intentContext.payload;const{fdc3intentChannel:r}=n;if(r.type===Ma.User){const e=(await this.glueController.listAllChannels()).find(e=>e.name===r.displayMetadata.name);return this.channelsFactory.buildModel({type:Ma.User,...r,displayMetadata:{...r.displayMetadata,glueChannel:e}})}if(r.type===Ma.App)return this.channelsFactory.buildModel(r);await this.glueEventsController.initializeCollaborateMethod();const o=this.channelsController.buildPrivateChannel(r.id,e,!1);o.setCollaborator({appId:t.handler.applicationName,instanceId:t.handler.instanceId},e);const i={action:"joinPrivateChannel",correlationId:o.id,collaborationObject:{channelId:o.id}};return await this.glueController.invokeSystemMethod(i,t.handler.instanceId),this.logger?.info(`[${e}] - returning private channel`),o.toApi()}convertGlue42IntentToFDC3Intent(e){const{name:t,handlers:n}=e;return{intent:{name:t,displayName:n[0].displayName||""},apps:n.map(e=>{const t=e.applicationName,n=this.glueController.getApplication(t);return{appId:t,instanceId:e.instanceId,name:t,title:e.applicationTitle||e.instanceTitle||t,tooltip:n?.userProperties.tooltip||`${t} (${e.type})`,description:e.applicationDescription,icons:e.applicationIcon?[e.applicationIcon,...n?.userProperties.icons||[]]:n?.userProperties.icons,images:n?.userProperties.images,resultType:e.resultType}})}}getResultType(e){return(e=>$a.every(t=>Object.keys(e).includes(t)))(e)?Fa.Channel:(e=>Na.every(t=>Object.keys(e).includes(t)))(e)?Fa.Context:void 0}getWrappedIntentHandler(e){return async(t,n)=>{const r=n?{source:{appId:n.application||n.applicationName||"",instanceId:n.instance}}:void 0;let o;try{o=await e({...t.data,type:t.type||""},r)}catch(e){throw this.logger?.warn("string"==typeof e?e:e.message||JSON.stringify(e)),new Error(Ol.IntentHandlerRejected)}if(!o)return;const i=this.getResultType(o);return i?i===Fa.Channel?{fdc3intentChannel:Bl(o)}:{fdc3intentContext:{contextType:o.type,payload:o}}:{fdc3error:{message:Ol.NoResultReturned,reason:"The intent handler exited without returning a valid result - a promise resolving to a Context, Channel object or void"}}}}getGlueIntentWithFilteredHandlers(e,t){const{name:n,handlers:r}=e;let o=r;const i=t.contextType;i&&(o=r.filter(e=>!!e.instanceId||e.contextTypes?.includes(i)));const s=t.resultType;return s&&(o=r.filter(e=>!!e.instanceId||e.resultType?.includes(s))),{name:n,handlers:o}}async invokeRaiseIntent(e,t){try{const n=await this.glueController.raiseIntent({...t,timeout:75e3});return{source:{appId:n.handler.applicationName,instanceId:n.handler.instanceId},intent:t.intent,getResult:(()=>this.getResult(e,n)).bind(this)}}catch(e){throw this.parseIoToFdc3Error(e)}}parseIoToFdc3Error(e){const t=Object.keys(this.ioToFDC3ErrorsDict).find(t=>e?.message?.includes(t)),n=t?this.ioToFDC3ErrorsDict[t]:Wl.IntentDeliveryFailed,r="string"==typeof e?e:JSON.stringify(e);return{message:n,reason:e instanceof Error?e.message:r}}async legacyRaiseIntentForContext({commandId:e,context:t,target:n}){this.logger?.info(`[${e}] - raiseIntentForContext() invoked with contextType ${t.type} and target ${n}`);const r=await this.findIntentsByContext({commandId:e,context:t});if(!r||0===r.length)throw{message:Wl.NoAppsFound,reason:`No apps registering intent with contextType ${t.type} ${n?`and target ${JSON.stringify(n)}`:""}`};return this.raiseIntent({commandId:e,intent:r[0].intent.name,context:t,target:n})}}class zl{glueController;appsStateStore;glueEventsController;_logger;defaultContextListenerInvokedPromiseTimeout=12e4;constructor(e,t,n){this.glueController=e,this.appsStateStore=t,this.glueEventsController=n}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.application.controller")),this._logger}async open({commandId:e,target:t,context:n}){await this.glueController.gluePromise,this.logger?.log(`[${e}] - open() invoked with target ${t} ${n?`and contextType ${n.type}`:""}`);const r="object"==typeof t?t.appId:t,o=this.glueController.getApplication(r);if(!o)throw{message:El.AppNotFound,reason:`Cannot find targeted ${r} application`};if(n)return await this.glueEventsController.initializeCollaborateMethod(),this.logger?.info(`[${e}] - opening app ${o} with startup context`),this.openAppWithContext(o,n);try{this.logger?.info(`[${e}] - opening app ${o}`);const t=await o.start();return this.logger?.info(`[${e}] - instance with id ${t.id} started`),this.parseGlueInstToAppIdentifier(t)}catch(e){throw{message:El.ErrorOnLaunch,reason:"string"==typeof e?e:JSON.stringify(e)}}}async findInstances({commandId:e,appIdentifier:t}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - findInstances() invoked with appIdentifier ${t}`);const{appId:n}=t;if(!this.glueController.getApplication(n))throw{message:Wl.NoAppsFound,reason:`App with appId: ${n} does not exist`};const r=this.glueController.getApplicationInstances(n).map(e=>this.parseGlueInstToAppIdentifier(e));return this.logger?.info(`[${e}] - ids of opened instances for appIdentifier ${t}: ${JSON.stringify(r.map(e=>e.instanceId))}`),r}async getAppMetadata({commandId:e,appIdentifier:t}){await this.glueController.gluePromise,this.logger?.info(`[${e}] - getAppMetadata() invoked with appIdentifier ${t}`);const{appId:n,instanceId:r}=t,o=this.glueController.getApplication(n);if(!o)throw{message:El.AppNotFound,reason:`Cannot find application with appId: ${n}`};if(!r)return this.logger?.info(`[${e}] - no opened instances found. Parsing app ${o}`),this.parseGlueAppToAppMetadata(o);const i=this.glueController.getAppInstanceById(r),s=this.parseGlueAppToAppMetadata(o,i);return this.logger?.info(`[${e}] - found app metadata: ${s}`),s}async getInfo({commandId:e}){await this.glueController.gluePromise,this.logger?.info(`${e} - getInfo() invoked`);const t=await this.getCurrentAppMetadata(),{provider:n,providerVersion:r,standardVersion:o}=window.fdc3Info;return{provider:n,providerVersion:r,fdc3Version:o,optionalFeatures:{OriginatingAppMetadata:!0,UserChannelMembershipAPIs:!0,DesktopAgentBridging:!1},appMetadata:t}}getCurrentAppMetadata(){const e=this.glueController.interopInstance();return Promise.resolve({appId:e.applicationName,instanceId:e.instance})}parseGlueInstToAppIdentifier(e){return{appId:e.application.name,instanceId:e.id}}async parseGlueAppToAppMetadata(e,t){const n=await this.getBaseGlueAppToAppMetadata(e);return t?this.addInstanceMetadataToAppMetadata(n,t):n}async getBaseGlueAppToAppMetadata(e){const t=window.glue42gd||window.iodesktop,n=t?await e.getConfiguration():e.userProperties,r=t?(await e.getConfiguration()).icon:e.icon;return{appId:e.name,name:e.name,version:e.version,description:n.description,title:e.title,icons:r?[{src:r}]:[],tooltip:n.tooltip,screenshots:t?n.customProperties.screenshots:n.screenshots}}addInstanceMetadataToAppMetadata(e,t){return{...e,instanceId:t.id,instanceMetadata:t.agm}}async openAppWithContext(e,t){const n=Ms(),r=this.buildStartContext(t,n),o=this.createContextListenerWrappedPromise(e);this.appsStateStore.addOpenAppPromise(n,o);try{const t=await e.start(r);return await o.promise,this.appsStateStore.removeOpenAppPromise(n),this.parseGlueInstToAppIdentifier(t)}catch(e){throw this.appsStateStore.removeOpenAppPromise(n),{message:El.AppTimeout,reason:"string"==typeof e?e:JSON.stringify(e)}}}buildStartContext(e,t){const n=this.glueController.getMyInteropInstance();return{fdc3:{collaborationId:t,openApp:{appId:n.application||n.applicationName||"",instanceId:n.instance},context:{contextType:e.type,payload:e}}}}createContextListenerWrappedPromise(e){let t=()=>{},n=()=>{};return{promise:js(()=>new Promise((e,r)=>{t=e,n=r}),this.defaultContextListenerInvokedPromiseTimeout,`Timeout of ${this.defaultContextListenerInvokedPromiseTimeout}ms hit waiting for application with appId: ${e.name} to register context listener`),resolve:t,reject:n}}}class Gl{glueController;eventDispatcher;glueResponseReceived=!1;glueInitialized=!1;_glueReceiverHandler;events={start:{name:"start",handle:this.handleStart.bind(this)},requestGlueResponse:{name:"requestGlueResponse",handle:this.handleRequestGlueResponse.bind(this)}};constructor(e,t){this.glueController=e,this.eventDispatcher=t}start(){this.wireCustomEventListener(),this.eventDispatcher.fireNotifyStarted()}wireCustomEventListener(){this._glueReceiverHandler=this.glueReceiverHandler.bind(this),window.addEventListener(xl,this._glueReceiverHandler)}handleStart(){this.eventDispatcher.fireRequestGlue()}glueReceiverHandler(e){const t=e.detail;if(!t||!t.glue42)return;const n=t.glue42.event,r=this.events[n];r&&r.handle(t.glue42.message)}async handleRequestGlueResponse(e){if(this.glueResponseReceived&&this.glueInitialized)return;this.glueResponseReceived=!0;const{glue:t}=e,n=this.glueController.validateGlue(t);if(!n.isValid)return this.glueController.initializeFailed(n.error),void window.removeEventListener(xl,this._glueReceiverHandler);window.removeEventListener(xl,this._glueReceiverHandler),this.glueController.initialize(t),this.eventDispatcher.fireFdc3Ready(),this.glueInitialized=!0}}class Hl{_privateChannels={};addPrivateChannel(e){this._privateChannels[e.id]=e}getPrivateChannelById(e){return this._privateChannels[e]}removePrivateChannelById(e){delete this._privateChannels[e]}}function Vl(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}Vl.default=Vl;var Ql=r(Vl);class Jl{channelsController;logger;isCreator;id;type=Ma.Private;displayMetadata;myAppMetadata;unsubFromInstanceStopped;collaborator;disconnected=!1;lastBroadcastedContextType;broadcastedContexts={};collaboratorListenerTypes=[];myListenerTypesBeforeBound=[];registry=Ql();constructor(e,t,n,r){this.channelsController=e,this.logger=t,this.isCreator=r,this.id=n;const o=this.channelsController.getMyServerInstance();this.myAppMetadata={source:{appId:o.applicationName,instanceId:o.instance}}}toApi(){return{id:this.id,type:this.type,displayMetadata:this.displayMetadata,broadcast:this.broadcast.bind(this),getCurrentContext:this.getCurrentContext.bind(this),addContextListener:this.addContextListener.bind(this),onAddContextListener:this.onAddContextListener.bind(this),onUnsubscribe:this.onUnsubscribe.bind(this),onDisconnect:this.onDisconnect.bind(this),disconnect:this.disconnect.bind(this)}}getCollaborator(){return this.collaborator}setCollaborator(e,t){if(this.collaborator&&this.collaborator.instanceId!==e.instanceId)throw new Error(`There's already a collaborator for private channel with id ${this.id}`);this.collaborator=e,this.subscribeForCollaboratorInstanceStop(t)}async handleCollaboratorJoin(e,t){this.setCollaborator(e,t),await Promise.all(this.myListenerTypesBeforeBound.map(e=>{const n={action:"addedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e||void 0}};return this.logger?.trace(`[${t}] - announcing addedContextListenerOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),this.channelsController.invokeSystemMethod(n,this.collaborator?.instanceId)})).catch(e=>this.logger?.error(e))}handleCollaboratorBroadcast(e,t,n){this.logger?.trace(`[${n}] - heard context with type ${e.type} broadcasted on the channel`),this.lastBroadcastedContextType=e.type,this.broadcastedContexts[e.type]={context:e,metadata:t},this.logger?.trace(`[${n}] - invoking all context listeners`),this.registry.execute(za.ListenerAdded,e,t)}handleCollaboratorAddContextListener(e,t){this.logger?.trace(`[${t}] - heard collaborator added context listener for type ${e}`),this.collaboratorListenerTypes.push(e),this.registry.execute(za.OnAddContextListener,e)}handleCollaboratorRemovedListener(e,t){this.logger?.trace(`[${t}] - heard collaborator removed context listener with type ${e}`);const n=this.collaboratorListenerTypes.indexOf(e);this.collaboratorListenerTypes.splice(n,1),this.registry.execute(za.OnUnsubscribe,e)}handleCollaboratorDisconnect(){this.disconnected=!0,this.collaboratorListenerTypes.forEach(e=>this.registry.execute(za.OnUnsubscribe,e)),this.registry.execute(za.OnDisconnect)}async announceJoin(e,t){const n={action:"joinPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id}};this.logger?.trace(`[${t}] - announcing joinPrivateChannel to target instance with id ${JSON.stringify(e)}`),await this.channelsController.invokeSystemMethod(n,e),this.logger?.trace(`[${t}] - collaborator received joinPrivateChannel action`)}async broadcast(e){if(!ml.run(e).ok)throw new Error(Dl.MalformedContext);const t=Bs();this.ensureAlive(t),this.ensureBound(t,"broadcast"),this.lastBroadcastedContextType=e.type,this.broadcastedContexts[e.type]={context:e,metadata:this.myAppMetadata};const n={action:"publishOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e.type,payload:e}};this.logger?.trace(`[${t}] - announcing publishOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),await this.channelsController.invokeSystemMethod(n,this.collaborator?.instanceId),this.logger?.trace(`[${t}] - collaborator received context for action publishOnPrivateChannel`)}async getCurrentContext(e){const t=Bs();this.ensureAlive(t);const n=e?` with contextType ${e}`:"";if(this.logger?.trace(`[${t}] - getCurrentContext invoked ${n}`),bl.runWithException(e),!e&&!this.lastBroadcastedContextType)return null;const r=e||this.lastBroadcastedContextType;return this.logger?.trace(`[${t}] - Returning context with type ${r}`),this.broadcastedContexts[r].context}async addContextListener(e,t){const n=Bs();if(this.ensureAlive(n),bl.runWithException(e),"function"!=typeof t)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};this.logger?.trace(`[${n}] - adding subscription for broadcasted contexts with type: ${e}`);const r=this.retrieveLatestBroadcastedContextPerType(e),o=r?[[r.context,r.metadata]]:void 0,i=this.registry.add(za.ListenerAdded,(n,r)=>{e?n.type===e&&t(n,r):t(n,r)},o);if(!this.collaborator){this.myListenerTypesBeforeBound.push(e);const t=this.getAddContextListenerUnsub(i,e,n);return Ns(t)}const s={action:"addedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:e||void 0}};this.logger?.trace(`[${n}] - announcing addedContextListenerOnPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`),await this.channelsController.invokeSystemMethod(s,this.collaborator?.instanceId),this.logger?.trace(`[${n}] - collaborator received action addedContextListenerOnPrivateChannel`);const a=this.getAddContextListenerUnsub(i,e,n);return Ns(a)}retrieveLatestBroadcastedContextPerType(e){if(e||this.lastBroadcastedContextType)return!e&&this.lastBroadcastedContextType?{context:this.broadcastedContexts[this.lastBroadcastedContextType].context,metadata:this.broadcastedContexts[this.lastBroadcastedContextType].metadata}:this.broadcastedContexts[e]}getAddContextListenerUnsub(e,t,n){return async()=>{if(e(),!this.collaborator){const e=this.myListenerTypesBeforeBound.indexOf(t);return void this.myListenerTypesBeforeBound.splice(e,1)}const r={action:"removedContextListenerOnPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id,contextType:t||void 0}};this.logger?.trace(`[${n}] - announcing unsubscribe from context listener for type ${t}`),await this.channelsController.invokeSystemMethod(r,this.collaborator?.instanceId),this.logger?.trace(`[${n}] - collaborator heard removedContextListenerOnPrivateChannel`)}}onAddContextListener(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnAddContextListener,e,this.collaboratorListenerTypes);return Ns(n)}onUnsubscribe(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnUnsubscribe,e);return Ns(n)}onDisconnect(e){if("function"!=typeof e)throw{message:Dl.AccessDenied,reason:"Expected function as an argument, got "+typeof e};const t=Bs();this.ensureAlive(t);const n=this.registry.add(za.OnDisconnect,e);return Ns(n)}async disconnect(){const e=Bs();if(this.isCreator&&!this.collaborator)return void(this.disconnected=!0);this.ensureAlive(e),this.ensureBound(e,"disconnect"),this.logger?.trace(`[${e}] - disconnect invoked`),this.disconnected=!0,this.logger?.trace(`[${e}] - announcing disconnectedFromPrivateChannel to collaborator ${JSON.stringify(this.collaborator)}`);const t={action:"disconnectedFromPrivateChannel",correlationId:this.id,collaborationObject:{channelId:this.id}};this.channelsController.removePrivateChannelFromStoreById(this.id),await this.channelsController.invokeSystemMethod(t,this.collaborator?.instanceId),this.logger?.trace(`[${e}] - collaborator received action disconnectedFromPrivateChannel`),this.unsubFromInstanceStopped&&this.unsubFromInstanceStopped()}ensureAlive(e){if(!this.disconnected)return;const t="Channel is disconnected - operation is no longer available";throw this.logger?.error(`[${e}] - ${t}`),{message:Dl.AccessDenied,reason:t}}ensureBound(e,t){if(this.collaborator)return;const n=`There's no collaborator on the other side of the channel - operation ${t} is unavailable`;throw this.logger?.error(`[${e}] - ${n}`),{message:Dl.AccessDenied,reason:n}}subscribeForCollaboratorInstanceStop(e){this.unsubFromInstanceStopped=this.channelsController.subscribeOnInstanceStop(this.id,(e=>{e.id===this.collaborator?.instanceId&&this.handleCollaboratorDisconnect()}).bind(this),e)}}class Kl{createUserChannelFn;createAppChannel;createPrivateChannel;constructor(e,t,n){this.createUserChannelFn=e,this.createAppChannel=t,this.createPrivateChannel=n}buildPrivateChannel(e){return this.createPrivateChannel(e.logger,e.id,e.isCreator)}buildModel(e){if(e.type===Ma.User)return this.createUserChannelFn(e.displayMetadata.glueChannel);if(e.type===Ma.App)return this.createAppChannel(e.id);throw new Error("Pass one of the supported channel types: user, app, private")}}class Yl{glueController;channelsStateStore;appsStateStore;_logger;actionDictionary={joinPrivateChannel:this.handleJoin.bind(this),publishOnPrivateChannel:this.handlePublish.bind(this),addedContextListenerOnPrivateChannel:this.handleContextListenerAdded.bind(this),removedContextListenerOnPrivateChannel:this.handleContextListenerRemoved.bind(this),disconnectedFromPrivateChannel:this.handleDisconnect.bind(this),startupContextOpened:this.handleStartupContextOpened.bind(this)};constructor(e,t,n){this.glueController=e,this.channelsStateStore=t,this.appsStateStore=n}async initializeCollaborateMethod(){this.checkSystemMethodRegistered()||await this.glueController.registerMethod(qa,this.handleReceivedAction.bind(this))}checkSystemMethodRegistered(){const e=this.glueController.getInteropMethods(qa),t=this.glueController.getMyInteropInstance().instance;return!!e.filter(e=>e.getServers().find(e=>e.instance===t)?e:void 0).length}async handleReceivedAction(e,t){const n=Il.run(e);if(!n.ok)throw new Error(`Interop Method ${qa} invoked with invalid argument object - ${n.error}`);const r=Bs();this.logger?.log(`${r} - received system method from instance with id ${t.instance} for action ${e.action} with arguments: ${JSON.stringify(e)}`);const o=this.actionDictionary[e.action];if(!o){const t=`Unsupported private channel action: ${e.action}`;throw this.logger?.error(`[${r}] - ${t}`),new Error(t)}await o(e,t,r)}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.private.channels.controller")),this._logger}validateAndRetrieveChannel({action:e,correlationId:t},n,r){const o=this.channelsStateStore.getPrivateChannelById(t);if(!o){const e=`There's no private channel with id ${t}`;throw this.logger?.error(`[${r}] - ${e}`),new Error(e)}const i=o.getCollaborator();if("joinPrivateChannel"===e)return o;if(i&&i.instanceId===n.instance)return this.logger?.log(`[${r}] - request sent from correct collaborator with id ${n.instance}. Returning channel`),o;const s=`Cannot proceed with action ${e} - ${i?`private channel ${t} established communication with collaborator with id ${i}`:`no collaborator joined private channel with id ${t}`}`;throw this.logger?.error(s),new Error(s)}async handleJoin(e,t,n){const r={appId:t.application||t.applicationName,instanceId:t.instance},o=this.validateAndRetrieveChannel(e,t,n);await o.handleCollaboratorJoin(r,n),this.logger?.log(`[${n}] - collaborator ${JSON.stringify(r)} set for private channel with id ${e.correlationId}`)}handlePublish(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, adding context with type ${e.collaborationObject?.contextType} to the private channel broadcasted contexts`);const r=this.validateAndRetrieveChannel(e,t,n),o={source:{appId:t.application||t.applicationName||"",instanceId:t.instance}};r.handleCollaboratorBroadcast(e.collaborationObject?.payload,o,n)}handleContextListenerAdded(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onAddContextListener' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorAddContextListener(e.collaborationObject?.contextType||null,n)}handleContextListenerRemoved(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onUnsubscribe' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorRemovedListener(e.collaborationObject?.contextType||null,n)}handleDisconnect(e,t,n){this.logger?.log(`[${n}] - received ${e.action} action, invoking all 'onDisconnect' callbacks`),this.validateAndRetrieveChannel(e,t,n).handleCollaboratorDisconnect()}handleStartupContextOpened(e,t,n){this.logger?.log(`[${n}] - received ${e.action} with correlationId: ${e.correlationId} from instance with id ${t.instance}`);const r=this.appsStateStore.getOpenAppPromise(e.correlationId);r?(this.logger?.log(`[${n}] - resolving open app promise related to guid ${e.correlationId} from instance with id ${t.instance}`),r.resolve()):this.logger?.log(`[${n}] - there's no open app promise related to guid ${e.correlationId}`)}}class Zl{openAppPromises={};addOpenAppPromise(e,t){this.openAppPromises[e]=t}getOpenAppPromise(e){return this.openAppPromises[e]}removeOpenAppPromise(e){delete this.openAppPromises[e]}}class Xl{glueController;stateStore;parser;channelsFactory;glueEventsController;legacyController;ioFdc3SupportedController;_logger;initDonePromise;invokeContextHandlerWithStartupContext=!0;isFdc3DataWrappingSupported;constructor(e,t,n,r,o,i,s){this.glueController=e,this.stateStore=t,this.parser=n,this.channelsFactory=r,this.glueEventsController=o,this.legacyController=i,this.ioFdc3SupportedController=s,this.initDonePromise=this.initialize(),this.initDonePromise.catch(e=>{this.logger?.error(e)})}async getStartupContext(){await this.initDonePromise;const e=await this.glueController.getMyWindowContext();return e?.fdc3?.context?.payload||null}async addContextListener({commandId:e,handler:t,contextType:n,channelId:r}){await this.initDonePromise,this.logger?.info(`[${e}] - addContextListener() invoked for contextType ${n} and channelId ${r}`),this.invokeContextHandlerWithStartupContext&&!r&&(this.logger?.info(`[${e}] - trying to invoke context handler with window context`),this.handleWindowContextOnOpening(e,t,n).catch(t=>this.logger?.warn(`[${e}] - ${t}`)));const o=r||(await this.getCurrentChannel(e))?.id,i="multi"===this.glueController.getChannelsMode()&&(await this.glueController.getMyChannels()).length>1,s=ql(t,n);return!o||i?{unsubscribe:this.glueController.channelsSubscribe(s,n)}:this.addContextListenerByChannelId({commandId:e,handler:s,invokedOnChannelModel:!!r,channelId:o,contextType:n})}async broadcast(e,t,n){if(await this.initDonePromise,this.logger?.info(`[${e}] - broadcast() invoked with contextType ${t.type} and channelId ${n}`),!await this.isBroadcastPermitted(e,n))return;const r=n||(await this.getCurrentChannel(e))?.id;if(!r)return;const o="multi"===this.glueController.getChannelsMode()&&(await this.glueController.getMyChannels()).length>1;return!r||o?this.glueController.channelsUpdate(t,{fdc3:!0}):this.broadcastByChannelId(e,r,t)}async getUserChannels(e){await this.initDonePromise,this.logger?.info(`[${e}] - getUserChannels() invoked`);const t=await this.glueController.listAllChannels();return this.mapIoToFDC3Channels(t)}async getOrCreateChannel({commandId:e,channelId:t}){await this.initDonePromise,this.logger?.info(`[${e}] - getOrCreateChannel() invoked for channel with id ${t}`);const n=(await this.getUserChannels(e)).find(e=>e.id===t);if(n)return n;if(this.stateStore.getPrivateChannelById(t))throw this.logger?.error("Cannot retrieve a private channel"),new Error(Dl.AccessDenied);return this.getOrCreateAppChannel(e,t)}async joinUserChannel({commandId:e,channelId:t}){if(await this.initDonePromise,this.logger?.info(`[${e}] - joinUserChannel() invoked for channel with id ${t}`),this.doesAppChannelExist(t))throw this.logger?.error("Cannot join an app channel"),new Error(Dl.AccessDenied);if(!(await this.getUserChannels(e)).find(e=>e.id===t))throw this.logger?.error(`Cannot find user channel with id ${t}`),new Error(Dl.NoChannelFound);const n=(await this.getOrCreateChannel({commandId:e,channelId:t}))?.displayMetadata?.name;if(!n)throw this.logger?.error(`[${e}] - Cannot find io channel name for fdc3 channel with id ${t}`),new Error(Dl.NoChannelFound);this.logger?.info(`[${e}] - joining fdc3 user channel with id ${t} (underlying io channel: ${n})`),await this.glueController.joinChannel(n)}async getCurrentChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - getCurrentChannel() invoked`);const t=await this.glueController.getMyChannel();return t?.meta.fdc3?this.channelsFactory.buildModel({type:Ma.User,displayMetadata:{glueChannel:t}}):null}async leaveCurrentChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - leaveCurrentChannel() invoked`),await this.getCurrentChannel(e)?(await this.glueController.leaveChannel(),this.logger?.info(`[${e}] - current channel is left. unsubscribing from all listeners`)):this.logger?.info(`[${e}] - no channel to leave`)}async getContextForChannel({commandId:e,channelId:t,contextType:n}){if(await this.initDonePromise,this.logger?.info(`[${e}] - getContextForChannel() invoked for channel with id ${t}`),await this.isUserChannel(e,t))return this.userChannelsSupportController.getContext({commandId:e,channelId:t,contextType:n});if(!n){const e=await this.glueController.getContext(t);return e.latest_fdc3_type?this.parser.parseContextsDataToInitialFDC3Data(e):null}const r=this.parser.mapFDC3TypeToChannelsDelimiter(n),{data:o}=await this.glueController.getContext(t);return o?.[`fdc3_${r}`]?this.parser.parseContextsDataToInitialFDC3Data({data:o,latest_fdc3_type:r}):null}async createPrivateChannel(e){await this.initDonePromise,this.logger?.info(`[${e}] - createPrivateChannel() invoked`);const t=`${Ua}${Ms()}`;return await this.glueEventsController.initializeCollaborateMethod(),this.buildPrivateChannel(t,e,!0).toApi()}async removePrivateChannelFromStoreById(e){this.stateStore.removePrivateChannelById(e)}async invokeSystemMethod(e,t){if(t)return this.glueController.invokeSystemMethod(e,t)}getMyServerInstance(){return this.glueController.getMyInteropInstance()}async addClientToPrivateChannel(e,t,n){this.logger?.info(`[${e}] - client with id ${n} added to private channel with id ${t}`),await this.glueController.updateContext(t,{clientId:n})}async isPrivateChannelDisconnected({commandId:e,channelId:t}){return this.logger?.info(`[${e}] - checking if private channel with id ${t} is disconnected`),!!(await this.glueController.getContext(t)).disconnected}subscribeOnInstanceStop(e,t,n){return this.logger?.info(`[${n}] - subscribing onInstanceStopped callback for channel with id ${e}`),this.glueController.registerOnInstanceStopped(t.bind(this))}buildPrivateChannel(e,t,n){const r=this.glueController.initSubLogger(e),o=this.channelsFactory.buildPrivateChannel({id:e,logger:r,isCreator:n});return this.logger?.info(`[${t}] - private channel with id ${e} created. Adding it to the store`),this.stateStore.addPrivateChannel(o),o}buildChannel(e,t){return this.channelsFactory.buildModel({type:e,...t})}async publish(e,t){return(await this.glueController.getMyChannels()).length?this.glueController.channelsUpdate(t,{fdc3:!0}):(this.logger?.info(`[${e}] - invocation of publish ignored - no channel to publish to`),void console.warn("You need to join a user channel to broadcast data"))}async getCurrentChannels(e){await this.initDonePromise,this.logger?.info(`[${e}] - getCurrentChannels() invoked`);const t=await this.glueController.getMyChannels();return this.mapIoToFDC3Channels(t)}async leave(e,t){if(await this.initDonePromise,this.logger?.info(`[${e}] - leave() invoked with options: ${JSON.stringify(t)}`),!t?.channelId)return this.logger?.info(`[${e}] - leaving all channels`),this.glueController.leaveChannel();const n=(await this.glueController.listAllChannels()).find(e=>e.meta.fdc3?.id===t.channelId);if(!n)throw new Error(Dl.NoChannelFound);return this.logger?.info(`[${e}] - leaving channel '${n.name}'`),this.glueController.leaveChannel({channel:n.name})}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.channels.controller")),this._logger}get userChannelsSupportController(){return this.isFdc3DataWrappingSupported?this.ioFdc3SupportedController:this.legacyController}async initialize(){await this.glueController.gluePromise,this.isFdc3DataWrappingSupported=await this.glueController.checkIsFdc3DataWrappingSupported()}async isBroadcastPermitted(e,t){if(t)return!0;const n=await this.getCurrentChannel(e);return n?n.type!==Ma.App||(this.logger?.info(`[${e}] - invocation of broadcast ignored - cannot broadcast on app channel directly`),console.error("You can't broadcast to an app channel directly - use channel's broadcast method instead"),!1):(this.logger?.info(`[${e}] - invocation of broadcast ignored - no channel to broadcast to`),console.warn("You need to join a user channel in order to broadcast"),!1)}mapIoToFDC3Channels(e){return e.filter(e=>e.meta.fdc3).map(e=>this.channelsFactory.buildModel({type:Ma.User,displayMetadata:{glueChannel:e}}))}async handleWindowContextOnOpening(e,t,n){const r=this.glueController.getMyWindow();if(!r)return this.logger?.trace(`[${e}] - Cannot get window context because this is not a Glue window, it's probably an iframe`),void(this.invokeContextHandlerWithStartupContext=!1);const o=await r.getContext();if(!o)return this.logger?.trace(`[${e}] - Cannot get window context because this is not a Glue window, it's probably an iframe`),void(this.invokeContextHandlerWithStartupContext=!1);if(!$s(o)||!o.fdc3)return this.logger?.info(`[${e}] - addContextListener handler won't be invoked - startup context is empty`),void(this.invokeContextHandlerWithStartupContext=!1);await this.glueEventsController.initializeCollaborateMethod(),kl.runWithException(o);const{fdc3:i}=o;if(this.logger?.trace(`[${e}] - received FDC3 startup context from ${JSON.stringify(i.openApp)} for contextType ${i.context.contextType}`),n&&i.context.contextType!==n)this.logger?.info(`[${e}] - addContextListener handler won't be invoked for contextType ${n} for startup context with type: ${i.context.contextType}`);else{this.logger?.info(`[${e}] - invoking addContextListener handler with startup context with type ${i.context.contextType}`);try{t(i.context.payload,{source:i.openApp})}catch(e){const t=e.message?JSON.stringify(e.message):JSON.stringify(e);this.logger?.error("string"==typeof e?e:t)}this.invokeContextHandlerWithStartupContext=!1,this.logger?.trace(`[${e}] - invoking response method to with target ${JSON.stringify(i.openApp)}`),await this.invokeSystemMethod({action:"startupContextOpened",correlationId:i.collaborationId},i.openApp.instanceId),this.logger?.trace(`[${e}] - system method invocation success for 'startupContextOpened' heard`)}}async getOrCreateAppChannel(e,t){this.doesAppChannelExist(t)||(this.logger?.info(`[${e}] - app channel with id ${t} does not exist. Creating one`),await this.glueController.updateContext(t,{})),this.logger?.info(`[${e}] - returning app channel with id ${t}`);const n=this.glueController.initSubLogger(`app.channel.${t}`);return this.channelsFactory.buildModel({type:Ma.App,id:t,logger:n})}doesAppChannelExist(e){return!e.includes(Ua)&&this.glueController.getAllContexts().some(t=>t===e)}async isUserChannel(e,t){return!!t&&(await this.getUserChannels(e)).some(e=>e.id===t)}async broadcastByChannelId(e,t,n){if(!await this.isUserChannel(e,t))return this.logger?.info(`[${e}] - broadcasting on app channel with id ${t}`),this.glueController.updateContextWithLatestFdc3Type(t,n);const r=(await this.getOrCreateChannel({commandId:e,channelId:t}))?.displayMetadata?.name;if(!r)throw this.logger?.error(`[${e}] - Cannot find io channel name for fdc3 channel with id ${t}`),new Error(Dl.NoChannelFound);return this.logger?.info(`[${e}] - broadcasting on fdc3 user channel with id ${t} (underlying glue channel: ${r})`),this.userChannelsSupportController.broadcast({ioChannelName:r,context:n})}async addContextListenerByChannelId({commandId:e,channelId:t,handler:n,contextType:r,invokedOnChannelModel:o}){const i=ql(n,r),s=await this.getChannelTypeById(e,t);if(s===Ma.User)return this.userChannelsSupportController.addContextListener({commandId:e,channelId:t,handler:i,contextType:r,invokedOnChannelModel:o});if(s===Ma.App){this.logger?.info(`[${e}] - subscribing for fdc3 app channel with id ${t} (underlying glue context with same name)`);const n=await this.glueController.contextsSubscribe(t,i);return{unsubscribe:()=>{this.logger?.info(`[${e}] - invoking unsubscribe for app channel with id ${t}`),n()}}}throw this.logger?.error("Cannot add a context listener on an invalid channel"),new Error(Dl.AccessDenied)}async getChannelTypeById(e,t){if(await this.isUserChannel(e,t))return Ma.User;if(this.doesAppChannelExist(t))return Ma.App;throw this.logger?.error(`Channel with id: ${t} does not exist`),new Error(Dl.NoChannelFound)}}class eu{parser;glueController;_logger;constructor(e,t){this.parser=e,this.glueController=t}async getContext({commandId:e,channelId:t,contextType:n}){this.logger?.info(`[${e}] - retrieving latest context of type ${n} broadcasted on channel with id ${t}`);const r=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!r)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);if(!n){const n=this.parser.mapChannelNameToContextName(r);this.logger?.info(`[${e}] - getting context for user channel with id ${t} (underlying glue channel ${r})`);const o=await this.glueController.getContext(n);return o.latest_fdc3_type?this.parser.parseContextsDataToInitialFDC3Data(o):null}const o=this.parser.mapFDC3TypeToChannelsDelimiter(n),{data:i}=await this.glueController.getChannel(r);return i?.[`fdc3_${o}`]?this.parser.parseContextsDataToInitialFDC3Data({data:i,latest_fdc3_type:o}):null}async broadcast({ioChannelName:e,context:t}){const{path:n,value:r}=this.parser.parseFDC3ContextToGlueContexts(t);return this.glueController.channelsUpdate({[n]:r},e)}async addContextListener({commandId:e,channelId:t,handler:n,invokedOnChannelModel:r,contextType:o}){if(!r)return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:this.glueController.legacyChannelsSubscribe(n,o)};const i=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!i)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const s=this.parser.mapChannelNameToContextName(i);return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:await this.glueController.contextsSubscribe(s,n)}}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.legacy.channels.controller")),this._logger}}class tu{parser;glueController;_logger;constructor(e,t){this.parser=e,this.glueController=t}async getContext({commandId:e,channelId:t,contextType:n}){this.logger?.info(`[${e}] - retrieving latest context of type ${n} broadcasted on channel with id ${t}`);const r=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!r)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const o=await this.glueController.getChannel(r);if(!n)return o.data.fdc3||null;if(n&&o.data.fdc3?.type===n)return o.data.fdc3;const i=this.parser.mapChannelNameToContextName(r),{data:s}=await this.glueController.getContext(i),a=this.parser.mapFDC3TypeToChannelsDelimiter(n);return s?.[`fdc3_${a}`]?this.parser.parseContextsDataToInitialFDC3Data({data:s,latest_fdc3_type:a}):null}async broadcast({ioChannelName:e,context:t}){return this.glueController.channelsUpdate(t,{name:e,fdc3:!0})}async addContextListener({commandId:e,channelId:t,invokedOnChannelModel:n,handler:r,contextType:o}){if(!n)return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:this.glueController.channelsSubscribe(r,o)};const i=await this.glueController.getIoChannelNameByFDC3ChannelId(t);if(!i)throw this.logger?.error(`[${e}] - io channel with fdc3 channel id ${t} not found`),new Error(Dl.AccessDenied);const s=this.parser.mapChannelNameToContextName(i);return this.logger?.info(`[${e}] - subscribing for fdc3 user channel with id ${t}`),{unsubscribe:await this.glueController.contextsSubscribe(s,r)}}get logger(){return this._logger||(this._logger=this.glueController.initSubLogger("fdc3.ioSupport.channels.controller")),this._logger}}class nu{_eventDispatcher;_eventReceiver;_desktopAgent;_glueController;_intentsController;_applicationController;_channelsBaseController;_legacyDataWrappingChannelsController;_newDataWrappingChannelsController;_channelsParser;_channelsStateStore;_channelsFactory;_fdc3;_eventsController;_applicationsStateStore;get ioc(){return this}get eventReceiver(){return this._eventReceiver||(this._eventReceiver=new Gl(this.glueController,this.eventDispatcher)),this._eventReceiver}get glueController(){return this._glueController||(this._glueController=new Tl(this.channelsParser,this.channelsStateStore)),this._glueController}get fdc3(){return this._fdc3||(this._fdc3=this.desktopAgent.toApi()),this._fdc3}get eventDispatcher(){return this._eventDispatcher||(this._eventDispatcher=new Al),this._eventDispatcher}get channelsFactory(){return this._channelsFactory||(this._channelsFactory=new Kl(this.createUserChannel.bind(this),this.createAppChannel.bind(this),this.createPrivateChannel.bind(this))),this._channelsFactory}createUserChannel(e){return new jl(this.channelsBaseController,e).toApi()}createAppChannel(e){return new $l(this.channelsBaseController,e).toApi()}createPrivateChannel(e,t,n){return new Jl(this.channelsBaseController,e,t,n)}get desktopAgent(){return this._desktopAgent||(this._desktopAgent=new Ml(this.intentsController,this.applicationController,this.channelsBaseController)),this._desktopAgent}get channelsParser(){return this._channelsParser||(this._channelsParser=new Nl),this._channelsParser}get intentsController(){return this._intentsController||(this._intentsController=new Ul(this.glueController,this.channelsBaseController,this.channelsFactory,this.eventsController)),this._intentsController}get applicationController(){return this._applicationController||(this._applicationController=new zl(this.glueController,this.applicationsStateStore,this.eventsController)),this._applicationController}get channelsBaseController(){return this._channelsBaseController||(this._channelsBaseController=new Xl(this.glueController,this.channelsStateStore,this.channelsParser,this.channelsFactory,this.eventsController,this.legacyDataWrappingChannelsController,this.ioFdc3SupportChannelsController)),this._channelsBaseController}get legacyDataWrappingChannelsController(){return this._legacyDataWrappingChannelsController||(this._legacyDataWrappingChannelsController=new eu(this.channelsParser,this.glueController)),this._legacyDataWrappingChannelsController}get ioFdc3SupportChannelsController(){return this._newDataWrappingChannelsController||(this._newDataWrappingChannelsController=new tu(this.channelsParser,this.glueController)),this._newDataWrappingChannelsController}get channelsStateStore(){return this._channelsStateStore||(this._channelsStateStore=new Hl),this._channelsStateStore}get eventsController(){return this._eventsController||(this._eventsController=new Yl(this.glueController,this.channelsStateStore,this.applicationsStateStore)),this._eventsController}get applicationsStateStore(){return this._applicationsStateStore||(this._applicationsStateStore=new Zl),this._applicationsStateStore}}let ru=window.fdc3;window.fdc3Info={provider:"io.Connect",providerVersion:"2.5.1",standardVersion:"2.1"},void 0===ru?(ru=(()=>{const e=new nu;return e.glueController.createGluePromise(),e.eventReceiver.start(),e.fdc3})(),window.fdc3=ru):console.warn("Defaulting to using the auto-injected fdc3.");let ou=(e=21)=>{let t="",n=0|e;for(;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t};function iu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function su(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}su.default=su;var au=iu(su);const lu="done",uu="in-progress",cu="error",du="info",hu="search",pu="cancel";var gu=function(e){return{ok:!0,result:e}},fu=function(e){return{ok:!1,error:e}},mu=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:gu(e(t.result,n.result))},yu=function(e,t){return!0===t.ok?t:fu(e(t.error))},wu=function(){return wu=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wu.apply(this,arguments)};function vu(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!vu(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!vu(e[r[n]],t[r[n]]))return!1}return!0}}var bu=function(e){return Array.isArray(e)},Cu=function(e){return"object"==typeof e&&null!==e&&!bu(e)},Su=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},Iu=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},ku=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return wu({at:e+(n||"")},r)},Tu=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return yu(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?gu(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?gu(e):fu({message:Su("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?gu(e):fu({message:Su("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?gu(e):fu({message:Su("a boolean",e)})})},e.constant=function(t){return new e(function(e){return vu(e,t)?gu(t):fu({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(Cu(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?fu({message:"the key '"+r+"' is required but was not present"}):fu(ku("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return gu(n)}return Cu(e)?gu(e):fu({message:Su("an object",e)})})},e.array=function(t){return new e(function(e){return bu(e)&&t?e.reduce(function(e,n,r){return mu(function(e,t){return e.concat([t])},e,function(e,n){return yu(function(e){return ku("["+n+"]",e)},t.decode(e))}(n,r))},gu([])):bu(e)?gu(e):fu({message:Su("an array",e)})})},e.tuple=function(t){return new e(function(e){if(bu(e)){if(e.length!==t.length)return fu({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return fu(ku("["+r+"]",o.error));n[r]=o.result}return gu(n)}return fu({message:Su("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return mu(Object.assign,t,n.decode(e))},gu({}))})},e.anyJson=function(){return new e(function(e){return gu(e)})},e.unknownJson=function(){return new e(function(e){return gu(e)})},e.dict=function(t){return new e(function(e){if(Cu(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return fu(ku("."+r,o.error));n[r]=o.result}return gu(n)}return fu({message:Su("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?gu(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return fu({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return gu(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return fu({at:Iu(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!Cu(r))return fu({at:Iu(t.slice(0,o+1)),message:Su("an object",r)});if("number"==typeof t[o]&&!bu(r))return fu({at:Iu(t.slice(0,o+1)),message:Su("an array",r)});r=r[t[o]]}return yu(function(e){return void 0===r?{at:Iu(t),message:"path does not exist"}:ku(Iu(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return gu(t)})},e.fail=function(t){return new e(function(e){return fu({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),xu=Tu.string,Au=Tu.number;Tu.boolean;var Eu=Tu.anyJson;Tu.unknownJson;var Wu=Tu.constant,Ou=Tu.object,Du=Tu.array;Tu.tuple,Tu.dict;var _u=Tu.optional,Pu=Tu.oneOf;Tu.union,Tu.intersection,Tu.withDefault,Tu.valueAt,Tu.succeed,Tu.fail,Tu.lazy;const Ru=xu().where(e=>e.length>0,"Expected a non-empty string"),Lu=Au().where(e=>e>=0,"Expected a non-negative number"),Fu=Ou({name:Ru,displayName:_u(Ru)}),Mu=Ou({id:Ru,interopId:Ru,name:Ru,appName:_u(Ru),types:_u(Du(Fu))}),$u=Ou({maxResults:_u(Lu),maxResultsPerType:_u(Lu)}),Nu=Ou({search:Ru,providers:_u(Du(Mu)),types:_u(Du(Fu)),providerLimits:_u($u)}),ju=Ou({name:Ru,types:_u(Du(Fu))}),Bu=Pu(Wu("cancel"),Wu("info"),Wu("search")),qu=Pu(Wu("done"),Wu("in-progress"),Wu("error")),Uu=Ou({id:Ru}),zu=Ou({method:Ru,target:_u(Pu(Ou({instance:Ru}),Wu("all"))),params:_u(Eu())}),Gu=Ou({name:Ru,method:Ru,target:_u(Pu(Ou({instance:Ru}),Wu("all"))),params:_u(Eu())}),Hu=Ou({type:Fu,id:_u(Ru),displayName:_u(Ru),description:_u(Ru),iconURL:_u(Ru),metadata:_u(Eu()),action:_u(zu),secondaryActions:_u(Du(Gu))}),Vu=Ou({type:xu(),category:_u(xu()),id:_u(xu()),displayName:_u(xu()),description:_u(xu()),iconURL:_u(xu()),action:_u(zu)}),Qu=Ou({items:Du(Pu(Hu,Vu)),provider:_u(Mu),queryId:Ru,status:Wu("in-progress")}),Ju=Ou({items:Du(Pu(Hu,Vu)),queryId:Ru,status:Wu("done")}),Ku=Ou({items:Du(Pu(Hu,Vu)),provider:_u(Mu),queryId:Ru,errorMessage:Ru,status:Wu("error")});class Yu{logger;glueController;modelFactory;registry=au();activeQueryLookup={};queryIdToMasterIdLookup={};pendingDebounce=[];debounceTimer;debounceMS=0;constructor(e,t,n){this.logger=e,this.glueController=t,this.modelFactory=n}setDebounceMS(e){this.logger.info(`[${e.commandId}] Setting the debounceMS to: ${e.milliseconds}`),this.debounceMS=e.milliseconds,this.logger.info(`[${e.commandId}] debounceMS set to: ${e.milliseconds}`)}getDebounceMS(e){return this.logger.info(`[${e.commandId}] Getting the debounceMS`),this.debounceMS}async query(e,t){if(this.debounceMS&&!t)return this.debounceQuery(e);await this.glueController.registerMainClientMethod(this.handleProviderCall.bind(this));const{queryConfig:n,commandId:r}=e;this.logger.info(`[${r}] Initiating a query request`);let o=await this.glueController.getAllProvidersInfo();this.logger.trace(`[${r}] Got all available providers: ${JSON.stringify(o)}`),n.providers&&(this.logger.info(`[${r}] Filtering providers by explicitly allowed providers.`),o=this.filterProvidersByAllowList(o,n.providers)),n.types&&(this.logger.info(`[${r}] Filtering providers by explicitly allowed types.`),o=this.filterProvidersByAllowedTypes(o,n.types)),o.length||this.logger.warn(`[${r}] There are no providers that can handle the query for ${e.queryConfig.search}`),this.logger.info(`[${r}] Sending query request to providers: ${JSON.stringify(o)}`);const i=await this.glueController.sendQueryRequest(n,o);this.logger.info(`[${r}] Received responses from the providers: ${JSON.stringify(i)}`);const s=this.generateMasterQueryId(),a=this.modelFactory.buildClientQueryModel(s,this);return this.logger.info(`[${r}] The query is in progress with master id: ${s}`),this.activeQueryLookup[s]={servers:i,model:a},i.forEach(e=>{this.queryIdToMasterIdLookup[e.queryId]=s}),i.length||setTimeout(()=>{this.registry.execute(`on-query-completed-${s}`),this.cleanUpQuery(s)},0),a.exposeFacade()}async cancelQuery(e,t){const n=this.activeQueryLookup[e];if(!n)throw new Error(`[${t}] Cannot cancel query: ${e}, because this query does not exist`);const r=n.servers;this.logger.info(`[${t}] Sending cancel query requests`),await Promise.all(r.map(e=>(this.logger.trace(`[${t}] Sending cancel query request to ${e.interopId} with queryId: ${e.queryId}`),this.glueController.sendQueryCancelRequest({id:e.queryId},{instance:e.interopId})))),this.logger.info(`[${t}] The query was cancelled`)}processClientOnResults(e){return this.registry.add(`on-query-results-${e.masterQueryId}`,e.callback)}processClientOnCompleted(e){return this.registry.add(`on-query-completed-${e.masterQueryId}`,e.callback)}processClientOnError(e){return this.registry.add(`on-query-error-${e.masterQueryId}`,e.callback)}async handleProviderCall(e){const{status:t}=e,n=qu.runWithException(t),r=ou(10);switch(n){case lu:return this.handleQueryCompleted({completedConfig:e,commandId:r});case uu:return this.handleQueryResults({resultsBatch:e,commandId:r});case cu:return this.handleQueryError({error:e,commandId:r});default:throw new Error(`Unrecognized status: ${t}`)}}handleQueryResults(e){const{resultsBatch:t,commandId:n}=e;this.logger.trace(`[${n}] Processing a results batch from provider: ${t.provider?.name} with id: ${t.provider?.id}`);const r=Qu.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received results for an unknown query. Provider ${JSON.stringify(r.provider)}, items: ${JSON.stringify(r.items)}`);this.logger.trace(`[${n}] The results batch is validated, forwarding to the callbacks`);const i=this.checkTransformLegacyResults(r.items),s={provider:r.provider,results:i};this.registry.execute(`on-query-results-${o}`,s)}handleQueryCompleted(e){const{completedConfig:t,commandId:n}=e;this.logger.trace(`[${n}] Processing a query completed message from query id: ${t.queryId}`);const r=Ju.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received completed message for an unknown query. Provider query id: ${JSON.stringify(r.queryId)}`);if(r.items.length){const e={results:this.checkTransformLegacyResults(r.items)};this.registry.execute(`on-query-results-${o}`,e)}delete this.queryIdToMasterIdLookup[r.queryId];const i=this.activeQueryLookup[o];i.servers=i.servers.filter(e=>e.queryId!==r.queryId),i.servers.length?this.logger.trace(`[${n}] Waiting for more providers to complete`):(this.logger.trace(`[${n}] All providers are done, marking this query as completed`),this.registry.execute(`on-query-completed-${o}`),this.cleanUpQuery(o))}handleQueryError(e){const{error:t,commandId:n}=e;this.logger.trace(`[${n}] Processing an error message from query: ${t.queryId}`);const r=Ku.runWithException(t),o=this.queryIdToMasterIdLookup[r.queryId];if(!o)return void this.logger.warn(`[${n}] Received error message for an unknown query. Provider query id: ${JSON.stringify(r.queryId)} and message: ${JSON.stringify(r.errorMessage)}`);const i={error:r.errorMessage,provider:r.provider};this.registry.execute(`on-query-error-${o}`,i)}filterProvidersByAllowList(e,t){const n=t.reduce((e,t)=>(e[t.id]=!0,e),{});return e.filter(e=>e.info.providers.some(e=>n[e.id]))}filterProvidersByAllowedTypes(e,t){const n=t.reduce((e,t)=>(e[t.name]=!0,e),{});return e.filter(e=>{const t=e.info.supportedTypes;return!!t.some(e=>"*"===e)||!t||!t.length||t.some(e=>n[e])})}generateMasterQueryId(){const e=ou(10);return this.activeQueryLookup[e]?this.generateMasterQueryId():e}cleanUpQuery(e){this.registry.clearKey(`on-query-results-${e}`),this.registry.clearKey(`on-query-completed-${e}`),this.registry.clearKey(`on-query-error-${e}`),delete this.activeQueryLookup[e]}debounceQuery(e){return new Promise((t,n)=>{clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{const t=[...this.pendingDebounce];this.pendingDebounce=[],this.query(e,!0).then(e=>t.forEach(({resolve:t})=>t(e))).catch(e=>t.forEach(({reject:t})=>t(e)))},this.debounceMS),this.pendingDebounce.push({resolve:t,reject:n})})}checkTransformLegacyResults(e){if(!e.length)return[];const t=e[0];return t&&"object"!=typeof t.type?e.map(e=>({type:{name:e.type,displayName:e.category},id:e.id,displayName:e.displayName,description:e.description,iconURL:e.iconURL,action:e.action})):e}}const Zu="T42.Search.Provider",Xu="T42.Search.Client";class ec{glue;constructor(e){this.glue=e}get myAppName(){return this.glue.interop.instance.applicationName}get myInteropId(){return this.glue.interop.instance.instance}async registerMainProviderMethod(e){this.checkMyMethodExists(Zu).exists||await this.glue.interop.register(Zu,e)}async registerMainClientMethod(e){this.checkMyMethodExists(Xu).exists||await this.glue.interop.register(Xu,e)}async clearMainProviderMethod(){await this.glue.interop.unregister(Zu)}async sendClientResultsBatch(e,t,n){const r={items:e.results,provider:e.provider,queryId:n,status:uu};await this.glue.interop.invoke(Xu,r,{instance:t})}async sendClientQueueCompleted(e,t){const n={items:[],queryId:t,status:lu};await this.glue.interop.invoke(Xu,n,{instance:e})}async sendClientErrorMessage(e,t,n,r){const o={items:[],provider:r,errorMessage:e,queryId:n,status:cu};await this.glue.interop.invoke(Xu,o,{instance:t})}async sendQueryRequest(e,t){if(!t.length)return[];const n=t.map(e=>({instance:e.interopId})),r={operation:hu,apiVersion:"1",...e};return((await this.glue.interop.invoke(Zu,r,n)).all_return_values||[]).map(e=>({interopId:e.executed_by?.instance,queryId:e.returned.id}))}async sendQueryCancelRequest(e,t){const n={operation:pu,id:e.id};await this.glue.interop.invoke(Zu,n,t)}async getAllProvidersInfo(){if(this.glue.interop.methods().every(e=>e.name!==Zu))return[];const e={operation:du},t=await this.glue.interop.invoke(Zu,e,"all");return(t.all_return_values||[]).map(e=>{const n=void 0===e.returned.apiVersion?{supportedTypes:e.returned.supportedTypes,apiVersion:e.returned.apiVersion,providers:[{interopId:e.executed_by?.instance,id:e.executed_by?.instance,name:e.executed_by?.instance,appName:t.executed_by?.application,types:e.returned.supportedTypes.map(e=>({name:e}))}]}:e.returned;return{interopId:e.executed_by?.instance,info:n}})}checkMyMethodExists(e){return{exists:this.glue.interop.methodsForInstance({instance:this.glue.interop.instance.instance}).some(t=>t.name===e)}}}class tc{logger;glueController;clientController;providerController;constructor(e,t,n,r){this.logger=e,this.glueController=t,this.clientController=n,this.providerController=r}setDebounceMS(e){this.logger.info(`[${e.commandId}] Starting setDebounceMS operation with duration ${e.milliseconds}`),this.clientController.setDebounceMS(e),this.logger.info(`[${e.commandId}] Operation setDebounceMS with duration ${e.milliseconds} completed`)}getDebounceMS(e){return this.logger.info(`[${e.commandId}] Starting getDebounceMS operation.`),this.clientController.getDebounceMS(e)}async query(e){if(this.logger.info(`[${e.commandId}] Starting query operation with config ${JSON.stringify(e.queryConfig)}`),Array.isArray(e.queryConfig.providers)&&!e.queryConfig.providers.length)throw new Error("Cannot sent a query with a defined empty array of providers, because this is an impossible query for complete.");if(Array.isArray(e.queryConfig.types)&&!e.queryConfig.types.length)throw new Error("Cannot sent a query with a defined empty array of types, because this is an impossible query for complete.");const t=await this.clientController.query(e);return this.logger.info(`[${e.commandId}] Operation query with config ${JSON.stringify(e.queryConfig)} completed.`),t}async registerProvider(e){this.logger.info(`[${e.commandId}] Starting registerProvider operation with config ${JSON.stringify(e.config)}`);const t=await this.providerController.processRegisterProvider(e);return this.logger.info(`[${e.commandId}] Operation registerProvider with config ${JSON.stringify(e.config)} completed.`),t}async providers(e){this.logger.info(`[${e.commandId}] Starting providers operation.`);const t=(await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers);return this.logger.info(`[${e.commandId}] Operation providers completed.`),t}async types(e){this.logger.info(`[${e.commandId}] Starting types operation.`);const t=(await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers).filter(e=>!!e.types).flatMap(e=>e.types),n=[...new Set(t)];return this.logger.info(`[${e.commandId}] Operation types completed.`),n}}const nc=e=>"string"==typeof e?e:e.message?JSON.stringify(e.message):JSON.stringify(e);class rc{logger;glueController;sequelizer;limitsTracker;modelsFactory;registry=au();providersModels={};activeQueries={};constructor(e,t,n,r,o){this.logger=e,this.glueController=t,this.sequelizer=n,this.limitsTracker=r,this.modelsFactory=o}async processRegisterProvider(e){const{config:t,commandId:n}=e;this.logger.info(`[${n}] enqueueing the provider registration process with config: ${JSON.stringify(t)}`);const r=await this.sequelizer.enqueue(async()=>{if((await this.glueController.getAllProvidersInfo()).flatMap(e=>e.info.providers).some(e=>e&&e.name===t.name))throw new Error(`Cannot register a new provider with name: ${t.name}, because there already is a provider with this name`);await this.glueController.registerMainProviderMethod(this.handleSearchQueryRequest.bind(this));const e={id:ou(10),name:t.name,interopId:this.glueController.myInteropId,appName:this.glueController.myAppName,types:t.types},n=this.modelsFactory.buildProviderModel(e,this);return this.providersModels[e.id]=n,n.exposeFacade()});return this.logger.info(`[${n}] the provider with name: ${t.name} has been registered.`),r}processProviderOnQuery(e){return this.registry.add(`on-search-query-${e.id}`,e.callback)}processProviderOnQueryCancel(e){return this.registry.add(`on-cancel-query-${e.id}`,e.callback)}async processProviderUnregister(e){this.logger.info(`[${e.commandId}] enqueueing the provider un-registration with id: ${e.id}`),await this.sequelizer.enqueue(async()=>{this.cleanUpProvider(e.id,e.commandId),Object.keys(this.providersModels).length||await this.glueController.clearMainProviderMethod()}),this.logger.info(`[${e.commandId}] the provider un-registration with id: ${e.id} completed`)}async processProviderQueryDone(e){const{commandId:t,identification:n}=e;this.activeQueries[n.queryId]?.publisher.syncSuspendProvider(n.providerId,t),await this.sequelizer.enqueue(async()=>{this.logger.trace(`[${t}] Processing a query done command with identification: ${JSON.stringify(n)}`);const e=this.activeQueries[n.queryId];e?(await this.cleanUpProviderQuery(n.queryId,n.providerId,t),e.providersAtWork.length?this.logger.trace(`[${t}] Query done command completed, but there are more providers still at work.`):(this.cleanUpQuery(n.queryId,t),this.logger.trace(`[${t}] Query is completed, signalling.`))):this.logger.warn(`[${t}] Cannot mark provider: ${n.providerId} done with query ${n.queryId}, because there is no active query with this id`)})}processProviderQueryError(e){const{commandId:t,identification:n,error:r}=e;return this.logger.warn(`[${t}] Processing an error sent by provider: ${n.providerId} for query id: ${n.queryId} -> ${r}`),this.activeQueries[n.queryId]?.publisher.markProviderError(e),this.processProviderQueryDone(e)}processProviderQueryResult(e){const{commandId:t,identification:n}=e,r=this.activeQueries[n.queryId];if(!r){const t=`Will not send this result to the client, because there is no active query with id ${n.queryId}. Most likely this query was cancelled.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}if(r.publisher.checkProviderSuspended(n.providerId)){const t=`Will not send this result to the client, because there is no info about this provider in the active query with id ${n.queryId}. Most likely this query was marked as done by this provider already.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}const o=r.requestedTypes;if(o&&o.every(t=>t.name!==e.result.type.name)){const t=`Will not send this result to the client, because this result has a defined type: ${e.result.type.name} which is not in the explicitly requested list of types by the client.`;throw this.logger.warn(`[${e}] ${t}`),new Error(t)}const i=this.limitsTracker.testResultLimit(e);if(i?.maxLimitHit){const t=`Will not process this result from provider ${e.identification.providerId}, because this provider has reached the max results limit set by the client. This provider cannot send more result, marking it as done.`;throw this.logger.info(t),setTimeout(()=>this.processProviderQueryDone(e),0),new Error(t)}if(i?.maxLimitPerTypeHit){const t=`Will not process this result from provider ${e.identification.providerId}, because this provider has reached the max results limit per type as set by the client.`;throw this.logger.info(t),new Error(t)}this.logger.trace(`[${t}] An active query for query ${n.queryId} was found and the provider is within limits, queueing the result`),this.limitsTracker.update(e),r.publisher.queueResult(e),this.logger.trace(`[${t}] The query result was queued successfully.`)}async handleSearchQueryRequest(e,t){const{operation:n}=e,r=Bu.runWithException(n),o=ou(10);switch(r){case du:return this.handleInfoOperation({commandId:o});case hu:return this.handleSearchOperation({args:e,commandId:o},t);case pu:return this.handleCancelOperation({args:e,commandId:o});default:throw new Error(`Unrecognized operation: ${n}`)}}async handleInfoOperation(e){this.logger.info(`[${e.commandId}] handling an info operation`);const t=Object.values(this.providersModels).flatMap(e=>e.myProviderData.types||[]),n=[...new Set(t)];Object.values(this.providersModels).some(e=>!e.myProviderData.types)&&n.push({name:"*"});const r=Object.values(this.providersModels).map(e=>e.myProviderData),o={supportedTypes:n.map(e=>e.name),providers:r,apiVersion:"1"};return this.logger.info(`[${e.commandId}] responding to an info operation with: ${JSON.stringify(o)}`),o}async handleSearchOperation(e,t){const n=e.commandId,r=this.generateQueryId();this.logger.info(`[${n}] Processing search operation with queryId: ${r} request details: ${JSON.stringify(e.args)}`);const o=this.checkRequestLegacy(e.args),i=this.prepareRequest(e.args,o,n);return this.logger.info(`[${n}] Search operation with queryId: ${r} is validated. Creating an active query and enqueueing calling the providers.`),this.activeQueries[r]={queryId:r,callerInstanceId:t.instance,providersAtWork:[],requestedTypes:i.types,publisher:this.modelsFactory.buildPublisher(t.instance,r,o),staleTimer:this.setClearStaleQueryTimer(r)},i.providerLimits&&this.limitsTracker.enableTracking(i.providerLimits,r),setTimeout(()=>{this.sequelizer.enqueue(async()=>{try{this.logger.info(`[${n}] Calling the providers.`),this.callProviders(i,r,n)}catch(e){this.logger.error(`[${n}] Error calling the providers: ${nc(e)}`)}})},0),this.logger.info(`[${n}] Search operation with queryID: ${r} processed successfully.`),{id:r}}async handleCancelOperation(e){await this.sequelizer.enqueue(async()=>{const t=Uu.run(e.args);if(!t.ok){const n=`Cannot process a cancel request, because of validation error: ${JSON.stringify(t.error)}`;throw this.logger.warn(`[${e.commandId}] ${n}`),new Error(n)}const n=t.result,r=this.activeQueries[n.id];r&&(clearTimeout(r.staleTimer),r.publisher.cancel(e.commandId),delete this.activeQueries[n.id],r.providersAtWork.forEach(e=>this.registry.execute(`on-cancel-query-${e.myProviderData.id}`,{id:n.id})))})}generateQueryId(){const e=ou(10);return this.activeQueries[e]?this.generateQueryId():e}translateLegacySearchRequest(e){return{search:e.search,types:e.types?.map(e=>({name:e})),providerLimits:{maxResults:e.limit,maxResultsPerType:e.categoryLimit}}}checkRequestLegacy(e){return void 0===e.apiVersion}callProviders(e,t,n){let r=e.providers?this.getFilteredProviderModels(e.providers):Object.values(this.providersModels);this.logger.trace(`[${n}] initial providers filtration yielded: ${JSON.stringify(r.map(e=>e.myProviderData.name).join(", "))}`),r=e.types?this.getFilteredProvidersBySearchTypes(r,e.types):r,this.logger.trace(`[${n}] search type providers filtration yielded: ${JSON.stringify(r.map(e=>e.myProviderData.name).join(", "))}`),this.activeQueries[t].publisher.configureProviders(r),this.activeQueries[t].providersAtWork.push(...r),r.forEach(r=>this.callProvider(r,e,t,n))}callProvider(e,t,n,r){const o=this.modelsFactory.buildProviderQueryModel(t,{queryId:n,providerId:e.myProviderData.id},this).exposeFacade();this.logger.info(`[${r}] The query facade for provider: ${e.myProviderData.id} with name ${e.myProviderData.name} is ready, raising the event for query ID: ${n}.`),this.registry.execute(`on-search-query-${e.myProviderData.id}`,o)}getFilteredProviderModels(e){const t=e.reduce((e,t)=>(this.providersModels[t.id]&&e.push(this.providersModels[t.id]),e),[]);return t}getFilteredProvidersBySearchTypes(e,t){return e.filter(e=>!e.myProviderData.types||!e.myProviderData.types.length||e.myProviderData.types?.some(e=>t.some(t=>t.name===e.name)))}setClearStaleQueryTimer(e){return setTimeout(()=>{const t=ou(10);this.logger.info(`[${t}] Stale query timer is activated for queryId: ${e}`),this.activeQueries[e]?(this.logger.info(`[${t}] force-marking the query as done`),this.cleanUpQuery(e,t),this.logger.info(`[${t}] the stale query was cleared.`)):this.logger.info(`[${t}] No active query was found, this was a false activation.`)},9e5)}prepareRequest(e,t,n){const r=t?this.translateLegacySearchRequest(e):e,o=Nu.run(r);if(!o.ok){const e=`Cannot process a search request, because of validation error: ${JSON.stringify(o.error)}`;throw this.logger.warn(`[${n}] ${e}`),new Error(e)}return o.result}cleanUpQuery(e,t){const n=this.activeQueries[e];clearTimeout(n.staleTimer),n.publisher.cleanPublisher(t),delete this.activeQueries[e],this.limitsTracker.cleanTracking(e)}cleanUpProvider(e,t){this.registry.clearKey(`on-search-query-${e}`),this.registry.clearKey(`on-cancel-query-${e}`),delete this.providersModels[e];Object.values(this.activeQueries).filter(t=>!t.publisher.checkProviderSuspended(e)).forEach(n=>{this.processProviderQueryDone({identification:{queryId:n.queryId,providerId:e},commandId:t})})}async cleanUpProviderQuery(e,t,n){const r=this.activeQueries[e];r?(r.providersAtWork=r.providersAtWork.filter(e=>e.myProviderData.id!==t),await r.publisher.markProviderDone(t,n)):this.logger.warn(`[${n}] Cannot clean up a provider query ${e} for provider ${t} because there is no such active query`)}}class oc{main;constructor(e){this.main=e}exposeApi(){const e={version:"3.0.0",setDebounceMS:this.setDebounceMS.bind(this),getDebounceMS:this.getDebounceMS.bind(this),listProviders:this.providers.bind(this),listTypes:this.types.bind(this),query:this.query.bind(this),registerProvider:this.registerProvider.bind(this)};return Object.freeze(e)}setDebounceMS(e){Lu.runWithException(e);const t=ou(10);return this.main.setDebounceMS({milliseconds:e,commandId:t})}getDebounceMS(){const e=ou(10);return this.main.getDebounceMS({commandId:e})}async providers(){const e=ou(10);return this.main.providers({commandId:e})}async types(){const e=ou(10);return this.main.types({commandId:e})}async query(e){const t=Nu.runWithException(e),n=ou(10);return this.main.query({queryConfig:t,commandId:n})}async registerProvider(e){const t=ju.runWithException(e),n=ou(10);return this.main.registerProvider({config:t,commandId:n})}}class ic{minSequenceInterval;queue=[];isExecutingQueue=!1;constructor(e=0){this.minSequenceInterval=e}enqueue(e){return new Promise((t,n)=>{this.queue.push({action:e,resolve:t,reject:n}),this.executeQueue()})}async executeQueue(){if(!this.isExecutingQueue){for(this.isExecutingQueue=!0;this.queue.length;){const e=this.queue.shift();if(!e)return void(this.isExecutingQueue=!1);try{const t=await e.action();e.resolve(t)}catch(t){e.reject(t)}await this.intervalBreak()}this.isExecutingQueue=!1}}intervalBreak(){return new Promise(e=>setTimeout(e,this.minSequenceInterval))}}class sc{limitsLookup={};limitsData={};enableTracking(e,t){this.limitsLookup[t]={},this.limitsData[t]={maxResults:e.maxResults?e.maxResults:Number.MAX_SAFE_INTEGER,maxResultsPerType:e.maxResultsPerType?e.maxResultsPerType:Number.MAX_SAFE_INTEGER}}testResultLimit(e){const t=this.limitsLookup[e.identification.queryId],n=this.limitsData[e.identification.queryId];if(!t||!n)return;let r=t[e.identification.providerId];if(r||(r={total:0},t[e.identification.providerId]=r),r.total+1>n.maxResults)return{maxLimitHit:!0};const o=e.result.type.name;return o&&(r[o]||0)+1>n.maxResultsPerType?{maxLimitPerTypeHit:!0}:void 0}update(e){const t=this.limitsLookup[e.identification.queryId],n=this.limitsData[e.identification.queryId];if(!t||!n)return;const r=t[e.identification.providerId];r.total+=1;const o=e.result.type.name;o&&(r[o]=r[o]?r[o]+1:1)}cleanTracking(e){delete this.limitsLookup[e],delete this.limitsData[e]}}class ac{controller;logger;masterQueryId;constructor(e,t,n){this.controller=e,this.logger=t,this.masterQueryId=n}exposeFacade(){const e={cancel:this.cancel.bind(this),onResults:this.onResults.bind(this),onCompleted:this.onCompleted.bind(this),onError:this.onError.bind(this)};return Object.freeze(e)}async cancel(){const e=ou(10);this.logger.info(`[${e}] received a valid query cancel request, forwarding to the controller.`),await this.controller.cancelQuery(this.masterQueryId,e),this.logger.info(`[${e}] the cancel request was completed.`)}onResults(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onResults request, forwarding to the controller.`);const n=this.controller.processClientOnResults({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onResults request was completed.`),n}onCompleted(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onCompleted request, forwarding to the controller.`);const n=this.controller.processClientOnCompleted({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onCompleted request was completed.`),n}onError(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid query onError request, forwarding to the controller.`);const n=this.controller.processClientOnError({callback:e,masterQueryId:this.masterQueryId,commandId:t});return this.logger.info(`[${t}] the onError request was completed.`),n}}class lc{myData;controller;logger;constructor(e,t,n){this.myData=e,this.controller=t,this.logger=n}get id(){return this.myData.id}get name(){return this.myData.name}get appName(){return this.myData.appName}get types(){return this.myData.types}get myProviderData(){return Object.assign({},this.myData)}exposeFacade(){const e={interopId:this.myData.interopId,id:this.id,name:this.name,appName:this.appName,types:this.types,onQuery:this.onQuery.bind(this),onQueryCancel:this.onQueryCancel.bind(this),unregister:this.unregister.bind(this)};return Object.freeze(e)}onQuery(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid onQuery request, forwarding to the controller.`);const n=this.controller.processProviderOnQuery({callback:e,id:this.id,commandId:t});return this.logger.info(`[${t}] the onQuery request was completed.`),n}onQueryCancel(e){if("function"!=typeof e)throw new Error("onQuery requires a callback of type function");const t=ou(10);this.logger.info(`[${t}] received a valid onQueryCancel request, forwarding to the controller.`);const n=this.controller.processProviderOnQueryCancel({callback:e,id:this.id,commandId:t});return this.logger.info(`[${t}] the onQueryCancel request was completed.`),n}async unregister(){const e=ou(10);this.logger.info(`[${e}] received a valid unregister request, forwarding to the controller.`),await this.controller.processProviderUnregister({id:this.id,commandId:e}),this.logger.info(`[${e}] the unregister request was completed.`)}}class uc{myData;controller;logger;identification;constructor(e,t,n,r){this.myData=e,this.controller=t,this.logger=n,this.identification=r}get id(){return this.identification.queryId}get search(){return this.myData.search}get providers(){return this.myData.providers}get types(){return this.myData.types}get providerLimits(){return this.myData.providerLimits}get myQueryData(){return Object.assign({},this.myData)}exposeFacade(){const e={id:this.id,search:this.search,providers:this.providers,types:this.types,providerLimits:this.providerLimits,sendResult:this.sendResult.bind(this),error:this.error.bind(this),done:this.done.bind(this)};return Object.freeze(e)}sendResult(e){Hu.runWithException(e);const t=ou(10);return this.logger.trace(`[${t}] Received a valid result, forwarding to the controller`),this.controller.processProviderQueryResult({identification:this.identification,result:e,commandId:t})}error(e){const t=ou(10);Ru.runWithException(e),this.logger.trace(`[${t}] Received a valid error, forwarding to the controller`),this.controller.processProviderQueryError({identification:this.identification,error:e,commandId:t}).catch(e=>this.logger.warn(`Error processing the error signal for this provider: ${this.id}, error: ${nc(e)}`))}done(){const e=ou(10);this.logger.trace(`[${e}] Received a valid done, forwarding to the controller`),this.controller.processProviderQueryDone({identification:this.identification,commandId:e}).catch(e=>this.logger.warn(`Error processing the done signal for this provider: ${this.identification.providerId}, error: ${nc(e)}`))}}class cc{sequelizer;glueController;logger;clientInstanceId;queryId;isLegacy;queues={};constructor(e,t,n,r,o,i){this.sequelizer=e,this.glueController=t,this.logger=n,this.clientInstanceId=r,this.queryId=o,this.isLegacy=i}checkProviderSuspended(e){return!!this.queues[e]&&!!this.queues[e].suspended}syncSuspendProvider(e,t){const n=this.queues[e];n?n.suspended=!0:this.logger.warn(`[${t}] Cannot suspend provider: ${e}, because there is no provider queue. This happens when the provider queue was already cancelled or completed`)}configureProviders(e){e.forEach(e=>{this.queues[e.myProviderData.id]={providerData:e,pendingResults:[]}})}queueResult(e){const{commandId:t,identification:n}=e;this.logger.trace(`[${t}] Queuing a new result from provider: ${n.providerId}`);const r=this.queues[n.providerId];if(!r)return void this.logger.warn(`[${t}] Cannot queue this result, because there is no provider queue. This happens when the provider queue was already cancelled or completed`);const o=this.isLegacy?this.translateLegacySearchItem(e.result):e.result;if(r.pendingResults.push(o),clearTimeout(r.flushTimer),10===r.pendingResults.length)return this.logger.trace(`[${t}] Reached the limit in the queue buffer, flushing to the client.`),void this.flushProviderQueue(n.providerId,t);this.logger.trace(`[${t}] The limit in the queue buffer is not reached yet, setting a flush timer.`),r.flushTimer=setTimeout(()=>{this.logger.trace(`[${t}] Reached the time limit in the queue buffer, flushing to the client.`),this.flushProviderQueue(n.providerId,t)},100)}cancel(e){this.logger.trace(`[${e}] Cancelling queue ${this.queryId}.`),Object.values(this.queues).forEach(e=>clearTimeout(e.flushTimer)),this.queues={},this.logger.trace(`[${e}] Queue ${this.queryId} publisher cancelled.`)}async markProviderDone(e,t){this.logger.trace(`[${t}] Marking provider ${e} as done.`);const n=this.queues[e];n?(clearTimeout(n.flushTimer),await this.flushProviderQueue(e,t),delete this.queues[e],this.logger.trace(`[${t}] Provider ${e} marked as done.`)):this.logger.info(`[${t}] Cannot mark this queue as done, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent an error`)}markProviderError(e){const t=this.queues[e.identification.providerId];t?this.glueController.sendClientErrorMessage(e.error,this.clientInstanceId,this.queryId,t.providerData.myProviderData).catch(t=>this.logger.warn(`[${e.commandId}] The client errored when handling error message for query: ${this.queryId} -> ${nc(t)}`)):this.logger.warn(`[${e.commandId}] Cannot mark this provider as errored, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent and error`)}cleanPublisher(e){Object.values(this.queues).forEach(e=>clearTimeout(e.flushTimer)),this.queues={},this.glueController.sendClientQueueCompleted(this.clientInstanceId,this.queryId).catch(t=>this.logger.warn(`[${e}] The client errored when handling search end message for query: ${this.queryId} -> ${nc(t)}`))}async flushProviderQueue(e,t){await this.sequelizer.enqueue(async()=>{const n=this.queues[e];if(!n)return void this.logger.warn(`[${t}] Cannot flush this queue, because there is no provider queue. This happens when the provider queue was already cancelled, completed or the provider sent and error`);if(!n.pendingResults.length)return void this.logger.info(`[${t}] This provider does not have any pending results to flush.`);const r={results:n.pendingResults,provider:n.providerData.myProviderData};n.pendingResults=[];try{await this.glueController.sendClientResultsBatch(r,this.clientInstanceId,this.queryId)}catch(e){this.logger.warn(`[${t}] The client errored when handling search results for query: ${this.queryId} -> ${nc(e)}`)}})}translateLegacySearchItem(e){return{type:e.type.name,category:e.type.displayName,id:e.id,displayName:e.displayName,description:e.description,iconURL:e.iconURL,action:e.action}}}class dc{glueController;glue;flushSequelizer;constructor(e,t,n){this.glueController=e,this.glue=t,this.flushSequelizer=n}buildProviderModel(e,t){return new lc(e,t,this.glue.logger.subLogger(`search.provider.model.${e.name}`))}buildProviderQueryModel(e,t,n){return new uc(e,n,this.glue.logger.subLogger(`search.provider.${t.providerId}.query.${t.queryId}`),t)}buildPublisher(e,t,n){return new cc(this.flushSequelizer,this.glueController,this.glue.logger.subLogger(`search.results.publisher.${t}`),e,t,n)}buildClientQueryModel(e,t){return new ac(t,this.glue.logger.subLogger(`search.provider.model.${e}`),e)}}class hc{glue;config;_glueController;_facade;_mainController;_providerController;_clientController;_asyncSequelizer;_flushSequelizer;_limitsTracker;_modelFactory;constructor(e,t){this.glue=e,this.config=t}get glueController(){return this._glueController||(this._glueController=new ec(this.glue)),this._glueController}get main(){return this._mainController||(this._mainController=new tc(this.glue.logger.subLogger("search.main.controller"),this.glueController,this.clientController,this.providerController)),this._mainController}get clientController(){return this._clientController||(this._clientController=new Yu(this.glue.logger.subLogger("search.client.controller"),this.glueController,this.modelFactory)),this._clientController}get providerController(){return this._providerController||(this._providerController=new rc(this.glue.logger.subLogger("search.provider.controller"),this.glueController,this.sequelizer,this.limitsTracker,this.modelFactory)),this._providerController}get facade(){return this._facade||(this._facade=new oc(this.main)),this._facade}get sequelizer(){return this._asyncSequelizer||(this._asyncSequelizer=new ic(10)),this._asyncSequelizer}get flushSequelizer(){return this._flushSequelizer||(this._flushSequelizer=new ic(10)),this._flushSequelizer}get limitsTracker(){return this._limitsTracker||(this._limitsTracker=new sc),this._limitsTracker}get modelFactory(){return this._modelFactory||(this._modelFactory=new dc(this.glueController,this.glue,this.flushSequelizer)),this._modelFactory}}const pc=async(e,t)=>{const n=new hc(e,t);e.search=n.facade.exposeApi()};function gc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function fc(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function r(n,r){var o=n instanceof Error?n:new Error(n);if(t)t(o);else{var i='[ERROR] callback-registry: User callback for key "'+r+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,o){var i=n[e];return i||(i=[],n[e]=i),i.push(t),o&&setTimeout(function(){o.forEach(function(o){var i;if(null===(i=n[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o])}catch(t){r(t,e)}})},0),function(){var r=n[e];r&&(0===(r=r.reduce(function(e,n,r){return n===t&&e.length===r||e.push(n),e},[])).length?delete n[e]:n[e]=r)}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var i=n[e];if(!i||0===i.length)return[];var s=[];return i.forEach(function(n){try{var o=n.apply(void 0,t);s.push(o)}catch(t){s.push(void 0),r(t,e)}}),s},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}"undefined"!=typeof window&&(window.IOSearch=pc),fc.default=fc;var mc=gc(fc),yc=function(e){return{ok:!0,result:e}},wc=function(e){return{ok:!1,error:e}},vc=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:yc(e(t.result,n.result))},bc=function(e,t){return!0===t.ok?t:wc(e(t.error))},Cc=function(){return Cc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Cc.apply(this,arguments)};function Sc(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!Sc(e[n],t[n]))return!1;return!0}var r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(n=0;n<r.length;n++){if(!t.hasOwnProperty(r[n]))return!1;if(!Sc(e[r[n]],t[r[n]]))return!1}return!0}}var Ic=function(e){return Array.isArray(e)},kc=function(e){return"object"==typeof e&&null!==e&&!Ic(e)},Tc=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},xc=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},Ac=function(e,t){var n=t.at,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["at"]);return Cc({at:e+(n||"")},r)},Ec=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return bc(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?yc(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,r){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(r)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?yc(e):wc({message:Tc("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?yc(e):wc({message:Tc("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?yc(e):wc({message:Tc("a boolean",e)})})},e.constant=function(t){return new e(function(e){return Sc(e,t)?yc(t):wc({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(kc(e)&&t){var n={};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r].decode(e[r]);if(!0!==o.ok)return void 0===e[r]?wc({message:"the key '"+r+"' is required but was not present"}):wc(Ac("."+r,o.error));void 0!==o.result&&(n[r]=o.result)}return yc(n)}return kc(e)?yc(e):wc({message:Tc("an object",e)})})},e.array=function(t){return new e(function(e){return Ic(e)&&t?e.reduce(function(e,n,r){return vc(function(e,t){return e.concat([t])},e,function(e,n){return bc(function(e){return Ac("["+n+"]",e)},t.decode(e))}(n,r))},yc([])):Ic(e)?yc(e):wc({message:Tc("an array",e)})})},e.tuple=function(t){return new e(function(e){if(Ic(e)){if(e.length!==t.length)return wc({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e[r]);if(!o.ok)return wc(Ac("["+r+"]",o.error));n[r]=o.result}return yc(n)}return wc({message:Tc("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.oneOf.apply(e,[t,n].concat(r))},e.intersection=function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return new e(function(e){return[t,n].concat(r).reduce(function(t,n){return vc(Object.assign,t,n.decode(e))},yc({}))})},e.anyJson=function(){return new e(function(e){return yc(e)})},e.unknownJson=function(){return new e(function(e){return yc(e)})},e.dict=function(t){return new e(function(e){if(kc(e)){var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=t.decode(e[r]);if(!0!==o.ok)return wc(Ac("."+r,o.error));n[r]=o.result}return yc(n)}return wc({message:Tc("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?yc(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],r=0;r<t.length;r++){var o=t[r].decode(e);if(!0===o.ok)return o;n[r]=o.error}var i=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return wc({message:'expected a value matching one of the decoders, got the errors ["'+i+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return yc(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var r=e,o=0;o<t.length;o++){if(void 0===r)return wc({at:xc(t.slice(0,o+1)),message:"path does not exist"});if("string"==typeof t[o]&&!kc(r))return wc({at:xc(t.slice(0,o+1)),message:Tc("an object",r)});if("number"==typeof t[o]&&!Ic(r))return wc({at:xc(t.slice(0,o+1)),message:Tc("an array",r)});r=r[t[o]]}return bc(function(e){return void 0===r?{at:xc(t),message:"path does not exist"}:Ac(xc(t),e)},n.decode(r))})},e.succeed=function(t){return new e(function(e){return yc(t)})},e.fail=function(t){return new e(function(e){return wc({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),Wc=Ec.string,Oc=Ec.number,Dc=Ec.boolean,_c=Ec.anyJson;Ec.unknownJson;var Pc=Ec.constant,Rc=Ec.object,Lc=Ec.array;Ec.tuple,Ec.dict;var Fc=Ec.optional,Mc=Ec.oneOf;Ec.union;var $c=Ec.intersection;Ec.withDefault,Ec.valueAt,Ec.succeed,Ec.fail;var Nc=Ec.lazy;const jc=Wc().where(e=>e.length>0,"Expected a non-empty string"),Bc=Oc().where(e=>e>=0,"Expected a non-negative number"),qc=Oc().where(e=>e>0,"Expected a positive number"),Uc=Mc(Pc("keepInside"),Pc("autoEject")),zc=Rc({inWorkspace:Dc()}),Gc=Rc({base64Image:jc}),Hc=Rc({icon:Gc,frameId:jc}),Vc=Mc(Pc("workspace"),Pc("row"),Pc("column"),Pc("group")),Qc=Mc(Pc("row"),Pc("column"),Pc("group")),Jc=Mc(Pc("maximized"),Pc("minimized"),Pc("normal")),Kc=Mc(Pc("workspace")),Yc=(e,t)=>{const n=typeof e;if(t&&"function"!==n&&"undefined"!==n)throw new Error(`Provided argument must be either undefined or of type function, provided: ${n}`);if(!t&&"function"!==n)throw new Error(`Provided argument must be of type function, provided: ${n}`)},Zc=Fc(Rc({saveLayout:Fc(Dc())})),Xc=Rc({name:jc}),ed=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc())}),td=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),allowDrop:Fc(Dc()),allowDropHeader:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropBottom:Fc(Dc()),showMaximizeButton:Fc(Dc()),showEjectButton:Fc(Dc()),showAddWindowButton:Fc(Dc())}),nd=Rc({minHeight:Fc(Oc()),maxHeight:Fc(Oc()),allowDrop:Fc(Dc()),allowSplitters:Fc(Dc()),isPinned:Fc(Dc()),maximizationBoundary:Fc(Dc())}),rd=Rc({minWidth:Fc(Oc()),maxWidth:Fc(Oc()),allowDrop:Fc(Dc()),allowSplitters:Fc(Dc()),isPinned:Fc(Dc()),maximizationBoundary:Fc(Dc())}),od=Rc({type:Fc(Pc("window")),appName:Fc(jc),windowId:Fc(jc),context:Fc(_c()),config:Fc(ed)}),id=Rc({type:Pc("window"),appName:Fc(jc),windowId:Fc(jc),context:Fc(_c()),config:Fc(ed)}),sd=Fc(Rc({type:Fc(Qc),children:Fc(Nc(()=>Lc(Mc(od,sd)))),config:Fc(_c())})),ad=Rc({type:Pc("column"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(rd)}),ld=Rc({type:Pc("row"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(nd)}),ud=Rc({type:Pc("group"),children:Fc(Nc(()=>Lc(Mc(id,cd)))),config:Fc(td)}),cd=Mc(ud,ad,ld);Mc(Wc().where(e=>"maximized"===e.toLowerCase(),"Expected a case insensitive variation of 'maximized'"),Wc().where(e=>"normal"===e.toLowerCase(),"Expected a case insensitive variation of 'normal'"));const dd=Rc({bounds:Fc(Rc({left:Fc(Oc()),top:Fc(Oc()),width:Fc(Bc),height:Fc(Bc)})),frameId:Fc(jc)}),hd=Mc(Pc("direct"),Pc("delayed"),Pc("lazy")),pd=Fc(Rc({app:Fc(jc),context:Fc(_c()),loadingStrategy:Fc(hd),title:Fc(jc),reuseWorkspaceId:Fc(jc),frameId:Fc(jc),applicationName:Fc(jc),lockdown:Fc(Dc()),activateFrame:Fc(Dc()),newFrame:Fc(Mc(dd,Dc())),noTabHeader:Fc(Dc()),inMemoryLayout:Fc(Dc()),icon:Fc(jc),isPinned:Fc(Dc()),isSelected:Fc(Dc()),positionIndex:Fc(Bc),allowSystemHibernation:Fc(Dc())})),gd=Rc({name:jc,restoreOptions:Fc(pd)}),fd=Rc({children:Fc(Lc(Mc(od,cd))),context:Fc(_c()),config:Fc(Rc({title:Fc(jc),position:Fc(Bc),isFocused:Fc(Dc()),noTabHeader:Fc(Dc()),reuseWorkspaceId:Fc(jc),loadingStrategy:Fc(hd),allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),showCloseButton:Fc(Dc()),allowSplitters:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),showEjectButtons:Fc(Dc()),showAddWindowButtons:Fc(Dc()),icon:Fc(jc),isPinned:Fc(Dc()),isSelected:Fc(Dc()),positionIndex:Fc(Bc),windowDragMode:Fc(Uc)})),frame:Fc(Rc({activate:Fc(Dc()),reuseFrameId:Fc(jc),applicationName:Fc(jc),newFrame:Fc(Mc(Dc(),dd))}))}),md=Rc({workspaceId:jc}),yd=Rc({name:jc,restoreOptions:Fc(pd)}),wd=Fc(Rc({applicationName:Fc(Wc()),frameConfig:Fc(dd),context:Fc(Rc()),layoutComponentId:Fc(jc)})),vd=Rc({workspaces:Lc(Mc(Fc(fd),Fc(yd)))}),bd=Rc({frameId:jc,workspaces:Lc(Mc(fd,yd))}),Cd=Rc({type:Vc,definition:Fc(Mc(fd,sd))}),Sd=$c(fd,Rc({saveConfig:Fc(Rc({saveLayout:Fc(Dc())}))})),Id=Rc({itemId:jc}),kd=Rc({context:Fc(Rc())}),Td=Rc({id:jc,isFocused:Fc(Dc()),isInitialized:Fc(Dc()),initializationContext:Fc(kd)});Rc({type:Qc,id:jc,frameId:jc,workspaceId:jc,positionIndex:Oc()});const xd=Mc(Pc("frame"),Pc("workspace"),Pc("container"),Pc("window")),Ad=Rc({type:xd,branch:jc}),Ed=Mc(Pc("opened"),Pc("closing"),Pc("closed"),Pc("focus"),Pc("added"),Pc("loaded"),Pc("removed"),Pc("childrenUpdate"),Pc("containerChange"),Pc("maximized"),Pc("restored"),Pc("minimized"),Pc("normal"),Pc("selected"),Pc("lock-configuration-changed"),Pc("hibernated"),Pc("resumed")),Wd=Rc({frameId:jc,title:jc,positionIndex:Bc,name:jc,layoutName:Fc(jc),isHibernated:Fc(Dc()),isSelected:Fc(Dc()),allowDrop:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),allowSplitters:Fc(Dc()),showCloseButton:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc()),showAddWindowButtons:Fc(Dc()),showEjectButtons:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),widthInPx:Fc(Oc()),heightInPx:Fc(Oc()),isPinned:Fc(Dc()),windowDragMode:Fc(Uc),loadingStrategy:Fc(hd)}),Od=Rc({frameId:jc,workspaceId:jc,positionIndex:Oc(),minWidth:Fc(Oc()),maxWidth:Fc(Oc()),minHeight:Fc(Oc()),maxHeight:Fc(Oc())}),Dd=_c(),_d=$c(Od,Rc({windowId:Fc(jc),isMaximized:Fc(Dc()),isFocused:Dc(),isSelected:Fc(Dc()),title:Fc(Wc()),appName:Fc(jc),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc()),minWidth:Fc(Oc()),minHeight:Fc(Oc()),maxWidth:Fc(Oc()),maxHeight:Fc(Oc()),widthInPx:Fc(Oc()),heightInPx:Fc(Oc()),context:Fc(_c())})),Pd=Rc({id:Fc(jc),config:Dd,children:Fc(Nc(()=>Lc(Ld))),type:Mc(Pc("row"),Pc("column"),Pc("group"))}),Rd=Rc({id:Fc(jc),config:_d,type:Pc("window")}),Ld=Mc(Rd,Pd),Fd=Rc({id:jc,config:Wd,children:Lc(Ld),frameSummary:Td,context:Fc(_c())}),Md=Rc({type:Pc("window"),config:Rc({appName:jc,windowId:Fc(jc),context:Fc(_c()),url:Fc(jc),title:Fc(Wc()),allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc()),minWidth:Fc(Oc()),minHeight:Fc(Oc()),maxWidth:Fc(Oc()),maxHeight:Fc(Oc()),isMaximized:Fc(Dc())})}),$d=Rc({type:Pc("group"),config:_c(),children:Lc(Mc(Md))}),Nd=Rc({type:Pc("column"),config:_c(),children:Lc(Mc($d,Md,Nc(()=>Nd),Nc(()=>jd)))}),jd=Rc({type:Pc("row"),config:_c(),children:Lc(Mc(Nd,$d,Md,Nc(()=>jd)))}),Bd=Rc({name:jc,type:Pc("Workspace"),metadata:Fc(_c()),components:Lc(Rc({type:Pc("Workspace"),application:Fc(Wc()),state:Rc({config:_c(),context:_c(),children:Lc(Mc(jd,Nd,$d,Md))})}))}),qd=Rc({layout:Bd,mode:Mc(Pc("replace"),Pc("merge"))}),Ud=Rc({layouts:Lc(Bd),mode:Mc(Pc("replace"),Pc("merge"))}),zd=Rc({layouts:Lc(Bd)}),Gd=Rc({id:jc,isFocused:Fc(Dc()),isInitialized:Fc(Dc()),initializationContext:Fc(kd)}),Hd=Rc({summaries:Lc(Gd)}),Vd=Rc({id:jc,config:Wd}),Qd=Rc({summaries:Lc(Vd)}),Jd=Rc({id:jc,config:_c(),workspaces:Lc(Fd)}),Kd=Rc({name:jc,applicationName:Fc(Wc())}),Yd=Rc({summaries:Lc(Kd)}),Zd=Rc({windowId:jc}),Xd=_c(),eh=Rc({state:Jc}),th=Rc({top:Oc(),left:Oc(),width:Bc,height:Bc}),nh=Rc({bounds:th}),rh=Rc({icon:Fc(jc)}),oh=Rc({id:Fc(jc)}),ih=Rc({isSupported:Dc()}),sh=Rc({width:Fc(qc),height:Fc(qc),relative:Fc(Dc())}),ah=Rc({top:Fc(Oc()),left:Fc(Oc()),relative:Fc(Dc())}),lh=Rc({itemId:jc}),uh=Rc({allowPrevent:Fc(Dc()),showDialog:Fc(Dc())}),ch=Rc({itemId:jc,closeOptions:Fc(uh)}),dh=Rc({itemId:jc,excludeIds:Fc(Dc())}),hh=Rc({frameId:jc,requestedState:Jc}),ph=Rc({itemId:jc,title:jc}),gh=Rc({itemId:jc,containerId:jc}),fh=$c(lh,sh),mh=Rc({itemId:jc,enabled:Dc()}),yh=$c(lh,ah);Rc({id:jc,type:Qc});const wh=Rc({definition:od,parentId:jc,parentType:Vc}),vh=Rc({definition:cd,parentId:jc,parentType:Vc}),bh=Rc({itemId:jc,windowId:Fc(jc)}),Ch=Rc({live:Dc()}),Sh=Rc({type:Mc(Pc("row"),Pc("column")),workspaceId:jc}),Ih=Rc({type:Mc(Pc("row"),Pc("column")),itemId:jc}),kh=Rc({itemId:jc,config:Dd}),Th=Rc({frameSummary:Td,frameBounds:Fc(th)}),xh=Rc({workspaceSummary:Vd,frameSummary:Td,workspaceSnapshot:Fc(Fd),frameBounds:Fc(th)}),Ah=Rc({containerSummary:kh}),Eh=Rc({windowSummary:Rc({itemId:jc,parentId:jc,config:_d})}),Wh=Rc({name:jc,workspaceId:jc,saveContext:Fc(Dc()),allowMultiple:Fc(Dc()),metadata:Fc(Rc())}),Oh=Rc({allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropBottom:Fc(Dc()),allowSystemHibernation:Fc(Dc()),allowExtract:Fc(Dc()),allowWindowReorder:Fc(Dc()),allowSplitters:Fc(Dc()),showCloseButton:Fc(Dc()),showSaveButton:Fc(Dc()),allowWorkspaceTabReorder:Fc(Dc()),allowWorkspaceTabExtract:Fc(Dc()),showWindowCloseButtons:Fc(Dc()),showAddWindowButtons:Fc(Dc()),showEjectButtons:Fc(Dc())}),Dh=Rc({workspaceId:jc,config:Fc(Oh)}),_h=Rc({allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),showCloseButton:Fc(Dc())}),Ph=Rc({width:Fc(Bc),height:Fc(Bc)}),Rh=Rc({windowPlacementId:jc,config:Fc(_h)}),Lh=Rc({allowDrop:Fc(Dc()),allowSplitters:Fc(Dc())}),Fh=Rc({allowDrop:Fc(Dc()),allowSplitters:Fc(Dc())}),Mh=Rc({allowExtract:Fc(Dc()),allowReorder:Fc(Dc()),allowDrop:Fc(Dc()),allowDropLeft:Fc(Dc()),allowDropRight:Fc(Dc()),allowDropTop:Fc(Dc()),allowDropBottom:Fc(Dc()),allowDropHeader:Fc(Dc()),showMaximizeButton:Fc(Dc()),showEjectButton:Fc(Dc()),showAddWindowButton:Fc(Dc())}),$h=Rc({itemId:jc,type:Pc("row"),config:Fc(Lh)}),Nh=Rc({itemId:jc,type:Pc("column"),config:Fc(Fh)}),jh=Rc({itemId:jc,type:Pc("group"),config:Fc(Mh)}),Bh=Mc($h,Nh,jh),qh=Rc({workspaceId:jc,icon:Fc(jc)}),Uh=Rc({workspaceId:jc,icon:Fc(jc)}),zh=Fc(Rc({icon:Fc(jc)})),Gh=Rc({shortcut:jc,frameId:jc}),Hh=Rc({shortcut:jc,frameId:jc}),Vh=Rc({frameId:jc}),Qh=Rc({enabled:Dc()}),Jh=Rc({itemId:jc,type:Kc}),Kh=Rc({operation:jc}),Yh=Rc({itemId:jc,dragMode:Uc}),Zh=Rc({itemId:jc,strategy:hd}),Xh=Rc({prevent:Dc()}),ep="T42.Web.Platform.Control",tp="T42.Web.Platform.WSP.Stream",np={control:{name:"T42.Workspaces.Control",isStream:!1},frameStream:{name:"T42.Workspaces.Stream.Frame",isStream:!0},workspaceStream:{name:"T42.Workspaces.Stream.Workspace",isStream:!0},containerStream:{name:"T42.Workspaces.Stream.Container",isStream:!0},windowStream:{name:"T42.Workspaces.Stream.Window",isStream:!0}},rp={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},op={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:Th},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:xh},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:Ah},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:Eh}},ip={shortcutClicked:{name:"shortcutClicked",argsDecoder:Hh,resultDecoder:Xd},frameClosing:{name:"frameClosing",argsDecoder:Vh,resultDecoder:Xh}},sp={ping:{name:"ping",resultDecoder:Ch},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:lh,resultDecoder:zc},createWorkspace:{name:"createWorkspace",resultDecoder:Fd,argsDecoder:Sd},createFrame:{name:"createFrame",resultDecoder:Gd,argsDecoder:wd},initFrame:{name:"initFrame",resultDecoder:Xd,argsDecoder:bd},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Hd},getFrameSummary:{name:"getFrameSummary",resultDecoder:Td,argsDecoder:Id},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Qd},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:Fd,argsDecoder:lh},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Yd},openWorkspace:{name:"openWorkspace",argsDecoder:gd,resultDecoder:Fd},deleteLayout:{name:"deleteLayout",resultDecoder:Xd,argsDecoder:Xc},saveLayout:{name:"saveLayout",resultDecoder:Bd,argsDecoder:Wh},importLayout:{name:"importLayout",resultDecoder:Xd,argsDecoder:qd},importLayouts:{name:"importLayouts",resultDecoder:Xd,argsDecoder:Ud},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:zd},restoreItem:{name:"restoreItem",argsDecoder:lh,resultDecoder:Xd},maximizeItem:{name:"maximizeItem",argsDecoder:lh,resultDecoder:Xd},focusItem:{name:"focusItem",argsDecoder:lh,resultDecoder:Xd},closeItem:{name:"closeItem",argsDecoder:ch,resultDecoder:Xd},resizeItem:{name:"resizeItem",argsDecoder:fh,resultDecoder:Xd},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:mh,resultDecoder:Xd},changeFrameState:{name:"changeFrameState",argsDecoder:hh,resultDecoder:Xd},getFrameState:{name:"getFrameState",argsDecoder:lh,resultDecoder:eh},getFrameBounds:{name:"getFrameBounds",argsDecoder:lh,resultDecoder:nh},moveFrame:{name:"moveFrame",argsDecoder:yh,resultDecoder:Xd},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:dh,resultDecoder:Jd},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:lh,resultDecoder:Zd},ejectWindow:{name:"ejectWindow",argsDecoder:lh,resultDecoder:Zd},setItemTitle:{name:"setItemTitle",argsDecoder:ph,resultDecoder:Xd},moveWindowTo:{name:"moveWindowTo",argsDecoder:gh,resultDecoder:Xd},addWindow:{name:"addWindow",argsDecoder:wh,resultDecoder:bh},addContainer:{name:"addContainer",argsDecoder:vh,resultDecoder:bh},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:Sh,resultDecoder:Xd},bundleItem:{name:"bundleItem",argsDecoder:Ih,resultDecoder:Xd},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:md,resultDecoder:Xd},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:md,resultDecoder:Xd},lockWorkspace:{name:"lockWorkspace",argsDecoder:Dh,resultDecoder:Xd},lockWindow:{name:"lockWindow",argsDecoder:Rh,resultDecoder:Xd},lockContainer:{name:"lockContainer",argsDecoder:Bh,resultDecoder:Xd},pinWorkspace:{name:"pinWorkspace",argsDecoder:qh,resultDecoder:Xd},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:md,resultDecoder:Xd},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:md,resultDecoder:rh},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Uh,resultDecoder:Xd},registerShortcut:{name:"registerShortcut",argsDecoder:Gh,resultDecoder:Xd},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:Gh,resultDecoder:Xd},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Jh,resultDecoder:Xd},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Jh,resultDecoder:Xd},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:oh},operationCheck:{name:"operationCheck",argsDecoder:Kh,resultDecoder:ih},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:Yh,resultDecoder:Xd},setLoadingStrategy:{name:"setLoadingStrategy",argsDecoder:Zh,resultDecoder:Xd},getTaskbarIcon:{name:"getTaskbarIcon",resultDecoder:Gc},setTaskbarIcon:{name:"setTaskbarIcon",argsDecoder:Hc,resultDecoder:Xd},subscribeToFrameClosing:{name:"subscribeToFrameClosing",argsDecoder:lh,resultDecoder:Xd}};class ap{resolve;reject;promise;constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class lp{transport;registry;activeSubscriptions=[];pendingSubScriptions=[];constructor(e,t){this.transport=e,this.registry=t}async createCoreEventSubscription(){await this.transport.coreSubscriptionReady(this.handleCoreEvent.bind(this))}handleCoreSubscription(e){const t=`${e.eventType}-${e.action}`,n=e.scope,r=e.scopeId;return this.registry.add(t,t=>{const o={type:n,id:r},i={frame:t.frameSummary?.id||t.windowSummary?.config.frameId,workspace:t.workspaceSummary?.id||t.windowSummary?.config.workspaceId,container:t.containerSummary?.itemId,window:t.windowSummary?.itemId};this.checkScopeMatch(o,i)&&e.callback(t)})}async send(e,t){const n=Object.values(sp).find(t=>t.name===e);if(!n)throw new Error(`Cannot find definition for operation name: ${e}`);if(n.argsDecoder)try{n.argsDecoder.runWithException(t)}catch(t){throw new Error(`Unexpected internal outgoing validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`)}try{const e=await this.transport.transmitControl(n.name,t);return n.resultDecoder.runWithException(e),e}catch(t){if(t.kind)throw new Error(`Unexpected internal incoming validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`);throw new Error(t.message)}}async subscribe(e){const t=this.getPendingSubscription(e);t&&await t.promise;let n=this.getActiveSubscription(e);const r=this.getRegistryKey(e);if(!n){const t=new ap,r={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(r);try{const r=op[e.eventType],o=await this.transport.subscribe(r.name,this.getBranchKey(e),e.eventType);o.onData(e=>{const t=e.data,n=Ad.run(e.requestArguments),r=Ed.run(t.action);if(!n.ok||!r.ok)return;const o=n.result.type,i=`${o}-${n.result.branch}-${r.result}`,s=op[o].payloadDecoder.run(t.payload);s.ok&&this.registry.execute(i,s.result)}),n={streamType:e.eventType,level:e.scope,levelId:e.scopeId,callbacksCount:0,gdSub:o},this.activeSubscriptions.push(n),t.resolve()}catch(e){throw t.reject(e),e}finally{this.removePendingSubscription(r)}}const o=this.registry.add(r,e.callback);return++n.callbacksCount,()=>{o(),--n.callbacksCount,0===n.callbacksCount&&(n.gdSub.close(),this.activeSubscriptions.splice(this.activeSubscriptions.indexOf(n),1))}}onOperation(e){return this.transport.onInternalMethodInvoked("control",(t,n)=>{const r=t.operation,o=t.data,i=Object.values(ip).find(e=>e.name===r);if(!i)throw new Error(`Cannot find definition for operation name: ${r}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(o)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}e(t,n)})}onOperationWithResponse(e){return this.transport.onInternalMethodInvoked("control",async(t,n)=>{const r=t.operation,o=t.data,i=Object.values(ip).find(e=>e.name===r);if(!i)throw new Error(`Cannot find definition for operation name: ${r}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(o)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}const s=await e(t,n);if(i.resultDecoder)try{i.resultDecoder.runWithException(s)}catch(e){throw new Error(`Unexpected internal outgoing result validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${r}`)}return s})}checkScopeMatch(e,t){return"global"===e.type||"frame"===e.type&&e.id===t.frame||"workspace"===e.type&&e.id===t.workspace||"container"===e.type&&e.id===t.container||"window"===e.type&&e.id===t.window}handleCoreEvent(e){const t=e.data;try{const e=Ed.runWithException(t.action),n=xd.runWithException(t.type),r=op[n].payloadDecoder.runWithException(t.payload),o=`${n}-${e}`;this.registry.execute(o,r)}catch(e){console.warn(`Cannot handle event with data ${JSON.stringify(t)}, because of validation error: ${e.message}`)}}getBranchKey(e){return"global"===e.scope?e.scope:`${e.scope}_${e.scopeId}`}getRegistryKey(e){return`${e.eventType}-${this.getBranchKey(e)}-${e.action}`}getActiveSubscription(e){return this.activeSubscriptions.find(t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId)}getPendingSubscription(e){return this.pendingSubScriptions.find(t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId)}removePendingSubscription(e){const t=this.pendingSubScriptions.indexOf(e);t>=0&&this.pendingSubScriptions.splice(t,1)}}const up=()=>"undefined"==typeof window||window.glue42gd||window.iodesktop,cp=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class dp{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(up())return await Promise.all(Object.values(np).map(e=>this.verifyMethodLive(e.name))),void await Promise.all(Object.keys(rp).map(e=>this.registerMethod(e)));const t=cp().communicationId;await Promise.all([this.verifyMethodLive(ep,t),this.verifyMethodLive(tp,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=cp().communicationId;this.corePlatformSubPromise=this.agm.subscribe(tp,t?{target:{instance:t}}:void 0),this.corePlatformSubPromise.then(t=>{t.onData(t=>e(t.data))})}async subscribe(e,t,n){const r={branch:t,type:n};let o;try{o=await this.agm.subscribe(e,{arguments:r})}catch(n){const r=`Internal subscription error! Error details: stream - ${e}, branch: ${t}. Internal message: ${n.message}`;throw new Error(r)}return o}async transmitControl(e,t){const n=up()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},r=up()?np.control.name:ep,o=up()?void 0:cp().communicationId;let i;const s=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(n)}. `;try{if(i=await this.agm.invoke(r,n,o?{instance:o}:"best",{methodResponseTimeoutMs:this.defaultTransportTimeout}),!i)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(i.all_return_values)||0===i.all_return_values.length)throw new Error("Received unsupported result from GD - empty values collection")}catch(e){if(e&&e.all_errors&&e.all_errors.length){const t=e.all_errors[0].message;throw new Error(`${s} -> Inner message: ${t}`)}throw new Error(`${s} -> Inner message: ${e.message}`)}return i.all_return_values[0].returned}onInternalMethodInvoked(e,t){return this.registry.add(e,t)}verifyMethodLive(e,t){return(e=>new Promise((t,n)=>{let r=!0;const o=setTimeout(()=>{r&&(r=!1,n("Timeout waiting for the Workspaces communication channels"))},15e3);e().then(e=>{r&&(r=!1,clearTimeout(o),t(e))}).catch(e=>{r&&(r=!1,clearTimeout(o),n(e))})}))(()=>new Promise(n=>{if(this.agm.methods().some(n=>{const r=n.name===e,o=!t||n.getServers().some(e=>e.instance===t);return r&&o}))return void n();const r=this.agm.serverMethodAdded(o=>{const i=o.method,s=o.server,a=!t||s.instance===t;i.name===e&&a&&(r(),n())})}))}registerMethod(e){const t=rp[e];return this.agm.register(t.name,(t,n)=>Promise.all(this.registry.execute(e,t,n)))}}const hp=new WeakMap;class pp{constructor(e,t){const n=t.wrapChildren(e.children);delete e.children,hp.set(this,{base:t,children:n,definition:e})}get type(){return hp.get(this).definition.type}addColumn(e){return hp.get(this).base.add("column",hp.get(this).children,e)}addRow(e){return hp.get(this).base.add("row",hp.get(this).children,e)}addGroup(e){return hp.get(this).base.add("group",hp.get(this).children,e)}addWindow(e){return hp.get(this).base.addWindow(hp.get(this).children,e),this}serialize(){const e=hp.get(this).definition;return e.children=hp.get(this).base.serializeChildren(hp.get(this).children),e}}class gp{getBuilder;constructor(e){this.getBuilder=e}wrapChildren(e){return e.map(e=>"window"===e.type?e:this.getBuilder({type:e.type,definition:e}))}add(e,t,n){const r=sd.runWithException(n),o=this.getBuilder({type:e,definition:r});return t.push(o),o}addWindow(e,t){const n=od.runWithException(t);n.type="window",e.push(n)}serializeChildren(e){return e.map(e=>e instanceof pp?e.serialize():e)}}const fp=new WeakMap;class mp{constructor(e,t,n){const r=t.wrapChildren(e.children);delete e.children,fp.set(this,{base:t,children:r,definition:e,controller:n})}addColumn(e){const t=fp.get(this).children;if(!t.every(e=>e instanceof pp&&"column"===e.type))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return fp.get(this).base.add("column",t,e)}addRow(e){const t=fp.get(this).children;if(!t.every(e=>e instanceof pp&&"row"===e.type))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return fp.get(this).base.add("row",t,e)}addGroup(e){const t=fp.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return fp.get(this).base.add("group",t,e)}addWindow(e){const t=fp.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return fp.get(this).base.addWindow(t,e),this}getChildAt(e){return Bc.runWithException(e),fp.get(this).children[e]}async create(e){const t=Zc.runWithException(e),n=fp.get(this).definition;return n.children=fp.get(this).base.serializeChildren(fp.get(this).children),fp.get(this).controller.createWorkspace(n,t)}}const yp=new WeakMap,wp=e=>yp.get(e).base;class vp{constructor(e){yp.set(this,{base:e})}get type(){return"row"}get id(){return wp(this).getId(this)}get frameId(){return wp(this).getFrameId(this)}get workspaceId(){return wp(this).getWorkspaceId(this)}get positionIndex(){return wp(this).getPositionIndex(this)}get children(){return wp(this).getAllChildren(this)}get parent(){return wp(this).getMyParent(this)}get frame(){return wp(this).getMyFrame(this)}get workspace(){return wp(this).getMyWorkspace(this)}get allowDrop(){return wp(this).getAllowDrop(this)}get allowSplitters(){return wp(this).getAllowSplitters(this)}get minWidth(){return wp(this).getMinWidth(this)}get minHeight(){return wp(this).getMinHeight(this)}get maxWidth(){return wp(this).getMaxWidth(this)}get maxHeight(){return wp(this).getMaxHeight(this)}get width(){return wp(this).getWidthInPx(this)}get height(){return wp(this).getHeightInPx(this)}get isPinned(){return wp(this).getIsPinned(this)}get isMaximized(){return wp(this).getIsMaximized(this)}get maximizationBoundary(){return wp(this).getMaximizationBoundary(this)}addWindow(e){return wp(this).addWindow(this,e,"row")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return wp(this).addParent(this,"group","row",e)}async addColumn(e){if(e?.type&&"column"!==e.type)throw new Error(`Expected a column definition, but received ${e.type}`);return wp(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return wp(this).removeChild(this,e)}maximize(){return wp(this).maximize(this)}restore(){return wp(this).restore(this)}close(){return wp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters}):e;const n=void 0===t?void 0:Lh.runWithException(t);return wp(this).lockContainer(this,n)}async setHeight(e){return Bc.runWithException(e),wp(this).setHeight(this,e)}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await wp(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Qh.runWithException(e);return wp(this).setMaximizationBoundary(this,t)}}const bp=new WeakMap,Cp=e=>bp.get(e).base;class Sp{constructor(e){bp.set(this,{base:e})}get type(){return"column"}get id(){return Cp(this).getId(this)}get frameId(){return Cp(this).getFrameId(this)}get workspaceId(){return Cp(this).getWorkspaceId(this)}get positionIndex(){return Cp(this).getPositionIndex(this)}get children(){return Cp(this).getAllChildren(this)}get parent(){return Cp(this).getMyParent(this)}get frame(){return Cp(this).getMyFrame(this)}get workspace(){return Cp(this).getMyWorkspace(this)}get allowDrop(){return Cp(this).getAllowDrop(this)}get allowSplitters(){return Cp(this).getAllowSplitters(this)}get minWidth(){return Cp(this).getMinWidth(this)}get minHeight(){return Cp(this).getMinHeight(this)}get maxWidth(){return Cp(this).getMaxWidth(this)}get maxHeight(){return Cp(this).getMaxHeight(this)}get width(){return Cp(this).getWidthInPx(this)}get height(){return Cp(this).getHeightInPx(this)}get isPinned(){return Cp(this).getIsPinned(this)}get isMaximized(){return Cp(this).getIsMaximized(this)}get maximizationBoundary(){return Cp(this).getMaximizationBoundary(this)}addWindow(e){return Cp(this).addWindow(this,e,"column")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Cp(this).addParent(this,"group","column",e)}async addColumn(){throw new Error("Adding columns as column children is not supported")}async addRow(e){if(e?.type&&"row"!==e.type)throw new Error(`Expected a row definition, but received ${e.type}`);return Cp(this).addParent(this,"row","column",e)}removeChild(e){return Cp(this).removeChild(this,e)}maximize(){return Cp(this).maximize(this)}restore(){return Cp(this).restore(this)}close(){return Cp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters}):e;const n=void 0===t?void 0:Fh.runWithException(t);return Cp(this).lockContainer(this,n)}async setWidth(e){return Bc.runWithException(e),Cp(this).setWidth(this,e)}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Cp(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Qh.runWithException(e);return Cp(this).setMaximizationBoundary(this,t)}}const Ip=new WeakMap,kp=e=>Ip.get(e).base;class Tp{constructor(e){Ip.set(this,{base:e})}get type(){return"group"}get id(){return kp(this).getId(this)}get frameId(){return kp(this).getFrameId(this)}get workspaceId(){return kp(this).getWorkspaceId(this)}get positionIndex(){return kp(this).getPositionIndex(this)}get children(){return kp(this).getAllChildren(this)}get parent(){return kp(this).getMyParent(this)}get frame(){return kp(this).getMyFrame(this)}get workspace(){return kp(this).getMyWorkspace(this)}get allowExtract(){return kp(this).getAllowExtract(this)}get allowReorder(){return kp(this).getAllowReorder(this)}get allowDropLeft(){return kp(this).getAllowDropLeft(this)}get allowDropRight(){return kp(this).getAllowDropRight(this)}get allowDropTop(){return kp(this).getAllowDropTop(this)}get allowDropBottom(){return kp(this).getAllowDropBottom(this)}get allowDropHeader(){return kp(this).getAllowDropHeader(this)}get allowDrop(){return kp(this).getAllowDrop(this)}get showMaximizeButton(){return kp(this).getShowMaximizeButton(this)}get showEjectButton(){return kp(this).getShowEjectButton(this)}get showAddWindowButton(){return kp(this).getShowAddWindowButton(this)}get minWidth(){return kp(this).getMinWidth(this)}get minHeight(){return kp(this).getMinHeight(this)}get maxWidth(){return kp(this).getMaxWidth(this)}get maxHeight(){return kp(this).getMaxHeight(this)}get width(){return kp(this).getWidthInPx(this)}get height(){return kp(this).getHeightInPx(this)}get isMaximized(){return kp(this).getIsMaximized(this)}addWindow(e){return kp(this).addWindow(this,e,"group")}async addGroup(){throw new Error("Adding groups as group child is not supported")}async addColumn(){throw new Error("Adding columns as group child is not supported")}async addRow(){throw new Error("Adding rows as group child is not supported")}removeChild(e){return kp(this).removeChild(this,e)}maximize(){return kp(this).maximize(this)}restore(){return kp(this).restore(this)}close(){return kp(this).close(this)}lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropRight:this.allowDropRight,allowDropTop:this.allowDropTop,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton}):e;const n=void 0===t?void 0:Mh.runWithException(t);return kp(this).lockContainer(this,n)}async setSize(e){const t=Ph.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return kp(this).setSize(this,e.width,e.height)}async bundleToRow(){await kp(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await kp(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){Yc(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await kp(this).processLocalSubscription(this,t)}}const xp=new WeakMap,Ap=e=>xp.get(e).manager.getWorkspaceData(e),Ep=e=>xp.get(e).manager;class Wp{constructor(e){xp.set(this,{manager:e})}get id(){return Ap(this).id}get frameId(){return Ap(this).config.frameId}get positionIndex(){return Ap(this).config.positionIndex}get title(){return Ap(this).config.title}get layoutName(){return Ap(this).config.layoutName}get isHibernated(){return Ap(this).config.isHibernated}get isSelected(){return Ap(this).config.isSelected}get children(){return Ap(this).children}get frame(){return Ap(this).frame}get allowSplitters(){return Ap(this).config.allowSplitters}get allowSystemHibernation(){return Ap(this).config.allowSystemHibernation}get allowDrop(){return Ap(this).config.allowDrop}get allowDropLeft(){return Ap(this).config.allowDropLeft}get allowDropTop(){return Ap(this).config.allowDropTop}get allowDropRight(){return Ap(this).config.allowDropRight}get allowDropBottom(){return Ap(this).config.allowDropBottom}get allowExtract(){return Ap(this).config.allowExtract}get allowWindowReorder(){return Ap(this).config.allowWindowReorder}get showCloseButton(){return Ap(this).config.showCloseButton}get showSaveButton(){return Ap(this).config.showSaveButton}get allowWorkspaceTabReorder(){return Ap(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return Ap(this).config.allowWorkspaceTabExtract}get minWidth(){return Ap(this).config.minWidth}get minHeight(){return Ap(this).config.minHeight}get maxWidth(){return Ap(this).config.maxWidth}get maxHeight(){return Ap(this).config.maxHeight}get width(){return Ap(this).config.widthInPx}get height(){return Ap(this).config.heightInPx}get showWindowCloseButtons(){return Ap(this).config.showWindowCloseButtons}get showEjectButtons(){return Ap(this).config.showEjectButtons}get showAddWindowButtons(){return Ap(this).config.showAddWindowButtons}get isPinned(){return Ap(this).config.isPinned}get windowDragMode(){return up()?Ap(this).config.windowDragMode:"keepInside"}get loadingStrategy(){return up()||console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser"),Ap(this).config.loadingStrategy}async setLoadingStrategy(e){if(!up())throw new Error("Not supported in IO Connect Browser");const t=Ap(this).controller;await t.setLoadingStrategy(this.id,e),await this.refreshReference()}async removeChild(e){Yc(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){Yc(e);const t=Ap(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await Ap(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=Ap(this).controller,t=await e.isLastWorkspaceInFrame(this.id,this.frameId),n=(await e.getPlatformFrameId()).id;if(t&&n!==this.frame.id)return this.frame.close();await e.closeItem(this.id)}snapshot(){return Ap(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){jc.runWithException(e),await Ap(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple})}async setTitle(e){jc.runWithException(e);const t=Ap(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return Ap(this).controller.getWorkspaceContext(this.id)}setContext(e){return Ap(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return Ap(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return Ap(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await Ap(this).controller.getSnapshot(this.id,"workspace"),t=Ap(this).controller.flatChildren(Ap(this).children),n=Ap(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),r=this.frame;let o;if(r.id===e.config.frameId)Ep(this).remapFrame(r,e.frameSummary),o=r;else{const t={summary:e.frameSummary};o=Ap(this).ioc.getModel("frame",t)}Ep(this).remapWorkspace(this,{config:e.config,children:n,frame:o})}async getIcon(){return Ap(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return Ap(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){Yc(e);const t=Ap(this).children;return Ap(this).controller.iterateFindChild(t,t=>"window"!==t.type&&e(t))}getAllBoxes(e){Yc(e,!0);const t=Ap(this).children,n=Ap(this).controller.iterateFilterChildren(t,e=>"window"!==e.type);return e?n.filter(e):n}getRow(e){return Yc(e),this.getBox(t=>"row"===t.type&&e(t))}getAllRows(e){return Yc(e,!0),e?this.getAllBoxes(t=>"row"===t.type&&e(t)):this.getAllBoxes(e=>"row"===e.type)}getColumn(e){return Yc(e),this.getBox(t=>"column"===t.type&&e(t))}getAllColumns(e){return Yc(e,!0),e?this.getAllBoxes(t=>"column"===t.type&&e(t)):this.getAllBoxes(e=>"column"===e.type)}getGroup(e){return Yc(e),this.getBox(t=>"group"===t.type&&e(t))}getAllGroups(e){return Yc(e,!0),e?this.getAllBoxes(t=>"group"===t.type&&e(t)):this.getAllBoxes(e=>"group"===e.type)}getWindow(e){Yc(e);const t=Ap(this).children;return Ap(this).controller.iterateFindChild(t,t=>"window"===t.type&&e(t))}getAllWindows(e){Yc(e,!0);const t=Ap(this).children,n=Ap(this).controller.iterateFilterChildren(t,e=>"window"===e.type);return e?n.filter(e):n}addRow(e){return Ap(this).base.addParent(this,"row","workspace",e)}addColumn(e){return Ap(this).base.addParent(this,"column","workspace",e)}addGroup(e){return Ap(this).base.addParent(this,"group","workspace",e)}addWindow(e){return Ap(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await Ap(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await Ap(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await Ap(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await Ap(this).controller.resumeWorkspace(this.id),await this.refreshReference()}async lock(e){let t;t="function"==typeof e?e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowWindowReorder:this.allowWindowReorder,allowSplitters:this.allowSplitters,showCloseButton:this.showCloseButton,showSaveButton:this.showSaveButton,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,showAddWindowButtons:this.showAddWindowButtons,showEjectButtons:this.showEjectButtons,showWindowCloseButtons:this.showWindowCloseButtons}):e;const n=void 0===t?void 0:Oh.runWithException(t);await Ap(this).controller.lockWorkspace(this.id,n),await this.refreshReference()}async pin(e){zh.runWithException(e),await Ap(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await Ap(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!up())throw new Error("Not supported in IO Connect Browser");await Ap(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!up())throw new Error("Not supported in IO Connect Browser");await Ap(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!up())throw new Error("Not supported in IO Connect Browser");Uc.runWithException(e),await Ap(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){Yc(e);const t=Ap(this).id,n={action:"closed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}};return await Ap(this).controller.processLocalSubscription(n,t)}async onHibernated(e){Yc(e);const t=Ap(this).id,n={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Ap(this).controller.processLocalSubscription(n,t)}async onResumed(e){Yc(e);const t=Ap(this).id,n={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowAdded(e){Yc(e);const t=Ap(this).id,n={action:"added",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowRemoved(e){Yc(e);const t=Ap(this).id,n={action:"removed",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowLoaded(e){Yc(e);const t=Ap(this).id,n={action:"loaded",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getWindow(e=>e.id&&e.id===t.windowSummary.config.windowId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowMaximized(e){Yc(e);const t=Ap(this).id,n={action:"maximized",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowRestored(e){Yc(e);const t=Ap(this).id,n={action:"restored",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onWindowSelected(e){Yc(e);const t=Ap(this).id,n={action:"selected",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const n=this.getBox(e=>e.id===t.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===t.windowSummary.itemId);e(n)}};return await Ap(this).controller.processLocalSubscription(n,t)}async onLockConfigurationChanged(e){Yc(e);const t=Ap(this).id,n={action:"lock-configuration-changed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowSplitters:this.allowSplitters,allowWindowReorder:this.allowWindowReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,showAddWindowButtons:this.showAddWindowButtons,showCloseButton:this.showCloseButton,showEjectButtons:this.showEjectButtons,showSaveButton:this.showSaveButton,showWindowCloseButtons:this.showWindowCloseButtons})}};return await Ap(this).controller.processLocalSubscription(n,t)}}const Op=new WeakMap,Dp=e=>Op.get(e).manager.getWindowData(e);class _p{constructor(e){Op.set(this,{manager:e})}get id(){return Dp(this).config.windowId}get elementId(){return Dp(this).id}get type(){return"window"}get frameId(){return Dp(this).frame.id}get workspaceId(){return Dp(this).workspace.id}get positionIndex(){return Dp(this).config.positionIndex}get isMaximized(){return Dp(this).config.isMaximized}get isLoaded(){return Dp(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return Dp(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return Dp(this).config.title}get allowExtract(){return Dp(this).config.allowExtract}get allowReorder(){return Dp(this).config.allowReorder}get showCloseButton(){return Dp(this).config.showCloseButton}get width(){return Dp(this).config.widthInPx}get height(){return Dp(this).config.heightInPx}get minWidth(){return Dp(this).config.minWidth}get minHeight(){return Dp(this).config.minHeight}get maxWidth(){return Dp(this).config.maxWidth}get maxHeight(){return Dp(this).config.maxHeight}get workspace(){return Dp(this).workspace}get frame(){return Dp(this).frame}get parent(){return Dp(this).parent}get appName(){return Dp(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=Dp(this).controller,t=Dp(this).id,n=await e.forceLoadWindow(t);Dp(this).config.windowId=n,await this.workspace.refreshReference()}async focus(){const e=Dp(this).id,t=Dp(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=Dp(this).id,t=Dp(this).controller;await t.closeItem(e),await Dp(this).parent.removeChild(t=>t.id===e),await this.workspace.refreshReference()}async setTitle(e){jc.runWithException(e);const t=Dp(this).id,n=Dp(this).controller;await n.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=Dp(this).id,t=Dp(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=Dp(this).id,t=Dp(this).controller;await t.restoreItem(e),await this.workspace.refreshReference()}async eject(){if(!this.isLoaded)throw new Error("Cannot eject this window, because it is not loaded yet");const e=Dp(this).id,t=await Dp(this).controller.ejectWindow(e);return Dp(this).config.windowId=t,await this.workspace.refreshReference(),this.getGdWindow()}getGdWindow(){if(!this.isLoaded)throw new Error("Cannot fetch this GD window, because the window is not yet loaded");const e=Dp(this).config.windowId;return Dp(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof vp||e instanceof Sp||e instanceof Tp))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=Dp(this).id,n=Dp(this).controller,r=await n.getParent(t=>t.id===e.id);if(!r)throw new Error("Cannot move the window to the selected parent, because this parent does not exist.");await n.moveWindowTo(t,e.id),await this.workspace.refreshReference()}async lock(e){let t;t="function"==typeof e?e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton}):e;const n=void 0===t?void 0:_h.runWithException(t),r=Dp(this).id;await Dp(this).controller.lockWindow(r,n),await this.workspace.refreshReference()}async setSize(e){const t=Ph.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const n=Dp(this).id,r=Dp(this).controller;await r.resizeItem(n,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){Yc(e);const t=Dp(this).id,n={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await Dp(this).controller.processLocalSubscription(n,t)}async onLockConfigurationChanged(e){Yc(e);const t=Dp(this).id,n={callback:async()=>{await this.workspace.refreshReference(),e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})},action:"lock-configuration-changed",eventType:"window",scope:"window"};return await Dp(this).controller.processLocalSubscription(n,t)}}const Pp=new WeakMap,Rp=e=>Pp.get(e).manager.getFrameData(e);class Lp{constructor(e){Pp.set(this,{manager:e})}async registerShortcut(e,t){jc.runWithException(e),Yc(t);const n=Rp(this).summary.id;return await Rp(this).controller.registerShortcut(e,n,t)}get id(){return Rp(this).summary.id}get isInitialized(){return Rp(this).summary.isInitialized}getBounds(){const e=Rp(this).summary.id;return Rp(this).controller.getFrameBounds(e)}async resize(e){const t=sh.runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.resizeItem(n,t)}async move(e){const t=ah.runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.moveFrame(n,t)}focus(){const e=Rp(this).summary.id;return Rp(this).controller.focusItem(e)}async state(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.getFrameState(e)}setIcon(e){if(!up())throw new Error("frame.setIcon() is not supported in IO Connect Browser");Gc.runWithException(e);const t=this.id;return Rp(this).controller.setTaskbarIcon(e,t)}getIcon(){if(!up())throw new Error("frame.getIcon() is not supported in IO Connect Browser");const e=this.id;return Rp(this).controller.getTaskbarIcon(e)}async minimize(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"maximized")}async restore(){if(!up())throw new Error("State operations are not supported in IO Connect Browser");const e=Rp(this).summary.id;return Rp(this).controller.changeFrameState(e,"normal")}close(e){const t=Fc(uh).runWithException(e),n=Rp(this).summary.id;return Rp(this).controller.closeFrame(n,t)}snapshot(){const e=Rp(this).summary.id;return Rp(this).controller.getSnapshot(e,"frame")}async workspaces(){return Rp(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=Rp(this).controller,t=Rp(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){jc.runWithException(e);const n=pd.runWithException(t);return Rp(this).controller.restoreWorkspace(e,n)}createWorkspace(e,t){const n=fd.runWithException(e),r=Zc.runWithException(t);return Rp(this).controller.createWorkspace(n,r)}async init(e){if(vd.runWithException(e),Rp(this).summary.isInitialized)throw new Error("The frame has already been initialized");return Rp(this).controller.initFrame(this.id,e)}async onClosing(e){if(!up())throw new Error("Frame closing operations are not supported in io.Connect Browser");return Yc(e),await Rp(this).controller.registerFrameOnClosing(this.id,async()=>{let t=!1;return await e({prevent:()=>t=!0}),{prevent:t}})}async onClosed(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onMaximized(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onMinimized(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onNormal(e){Yc(e);const t=Rp(this).summary.id,n={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceOpened(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=await Rp(this).controller.transformStreamPayloadToWorkspace(t);e(n)},action:"opened",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceSelected(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=await Rp(this).controller.getWorkspaceById(t.workspaceSummary.id);e(n)},action:"selected",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWorkspaceClosed(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"workspace",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowAdded(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=(await Rp(this).controller.getParent(e=>e.id===t.windowSummary.parentId)).children.find(e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex);e(n)},action:"added",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowRemoved(e){Yc(e);const t=Rp(this).summary.id,n={callback:t=>{const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})},action:"removed",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onWindowLoaded(e){Yc(e);const t=Rp(this).summary.id,n={callback:async t=>{const n=(await Rp(this).controller.getParent(e=>e.id===t.windowSummary.parentId)).children.find(e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex);e(n)},action:"loaded",eventType:"window",scope:"frame"};return await Rp(this).controller.processLocalSubscription(n,t)}async onInitializationRequested(e){return Yc(e),this.isInitialized||e(Rp(this).summary.initializationContext),()=>{}}async onFocusChanged(e){Yc(e);const t=Rp(this),{id:n}=t.summary,r={callback:t=>{e({isFocused:t.frameSummary.isFocused})},action:"focus",eventType:"frame",scope:"frame"};return await t.controller.processLocalSubscription(r,n)}}class Fp{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof _p&&this.windowsData.delete(e),e instanceof Wp&&this.workspacesData.delete(e),(e instanceof vp||e instanceof Sp||e instanceof Tp)&&this.parentsData.delete(e),e instanceof Lp&&this.framesData.delete(e)}setWindowData(e,t){this.windowsData.set(e,t)}setWorkspaceData(e,t){this.workspacesData.set(e,t)}setParentData(e,t){this.parentsData.set(e,t)}setFrameData(e,t){this.framesData.set(e,t)}getWindowData(e){return this.windowsData.get(e)}getWorkspaceData(e){return this.workspacesData.get(e)}getParentData(e){return this.parentsData.get(e)}getFrameData(e){return this.framesData.get(e)}remapChild(e,t){if(e instanceof _p){const n=this.windowsData.get(e);n.parent=t.parent||n.parent,n.config=t.config||n.config}if(e instanceof vp||e instanceof Sp||e instanceof Tp){const n=this.parentsData.get(e);n.parent=t.parent||n.parent,n.config=t.config||n.config,n.children=t.children||n.children}}remapFrame(e,t){this.framesData.get(e).summary=t}remapWorkspace(e,t){const n=this.workspacesData.get(e);n.frame=t.frame||n.frame,n.config=t.config||n.config,n.children=t.children||n.children}}const Mp=new WeakMap,$p=(e,t)=>{const n=Mp.get(e).manager;return t instanceof Wp?n.getWorkspaceData(t):Mp.get(e).manager.getParentData(t)};class Np{frameId;workspaceId;positionIndex;constructor(e){Mp.set(this,{manager:e})}getId(e){return $p(this,e).id}getPositionIndex(e){return $p(this,e).config.positionIndex}getWorkspaceId(e){const t=$p(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return $p(this,e).frame.id}getAllChildren(e,t){Yc(t,!0);const n=$p(this,e).children;return void 0===t?n:n.filter(t)}getMyParent(e){return e instanceof Wp?e:$p(this,e).parent}getMyFrame(e){return $p(this,e).frame}getMyWorkspace(e){return e instanceof Wp?e:$p(this,e).workspace}async addWindow(e,t,n){if(!t.appName&&!t.windowId)throw new Error("The window definition should contain either an appName or a windowId");const r=od.runWithException(t),o=$p(this,e).controller,i=await o.add("window",$p(this,e).id,n,r);if(e instanceof Wp)return await e.refreshReference(),e.getWindow(e=>e.elementId===i.itemId);const s=this.getMyWorkspace(e);return await s.refreshReference(),s.getWindow(e=>e.elementId===i.itemId)}async addParent(e,t,n,r){const o=this.transformDefinition(t,r),i=$p(this,e).controller,s=(await i.add("container",$p(this,e).id,n,o)).itemId;if(e instanceof Wp)return await e.refreshReference(),e.getBox(e=>e.id===s);const a=this.getMyWorkspace(e);return await a.refreshReference(),a.getBox(e=>e.id===s)}async removeChild(e,t){Yc(t);const n=this.getAllChildren(e).find(t);n&&(await n.close(),e instanceof Wp?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:n}=$p(this,e);await t.maximizeItem(n),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:n}=$p(this,e);await t.restoreItem(n),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=$p(this,e),n=$p(this,e).controller;await n.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const n=$p(this,e),r=$p(this,e).controller;await r.lockContainer(n.id,e.type,t),await this.getMyWorkspace(n.parent).refreshReference()}getAllowDrop(e){return $p(this,e).config.allowDrop}getAllowDropLeft(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropLeft is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropLeft}getAllowDropRight(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropRight is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropRight}getAllowDropTop(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropTop is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropTop}getAllowDropBottom(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropBottom is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropBottom}getAllowDropHeader(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Property allowDropHeader is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropHeader}getAllowSplitters(e){const t=$p(this,e);if("group"===t.type)throw new Error(`Cannot get allow splitters from private data ${t.type}`);return t.config.allowSplitters}getAllowExtract(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowExtract}getAllowReorder(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowReorder}getShowMaximizeButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get show maximize button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showMaximizeButton}getShowEjectButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get show eject button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showEjectButton}getShowAddWindowButton(e){const t=$p(this,e);if("group"!==t.type)throw new Error(`Cannot get add window button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showAddWindowButton}getMinWidth(e){return $p(this,e).config.minWidth}getMaxWidth(e){return $p(this,e).config.maxWidth}getMinHeight(e){return $p(this,e).config.minHeight}getMaxHeight(e){return $p(this,e).config.maxHeight}getWidthInPx(e){return $p(this,e).config.widthInPx}getHeightInPx(e){return $p(this,e).config.heightInPx}getIsPinned(e){return $p(this,e).config.isPinned}getIsMaximized(e){return $p(this,e).config.isMaximized}getMaximizationBoundary(e){return $p(this,e).config.maximizationBoundary}async setHeight(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.resizeItem(o,{height:t}),await this.getMyWorkspace(n.parent).refreshReference()}async setWidth(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.resizeItem(o,{width:t}),await this.getMyWorkspace(n.parent).refreshReference()}async setSize(e,t,n){const r=$p(this,e),{controller:o,id:i}=r;await o.resizeItem(i,{width:t,height:n}),await this.getMyWorkspace(r.parent).refreshReference()}async setMaximizationBoundary(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.setMaximizationBoundary(o,t),await this.getMyWorkspace(n.parent).refreshReference()}async bundleTo(e,t){const n=$p(this,e),{controller:r,id:o}=n;await r.bundleItemTo(t,o)}async processLocalSubscription(e,t){return $p(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let n;return void 0===t?n={type:e,children:[]}:t instanceof pp?n=t.serialize():(void 0===t.type&&(t.type=e),n=cd.runWithException(t),n.children=n.children||[]),n}}class jp{ioc;windows;contexts;layouts;constructor(e,t,n,r){this.ioc=e,this.windows=t,this.contexts=n,this.layouts=r}get bridge(){return this.ioc.bridge}get privateDataManager(){return this.ioc.privateDataManager}checkIsWindowLoaded(e){return!!e&&this.windows.list().some(t=>t.id===e)}async createWorkspace(e){const t=await this.bridge.send(sp.createWorkspace.name,e),n={summary:t.frameSummary},r={frame:this.ioc.getModel("frame",n),snapshot:t};return this.ioc.getModel("workspace",r)}async createEmptyFrame(e){const t={summary:await this.bridge.send(sp.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(sp.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const n=await this.bridge.send(sp.openWorkspace.name,{name:e,restoreOptions:t}),r={summary:await this.bridge.send(sp.getFrameSummary.name,{itemId:n.config.frameId})},o={frame:this.ioc.getModel("frame",r),snapshot:n};return this.ioc.getModel("workspace",o)}async add(e,t,n,r){let o;const i={definition:r,parentId:t,parentType:n};if("window"===e)o=sp.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);o=sp.addContainer.name}return await this.bridge.send(o,i)}async getFrame(e){const t={summary:await this.bridge.send(sp.getFrameSummary.name,{itemId:e})};return this.ioc.getModel("frame",t)}getFrames(e,t){return e.reduce((e,n)=>{const r={summary:n},o=this.ioc.getModel("frame",r);return t&&!t(o)||e.push(o),e},[])}getAllWorkspaceSummaries(...e){return e.reduce((e,t)=>(e.push(...t.summaries),e),[]).map(e=>Object.assign({},{id:e.id,width:e.config.widthInPx,height:e.config.heightInPx},e.config))}handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)},n=this.layouts.onAdded(t),r=this.layouts.onChanged(t);return()=>{n(),r()}}handleOnRemoved(e){return this.layouts.onRemoved(t=>{"Workspace"===t.type&&e(t)})}async importLayouts(e,t){await this.layouts.import(e,t)}async transformStreamPayloadToWorkspace(e){const t={summary:e.frameSummary},n={frame:this.ioc.getModel("frame",t),snapshot:e.workspaceSnapshot||await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",n)}async fetchWorkspace(e){const t=await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e}),n={summary:t.frameSummary},r={frame:this.ioc.getModel("frame",n),snapshot:t};return this.ioc.getModel("workspace",r)}async bundleWorkspaceTo(e,t){await this.bridge.send(sp.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(sp.bundleItem.name))throw new Error(`Operation ${sp.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(sp.bundleItem.name,{type:e,itemId:t})}async getTaskbarIcon(e){return await this.bridge.send(sp.getTaskbarIcon.name,{frameId:e})}async setTaskbarIcon(e,t){await this.bridge.send(sp.setTaskbarIcon.name,{icon:e,frameId:t})}getWorkspaceContext(e){const t=`___workspace___${e}`;return this.contexts.get(t)}setWorkspaceContext(e,t){const n=`___workspace___${e}`;return this.contexts.set(n,t)}updateWorkspaceContext(e,t){const n=`___workspace___${e}`;return this.contexts.update(n,t)}subscribeWorkspaceContextUpdated(e,t){const n=`___workspace___${e}`;return this.contexts.subscribe(n,t)}async restoreItem(e){await this.bridge.send(sp.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(sp.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(sp.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send(sp.closeItem.name,{itemId:e})}async closeFrame(e,t){await this.bridge.send(sp.closeItem.name,{itemId:e,closeOptions:t})}async resizeItem(e,t){await this.bridge.send(sp.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(sp.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(sp.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(sp.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send(sp.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send(sp.moveFrame.name,Object.assign({},{itemId:e},t))}getGDWindow(e){return this.windows.list().find(t=>t.id===e)}async forceLoadWindow(e){return(await this.bridge.send(sp.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send(sp.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send(sp.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let n;return"workspace"===t?n=await this.bridge.send(sp.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(n=await this.bridge.send(sp.getFrameSnapshot.name,{itemId:e})),n}async setItemTitle(e,t){await this.bridge.send(sp.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:n,existingChildren:r,workspace:o}=e;if(t instanceof _p||"window"===t.type)return;const i=n.map(e=>{let n=r.find(t=>"window"===t.type?t.elementId===e.id:t.id===e.id);if(n)this.privateDataManager.remapChild(n,{parent:t,children:[],config:e.config});else{let r;r="window"===e.type?{id:e.id,parent:t,frame:o.frame,workspace:o,config:e.config}:{id:e.id,parent:t,frame:o.frame,workspace:o,config:e.config,children:[]},n=this.ioc.getModel(e.type,r)}return"window"!==e.type&&this.refreshChildren({workspace:o,existingChildren:r,children:e.children,parent:n}),n});return t instanceof Wp||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let n=e.find(e=>t(e));return n||(e.some(e=>!(e instanceof _p)&&(n=this.iterateFindChild(e.children,t),!!n||void 0)),n)}iterateFilterChildren(e,t){const n=e.filter(e=>t(e)),r=e.reduce((e,n)=>(n instanceof _p||e.push(...this.iterateFilterChildren(n.children,t)),e),[]);return n.push(...r),n}notifyWindowAdded(e){return new Promise(t=>{if(this.windows.list().some(t=>t.id===e))return t();const n=this.windows.onWindowAdded(r=>{r.id===e&&(n&&n(),t())})})}async hibernateWorkspace(e){await this.bridge.send(sp.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(sp.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(sp.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(sp.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,n){await this.bridge.send(sp.lockContainer.name,{itemId:e,type:t,config:n})}async pinWorkspace(e,t){await this.bridge.send(sp.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(sp.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(sp.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(sp.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(sp.getPlatformFrameId.name,{})}catch(e){return{}}}async setLoadingStrategy(e,t){return await this.isOperationSupported(sp.setLoadingStrategy.name),this.bridge.send(sp.setLoadingStrategy.name,{itemId:e,strategy:t})}async isOperationSupported(e){return up()?{isSupported:!0}:await this.bridge.send(sp.operationCheck.name,{operation:e})}}class Bp{bridge;base;shortcutsController;closingController;constructor(e,t,n,r){this.bridge=e,this.base=t,this.shortcutsController=n,this.closingController=r}setTaskbarIcon(e,t){return this.base.setTaskbarIcon(e,t)}getTaskbarIcon(e){return this.base.getTaskbarIcon(e)}checkIsWindowLoaded(e){return this.base.checkIsWindowLoaded(e)}async checkIsInSwimlane(e){return(await this.bridge.send(sp.isWindowInWorkspace.name,{itemId:e})).inWorkspace}async createWorkspace(e,t){const n=Object.assign({},e,{saveConfig:t});return await this.base.createWorkspace(n)}async createEmptyFrame(e){return await this.base.createEmptyFrame(e)}async initFrame(e,t){return this.base.initFrame(e,t)}async restoreWorkspace(e,t){if(!(await this.getLayoutSummaries()).some(t=>t.name===e))throw new Error(`This layout: ${e} cannot be restored, because it doesn't exist.`);if(t?.frameId&&!(await this.bridge.send(sp.getAllFramesSummaries.name)).summaries.some(e=>e.id===t.frameId))throw new Error(`Cannot reuse the frame with id: ${t.frameId}, because there is no frame with that ID found`);return await this.base.restoreWorkspace(e,t)}async add(e,t,n,r){return await this.base.add(e,t,n,r)}processLocalSubscription(e,t){return up()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,n){return up()?this.handleEnterpriseGlobalSubscription(e,t,n):this.handleCoreGlobalSubscription(e,t,n)}async getFrame(e){if(e.windowId)return await this.base.getFrame(e.windowId);if(e.predicate)return(await this.getFrames(e.predicate))[0];throw new Error(`The provided selector is not valid: ${JSON.stringify(e)}`)}async getFrames(e){const t=await this.bridge.send(sp.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return up()?this.base.fetchWorkspace(e):(await this.getWorkspaces(t=>!!t.getWindow(t=>t.id===e)))[0]}transformStreamPayloadToWorkspace(e){return this.base.transformStreamPayloadToWorkspace(e)}async getWorkspace(e){let t;return await this.iterateWorkspaces((n,r)=>{e(n)&&(t=n,r())}),t}async getWorkspaces(e){const t=[];return await this.iterateWorkspaces(n=>{e&&!e(n)||t.push(n)}),t}async getWorkspacesByFrameId(e){const t=(await this.getAllWorkspaceSummaries()).filter(t=>t.frameId===e);return await Promise.all(t.map(e=>this.base.fetchWorkspace(e.id)))}async isLastWorkspaceInFrame(e,t){const n=(await this.getAllWorkspaceSummaries()).filter(e=>e.frameId===t);return 1===n.length&&n[0].id===e}async getAllWorkspaceSummaries(){const e=await this.bridge.send(sp.getAllWorkspacesSummaries.name,{});return this.base.getAllWorkspaceSummaries(e)}async getWindow(e){let t;return await this.iterateWorkspaces((n,r)=>{const o=n.getWindow(e);o&&(t=o,r())}),t}async getParent(e){let t;return await this.iterateWorkspaces((n,r)=>{const o=n.getBox(e);o&&(t=o,r())}),t}async getLayoutSummaries(){return(await this.bridge.send(sp.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(sp.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send(sp.exportAllLayouts.name)).layouts.reduce((t,n)=>(e&&!e(n)||t.push(n),t),[])}async saveLayout(e){return await this.bridge.send(sp.saveLayout.name,e)}async importLayouts(e,t){if(up())try{await this.bridge.send(sp.importLayouts.name,{layouts:e,mode:t})}catch(n){await Promise.all(e.map(e=>this.bridge.send(sp.importLayout.name,{layout:e,mode:t})))}else await this.base.importLayouts(e,t)}handleOnSaved(e){return this.base.handleOnSaved(e)}handleOnRemoved(e){return this.base.handleOnRemoved(e)}async bundleWorkspaceTo(e,t){return await this.base.bundleWorkspaceTo(e,t)}async bundleItemTo(e,t){return await this.base.bundleItemTo(e,t)}getWorkspaceContext(e){return this.base.getWorkspaceContext(e)}setWorkspaceContext(e,t){return this.base.setWorkspaceContext(e,t)}updateWorkspaceContext(e,t){return this.base.updateWorkspaceContext(e,t)}subscribeWorkspaceContextUpdated(e,t){return this.base.subscribeWorkspaceContextUpdated(e,t)}async restoreItem(e){return await this.base.restoreItem(e)}async maximizeItem(e){return await this.base.maximizeItem(e)}async focusItem(e){return await this.base.focusItem(e)}async changeFrameState(e,t){await this.bridge.send(sp.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(sp.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(sp.getFrameState.name,{itemId:e})).state}async closeItem(e){return await this.base.closeItem(e)}async closeFrame(e,t){return await this.base.closeFrame(e,t)}async resizeItem(e,t){return await this.base.resizeItem(e,t)}async setMaximizationBoundary(e,t){return await this.base.setMaximizationBoundary(e,t)}async showWorkspaceLoadingAnimation(e){return await this.base.showWorkspaceLoadingAnimation(e)}async hideWorkspaceLoadingAnimation(e){return await this.base.hideWorkspaceLoadingAnimation(e)}async setWindowDragMode(e,t){return await this.base.setWindowDragMode(e,t)}async moveFrame(e,t){return await this.base.moveFrame(e,t)}getGDWindow(e){return this.base.getGDWindow(e)}async forceLoadWindow(e){const t=await this.base.forceLoadWindow(e);return await this.base.notifyWindowAdded(t),t}async ejectWindow(e){const t=(await this.base.ejectWindow(e)).windowId;return await this.base.notifyWindowAdded(t),t}async moveWindowTo(e,t){return await this.base.moveWindowTo(e,t)}async getSnapshot(e,t){return await this.base.getSnapshot(e,t)}async setItemTitle(e,t){return await this.base.setItemTitle(e,t)}flatChildren(e){return e.reduce((e,t)=>(e.push(t),"window"!==t.type&&e.push(...this.flatChildren(t.children)),e),[])}refreshChildren(e){return this.base.refreshChildren(e)}iterateFindChild(e,t){return this.base.iterateFindChild(e,t)}iterateFilterChildren(e,t){return this.base.iterateFilterChildren(e,t)}hibernateWorkspace(e){return this.base.hibernateWorkspace(e)}resumeWorkspace(e){return this.base.resumeWorkspace(e)}lockWorkspace(e,t){return this.base.lockWorkspace(e,t)}lockWindow(e,t){return this.base.lockWindow(e,t)}lockContainer(e,t,n){return this.base.lockContainer(e,t,n)}pinWorkspace(e,t){return this.base.pinWorkspace(e,t)}unpinWorkspace(e){return this.base.unpinWorkspace(e)}getWorkspaceIcon(e){return this.base.getWorkspaceIcon(e)}setWorkspaceIcon(e,t){return this.base.setWorkspaceIcon(e,t)}async getFrameConstraints(e){const t=await this.getSnapshot(e,"frame");return{minWidth:t.config.minWidth,maxWidth:t.config.maxWidth,minHeight:t.config.minHeight,maxHeight:t.config.maxHeight}}registerShortcut(e,t,n){return this.shortcutsController.registerShortcut(e,t,n)}getPlatformFrameId(){return this.base.getPlatformFrameId()}setLoadingStrategy(e,t){return this.base.setLoadingStrategy(e,t)}registerFrameOnClosing(e,t){return this.closingController.registerFrameOnClosing(e,t)}async handleCoreLocalSubscription(e,t){if(await this.bridge.createCoreEventSubscription(),e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,n=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=n}return this.bridge.handleCoreSubscription(e)}handleEnterpriseLocalSubscription(e,t){if(e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,n=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=n}return this.bridge.subscribe(e)}async handleCoreGlobalSubscription(e,t,n){await this.bridge.createCoreEventSubscription();const r={eventType:t,callback:e,action:n,scope:"global"};if("window"===t&&"loaded"===n){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};r.callback=t}return this.bridge.handleCoreSubscription(r)}handleEnterpriseGlobalSubscription(e,t,n){const r={eventType:t,callback:e,action:n,scope:"global"};if("window"===t&&"loaded"===n){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};r.callback=t}return this.bridge.subscribe(r)}async iterateWorkspaces(e){let t=!1;const n=()=>{t=!0},r=await this.getAllWorkspaceSummaries();for(const o of r){if(t)return;e(await this.base.fetchWorkspace(o.id),n)}}}class qp{bridge;_shortcuts=mc();constructor(e){this.bridge=e,this.bridge.onOperation(e=>{if(e.operation===ip.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}})}async registerShortcut(e,t,n){await this.bridge.send(sp.registerShortcut.name,{shortcut:e,frameId:t});const r=this._shortcuts.add(`${t}-${e}`,n);return()=>{r(),this.bridge.send(sp.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Up{bridge;registry=mc();constructor(e){this.bridge=e,this.subscribeToFrameClosing()}async registerFrameOnClosing(e,t){return await this.bridge.send(sp.subscribeToFrameClosing.name,{itemId:e}),this.registry.add(e,t)}subscribeToFrameClosing(){this.bridge.onOperationWithResponse(async e=>{if(e.operation!==ip.frameClosing.name)return;const t=e.data,n=await Promise.all(this.registry.execute(t.frameId));return this.aggregateFrameClosingResult(n)})}aggregateFrameClosingResult(e){return{prevent:e.some(e=>e?.prevent)}}}class zp{agm;windows;layouts;contexts;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;_closingController;constructor(e,t,n,r){this.agm=e,this.windows=t,this.layouts=n,this.contexts=r}get baseController(){return this._baseController||(this._baseController=new jp(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new Bp(this.bridge,this.baseController,this.shortcutsController,this.closingController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new qp(this.bridge)),this._shortcutsController}get closingController(){return this._closingController||(this._closingController=new Up(this.bridge)),this._closingController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new lp(this.transport,mc())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new dp(this.agm,mc())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new Fp),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new Np(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new Lp(this.privateDataManager),{summary:n}=t,r={summary:n,controller:this.controller};return this.privateDataManager.setFrameData(e,r),e}case"window":{const{id:e,parent:n,frame:r,workspace:o,config:i}=t,s={type:"window",controller:this.controller,config:i,id:e,parent:n,frame:r,workspace:o},a=new _p(this.privateDataManager);return this.privateDataManager.setWindowData(a,s),a}case"row":case"column":case"group":{const{id:n,children:r,parent:o,frame:i,workspace:s,config:a}=t,l="column"===e?new Sp(this.parentBase):"row"===e?new vp(this.parentBase):new Tp(this.parentBase),u=this.buildChildren(r,i,s,l),c={id:n,parent:o,frame:i,workspace:s,config:a,type:e,controller:this.controller,children:u};return this.privateDataManager.setParentData(l,c),l}case"workspace":{const{snapshot:e,frame:n}=t,r=new Wp(this.privateDataManager),o=this.buildChildren(e.children,n,r,r),i={id:e.id,type:"workspace",config:e.config,base:this.parentBase,controller:this.controller,children:o,frame:n,ioc:this};return this.privateDataManager.setWorkspaceData(r,i),r}default:throw new Error(`Unrecognized type: ${e}`)}}getBuilder(e){e.definition=e.definition||{},Array.isArray(e.definition.children)||(e.definition.children=[]);const t=new gp(this.getBuilder.bind(this));switch(e.type){case"workspace":return new mp(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new pp(e.definition,t);default:throw new Error(`Unexpected Builder creation error, provided config: ${JSON.stringify(e)}`)}}buildChildren(e,t,n,r){return e.map(e=>{switch(e.type){case"window":return this.getModel("window",{id:e.id,config:e.config,frame:t,workspace:n,parent:r});case"column":case"row":case"group":return this.getModel(e.type,{id:e.id,config:e.config,children:e.children,frame:t,workspace:n,parent:r});default:throw new Error(`Unsupported child type: ${e.type}`)}})}}const Gp=async e=>{const t=new zp(e.agm,e.windows,e.layouts,e.contexts),n=e.interop.instance.windowId;await t.initiate(n),e.workspaces=((e,t)=>{const n=t.controller,r=async e=>(Yc(e,!0),n.getFrames(e)),o=async e=>(Yc(e),await n.processGlobalSubscription(n=>{const r={summary:n.frameSummary},o=t.getModel("frame",r);e(o)},"frame","opened"));return{inWorkspace:()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");return n.checkIsInSwimlane(t)},getBuilder:e=>{const n=Cd.runWithException(e);return t.getBuilder(n)},getMyFrame:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");if(!await n.checkIsInSwimlane(t))throw new Error("Cannot fetch your frame, because this window is not in a workspace");return n.getFrame({windowId:t})},getFrame:async e=>(Yc(e),n.getFrame({predicate:e})),getAllFrames:r,getAllWorkspacesSummaries:()=>n.getAllWorkspaceSummaries(),getMyWorkspace:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my workspace, because my id is undefined.");if(!await n.checkIsInSwimlane(t))throw new Error("Cannot fetch your workspace, because this window is not in a workspace");return await n.getWorkspaceByWindowId(t)},getWorkspace:async e=>(Yc(e),(await n.getWorkspaces(e))[0]),getWorkspaceById:async e=>(jc.runWithException(e),n.getWorkspaceById(e)),getAllWorkspaces:e=>(Yc(e,!0),n.getWorkspaces(e)),getWindow:async e=>(Yc(e),n.getWindow(e)),getBox:async e=>(Yc(e),n.getParent(e)),restoreWorkspace:async(e,t)=>{jc.runWithException(e);const r=pd.runWithException(t);return n.restoreWorkspace(e,r)},createWorkspace:async(e,t)=>{const r=fd.runWithException(e),o=Zc.runWithException(t);return n.createWorkspace(r,o)},createEmptyFrame:async e=>{const t=wd.runWithException(e);return n.createEmptyFrame(t??{})},waitForFrame:async e=>(jc.runWithException(e),new Promise((t,n)=>{let i=()=>{};o(n=>{n.id===e&&(t(n),i())}).then(e=>(i=e,r())).then(n=>{const r=n.find(t=>t.id===e);r&&(t(r),i())}).catch(n)})),layouts:{getSummaries:()=>n.getLayoutSummaries(),delete:async e=>(jc.runWithException(e),n.deleteLayout(e)),export:async e=>(Yc(e,!0),n.exportLayout(e)),import:async(e,t="replace")=>{if(!Array.isArray(e))throw new Error(`The provided layouts argument is not an array: ${JSON.stringify(e)}`);return e.forEach(e=>Bd.runWithException(e)),n.importLayouts(e,t)},save:async e=>{const t=Wh.runWithException(e);return n.saveLayout(t)},onSaved:async e=>(Yc(e),n.handleOnSaved(e)),onRemoved:async e=>(Yc(e),n.handleOnRemoved(e))},onFrameOpened:o,onFrameClosed:async e=>(Yc(e),await n.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},"frame","closed")),onWorkspaceOpened:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","opened")),onWorkspaceClosed:async e=>(Yc(e),await n.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},"workspace","closed")),onWorkspaceHibernated:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","hibernated")),onWorkspaceResumed:async e=>(Yc(e),await n.processGlobalSubscription(async t=>{const r=await n.transformStreamPayloadToWorkspace(t);e(r)},"workspace","resumed")),onWindowAdded:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","added")),onWindowLoaded:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getWindow(e=>e.id&&e.id===r.windowSummary.config.windowId);e(a)},"window","loaded")),onWindowRemoved:async e=>(Yc(e),await n.processGlobalSubscription(t=>{const{windowId:n,workspaceId:r,frameId:o}=t.windowSummary.config;e({windowId:n,workspaceId:r,frameId:o})},"window","removed")),onWindowMaximized:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","maximized")),onWindowRestored:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","restored")),onWindowSelected:async e=>(Yc(e),await n.processGlobalSubscription(async r=>{const o=await n.getSnapshot(r.windowSummary.config.workspaceId,"workspace"),i={summary:o.frameSummary},s={frame:t.getModel("frame",i),snapshot:o},a=t.getModel("workspace",s).getBox(e=>e.id===r.windowSummary.parentId).children.find(e=>"window"===e.type&&e.elementId===r.windowSummary.itemId);e(a)},"window","selected")),version:"4.0.2"}})(e,t)};"undefined"!=typeof window&&(window.IOWorkspaces=Gp);var Hp=n(4744),Vp=n.n(Hp),Qp=n(2543),Jp=n.n(Qp);class Kp{static delay(e){return new Promise(t=>setTimeout(t,e))}get ended(){return this.rejected||this.resolved}constructor(){this.rejected=!1,this.resolved=!1,this.promise=new Promise((e,t)=>{this.resolve=t=>{this.resolved||this.rejected||(this.resolved=!0,e(t))},this.reject=e=>{this.resolved||this.rejected||(this.rejected=!0,t(e))}})}setTimeout(e,t){return setTimeout(()=>{this.reject(null!=t?t:"PromiseWrapper timed out")},e)}}var Yp=n(4342),Zp=n.n(Yp);let Xp=Promise;const eg=()=>Xp,tg="$FINSEMBLECONFIG",ng="$FINSEMBLECREDENTIALS",rg="$FINSEMBLEDIMENSIONMEMORY";class og{constructor(){this.gatePromises=[]}async runOldest(){var e;const t=this.gatePromises[this.gatePromises.length-1],n=await t.func();this.gatePromises=this.gatePromises.filter(e=>e!==t),null===(e=t.resolve)||void 0===e||e.call(t,n),this.gatePromises.length&&this.runOldest()}async wait(e){const t={func:e};return t.gatePromise=new Promise(e=>{t.resolve=e}),this.gatePromises=this.gatePromises.concat(t),1===this.gatePromises.length&&this.runOldest(),t.gatePromise}}const ig=(e,t)=>(n,r)=>{try{const o=e(n,r);return(null==o?void 0:o.catch)&&o.catch(e=>{(null!=t?t:console).error("Unhandled exception or rejection in interop.register handler",e)}),o}catch(e){throw(null!=t?t:console).error("Unhandled exception in interop.register handler",e),e}},sg=async(e,t)=>{const n=e.map(e=>t(e)),r=await eg().allSettled(n),o=r.filter(e=>"rejected"===e.status);if(o.length)throw o.map(e=>e.reason);return r.flatMap(e=>"fulfilled"===e.status?[e.value]:[])},ag=async(e,t)=>{const n=e.map(e=>t(e)),r=await Promise.allSettled(n),o=r.filter(e=>"rejected"===e.status);if(o.length)throw o.map(e=>e.reason);return r},lg=async e=>{var t,n;const r=await(null===(t=e.windows)||void 0===t?void 0:t.my());return{windowName:null!==(n=null==r?void 0:r.id)&&void 0!==n?n:"Unknown Window: running in node?",componentType:null==r?void 0:r.name}},ug=async(e,t)=>{const n=await e.windows.list(),r=await e.appManager.getConfigurations(n.filter(e=>e.application).map(e=>e.application.name));return n.filter(e=>t?t.includes(e.id):e.isVisible&&!((e,t)=>{var n;if(!1===e.settings.ignoreFromLayouts||!0===e.settings.ignoreFromLayouts)return e.settings.ignoreFromLayouts;const r=t.find(t=>t.name===e.name);return!r||null!==(n=null==r?void 0:r.ignoreFromLayouts)&&void 0!==n&&n})(e,r))},cg=async(e,t,n)=>{let r=[];return await ag(await ug(e,null==t?void 0:t.windowList),async e=>{const{group:t}=e;r.includes(null==t?void 0:t.id)||((null==t?void 0:t.id)&&r.push(t.id),"minimized"===e.state?await e.restore():await e.focus())}),null==n||n(null),{err:null}},dg=async(e,t,n)=>(await ag(await ug(e,null==t?void 0:t.windowList),async e=>{await e.minimize()}),null==n||n(null),{err:null}),hg=e=>!1===e||!0!==e&&(null!=e?e:void 0),pg=async(e,t)=>{var n;try{const n=await e();return null==t||t(null,n),{err:null,data:n}}catch(e){const r=e instanceof Error?e.toString():null!==(n=e.message)&&void 0!==n?n:JSON.stringify(e);return null==t||t(r),{err:r}}},gg=async(e,t)=>{var n,r;const{err:o,data:i}=await pg(e);if(o||!i)return null==t||t(o),{err:o};const s=i.all_errors?i.all_errors.join(" "):null;if(s)return null==t||t(s),{err:s};const a=i.returned;return Object.prototype.hasOwnProperty.call(a,"err")||Object.prototype.hasOwnProperty.call(a,"data")?(null==t||t(null!==(n=a.err)&&void 0!==n?n:null,a.data),{err:null!==(r=a.err)&&void 0!==r?r:null,data:a.data}):(null==t||t(null,a),{data:a,invocationResult:i})},fg=e=>null!=e,mg=(e,t,n,r)=>{var o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S,I,k,T,x,A;if(null==(null!==(u=null!==(l=null!==(a=null!==(s=null!==(i=null!==(o=null==t?void 0:t.left)&&void 0!==o?o:null==t?void 0:t.right)&&void 0!==i?i:null==t?void 0:t.top)&&void 0!==s?s:null==t?void 0:t.bottom)&&void 0!==a?a:null==t?void 0:t.width)&&void 0!==l?l:null==t?void 0:t.height)&&void 0!==u?u:null==t?void 0:t.monitor))return;const E=null!==(c=null==t?void 0:t.left)&&void 0!==c?c:null===(d=null==t?void 0:t.options)||void 0===d?void 0:d.left,W=null!==(h=null==t?void 0:t.top)&&void 0!==h?h:null===(p=null==t?void 0:t.options)||void 0===p?void 0:p.top,O=null!==(g=null==t?void 0:t.right)&&void 0!==g?g:null===(f=null==t?void 0:t.options)||void 0===f?void 0:f.right,D=null!==(m=null==t?void 0:t.bottom)&&void 0!==m?m:null===(y=null==t?void 0:t.options)||void 0===y?void 0:y.bottom,_=null!==(w=null==t?void 0:t.width)&&void 0!==w?w:null===(v=null==t?void 0:t.options)||void 0===v?void 0:v.width,P=null!==(b=null==t?void 0:t.height)&&void 0!==b?b:null===(C=null==t?void 0:t.options)||void 0===C?void 0:C.height,R={snapped:null!==(k=null===(I=null===(S=null==r?void 0:r.details)||void 0===S?void 0:S.placement)||void 0===I?void 0:I.snapped)&&void 0!==k&&k,left:E,top:W,right:O,bottom:D,width:_,height:P,display:null!=n?n:null===(x=null===(T=null==r?void 0:r.details)||void 0===T?void 0:T.placement)||void 0===x?void 0:x.display};return yg(R,t,null===(A=null==r?void 0:r.details)||void 0===A?void 0:A.placement),""===R.width&&delete R.width,""===R.height&&delete R.height,0!==R.height&&"0"!==R.height||(R.height=1),0!==R.width&&"0"!==R.width||(R.width=1),L=R,Object.keys(L).forEach(e=>{null!==L[e]&&void 0!==L[e]||delete L[e]}),L;var L},yg=(e,t,n)=>{var r,o,i;"center"===e.top&&(e.verticalAlignment="center"),"center"===e.left&&(e.horizontalAlignment="center"),(null==t?void 0:t.dockable)&&(null==t?void 0:t.docked)&&t.dockable.some(e=>e===t.docked)&&(e.snapped=!0,e.height=null!==(r=t.dockedHeight)&&void 0!==r?r:e.height,e.verticalAlignment="bottom"===t.docked?"bottom":"top",e.horizontalAlignment="stretch"),!e.horizontalAlignment&&fg(e.right)&&(e.horizontalAlignment="right"),!e.horizontalAlignment&&fg(e.left)&&(e.horizontalAlignment="left"),!e.verticalAlignment&&fg(e.bottom)&&(e.verticalAlignment="bottom"),!e.verticalAlignment&&fg(e.top)&&(e.verticalAlignment="top"),e.horizontalAlignment||(e.horizontalAlignment=null!==(o=null==n?void 0:n.horizontalAlignment)&&void 0!==o?o:"left"),e.verticalAlignment||(e.verticalAlignment=null!==(i=null==n?void 0:n.verticalAlignment)&&void 0!==i?i:"top")},wg=async(e,t)=>{var n,r;if(!t||"mine"===t){const t=null===(n=e.windows.my())||void 0===n?void 0:n.id,o=t?await e.displays.getByWindowId(t):void 0;return null===(r=null==o?void 0:o.isPrimary)||void 0===r||r?"main":null==o?void 0:o.index.toString()}return bg(t)},vg=async(e,t,n)=>{var r,o;const i=await e.displays.all(),s=t.display,a=i.find(e=>e.index===Number(s)||"current"===s&&e.index===Number(n)||"object"==typeof s&&s.index===e.index||!("main"!==s||!e.isPrimary)),l=i.find(e=>e.isPrimary),u=a?a.workArea.top:0,c=a?a.workArea.left:0,d=a?a.bounds.top:0,h=a?a.bounds.left:0,p=(null!==(r=null==a?void 0:a.scaleFactor)&&void 0!==r?r:1)/(null!==(o=null==l?void 0:l.scaleFactor)&&void 0!==o?o:1);"number"==typeof t.left&&(t.left-=(c-h)/p,t.left=t.left/p),"number"==typeof t.top&&(t.top-=(u-d)/p,t.top=t.top/p),t.display&&"object"!=typeof t.display&&(t.display=(parseInt(t.display)+1).toString())},bg=e=>"number"==typeof e?(e+1).toString():"main",Cg=async(e,t)=>{var n;const r=await(null==t?void 0:t.getContext()),o=null!==(n=null==r?void 0:r["#finsemble-componentState"])&&void 0!==n?n:{};let i;if(null==e?void 0:e.field)i=o[e.field];else if(null==e?void 0:e.fields){i={};for(let t=0;t<e.fields.length;t++)i[e.fields[t]]=o[e.fields[t]]}else i={...o};return{err:null,data:i}},Sg=async(e,t)=>{var n,r;const o=e.windows.list(),i=await(null===(n=e.windows.findById(t))||void 0===n?void 0:n.getBounds());if(!i)return void console.log("formGroup() called on invalid window?",t);i.right=i.left+i.width,i.bottom=i.top+i.height;const s=e=>{if(e.right=e.left+e.width,e.bottom=e.top+e.height,i.left>e.right)return null;if(i.right<e.left)return null;if(i.top>e.bottom)return null;if(i.bottom<e.top)return null;const t=[{direction:"left",distance:e.right-i.left},{direction:"right",distance:i.right-e.left},{direction:"top",distance:e.bottom-i.top},{direction:"bottom",distance:i.bottom-e.top}].flatMap(e=>e.distance<0?[]:e);return t.length?t.sort((e,t)=>e.distance>t.distance?1:t.distance>e.distance?-1:0)[0].direction:null};for(let n=0;n<o.length;n++){const i=o[n];if(i.id===t)continue;if(!i.isVisible)continue;if(!i.isSticky)continue;const a=s(i.bounds);if(a){console.log(i.name,"snap to",null===(r=e.windows.findById(t))||void 0===r?void 0:r.name," ",a),i.snap(t,a);break}}},Ig=async(e,t)=>{var n;if(!(null==e?void 0:e.field)&&!(null==e?void 0:e.fields))return{err:null};let r={};try{const o=await(null==t?void 0:t.getContext()),i=null!==(n=null==o?void 0:o["#finsemble-componentState"])&&void 0!==n?n:{};e.field?r=Object.assign(i,{[e.field]:e.value}):e.fields&&(r=Object.assign(i,...e.fields.map(({field:e,value:t})=>({[e]:t})))),await(null==t?void 0:t.updateContext({"#finsemble-componentState":r}))}catch(e){return{err:e.toString()}}return{err:null}},kg=async(e,t)=>{if(!(null==e?void 0:e.field)&&!(null==e?void 0:e.fields))return{err:null};const n=await(null==t?void 0:t.getContext()),r=null==n?void 0:n["#finsemble-componentState"];return r?(e.field?null==r||delete r[e.field]:e.fields&&e.fields.forEach(e=>{delete r[null==e?void 0:e.field]}),null==t||t.updateContext({"#finsemble-componentState":r}),{err:null}):{err:null}},Tg=async(e,t)=>{var n,r;if("about:blank"!==(r=t)&&!new RegExp("^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?)?([;&a-z\\d\\/#\\?%_.~+=-]*)?","i").test(r))return{err:`Failed to open browser - invalid url provided: '${t}'`};try{await(null===(n=e.appManager.application("open-browser"))||void 0===n?void 0:n.start({url:t}))}catch(e){}return{}},xg=async e=>{var t,n,r,o,i,s,a,l,u;const c=await Wg(e),d=await(null==e?void 0:e.getContext());return{componentType:null==e?void 0:e.name,resizable:null===(t=null==c?void 0:c.details.hasSizeAreas)||void 0===t||t,customData:{component:{type:null==e?void 0:e.name},interop:{useLinker:null===(r=null===(n=null==c?void 0:c.details.channelSelector)||void 0===n?void 0:n.enabled)||void 0===r||r},appConfig:null===(o=null==c?void 0:c.customProperties)||void 0===o?void 0:o.appd,custom:null===(l=null===(a=null===(s=null===(i=null==c?void 0:c.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble)||void 0===l?void 0:l.custom,isAnApp:!!(null===(u=null==c?void 0:c.customProperties)||void 0===u?void 0:u.appd),spawnData:null==d?void 0:d["#finsemble-spawnData"]}}},Ag={},Eg=new og,Wg=async e=>await Eg.wait(async()=>{var t;if(!(null===(t=null==e?void 0:e.application)||void 0===t?void 0:t.name))return;if(Ag[e.application.name])return Ag[e.application.name];const n=await e.application.getConfiguration();return n&&(Ag[e.application.name]=n),n}),Og=async(e,t,n)=>{var r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S,I,k,T,x,A,E,W,O,D,_,P,R,L,F,M,$,N,j,B,q,U,z,G,H,V,Q,J,K,Y,Z,X,ee,te,ne,re,oe,ie,se,ae,le,ue;const ce=null!=t?t:{},de=null===(r=e.windows.my())||void 0===r?void 0:r.tabGroupId,he={ignoreSavedLayout:!0},pe=await wg(e,null==t?void 0:t.monitor);let ge=mg(0,ce,pe,n);ge&&(ge=await(async(e,t,n,r)=>{var o,i,s,a;if("absolute"===r||"virtual"===r)return t;const l=n?e.windows.findById(n):e.windows.my(),u=await(null==l?void 0:l.getDisplay());if(!l||!u)return t;if("monitor"===r||!r)return(t=null!=t?t:{snapped:!1}).display=u.index+1,t;const c={relative:l.bounds,available:u.workArea};if(Object.hasOwnProperty.call(c,r)&&t){const{left:e,top:n,height:l,width:u}=c[r];(Number.isInteger(t.left)||Number.isInteger(t.top))&&(t.left=(null!==(o=t.left)&&void 0!==o?o:0)+e,t.top=(null!==(i=t.top)&&void 0!==i?i:0)+n),(null===(s=t.height)||void 0===s?void 0:s.toString().includes("%"))&&(t.height=parseFloat(t.height)/100*l),(null===(a=t.width)||void 0===a?void 0:a.toString().includes("%"))&&(t.width=parseFloat(t.width)/100*u),t.horizontalAlignment="left",t.verticalAlignment="top"}return t})(e,ge,null===(o=ce.relativeWindow)||void 0===o?void 0:o.windowName,null==t?void 0:t.position)),he.placement=ge,he.cascade=(e=>{const t=null==e?void 0:e.staggerPixels;return{enabled:!0,offset:null!=t?t:50}})(ce);const fe=((e,t)=>{var n,r,o,i,s,a,l,u,c,d,h;const p="adjacent",g={};return(null!==(n=null==t?void 0:t.left)&&void 0!==n?n:null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.left)===p&&(g.relativeDirection="right"),(null!==(o=null==t?void 0:t.top)&&void 0!==o?o:null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.top)===p&&(g.relativeDirection="bottom"),(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:null===(a=null==t?void 0:t.options)||void 0===a?void 0:a.right)===p&&(g.relativeDirection="left"),(null!==(l=null==t?void 0:t.bottom)&&void 0!==l?l:null===(u=null==t?void 0:t.options)||void 0===u?void 0:u.bottom)===p&&(g.relativeDirection="top"),Object.keys(g).length>0&&(g.relativeTo=null!==(d=null===(c=null==t?void 0:t.relativeWindow)||void 0===c?void 0:c.windowName)&&void 0!==d?d:null===(h=e.windows.my())||void 0===h?void 0:h.id),g})(e,ce);ce.ephemeral&&(he.showInTaskbar=ce.ephemeral,he.onTop=!0,he.hasSizeAreas=!1,he.isSticky=!1);const me=null===(a=null===(s=null===(i=null==n?void 0:n.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble,ye=null!==(d=null===(c=null===(u=null===(l=null==me?void 0:me.foreign)||void 0===l?void 0:l.services)||void 0===u?void 0:u.windowService)||void 0===c?void 0:c.addToWorkspace)&&void 0!==d?d:null===(h=null==me?void 0:me.window)||void 0===h?void 0:h.addToWorkspace,we=null!==(p=null!=ye?ye:ce.addToWorkspace)&&void 0!==p&&p;if(he.ignoreFromLayouts=hg(we),fg(fe.relativeTo)&&(he.relativeTo=fe.relativeTo),fg(fe.relativeDirection)&&(he.relativeDirection=fe.relativeDirection),fg(ce.canGroup)&&(he.isSticky=null!==(g=ce.canGroup)&&void 0!==g?g:void 0),fg(null===(f=ce.options)||void 0===f?void 0:f.showTaskbarIcon)&&(he.showInTaskbar=null===(m=ce.options)||void 0===m?void 0:m.showTaskbarIcon),fg(null===(y=ce.options)||void 0===y?void 0:y.resizable)&&(he.hasSizeAreas=null===(w=ce.options)||void 0===w?void 0:w.resizable),fg(null===(v=ce.options)||void 0===v?void 0:v.alwaysOnTop)&&(he.onTop=null===(b=ce.options)||void 0===b?void 0:b.alwaysOnTop),fg(null===(C=ce.options)||void 0===C?void 0:C.autoShow)&&(he.hidden=null!==(I=hg(null===(S=ce.options)||void 0===S?void 0:S.autoShow))&&void 0!==I?I:void 0),fg(ce.minWidth)&&(he.minWidth=ce.minWidth),fg(ce.minHeight)&&(he.minHeight=ce.minHeight),fg(ce.maxWidth)&&(he.maxWidth=ce.maxWidth),fg(ce.maxHeight)&&(he.maxHeight=ce.maxHeight),fg(ce.slave)&&(he.isChild=ce.slave),fg(null===(k=ce.options)||void 0===k?void 0:k.windowState)&&(he.windowState=null===(T=ce.options)||void 0===T?void 0:T.windowState),fg(ce.frame)&&(he.showTitleBar=null!==(x=hg(ce.frame))&&void 0!==x?x:void 0),ce.addToTabCollection&&(he.tabGroupId="string"==typeof ce.addToTabCollection?ce.addToTabCollection:de),(null===(A=ce.options)||void 0===A?void 0:A.preloadScripts)&&(he.preloadScripts=ce.options.preloadScripts),!1===ce.autoFocus&&(he.focus=!1),ce.url&&(he.url=ce.url),ce.path){const e=ce.path.split(/[\\/]/),t=e.pop(),n=e.join("/");he.command=t,he.path=n}fg(null===(E=ce.options)||void 0===E?void 0:E.windowSpawnTimeout)&&(he.timeout=null===(W=ce.options)||void 0===W?void 0:W.windowSpawnTimeout);const ve=null!==(O=ce.argumentsAsQueryString)&&void 0!==O?O:null===(L=null===(R=null===(P=null===(_=null===(D=n.customProperties)||void 0===D?void 0:D.appd)||void 0===_?void 0:_.hostManifests)||void 0===P?void 0:P.Finsemble)||void 0===R?void 0:R.window)||void 0===L?void 0:L.argumentsAsQueryString;if(fg(ce.arguments)&&(ve?he.urlLoadOptions={queryString:ce.arguments}:he.parameters=ce.arguments),fg(ce.env)&&(he.env=ce.env),"exe"===n.type||"assimilation"===(null===(j=null===(N=null===($=null===(M=null===(F=null==n?void 0:n.customProperties)||void 0===F?void 0:F.appd)||void 0===M?void 0:M.hostManifests)||void 0===$?void 0:$.Finsemble)||void 0===N?void 0:N.window)||void 0===j?void 0:j.windowType)){let t=null!==(Z=null!==(H=null!==(q=null!==(B=he.parameters)&&void 0!==B?B:n.details.parameters)&&void 0!==q?q:null===(G=null===(z=null===(U=null==n?void 0:n.customProperties)||void 0===U?void 0:U.appd)||void 0===z?void 0:z.details)||void 0===G?void 0:G.arguments)&&void 0!==H?H:null===(Y=null===(K=null===(J=null===(Q=null===(V=null==n?void 0:n.customProperties)||void 0===V?void 0:V.appd)||void 0===Q?void 0:Q.hostManifests)||void 0===J?void 0:J.Finsemble)||void 0===K?void 0:K.window)||void 0===Y?void 0:Y.arguments)&&void 0!==Z?Z:"";if("exe"===n.type&&"assimilation"!==(null===(re=null===(ne=null===(te=null===(ee=null===(X=null==n?void 0:n.customProperties)||void 0===X?void 0:X.appd)||void 0===ee?void 0:ee.hostManifests)||void 0===te?void 0:te.Finsemble)||void 0===ne?void 0:ne.window)||void 0===re?void 0:re.windowType)&&"external"!==(null===(le=null===(ae=null===(se=null===(ie=null===(oe=null==n?void 0:n.customProperties)||void 0===oe?void 0:oe.appd)||void 0===ie?void 0:ie.hostManifests)||void 0===se?void 0:se.Finsemble)||void 0===ae?void 0:ae.window)||void 0===le?void 0:le.windowType)){let r=!1;if(!t.includes("apiToLogFile")){const t=await e.contexts.get(tg);!0===(null===(ue=null==t?void 0:t.iocd)||void 0===ue?void 0:ue.apiToLogFile)&&(r=!0)}t=((e,t,n,r)=>{const o=(e=>{var t,n;return new Map([["componentType",null!=e?e:"Unknown"],["iocdGatewayAddress",null!==(n=null===(t=null===globalThis||void 0===globalThis?void 0:globalThis.glue42gd)||void 0===t?void 0:t.gwURL)&&void 0!==n?n:"ws://127.0.0.1:8385/"],["hostType","iocd"]])})(t);n&&!e.includes("apiToLogFile")&&o.set("apiToLogFile","true");let i=e;if(r){i.includes("?")||(i=`${i}?`);let t="";o.forEach((n,r)=>{e.includes(r)||(t=`${t}&${r}=${n}`)}),i.endsWith("?")&&(t=t.slice(1)),i=`${i}${t}`}else o.forEach((t,n)=>{e.includes(n)||(i=`${i} "${n}=${t}"`)}),""===e&&(i=i.slice(1));return i})(t,n.name,r,ve)}he.parameters=t}return he.ignoreFromLayouts&&(he.isSticky=!1,"tab"!==he.mode&&"tab"!==n.details.mode||(he.mode="flat")),fg(he.iocd)?Vp()(he,he.iocd):he};class Dg{constructor(){this.promises=[]}addConstructor(){const e=new Kp;return this.promises.push(e.promise),e}finishConstructor(e){e.resolve()}async ready(){await eg().allSettled(this.promises)}}const _g=(e,t,n)=>n.indexOf(e)===t,Pg=(e,t,n)=>n.filter(t=>t===e).length>1,Rg=(e,t)=>t.failed.find(t=>t.name===e)?"failed":"success",Lg=(e,t)=>{var n;const r=null===(n=e.windowData)||void 0===n?void 0:n.filter(e=>"StackedWindow"===e.windowType),o=null==r?void 0:r.find(e=>{var n;return null===(n=e.childWindowIdentifiers)||void 0===n?void 0:n.some(e=>e.windowName===t.name)});return null!=o?o:null},Fg=e=>{var t,n;const r=e.icon&&""!==e.icon?{imageType:"url",path:e.icon}:void 0;return{window:{},component:{displayName:e.title,type:e.name,isUserDefined:!!(null===(t=e.customProperties)||void 0===t?void 0:t.isUserDefined)},foreign:{components:{"App Launcher":{launchableByUser:null===(n=hg(e.hidden))||void 0===n||n}}},icons:{toolbarIcon:r,taskbarIcon:r,titleBarIcon:r}}},Mg=(e,t,n)=>{var r;const o=(null!==(r=t.windowData)&&void 0!==r?r:[]).flatMap(e=>{var n,r,o,i,s,a,l;if("StackedWindow"===e.windowType)return[];const u=$g(((e,t)=>{var n,r,o,i;return null!==(i=null===(o=null===(r=null===(n=null==e?void 0:e.componentStates)||void 0===n?void 0:n[t.name])||void 0===r?void 0:r["Interop-#Linker-linkedChannels"])||void 0===o?void 0:o.channels)&&void 0!==i?i:[]})(t,e)),c=(e=>0===e?{windowState:"Normal",restoreState:"Normal"}:1===e?{windowState:"Minimized",restoreState:"Normal"}:3===e?{windowState:"Minimized",restoreState:"Maximized"}:2===e?{windowState:"Maximized",restoreState:"Normal"}:{windowState:"Normal",restoreState:"Normal"})(e.windowState),d=null===(n=Lg(t,e))||void 0===n?void 0:n.name,h=((e,t)=>{var n,r;const o=null!==(r=null===(n=e.componentStates)||void 0===n?void 0:n[t])&&void 0!==r?r:{},i={};return Object.keys(o).forEach(e=>{if("#finsemble-windowName"!==e&&"#finsemble-spawnData"!==e)if("Interop-#Linker-linkedChannels"!==e){if("Interop-#Workspace-contexts"===e){const t=o[e];return Object.entries(t).forEach(([e,t])=>{o[`#finsemble-persistedContext-${e}`]=t}),void delete o[e]}i[e]=o[e],delete o[e]}else delete o[e]}),o["#finsemble-componentState"]=i,o})(t,e.name),p=null!==(o=null===(r=t.componentStates)||void 0===r?void 0:r[e.name])&&void 0!==o?o:{},g={channels:Object.entries(null!==(i=p["customFDC3-channels"])&&void 0!==i?i:{}).flatMap(([e,t])=>"Both"===t?[{name:e,read:!0,write:!0}]:"Broadcast"===t?[{name:e,read:!1,write:!0}]:"Listen"===t?[{name:e,read:!0,write:!1}]:[])},f={application:e.componentType,type:null!==(s=e.type)&&void 0!==s?s:"window",componentType:"application",state:{context:h,isCollapsed:!1,windowState:c.windowState,channelSelector:{enabled:!0},channelRestrictions:g,mode:"tab",channelId:u,restoreState:c.restoreState,bounds:{left:e.left,top:e.top,width:e.width,height:e.height},isSticky:!0,instanceId:e.name}},{workspaces:m}=e;m&&(f.state.workspaces=m);const y=null!==(a=p.persistedTitle)&&void 0!==a?a:null;y&&(f.state.userTitle=y);const w=((e,t)=>{var n,r,o;const i=Lg(e,t),s=null!==(r=null===(n=null==i?void 0:i.childWindowIdentifiers)||void 0===n?void 0:n.findIndex(e=>e.windowName===t.name))&&void 0!==r?r:0,a=(null===(o=null==i?void 0:i.visibleWindowIdentifier)||void 0===o?void 0:o.windowName)===t.name;return(s+1)*(!i||a?-1:1)})(t,e),v=null!==(l=((e,t)=>{const n=Lg(e,t);return null==n?void 0:n.name})(t,e))&&void 0!==l?l:Zp()(),b=((e,t,n)=>{var r;const[o]=null!==(r=Object.entries(e.groups).find(([e,r])=>(e=>{let r=!1;return e.isMovable&&(r=e.windowNames.includes(t.name)||e.windowNames.includes(null!=n?n:""),r||e.windowNames.forEach(e=>{t.name.endsWith(e)&&(r=!0)})),r})(r)))&&void 0!==r?r:[null];return o})(t,e,d);return fg(w)&&(f.state.tabIndex=w),f.state.tabGroupId=v,("exe"!==e.type||b)&&(f.state.restoreSettings={groupId:null!=b?b:`${v}-1`,groupZOrder:0}),[f]}),i={"iop#position":n};return t.id&&(i.id=t.id),{name:e,type:"Global",components:o,context:{},metadata:i,version:2}},$g=e=>e.join("+++"),Ng=e=>""!==e&&e?e.split("+++"):[],jg=e=>{var t;const n=(e=>{const t=e.map(e=>{var t,n;return null===(n=null===(t=e.state)||void 0===t?void 0:t.restoreSettings)||void 0===n?void 0:n.groupId}).filter(fg).filter(_g),n=t.map(t=>[t,{isMovable:!0,isAlwaysOnTop:!1,windowNames:e.flatMap(e=>{var n,r;return(null===(r=null===(n=e.state)||void 0===n?void 0:n.restoreSettings)||void 0===r?void 0:r.groupId)===t?[e.state.instanceId]:[]})}]).filter(e=>e[1].windowNames.length>1);return Object.fromEntries(n)})(e.components),{windowData:r,stacks:o}=(e=>{const t=e.map(e=>{var t,n,r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b;const C=e.application;return{componentType:C,name:`${C}${e.state.instanceId}`,opacity:1,windowState:(S=e.state.windowState,I=e.state.restoreState,"Normal"===S?0:"Minimized"===S&&"Normal"===I?1:"Minimized"===S&&"Maximized"===I?3:"Maximized"===S?2:0),left:null===(n=null===(t=e.state)||void 0===t?void 0:t.bounds)||void 0===n?void 0:n.left,top:null===(o=null===(r=e.state)||void 0===r?void 0:r.bounds)||void 0===o?void 0:o.top,width:null===(s=null===(i=e.state)||void 0===i?void 0:i.bounds)||void 0===s?void 0:s.width,height:null===(l=null===(a=e.state)||void 0===a?void 0:a.bounds)||void 0===l?void 0:l.height,right:null===(c=null===(u=e.state)||void 0===u?void 0:u.bounds)||void 0===c?void 0:c.right,bottom:null===(h=null===(d=e.state)||void 0===d?void 0:d.bounds)||void 0===h?void 0:h.bottom,defaultLeft:null===(g=null===(p=e.state)||void 0===p?void 0:p.bounds)||void 0===g?void 0:g.left,defaultTop:null===(m=null===(f=e.state)||void 0===f?void 0:f.bounds)||void 0===m?void 0:m.top,defaultWidth:null===(w=null===(y=e.state)||void 0===y?void 0:y.bounds)||void 0===w?void 0:w.width,defaultHeight:null===(b=null===(v=e.state)||void 0===v?void 0:v.bounds)||void 0===b?void 0:b.height,workspaces:e.state.workspaces,type:e.type};var S,I}),n=e.map(e=>e.state.tabGroupId).filter(fg).filter(Pg).filter(_g),r=(e,t)=>Math.abs(e.state.tabIndex)>Math.abs(t.state.tabIndex)?1:Math.abs(e.state.tabIndex)<Math.abs(t.state.tabIndex)?-1:0,o=n.map(t=>{const n=e.find(e=>e.state.tabGroupId===t&&e.state.tabIndex<0),o=e.filter(e=>e.state.tabGroupId===t).sort(r).map(e=>({windowName:`${e.application}${e.state.instanceId}`}));return{name:t,windowType:"StackedWindow",componentType:"StackedWindow",visibleWindowIdentifier:{windowName:n?`${n.application}${n.state.instanceId}`:void 0},childWindowIdentifiers:o,left:null==n?void 0:n.state.bounds.left,top:null==n?void 0:n.state.bounds.top,width:null==n?void 0:n.state.bounds.width,height:null==n?void 0:n.state.bounds.height,bounds:{left:null==n?void 0:n.state.bounds.left,top:null==n?void 0:n.state.bounds.top,width:null==n?void 0:n.state.bounds.width,height:null==n?void 0:n.state.bounds.height}}});return{windowData:t.concat(o),stacks:o}})(e.components),i=(e=>{const t=e.map(e=>{var t,n,r,o,i,s;const a=`${e.application}${e.state.instanceId}`,l=Ng(e.state.channelId),u=e.state.channelId?{"Interop-#Linker-linkedChannels":{channels:l}}:{},c={...null!==(n=null===(t=e.state)||void 0===t?void 0:t.context)&&void 0!==n?n:{},...null===(o=null===(r=e.state)||void 0===r?void 0:r.context)||void 0===o?void 0:o["#finsemble-componentState"],...u};delete c["#finsemble-componentState"];const d=null!==(s=null===(i=e.state.channelRestrictions)||void 0===i?void 0:i.channels)&&void 0!==s?s:[];return c["customFDC3-channels"]=Object.fromEntries(l.map(e=>{const t=d.find(t=>t.name===e);return t&&!t.read?[e,"Broadcast"]:t&&!t.write?[e,"Listen"]:[e,"Both"]})),e.state.userTitle&&(c.persistedTitle=e.state.userTitle),(e=>{const t={};Object.keys(e).forEach(n=>{const r=n.split("#finsemble-persistedContext-")[1];r&&(t[r]=e[n],delete e[n])}),e["Interop-#Workspace-contexts"]=t})(c),[a,c]});return Object.fromEntries(t)})(e.components);o.forEach(e=>i[e.name]={});const s=r.map(e=>e.name),a={version:"1.0.0",name:e.name,type:"workspace",groups:n,windows:s,componentStates:i,custom:{},windowData:r,tabCollections:[]};return(null===(t=e.metadata)||void 0===t?void 0:t.id)&&(a.id=e.metadata.id),a},Bg=e=>{var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return;const n={left:(null===(t=e.workArea)||void 0===t?void 0:t.left)*(null==e?void 0:e.scaleFactor),top:e.workArea.top*e.scaleFactor,width:e.workArea.width,height:e.workArea.height};n.right=n.left+n.width,n.bottom=n.top+n.height;const r={left:e.bounds.left*e.scaleFactor,top:e.bounds.top*e.scaleFactor,width:e.bounds.width,height:e.bounds.height};return r.right=r.left+r.width,r.bottom=r.top+r.height,{availableRect:n,monitorRect:r}},qg=e=>{var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return null;const{availableRect:n,monitorRect:r}=Bg(e);return{monitor:{dipRect:n,scaledRect:n},availableRect:n,monitorRect:r,name:`device${e.index}`,deviceId:Number(null!==(t=e.id)&&void 0!==t?t:0).toString(),deviceScaleFactor:1/e.scaleFactor,displayDeviceActive:!0,position:e.index,whichMonitor:e.isPrimary?"primary":e.index}},Ug=(e,t)=>{if(t.includes("%")){const n=parseFloat(t)/100;return Math.abs(e*n)}return parseInt(t)},zg=(e,t)=>{const n="string"==typeof t.top?Ug(e.height,t.top):t.top,r="string"==typeof t.left?Ug(e.width,t.left):t.left,o="string"==typeof t.height?Ug(e.height,t.height):t.height;return{top:n,left:r,width:"string"==typeof t.width?Ug(e.width,t.width):t.width,height:o}},Gg=async(e,t,n)=>{const r=`#internal-tmp-${Zp()()}`,{err:o}=await pg(()=>e.layouts.save({name:r,type:"Global",setAsCurrent:!1,metadata:null==n?void 0:n.metadata}));o&&t("getBlobForCurrentLayout layouts.save()","error",o.toString());const{err:i,data:s}=await pg(()=>e.layouts.export("Global"));i&&t("getBlobForCurrentLayout layouts.export()","error",i.toString());const a=null==s?void 0:s.find(e=>e.name===r),{err:l}=await pg(()=>e.layouts.remove("Global",r));return l&&t("getBlobForCurrentLayout layouts.remove()","error",l.toString()),a},Hg=async(e,t)=>{var n,r;const o=e=>e.map(e=>{var t,n,r,o,i,s,a,l,u,c,d,h;return{application:e.application,state:{userTitle:e.state.userTitle,bounds:{left:null===(n=null===(t=e.state)||void 0===t?void 0:t.bounds)||void 0===n?void 0:n.left,top:null===(o=null===(r=e.state)||void 0===r?void 0:r.bounds)||void 0===o?void 0:o.top,width:null===(s=null===(i=e.state)||void 0===i?void 0:i.bounds)||void 0===s?void 0:s.width,height:null===(l=null===(a=e.state)||void 0===a?void 0:a.bounds)||void 0===l?void 0:l.height},channelId:null===(u=null==e?void 0:e.state)||void 0===u?void 0:u.channelId,channelRestrictions:null===(c=null==e?void 0:e.state)||void 0===c?void 0:c.channelRestrictions,tabIndex:null===(d=null==e?void 0:e.state)||void 0===d?void 0:d.tabIndex,windowState:null===(h=null==e?void 0:e.state)||void 0===h?void 0:h.windowState}}});try{const i=await e.layouts.getCurrentLayout(),s=await Gg(e,t,i),a=(await e.layouts.export("Global")).find(e=>e.name===(null==i?void 0:i.name)),l=o(null!==(n=null==a?void 0:a.components)&&void 0!==n?n:[]),u=o(null!==(r=null==s?void 0:s.components)&&void 0!==r?r:[]);t("isWorkspaceDirty","debug",{minimalOld:l,minimalNew:u});const c=JSON.stringify(l)!==JSON.stringify(u);return t("isWorkspaceDirty","return",c),c}catch(e){t("isWorkspaceDirty","error",e)}return t("isWorkspaceDirty","return",!1),!1},Vg=async(e,t,n,r,o)=>{var i,s,a,l,u,c,d,h,p;if(null==o?void 0:o.bypassSaving)return!1;const g=await e.contexts.get(tg);if(null!==(a=null===(s=null===(i=null==g?void 0:g.servicesConfig)||void 0===i?void 0:i.workspace)||void 0===s?void 0:s.discardUnsavedChanges)&&void 0!==a&&a)return!1;const f=await Hg(e,()=>{});if(!f)return!1;if(f&&(null==o?void 0:o.forceRestart))return n(),!1;if(null===(d=null===(c=null===(u=null===(l=null==g?void 0:g.finsemble)||void 0===l?void 0:l.servicesConfig)||void 0===u?void 0:u.workspace)||void 0===c?void 0:c.promptUserOnDirtyWorkspace)||void 0===d||d){const o=await e.layouts.getCurrentLayout(),i=null!==(p=null===(h=null==g?void 0:g.finsemble)||void 0===h?void 0:h.shutdownTimeout)&&void 0!==p?p:15e3,s=new Kp;t("YesNoDialog",{monitor:"primary",title:"Save your workspace?",question:`Would you like to save "${null==o?void 0:o.name}" before ${r?"restarting":"shutting down"}?`,showTimer:!0,timerDuration:i-5e3,negativeResponseLabel:"Don't Save",affirmativeResponseLabel:"Save",showCancelButton:!1},(e,t)=>{s.resolve(t)});const a=await s.promise;if("cancel"===(null==a?void 0:a.choice))return!0;"affirmative"===(null==a?void 0:a.choice)&&n(),"expired"===(null==a?void 0:a.choice)&&n()}return!1},Qg="FSBL.SearchProvider.",Jg=async(e,t,n)=>{const{err:r,data:o}=await gg(()=>e.interop.invoke("FSBL.Clients.WorkspaceClient.triggerEventHandlers",{event:t,workspaceName:n}));return{err:r,data:o}},Kg=(e,t,{api:n,method:r,type:o,data:i})=>{if("start"===o&&(null==t||t.metrics.featureMetric("finsemble-polyfill",n,r)),"deprecated"===o)return null==t||t.metrics.featureMetric("finsemble-polyfill-deprecated",n,r),void e.error("DEPRECATED FUNCTION CALLED",`${n}.${r}()`,o,i);e[o]?e[o](`${n}.${r}()`,i):e.debug(`${n}.${r}()`,o,i)};var Yg;!function(e){e[e.NORMAL=0]="NORMAL",e[e.MINIMIZED_WAS_NORMAL=1]="MINIMIZED_WAS_NORMAL",e[e.MAXIMIZED=2]="MAXIMIZED",e[e.MINIMIZED_WAS_MAXIMIZED=3]="MINIMIZED_WAS_MAXIMIZED"}(Yg||(Yg={}));class Zg{constructor(e,t){this.asyncConstructors=t,this.windowOptions={},this.gate=new og,this.eventHandlers=[],this.closeRequestedHandlers=[],this.wrap=Zg.getInstance;const n=t.addConstructor();e.then(async e=>{var r,o,i,s;this.glue=e;const a=null===(r=this.glue.windows)||void 0===r?void 0:r.my();if(a){this.gdwin=a,this.windowName=null!==(i=null===(o=this.gdwin)||void 0===o?void 0:o.context["#finsemble-windowName"])&&void 0!==i?i:null===(s=this.gdwin)||void 0===s?void 0:s.id,this.name=this.windowName,this.windowOptions=await xg(this.gdwin);const{data:e}=await Cg({field:"isAlwaysOnTop"},this.gdwin);e?await this.gdwin.setOnTop("always"):this.gdwin.settings.onTop&&await Ig({field:"isAlwaysOnTop",value:this.gdwin.settings.onTop},this.gdwin)}else globalThis.window&&this.logStatus("constructor","warn","Constructing FinsembleWindow on incompatible window type.");t.finishConstructor(n)})}logStatus(e,t,n){Kg(Zg.loggerClient,this.glue,{api:"FinsembleWindow",method:e,type:t,data:n})}static setStaticInstances(e,t){Zg.glueInstance=e,Zg.loggerClient=t}async getComponentState(e,t){this.logStatus("getComponentState","start"),await this.asyncConstructors.ready();const n=(null==e?void 0:e.windowName)?this.glue.windows.findById(e.windowName):this.gdwin,r=await Cg(e,n);return this.logStatus("getComponentState","return",r),null==t||t(r.err,r.data),r}async setComponentState(e,t){return await this.gate.wait(async()=>this.setComponentStateInternal(e,t))}async setComponentStateInternal(e,t){this.logStatus("setComponentState","start"),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await Ig(e,n);return this.logStatus("setComponentState","return"),null==t||t(r.err,r.data),r}async removeComponentState(e,t){this.logStatus("removeComponentState","start"),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await kg(e,n);return this.logStatus("removeComponentState","return"),null==t||t(r.err,r.data),r}static async getInstance(e,t){var n,r,o,i,s;Zg.loggerClient.debug("FinsembleWindowImpl.getInstance","start");const a=new Dg,l=new Zg(Zg.glueInstance,a);await a.ready();const u=null!==(r=null!==(n=null==e?void 0:e.windowName)&&void 0!==n?n:null==e?void 0:e.name)&&void 0!==r?r:null==e?void 0:e.id,c=null!==(i=null!==(o=l.glue.windows.findById(u))&&void 0!==o?o:l.glue.windows.list().find(e=>e.name===u))&&void 0!==i?i:l.glue.windows.list().find(e=>e.context["#finsemble-windowName"]===u);if(c)return l.gdwin=c,l.windowName=null!==(s=null==c?void 0:c.context["#finsemble-windowName"])&&void 0!==s?s:null==c?void 0:c.id,l.name=l.windowName,l.windowOptions=await xg(c),null==t||t(null,l),Zg.loggerClient.debug("FinsembleWindowImpl.getInstance","return"),{wrap:l};{const e=`FinsembleWindow.getInstance(): Cannot find window instance for id ${u}`;throw null==t||t(e),new Error(e)}}removeEventListener(e,t,n=!1){if(this.logStatus("removeEventListener","start",e),"close-requested"===e){const e=this.closeRequestedHandlers.findIndex(e=>e.handler===t);e>-1&&(this.closeRequestedHandlers[e].gdwin.onClosing(async()=>{}),this.closeRequestedHandlers.splice(e,1))}else{const n=this.eventHandlers.findIndex(n=>(null==n?void 0:n.eventName)===e&&(null==n?void 0:n.handler)===t);this.eventHandlers[n].unsubscriber(),delete this.eventHandlers[n]}this.logStatus("removeEventListener","return")}addEventListener(e,t){switch(this.logStatus("addEventListener","start",e),e){case"maximized":{const n=this.gdwin.onMaximized(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"minimized":{const n=this.gdwin.onMinimized(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"restored":{const n=this.gdwin.onNormal(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"blurred":{const n=this.gdwin.onFocusChanged(()=>{this.gdwin.isFocused||t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"focused":{const n=this.gdwin.onFocusChanged(()=>{this.gdwin.isFocused&&t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"shown":{const n=this.gdwin.onVisibilityChanged(()=>{this.gdwin.isVisible&&t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"hidden":{const n=this.gdwin.onVisibilityChanged(()=>{this.gdwin.isVisible||t()});return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"title-changed":{const n=this.gdwin.onTitleChanged(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"bounds-changed":{const n=this.gdwin.onBoundsChanged(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"clicked":{const n=this.gdwin.onFrameButtonClicked(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"created":{const n=this.glue.windows.onWindowAdded(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"closed":case"close-complete":{const n=this.gdwin.onClose(t);return this.eventHandlers.push({eventName:e,handler:t,unsubscriber:n}),n}case"close-requested":{const e={handler:t,gdwin:this.gdwin};this.closeRequestedHandlers.push(e);const n=async e=>{await new Promise(n=>{let r=!1,o=!1;t({wait:()=>{r=!0},done:()=>{o=!0,n()},cancel:()=>{o=!0,e({showDialog:!1}),n()}}),r||o||n()})};return this.gdwin.onClosing(n),()=>{console.error("iocd does not support unsubscribing from onClosing() handler")}}default:return()=>{console.log(`Event ${e} is not implemented`)}}}removeListener(e,t,n=!1){return this.logStatus("removeListener","start",e),this.removeEventListener(e,t,n)}addListener(e,t){return this.addEventListener(e,t)}ejectFromGroup(){this.logStatus("ejectFromGroup","start"),console.log("ejectFromGroup is not implemented in the Finsemble polyfill")}formGroup(){this.logStatus("formGroup","start"),Sg(this.glue,this.gdwin.id),this.logStatus("formGroup","return")}async getOptions(e){return this.logStatus("getOptions","start"),null==e||e(null,this.windowOptions),{data:this.windowOptions}}getMonitor(e){this.logStatus("getMonitor","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.getDisplay().then(t=>{const n=this.convertGetMonitor(t);e(n)})}),this.logStatus("getMonitor","return")}convertGetMonitor(e){var t;if(!(null==e?void 0:e.workArea)||!(null==e?void 0:e.scaleFactor)||!e.bounds)return;const{availableRect:n,monitorRect:r}=Bg(e);return{name:"device"+(Number(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.replace(/\D/g,""))-1),left:n.left,top:n.top,right:n.right,bottom:n.bottom,availableRect:n,monitorRect:r,bounds:{max:{x:n.right,y:n.bottom},min:{x:n.left,y:n.top}}}}setOpacity(e,t){this.logStatus("setOpacity","start"),console.log("setOpacity is not implemented in the Finsemble polyfill")}showNativeOpenDialog(e={},t){this.logStatus("showNativeOpenDialog","start"),console.log("showNativeOpenDialog is not implemented in the Finsemble polyfill")}async close(e={},t){this.logStatus("close","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.close(),t);return this.logStatus("close","return"),{err:n}}showAt(e,t){this.logStatus("showAt","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.isVisible||this.gdwin.show(),this.gdwin.moveTo(null==e?void 0:e.top,null==e?void 0:e.left).then(()=>{this.logStatus("showAt","return"),null==t||t(null)})})}async show(e={},t){this.logStatus("show","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.show(),t);return this.logStatus("show","return"),{err:n}}reload(e={},t){this.logStatus("reload","start"),this.asyncConstructors.ready().then(()=>{this.gdwin.refresh(!1).then(()=>{this.logStatus("reload","return"),null==t||t(null)})})}async hide(e={},t){this.logStatus("hide","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.hide(),t);return this.logStatus("hide","return"),{err:n}}updateOptions(e,t){this.logStatus("updateOptions","start"),console.log("updateOptions is not implemented in the Finsemble polyfill")}async getBounds(e,t){this.logStatus("getBounds","start"),await this.asyncConstructors.ready();const n="function"==typeof e?e:t,{err:r,data:o}=await pg(()=>this.gdwin.getBounds());return r&&this.logStatus("getBounds","error",r),null==n||n(null,o),this.logStatus("getBounds","return",o),{err:null,data:o}}async setBounds(e={bounds:{}},t){this.logStatus("setBounds","start"),await this.asyncConstructors.ready(),"function"==typeof e||e.bounds||(e={bounds:e});const{err:n}=await pg(()=>this.gdwin.moveResize(e.bounds),t);return this.logStatus("setBounds","return"),{err:n}}async setViewBounds(e,t){this.logStatus("setViewBounds","start"),console.log("setViewBounds is not implemented in the Finsemble polyfill")}async bringViewToFront(e,t){this.logStatus("bringViewToFront","start"),console.log("bringViewToFront is not implemented in the Finsemble polyfill")}async removeBrowserView(e,t){this.logStatus("removeBrowserView","start"),console.log("removeBrowserView is not implemented in the Finsemble polyfill")}async addBrowserView(e,t){return this.logStatus("addBrowserView","start"),console.log("addBrowserView is not implemented in the Finsemble polyfill"),null}async showBrowserView(e,t){this.logStatus("showBrowserView","start"),console.log("showBrowserView is not implemented in the Finsemble polyfill")}async hideBrowserView(e,t){this.logStatus("hideView","start"),console.log("hideView is not implemented in the Finsemble polyfill")}setShape(e,t){this.logStatus("setShape","start"),console.log("setShape is not implemented in the Finsemble polyfill")}isShowing(e={},t){this.logStatus("isShowing","start"),t(null,this.gdwin.isVisible&&"minimized"!==this.gdwin.state),this.logStatus("isShowing","return")}async isAlwaysOnTop(e={},t){this.logStatus("isAlwaysOnTop","start");const{data:n}=await this.getComponentState({field:"isAlwaysOnTop"});return null==t||t(null,n),this.logStatus("isAlwaysOnTop","return"),n}async setAlwaysOnTop(e={alwaysOnTop:!0},t){this.logStatus("setAlwaysOnTop","start"),await this.asyncConstructors.ready(),this.setComponentState({field:"isAlwaysOnTop",value:e.alwaysOnTop});const{err:n}=await pg(()=>this.gdwin.setOnTop(!!e.alwaysOnTop&&"always"),t);return this.logStatus("setAlwaysOnTop","return"),{err:n}}async bringToFront(e=null,t){this.logStatus("bringToFront","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.show()),{err:r}=await pg(()=>this.gdwin.focus());return null==t||t(null!=n?n:r),this.logStatus("bringToFront","return"),{err:null!=n?n:r}}async focus(e=null,t){this.logStatus("focus","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.focus(),t);return this.logStatus("focus","return"),{err:n}}async blur(e=null,t){return this.logStatus("blur","start"),await this.asyncConstructors.ready(),console.log("blur is not implemented in the Finsemble polyfill"),{err:null}}async restore(e=null,t){this.logStatus("restore","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.restore(),t);return this.logStatus("restore","return"),{err:n}}async maximize(e=null,t){this.logStatus("maximize","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.maximize(),t);return this.logStatus("maximize","return"),{err:n}}async minimize(e=null,t){this.logStatus("minimize","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.minimize(),t);return this.logStatus("minimize","return"),{err:n}}}Zg.WINDOWSTATE=Yg;const Xg={};class ef{constructor(e,t,n,r){this.asyncConstructors=t,this.routerClient=n,this.loggerClient=r;const o=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(o)}),this.bringWindowsToFront=this.bringWindowsToFront.bind(this),this.minimizeWindows=this.minimizeWindows.bind(this)}async getInstance(e,t){try{t&&(this.logStatus("spawn","debug","waiting for instance.getWindow()"),await t.getWindow());const{wrap:n}=await Zg.getInstance({windowName:e});return n}catch(e){return this.logStatus("getInstance","error",e.toString()),null}}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AppsClient",method:e,type:t,data:n})}async addUserDefinedComponent(e,t){const n={type:"window",name:e.name,title:e.name,details:{url:e.url},customProperties:{isUserDefined:!0}},{err:r}=await pg(()=>this.glue.appManager.inMemory.import([n],"merge"));if(!r){const t={[e.name]:e};await pg(()=>this.glue.prefs.updateFor("IO.Global.UserDefinedApps",t))}return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.addUserDefinedComponent",e)),null==t||t(r),{err:r}}async removeUserDefinedComponent(e,t){var n;const{err:r}=await pg(()=>this.glue.appManager.inMemory.remove(e.name));if(!r){const{data:t}=await pg(()=>this.glue.prefs.get("IO.Global.UserDefinedApps")),r=null!==(n=null==t?void 0:t.data)&&void 0!==n?n:{};delete r[e.name],await pg(()=>this.glue.prefs.setFor("IO.Global.UserDefinedApps",r))}return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.removeUserDefinedComponent",e)),null==t||t(r),{err:r}}async getApps(e,t){this.logStatus("getApps","start",{appIds:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await pg(()=>this.glue.appManager.getConfigurations());if(n||!r){const r=`AppsClient.getApps:getConfigurations ${n}`;return this.logStatus("getApps","error",{appIds:e}),null==t||t(r),{err:r}}const o=r.flatMap(e=>{var t,n,r,o;return(null===(t=null==e?void 0:e.customProperties)||void 0===t?void 0:t.component)?[]:[Vp()(null!==(n=(e=>{const t=Fg(e);return{appId:e.name,type:"exe"===e.type?"native":"web",hostManifests:{Finsemble:t},details:e.details.url?{url:e.details.url}:{path:e.details.command}}})(e))&&void 0!==n?n:{},null!==(o=null===(r=null==e?void 0:e.customProperties)||void 0===r?void 0:r.appd)&&void 0!==o?o:{})]}),i=o.filter(t=>!e||e.includes(t.appId));return this.logStatus("getApps","return",{err:null,data:i}),null==t||t(null,i),{err:null,data:i}}async getComponentList(e){this.logStatus("getComponentList","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await(async e=>{const{err:t,data:n}=await pg(()=>e.appManager.getConfigurations());if(t||!n)return{err:`getComponentList:getConfigurations ${t}`};const r=n.flatMap(e=>{var t,n,r,o,i,s;const a=null!==(n=null===(t=null==e?void 0:e.customProperties)||void 0===t?void 0:t.component)&&void 0!==n?n:null===(i=null===(o=null===(r=null==e?void 0:e.customProperties)||void 0===r?void 0:r.appd)||void 0===o?void 0:o.hostManifests)||void 0===i?void 0:i.Finsemble,l=Vp()(null!=a?a:{},Fg(e));return[Vp()(l,{appConfig:null===(s=null==e?void 0:e.customProperties)||void 0===s?void 0:s.appd})]}),o=Object.fromEntries(r.map(e=>{var t,n;return[null!==(n=null===(t=null==e?void 0:e.component)||void 0===t?void 0:t.type)&&void 0!==n?n:"Unknown Component",e]}));return{err:null,data:o}})(this.glue);return this.logStatus("getComponentList","return",{err:t,data:n}),null==e||e(t,n),{err:t,data:n}}async addApps(e,t){this.logStatus("addApps","start",{apps:e}),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.addApps",{apps:e}));return this.logStatus("addApps","return",{err:n,data:e}),null==t||t(n,e),{err:n,data:e}}async removeApps(e,t){this.logStatus("removeApps","start",{appIds:e}),await this.asyncConstructors.ready();const n=e.map(e=>this.glue.appManager.inMemory.remove(e)),r=(await eg().allSettled(n)).flatMap(e=>"rejected"===e.status?[e.reason]:[]),o=r.length?r.join(" "):null;return gg(()=>this.glue.interop.invoke("FSBL.Clients.AppsClient.removeApps",{appIds:e})),this.logStatus("removeApps","return",{err:o,data:e}),null==t||t(o,e),{err:o,data:e}}async getActiveDescriptors(e){this.logStatus("getActiveDescriptors","start"),await this.asyncConstructors.ready();const t=this.glue.windows.list(),n=await this.glue.appManager.getConfigurations(),r=t.map(e=>((e,t)=>{var n,r,o,i,s,a,l,u,c;const d=t.find(t=>t.name===e.name);return{name:null!==(n=e.context["#finsemble-windowName"])&&void 0!==n?n:e.id,iocdID:e.id,defaultLeft:e.bounds.left,defaultTop:e.bounds.top,defaultBottom:e.bounds.top+e.bounds.height,defaultWidth:e.bounds.width,defaultHeight:e.bounds.height,defaultRight:e.bounds.left+e.bounds.width,componentType:e.name,customData:{isAnApp:!!(null===(r=null==d?void 0:d.customProperties)||void 0===r?void 0:r.appd),appConfig:{appId:e.name,component:e.name},spawnData:null===(o=e.context)||void 0===o?void 0:o["#finsemble-spawnData"],preload:null!==(c=null===(u=null===(l=null===(a=null===(s=null===(i=null==d?void 0:d.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble)||void 0===l?void 0:l.component)||void 0===u?void 0:u.preload)&&void 0!==c?c:[]},left:e.bounds.left,top:e.bounds.top,right:e.bounds.left+e.bounds.width,bottom:e.bounds.top+e.bounds.height,width:e.bounds.width,height:e.bounds.height}})(e,n)),o=Object.fromEntries(r.map(e=>[e.name,e]));return this.logStatus("getActiveDescriptors","return",{err:null,data:o}),null==e||e(null,o),{err:null,data:o}}async getMyWindowIdentifier(e){this.logStatus("getMyWindowIdentifier","start"),await this.asyncConstructors.ready();const t=await lg(this.glue);return this.logStatus("getMyWindowIdentifier","return",t),null==e||e(t),t}async bringWindowsToFront(e,t){return await this.asyncConstructors.ready(),await cg(this.glue,e,t)}async minimizeWindows(e,t){return await this.asyncConstructors.ready(),await dg(this.glue,e,t)}async spawnTabCollection({componentList:e,globalParams:t},n){var r,o,i;this.logStatus("spawnTabCollection","start",{componentList:e,globalParams:t}),await this.asyncConstructors.ready();let s=null;const a=await(async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)try{const o=await t(e[r]);n.push({status:"fulfilled",value:o})}catch(e){n.push({status:"rejected",reason:e.toString()})}return n.flatMap(e=>"fulfilled"===e.status?[e.value]:[])})(e,async e=>{var n,r,o,i,a,l;const u=this.glue.appManager.application(e.appID);if(!u)return{err:`Application ${e.appID} not found`,data:null};const c=await this.glue.appManager.getConfigurations([e.appID]),d=await Og(this.glue,(0,Qp.merge)({},null!==(n=e.individualParams)&&void 0!==n?n:{},null!=t?t:{}),null!==(r=c[0])&&void 0!==r?r:{});s&&(d.tabGroupId=s);const h=null!==(a=null===(i=null===(o=e.individualParams)||void 0===o?void 0:o.options)||void 0===i?void 0:i.customData)&&void 0!==a?a:null===(l=e.individualParams)||void 0===l?void 0:l.data,p=h?{"#finsemble-spawnData":h}:{},g=await u.start(p,d);return s=g.window.tabGroupId,{err:null,data:g}}),l={id:null!==(i=null===(o=null===(r=null==a?void 0:a[0])||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)&&void 0!==i?i:"",windows:await sg(a,async e=>{var t,n,r,o,i,s;const a=await this.getInstance(null===(t=e.data)||void 0===t?void 0:t.id,e.data);return{windowDescriptor:{name:null!==(r=null===(n=e.data)||void 0===n?void 0:n.id)&&void 0!==r?r:""},windowIdentifier:{windowName:null!==(i=null===(o=e.data)||void 0===o?void 0:o.id)&&void 0!==i?i:"",componentType:null===(s=e.data)||void 0===s?void 0:s.window.name},finWindow:a}})};return this.logStatus("spawnTabCollection","return",{err:null,data:l}),null==n||n(null,l),{err:null,data:l}}async clone(e,t,n){this.logStatus("clone","start",{toClone:e,spawnParams:t}),await this.asyncConstructors.ready();const r=e?this.glue.windows.findById(e.windowName):this.glue.windows.my();if(!r){const e="Attempt to clone incompatible window type (called from webgroup?)";return this.logStatus("clone","error",e),null==n||n(e),{error:e}}try{const e=await r.clone();this.logStatus("clone","return");const t=await this.getInstance(e.id),o={windowDescriptor:{name:e.id},windowIdentifier:{windowName:e.id,componentType:e.name},finWindow:t};return null==n||n(null,o),{error:null,response:o}}catch(e){const t=e.toString();return this.logStatus("clone","error",t),null==n||n(t),{error:t}}}async spawn(e,t,n){var r,o,i,s,a,l;this.logStatus("spawn","start",{component:e,params:t}),await this.asyncConstructors.ready();const u=await this.glue.appManager.getConfigurations([e]),{error:c,data:d,launchGroupWindows:h}=await(async(e,t,n)=>{var r,o,i,s,a,l,u,c,d,h,p,g,f,m,y,w,v,b,C,S;const I=await e.appManager.getConfigurations([t]),{didSpawn:k,error:T,instance:x,launchGroupWindows:A}=await(async(e,t,n)=>{var r,o,i,s,a,l;if(!n)return{didSpawn:!1};if("launchGroup"!==(null===(a=null===(s=null===(i=null===(o=null===(r=n.customProperties)||void 0===r?void 0:r.appd)||void 0===o?void 0:o.hostManifests)||void 0===i?void 0:i.Finsemble)||void 0===s?void 0:s.window)||void 0===a?void 0:a.windowType))return{didSpawn:!1};const{err:u,data:c}=await(async(e,t,n)=>{var r,o,i,s,a,l,u;const c=null!==(r=t.title)&&void 0!==r?r:"Group",d=null!==(o=null==n?void 0:n.toSpawn)&&void 0!==o?o:null===(a=null===(s=null===(i=t.hostManifests)||void 0===i?void 0:i.Finsemble)||void 0===s?void 0:s.window)||void 0===a?void 0:a.toSpawn;if(!d||!Array.isArray(d))return{err:`convertFinsembleLaunchGroupAppd2GlueGroupOptions: Unexpected value in appd hostManifests.Finsemble.window.toSpawn property. Expected array, received: ${d}`};let h=e.windows.my();h||(h=e.windows.find("Toolbar"));const p=await(null==h?void 0:h.getDisplay());if(!p)return{err:"convertFinsembleLaunchGroupAppd2GlueGroupOptions: Can't get display"};const g=await zg(null==p?void 0:p.bounds,null===(u=null===(l=t.hostManifests)||void 0===l?void 0:l.Finsemble)||void 0===u?void 0:u.window),f=d.map(e=>{var t;const{top:n,left:r,height:o,width:i}=null!==(t=e.spawnOptions)&&void 0!==t?t:{},s=zg(g,{top:n,left:r,height:o,width:i});return"components"in e?{mode:"tab",bounds:s,applications:e.components.map(({componentType:e})=>({name:e}))}:{mode:"tab",bounds:s,applications:[{name:e.componentType}]}});return{data:{context:{},groups:[{title:c,frames:f}]}}})(e,null===(l=n.customProperties)||void 0===l?void 0:l.appd,t);if(!c)return{didSpawn:!1};const{err:d,data:h}=await pg(()=>e.windows.groups.create(c));if(d||!h)return{didSpawn:!1,error:null!=d?d:"No data returned"};const p=h[0];return{didSpawn:!0,error:d,instance:p,launchGroupWindows:p.windows.map(({id:e})=>e)}})(e,null!=n?n:{},null!==(r=I[0])&&void 0!==r?r:{});if(k)return{error:T,data:x,launchGroupWindows:A};const{err:E,data:W}=await pg(()=>e.appManager.application(t));if(E||!W){const e=`AppsClient.spawn:application ${E}`;return console.log(e),{error:e,data:void 0}}const O=await Og(e,n,null!==(o=I[0])&&void 0!==o?o:{});O.awaitInterop=!1;const{data:D}=null!==(i=await pg(()=>Wg(e.windows.my())))&&void 0!==i?i:{},_=(null!==(d=null===(c=null===(u=null===(l=null===(a=null===(s=null==D?void 0:D.customProperties)||void 0===s?void 0:s.appd)||void 0===a?void 0:a.hostManifests)||void 0===l?void 0:l.Finsemble)||void 0===u?void 0:u.interop)||void 0===c?void 0:c.selectConnect)&&void 0!==d?d:[]).find(e=>e.autoAssociate);if(_){const n=await e.channels.current();(_.autoAssociate.allChildren||(null===(h=_.autoAssociate.selectChildren)||void 0===h?void 0:h.includes(t)))&&(O.channelId=n)}const P=(0,Qp.merge)(null!==(v=null===(w=null===(y=null===(m=null===(f=null===(g=null===(p=I[0])||void 0===p?void 0:p.customProperties)||void 0===g?void 0:g.appd)||void 0===f?void 0:f.hostManifests)||void 0===m?void 0:m.Finsemble)||void 0===y?void 0:y.window)||void 0===w?void 0:w.data)&&void 0!==v?v:{},null!==(S=null!==(b=null==n?void 0:n.data)&&void 0!==b?b:null===(C=null==n?void 0:n.options)||void 0===C?void 0:C.customData)&&void 0!==S?S:{}),R=null==n?void 0:n.componentState,L=P?{"#finsemble-spawnData":P}:{};R&&(L["#finsemble-componentState"]=R),(null==n?void 0:n.name)&&(L["#finsemble-windowName"]=n.name);const{err:F,data:M}=await pg(()=>W.start(L,O));return{error:F,data:M}})(this.glue,e,t);if(c||!d){const e=`AppsClient.spawn:start ${c}`;return this.logStatus("spawn","error",e),null==n||n(e),{error:e}}const p="assimilation"===(null===(l=null===(a=null===(s=null===(i=null===(o=null===(r=u[0])||void 0===r?void 0:r.customProperties)||void 0===o?void 0:o.appd)||void 0===i?void 0:i.hostManifests)||void 0===s?void 0:s.Finsemble)||void 0===a?void 0:a.window)||void 0===l?void 0:l.windowType)?null:await this.getInstance(d.id,d),g={launchGroupWindows:h,windowDescriptor:{name:d.id},windowIdentifier:{windowName:d.id,componentType:e},finWindow:p};return this.logStatus("spawn","return",{error:null,response:g}),null==n||n(null,g),{error:null,response:g}}async toggleWindowOnClick(e,t,n){this.logStatus("toggleWindowOnClick","start",{element:e,windowLocator:t,params:n});const r="windowName"in t?t.windowName:t,o="componentType"in t?t.componentType:null,i=this.glue.windows.list().find(e=>"string"==typeof r?r===e.id||r===e.name||r===e.title:o===e.name);if(!i){const e=["AppsClient.toggleWindowOnClick() cannot find window",t];return void this.logStatus("toggleWindowOnClick","error",...e)}const s=i.id;if(!1===Xg[s])return void(Xg[s]=!0);n.position||(n.position="absolute");const{err:a}=await this.showWindow(t,n);if(a){const e=["AppsClient.toggleWindowOnClick() cannot show window",a];return void this.logStatus("toggleWindowOnClick","error",...e)}i.onFocusChanged(async()=>{if(i.isFocused)return;Xg[s]=!0;const t=await(async(e,t)=>{const n=await(async(e,t)=>{var n,r,o;const i="string"==typeof t?document.querySelector(t):t;i||console.error("getDesktopBoundingBox can't find element",t);const s=i?i.getBoundingClientRect():{top:0,left:0,width:0,height:0},a=await(null===(n=e.windows.my())||void 0===n?void 0:n.getBounds()),l=null!==(r=null==a?void 0:a.top)&&void 0!==r?r:0,u=null!==(o=null==a?void 0:a.left)&&void 0!==o?o:0,c={top:l+s.top,left:u+s.left,width:s.width,height:s.height,right:0,bottom:0};return c.right=c.left+c.width,c.bottom=c.top+c.height,c})(e,t);return r=await e.displays.getMousePosition(),(o=n).bottom||(o.bottom=o.top+o.height),o.right||(o.right=o.left+o.width),r.x>o.left&&r.x<o.right&&r.y<o.bottom&&r.y>o.top;var r,o})(this.glue,e);Xg[s]=!t}),this.logStatus("toggleWindowOnClick","return")}async showWindow(e,t={},n){var r,o,i;this.logStatus("showWindow","start",{windowLocator:e,params:t}),await this.asyncConstructors.ready();const s="windowName"in e?e.windowName:e,a="componentType"in e?e.componentType:null,l=this.glue.windows.list().find(e=>"string"==typeof s?s===e.id||s===e.name||s===e.title:a===e.name);if(!l){if(this.loggerClient.debug(`AppsClient.showWindow(): Window ${s} not found. Spawning.`),a){const{response:e,error:r}=await this.spawn(a,t,n);return this.logStatus("showWindow","return",{err:r,data:e}),{err:r,data:e}}const e=`Window ${s} type ${a} not found`;return this.loggerClient.warn("AppsClient.toggleWindowOnClick",{err:e}),{err:e}}const u=await wg(this.glue,null==t?void 0:t.monitor),c=mg(this.glue,t,u),d=await this.glue.contexts.get(rg),h=null!==(r=null==d?void 0:d[l.id])&&void 0!==r?r:await l.getBounds();if(!(null==d?void 0:d[l.id])){const{err:e}=await pg(()=>this.glue.contexts.update(rg,{[l.id]:h}));e&&this.logStatus("showWindow","error",{subFunction:"this.glue.contexts.update(FINSEMBLEDIMENSIONMEMORY)",err:e.toString()})}!1===t.autoFocus&&(l.settings.focus=!1),c&&(await vg(this.glue,c,u),c.width=null!==(o=c.width)&&void 0!==o?o:null==h?void 0:h.width,c.height=null!==(i=c.height)&&void 0!==i?i:null==h?void 0:h.height,await l.place(c)),t.setBoundsOnly||(await l.show(),await l.focus());const p=await this.getInstance(l.id),g={windowDescriptor:{name:l.id},windowIdentifier:{windowName:l.id},finWindow:p};return this.logStatus("showWindow","return",{err:null,data:g}),null==n||n(null,g),{err:null,data:g}}async getMonitorInfo(e={},t){var n,r,o,i,s;this.logStatus("getMonitorInfo","start",{params:e}),await this.asyncConstructors.ready();let a=null;if(null===(n=null==e?void 0:e.windowIdentifier)||void 0===n?void 0:n.windowName){const t=this.glue.windows.findById(e.windowIdentifier.windowName);a=await(null==t?void 0:t.getDisplay())}else if("primary"===(null==e?void 0:e.monitor))a=(await this.glue.displays.all()).find(e=>e.isPrimary);else if("number"==typeof(null==e?void 0:e.monitor))a=(await this.glue.displays.all()).find(t=>t.index===e.monitor);else if("previous"===(null==e?void 0:e.monitor)){const e=await(null===(r=this.glue.windows.my())||void 0===r?void 0:r.getDisplay());a=(await this.glue.displays.all()).find(t=>{var n;return t.index-1===(null!==(n=null==e?void 0:e.index)&&void 0!==n?n:0)})}else if("next"===(null==e?void 0:e.monitor)){const e=await(null===(o=this.glue.windows.my())||void 0===o?void 0:o.getDisplay());a=(await this.glue.displays.all()).find(t=>{var n;return t.index+1===(null!==(n=null==e?void 0:e.index)&&void 0!==n?n:0)})}else"mine"!==(null==e?void 0:e.monitor)&&(null===(i=null==e?void 0:e.windowIdentifier)||void 0===i?void 0:i.windowName)||(a=await(null===(s=this.glue.windows.my())||void 0===s?void 0:s.getDisplay()));const l=a?qg(a):null;if(!l){const e="Cannot fetch monitor. Check application.log for errors";return this.logStatus("getMonitorInfo","error",e),null==t||t(e),{err:e}}return this.logStatus("getMonitorInfo","return",{err:null,data:l}),null==t||t(null,l),{err:null,data:l}}async getMonitorInfoAll(e){this.logStatus("getMonitorInfoAll","start"),await this.asyncConstructors.ready();const t=(await this.glue.displays.all()).map(e=>qg(e)),n=t.filter(e=>null!==e);if(t.length!==n.length){const t="Cannot fetch some monitors. Check application.log for errors";return this.logStatus("getMonitorInfoAll","error",t),null==e||e(t),{err:t}}return this.logStatus("getMonitorInfoAll","return",{err:null,data:n}),null==e||e(null,n),{err:null,data:n}}async getComponentDefaultConfig(e,t){this.logStatus("getComponentDefaultConfig","start",{componentType:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await this.getComponentList();let o;if(!n&&r){const t=Object.entries(r).find(([t])=>t===e);t&&(o=t[1])}return this.logStatus("getComponentDefaultConfig","return",{err:n,data:o}),null==t||t(n,o),{err:n,data:o}}}class tf{constructor(e,t,n,r,o){this.asyncConstructors=t,this.loggerClient=n,this.Router=r,this.storageClient=o;const i=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(i)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AuthenticationClient",method:e,type:t,data:n})}async beginAuthentication(e,t){this.logStatus("beginAuthentication","start",e),await this.asyncConstructors.ready();const n=`FSBL.Clients.AuthenticationClient.beginAuthentication.handler.${Zp()()}`;this.glue.interop.register(n,ig((e,n)=>{null==t||t(e,n)}));const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AuthenticationClient.beginAuthentication",{...e,handlerName:n}));return r&&this.logStatus("beginAuthentication","error",r),this.logStatus("beginAuthentication","return",o),{err:r,data:o}}async completeOAUTH(e,t,n){if(this.logStatus("completeOAUTH","start",{err:e,params:t}),await this.asyncConstructors.ready(),!t){t={};const e=""===window.location.search?window.location.hash:window.location.search;new URLSearchParams(e).forEach((e,n)=>{t[n]=e})}const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.AuthenticationClient.completeOAUTH",{err:e,data:t}));return r&&this.logStatus("completeOAUTH","error",r),this.logStatus("completeOAUTH","return",o),{err:r,data:o}}async getCurrentCredentials(e){this.logStatus("getCurrentCredentials","start"),await this.asyncConstructors.ready();const t=await this.glue.contexts.get(ng);return this.logStatus("getCurrentCredentials","return","For security reasons, credentials were not logged."),null==e||e(null,t),{err:null,data:t}}async publishAuthorization(e,t){var n,r;if(this.logStatus("publishAuthorization","start","For security reasons, credentials were not logged."),await this.asyncConstructors.ready(),this.glue.contexts.set(ng,{user:e,credentials:t}),"sso-application"===(null===(n=this.glue.windows.my())||void 0===n?void 0:n.name)){const n={user:e,token:null!==(r=null==t?void 0:t.token)&&void 0!==r?r:null,headers:t};this.loggerClient.debug("publishAuthorization() Calling authDone(credentials)"),globalThis.glue42gd.authDone(n),this.Router.publish("AuthorizationState",{state:"done"})}else if(this.loggerClient.debug("publishAuthorization","Called on window other than sso-application. Sending via backChannel."),this.glue.windows.find("sso-application")){const{err:n}=await gg(()=>this.glue.interop.invoke("Finsemble.Clients.AuthenticationClient.publishAuthorization.backChannel",{user:e,credentials:t}));n&&this.loggerClient.error("publishAuthorization error.",n.toString())}else this.loggerClient.debug("sso-application not running. Skipping backChannel communication."),this.loggerClient.debug("Calling StorageClient.setUser"),this.storageClient.setUser({user:e});this.logStatus("publishAuthorization","return")}}const nf=(e,t)=>e.split(".").reduceRight((e,t)=>({[t]:e}),t),rf=e=>{let t={};for(const n in e)t=(0,Qp.merge)(t,nf(n,e[n]));return t},of=e=>{return`${e.minute} ${e.hour} * * ${t=e.dayOfWeek,!1===t||void 0===t?"*":t.toString()}`;var t},sf=async(e,t,n,r)=>{const o=await(async e=>{var t,n,r,o,i,s,a,l,u;const c=null!==(t=await e.contexts.get(tg))&&void 0!==t?t:{},{data:d}=await pg(()=>e.prefs.get("IO.Global.FinsemblePreferences")),h=null!==(n=null==d?void 0:d.data)&&void 0!==n?n:{};return null===(u=null!==(i=null!==(r=null==h?void 0:h["finsemble.scheduledCloseDiscardUnsavedChanges"])&&void 0!==r?r:null===(o=null==c?void 0:c.finsemble)||void 0===o?void 0:o.scheduledCloseDiscardUnsavedChanges)&&void 0!==i?i:null===(l=null===(a=null===(s=null==c?void 0:c.finsemble)||void 0===s?void 0:s.servicesConfig)||void 0===a?void 0:a.workspace)||void 0===l?void 0:l.discardUnsavedChanges)||void 0===u||u})(e);if(n){const i=of(n);r("scheduledRestartOrShutdown","start",{command:t,value:n,discardUnsavedLayoutChanges:o,cronTime:i});const{err:s}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:`schedule-${t}`,args:{cronTime:i,title:t,message:`Are you sure you want to ${t}?`,timerDuration:60,discardUnsavedLayoutChanges:o}}));s&&r("scheduledRestartOrShutdown","error",s.toString())}else{r("scheduledRestartOrShutdown","start",{command:t,value:n});const{err:o}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:`cancel-${t}`,args:{}}));o&&r("scheduledRestartOrShutdown","error",o.toString())}r("scheduledRestartOrShutdown","return")},af="Invalid path - MUST be a path array. e.g. for myObject.property use ['myObj', 'property']",lf=(e,t)=>{if("object"!=typeof e)return;if(!t.length)return e;const n=t[0];return 1===t.length?e[n]:e[n]?lf(e[n],t.slice(1)):void 0},uf=e=>{const t=[],n=e=>{if("object"!=typeof e)return;const r=Object.keys(e);r.length&&(t.push(r[0]),n(e[r[0]]))};return n((0,Qp.set)({},e,"dummy")),t},cf=(e,t)=>{let n=t;for(let t=0;t<e.length-1;t++){const r=e[t];n[r]||(n[r]={}),n=n[r]}delete n[e[e.length-1]]};class df{async maybeSendCommandToIOCD(e){switch(e.field){case"finsemble.scheduledRestart":await sf(this.glue,"restart",e.value,this.logStatus);break;case"finsemble.scheduledShutdown":await sf(this.glue,"shutdown",e.value,this.logStatus);break;case"finsemble.scheduledCloseDiscardUnsavedChanges":await(async(e,t,n)=>{const r=await(async e=>{var t,n,r,o,i,s;const a=null!==(t=await e.contexts.get(tg))&&void 0!==t?t:{},{data:l}=await pg(()=>e.prefs.get("IO.Global.FinsemblePreferences")),u=null!==(n=null==l?void 0:l.data)&&void 0!==n?n:{},c=null!==(r=null==u?void 0:u["finsemble.scheduledShutdown"])&&void 0!==r?r:null===(o=null==a?void 0:a.finsemble)||void 0===o?void 0:o.scheduledShutdown,d=null!==(i=null==u?void 0:u["finsemble.scheduledRestart"])&&void 0!==i?i:null===(s=null==a?void 0:a.finsemble)||void 0===s?void 0:s.scheduledRestart;return{shutdown:c?of(c):void 0,restart:d?of(d):void 0}})(e);if(r.shutdown){const o=r.shutdown;n("scheduledCloseDiscardUnsavedChanges","start",{command:"shutdown",cronTime:o,discardUnsavedLayoutChanges:t});const{err:i}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"schedule-shutdown",args:{cronTime:o,title:"shutdown",message:"Are you sure you want to shutdown?",timerDuration:60,discardUnsavedLayoutChanges:t}}));i&&n("scheduledCloseDiscardUnsavedChanges","error",i.toString())}if(r.restart){const o=r.restart;n("scheduledCloseDiscardUnsavedChanges","start",{command:"restart",cronTime:o,discardUnsavedLayoutChanges:t});const{err:i}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"schedule-restart",args:{cronTime:o,title:"restart",message:"Are you sure you want to restart?",timerDuration:60,discardUnsavedLayoutChanges:t}}));i&&n("scheduledCloseDiscardUnsavedChanges","error",i.toString())}})(this.glue,e.value,this.logStatus);break;case"finsemble.initialWorkspace":case"finsemble.servicesConfig.workspace.promptUserOnDirtyWorkspace":case"finsemble.servicesConfig.workspace.discardUnsavedChanges":case"finsemble.servicesConfig.notifications.disableDotOnToolbarIcon":case"finsemble.servicesConfig.notifications.showDotOnToolbarIconForMutedNotifications":case"finsemble.servicesConfig.notifications.toastTimeoutOnActionableNotifications":case"finsemble.servicesConfig.notifications.informationalNotificationToastPeriodSeconds":case"finsemble.servicesConfig.notifications.defaultSnoozePeriodSeconds":case"finsemble.servicesConfig.notifications.newNotificationHaloPeriodSeconds":break;default:return}}maybeTriggerListeners(e){this.listeners.forEach(t=>{try{const{pathArray:n,listener:r,config:o}=t,i=lf(o,n),s=lf(e,n);JSON.stringify(i)!==JSON.stringify(s)&&r(null,{field:n.join("."),value:s}),t.config=e}catch(e){this.glue.logger.error(`ConfigClient, exception in listener: ${e.toString()}`)}})}async waitForUserStage(){const e=await this.glue.contexts.get("IO.Global.InUserStage");e||await this.glue.contexts.set("IO.Global.InUserStage",{inUserStage:!1}),(null==e?void 0:e.inUserStage)?this.preferencesAreAvailable.resolve():(await this.glue.contexts.subscribe("IO.Global.InUserStage",e=>{e.inUserStage&&this.preferencesAreAvailable.resolve()}),await this.preferencesAreAvailable.promise),this.glue.prefs.subscribeFor("IO.Global.FinsemblePreferences",async e=>{this.cachedPreferences=e.data;const t=await this.glue.contexts.get(tg);this.maybeTriggerListeners((0,Qp.merge)(t,e.data))})}async initialize(){this.waitForUserStage()}async subscribeToConfigContext(){this.listeners.length||await this.glue.contexts.subscribe(tg,async(e,t,n,r,o)=>{const i=await this.getPreferencesNoWait(),s=rf(i);this.maybeTriggerListeners((0,Qp.merge)(e,s))})}constructor(e,t,n,r){this.gluePromise=e,this.asyncConstructors=t,this.routerClient=n,this.loggerClient=r,this.cachedPreferences=null,this.listeners=[],this.preferencesAreAvailable=new Kp,this.whichContext=e=>"finsemble"!==e[0]?tg:"apps"===e[1]||"components"===e[1]?"$FINSEMBLECONFIGAPPS":tg;const o=t.addConstructor();this.loggerClient.debug("ConfigClient Constructor"),e.then(e=>{this.glue=e,this.initialize().finally(()=>{this.loggerClient.debug("ConfigClient initialized"),t.finishConstructor(o)})}),this.logStatus=this.logStatus.bind(this)}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"ConfigClient",method:e,type:t,data:n})}async addListener(e,t,n){this.logStatus("addListener","start",{params:e}),await this.asyncConstructors.ready();const r=Array.isArray(e)?e:e.field?uf(e.field):[],o=await this.glue.contexts.get(tg);await this.subscribeToConfigContext(),this.listeners.push({pathArray:r,listener:t,config:o}),null==n||n(),this.logStatus("addListener","return")}async addListeners(e,t,n){this.logStatus("addListeners","start",e),await this.asyncConstructors.ready();const r=e.map(e=>e?"string"==typeof e?this.addListener({field:e},t):"string"==typeof e.field?this.addListener({field:e.field},e.listener):this.addListener(e.field,e.listener):this.addListener({field:null},t));await eg().allSettled(r),null==n||n(),this.logStatus("addListeners","return")}async getValue(e,t){this.logStatus("getValue","start",e),await this.asyncConstructors.ready();const n="string"==typeof e?e:e.field,{err:r,data:o}=await this.get(uf(n));return this.logStatus("getValue","return",{err:r,data:o}),null==t||t(r,o),{err:r,data:o}}async getValues(e,t){if(this.logStatus("getValues","start",e),await this.asyncConstructors.ready(),!e){const e=this.getManifest(t);return this.logStatus("getValues","return",e),e}const n=e.map(e=>"string"==typeof e?e:e.field),r=n.map(e=>this.get(uf(e))),o=await eg().allSettled(r),i={};o.forEach((e,t)=>{"fulfilled"===e.status&&(i[n[t]]=e.value.data)});const s=o.map(e=>"fulfilled"===e.status?e.value.err:e.reason).find(e=>"string"==typeof e);return this.logStatus("getValues","return",{err:s,data:i}),null==t||t(s,i),{err:s,data:i}}async getManifest(e){this.logStatus("getManifest","start"),await this.asyncConstructors.ready();const t=this.get([],e);return this.logStatus("getManifest","return",t),t}async getPreferences(e){return this.preferencesAreAvailable.resolved||console.warn("ConfigClient.getPreferences() called before having entered UserStage. Waiting..."),await this.preferencesAreAvailable.promise,this.getPreferencesNoWait(e)}async getPreferencesNoWait(e){var t;if(this.logStatus("getPreferences","start"),await this.asyncConstructors.ready(),!this.preferencesAreAvailable.resolved)return{data:{}};if(this.cachedPreferences)return this.logStatus("getPreferences","return",{err:null,data:this.cachedPreferences}),null==e||e(null,this.cachedPreferences),{err:null,data:this.cachedPreferences};{const{err:n=null,data:r}=await pg(()=>this.glue.prefs.get("IO.Global.FinsemblePreferences")),o=null!==(t=null==r?void 0:r.data)&&void 0!==t?t:{};return this.cachedPreferences=o,this.logStatus("getPreferences","return",{err:n,data:o}),null==e||e(n,o),{err:n,data:o}}}async processAndSet(e,t){await this.asyncConstructors.ready();const{newConfig:n,replace:r,overwrite:o}=e,{err:i,data:s}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.ConfigClient.processAndSet",{newConfig:n,replace:r,overwrite:o}));return i||this.routerClient.publish("Config.changeNotification",{newConfig:n,finsemble:s}),null==t||t(i,{data:s}),this.logStatus("processAndSet","return"),{err:i,data:s}}removeListener(e,t,n){this.logStatus("removeListener","start",e);const r=Array.isArray(e)?e:e.field?uf(e.field):[];this.listeners=this.listeners.filter(e=>t&&e.listener!==t||e.pathArray.join(".")!==r.join(".")),this.logStatus("removeListener","return"),null==n||n()}removeListeners(e,t,n){this.logStatus("removeListeners","start",e),(Array.isArray(e)?e:[e]).map(e=>{if(e)return"string"==typeof e?void this.removeListener({field:e},t):"string"==typeof e.field?void this.removeListener({field:e.field},e.listener):void this.removeListener(e.field,e.listener);this.removeListener({field:null},t)}),this.logStatus("removeListeners","return"),null==n||n(null,!0)}async removeValue(e,t){this.logStatus("removeValue","start",e),await this.asyncConstructors.ready();const n="string"==typeof e?e:e.field,{err:r,data:o}=await this.remove(uf(n));return this.logStatus("removeValue","return",{err:r,data:o}),null==t||t(r,o),{err:r,data:o}}async removeValues(e,t){this.logStatus("removeValues","start",e),await this.asyncConstructors.ready();const n=e.map(e=>"string"==typeof e?e:e.field);let r=await this.glue.contexts.get(tg);return r||(r={}),n.map(e=>cf(uf(e),r)),await this.glue.contexts.set(tg,r),this.logStatus("removeValues","return",{err:null}),null==t||t(null),{err:null}}async setPreference(e,t){this.logStatus("setPreference","start",{params:e}),await this.asyncConstructors.ready(),await this.maybeSendCommandToIOCD(e);const{err:n=null,data:r}=await pg(()=>this.glue.prefs.updateFor("IO.Global.FinsemblePreferences",{[e.field]:e.value}));return this.logStatus("setPreference","return",{err:n,data:r}),null==t||t(n,r),{err:n,data:r}}async setValue(e,t){this.logStatus("setValue","start",e),await this.asyncConstructors.ready();const n=await this.set(uf(e.field),e.value),r=n.err?n.err.toString():null;return this.logStatus("setValue","return",{err:r}),null==t||t(r),{err:r}}async setValues(e,t){this.logStatus("setValues","start",e),await this.asyncConstructors.ready();const n=e.map(e=>this.setValue(e)),r=(await eg().allSettled(n)).map(e=>"fulfilled"===e.status?e.value.err:e.reason).find(e=>"string"==typeof e);return this.logStatus("setValues","return",{err:r}),null==t||t(r),{err:r}}async unsetPreference(e,t){this.logStatus("unsetPreference","start",{params:e}),await this.asyncConstructors.ready();const{err:n,data:r}=await this.getPreferences();if(n)return this.logStatus("unsetPreference","error",{err:n}),null==t||t(n),{err:n};if(r&&Object.keys(r).length>0){delete r[e.field];const{err:n}=await pg(()=>this.glue.prefs.setFor("IO.Global.FinsemblePreferences",r));return this.logStatus("unsetPreference","return",{err:n,data:r}),null==t||t(n),{err:n}}return this.logStatus("unsetPreference","return",{err:null}),null==t||t(null),{err:null}}async get(e,t){if(this.logStatus("get","start",e),await this.asyncConstructors.ready(),null===e||!Array.isArray(e))return this.logStatus("get","error",{err:af}),null==t||t(af),{err:af};const{err:n,data:r={}}=await this.getPreferencesNoWait(),o=rf(r),i=await this.glue.contexts.get(this.whichContext(e)),s=0===Object.keys(i).length?"No config available. Is Finsemble service running?":null,a=(0,Qp.merge)(i,o),l={err:null!=s?s:n,data:lf(a,e)};return this.logStatus("get","return",l),null==t||t(l.err,l.data),l}async getMultiple(e,t){this.logStatus("getMultiple","start",e),await this.asyncConstructors.ready();const n=null,r=await this.glue.contexts.get(tg),{data:o={}}=await this.getPreferencesNoWait(),i=rf(o),s={};e.forEach(e=>{const t=lf(i,e);if(void 0!==t)return void(s[e.join(".")]=t);const n=lf(r,e);void 0!==n&&(s[e.join(".")]=n)});const a=Object.keys(s).length?s:void 0;return this.logStatus("getMultiple","return",{err:n,data:a}),null==t||t(n,a),{err:n,data:a}}async set(e,t,n){this.logStatus("set","start",{path:e,value:t}),await this.asyncConstructors.ready();const r=e.join("."),{err:o}=await pg(()=>this.glue.contexts.setPath(tg,r,t));return o&&this.logStatus("set","error",{subFunction:"this.glue.contexts.update(FINSEMBLECONFIG",err:o}),this.logStatus("set","return",{err:o,data:t}),null==n||n(o,t),{err:o,data:t}}async setMultiple(e,t){this.logStatus("setMultiple","start",{pathsAndValues:e}),await this.asyncConstructors.ready();const n=e.map(e=>({path:e.field.join("."),value:e.value})),{err:r}=await pg(()=>this.glue.contexts.setPaths(tg,n));return this.logStatus("setMultiple","start",{err:r,data:e}),null==t||t(r,e),{err:r,data:e}}async remove(e,t){this.logStatus("remove","start",{path:e}),await this.asyncConstructors.ready();let n=await this.glue.contexts.get(tg);return n||(n={}),cf(e,n),await this.glue.contexts.set(tg,n),this.logStatus("remove","return",{path:e}),null==t||t(null,e),{err:null,data:e}}async removeMultiple(e,t){this.logStatus("removeMultiple","start",e),await this.asyncConstructors.ready();const n=null;let r=await this.glue.contexts.get(tg);return r||(r={}),e.forEach(e=>{let t=r;for(let n=0;n<e.length-1;n++){const r=e[n];t[r]||(t[r]={}),t=t[r]}delete t[e[e.length-1]]}),await this.glue.contexts.set(tg,r),this.logStatus("removeMultiple","return",{err:n,data:e}),null==t||t(n,e),{err:n,data:e}}}class hf{constructor(e,t){this.glue=e,this.distributedStoreClient=t,this.initialized=!1,this.userInputTimeout=null,this.DialogStore=null,this.isDialog=!1,this.RESPONDER_CHANNEL=null,this.openerMessage=null,this.spawnData={}}async checkIfWindowIsDialog(e){var t,n,r,o,i,s,a;this.isDialog=!1;const l=null!==(t=await Wg(this.glue.windows.my()))&&void 0!==t?t:{};this.isDialog=null!==(a=null===(s=null===(i=null===(o=null===(r=null===(n=null==l?void 0:l.customProperties)||void 0===n?void 0:n.component)||void 0===r?void 0:r.foreign)||void 0===o?void 0:o.clients)||void 0===i?void 0:i.dialogManager)||void 0===s?void 0:s.isDialog)&&void 0!==a&&a,null==e||e(null)}async registerWithStore(e){var t,n;if(this.isDialog){const r=this.glue.windows.my();if(!r)return console.error("Attempt to register an incompatible window type as a dialog."),void(null==e||e());this.RESPONDER_CHANNEL=`Dialog.${r.id}.Show`,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","available",r.id],{windowName:r.id,componentType:null===(n=r.application)||void 0===n?void 0:n.name}))}null==e||e()}async initializeOnce(){this.initialized||(this.initialized=!0,await this.checkIfWindowIsDialog(),await this.createStore(),await this.registerWithStore())}async createStore(){const{err:e,data:t}=await this.distributedStoreClient.createStore({store:"DialogStore",values:{dialogs:{opened:{},available:{}}},global:!0});e||!t?console.error('DialogManagerClient could not create store "DialogStore"',e):this.DialogStore=t}async getAvailableDialog(e,t){if(!this.DialogStore){const e="DialogMangerClient.getAvailableDialogs() store not yet initialized}";return console.error(e),null==t||t(null),null}const{err:n,data:r}=await this.DialogStore.getGlobalValue("dialogs.available");if(n){const e=`DialogMangerClient.getAvailableDialogs() store error ${n}`;return console.error(e),null==t||t(null),null}for(const n in r){const o=r[n];if(o.componentType===e)return null==t||t(o),o}return null==t||t(null),null}async moveDialogFromOpenedToAvailable(e){var t,n;if(!this.DialogStore){const e="DialogMangerClient.moveDialogFromOpenedToAvailable() store not yet initialized}";return console.error(e),e}const{err:r,data:o}=await this.DialogStore.getGlobalValue("dialogs");if(r||!o){const e='DialogManagerClient.moveDialogFromOpenedToAvailable() no "dialogs" object returned from store';return console.error(e),e}const i=o.opened,s=o.available;return delete i[e.windowName],s[e.windowName]=e,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","opened"],i)),await(null===(n=this.DialogStore)||void 0===n?void 0:n.set(["dialogs","available"],s)),null}async moveDialogFromAvailableToOpened(e){var t,n;if(!this.DialogStore){const e="DialogMangerClient.moveDialogFromAvailableToOpened() store not yet initialized}";return console.error(e),e}const{err:r,data:o}=await this.DialogStore.getGlobalValue("dialogs");if(r||!o){const e='DialogManagerClient.moveDialogFromAvailableToOpened no "dialogs" object returned from store';return console.error(e),e}const i=o.available,s=o.opened;return delete i[e.windowName],s[e.windowName]=e,await(null===(t=this.DialogStore)||void 0===t?void 0:t.set(["dialogs","available"],i)),await(null===(n=this.DialogStore)||void 0===n?void 0:n.set(["dialogs","opened"],s)),null}}const pf={fdc3Resolver:"FDC3Resolver",linkerWindow:"LinkerWindow","Docking Move Mask":"DockingGroupMask",yesNo:"YesNoDialog",singleInput:"SingleInputDialog","Process Monitor":"ProcessMonitor","Advanced App Catalog":"AppCatalog"},gf=e=>`Dialog.${e}.ready`;class ff{constructor(e,t,n,r,o,i){this.gluePromise=e,this.asyncConstructors=t,this.router=n,this.appsClient=r,this.distributedStoreClient=o,this.loggerClient=i;const s=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(s)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DialogManagerClient",method:e,type:t,data:n})}async hideModal(){return null}async showModal(){return null}async getControllerInstance(){var e;const t=null!==(e=globalThis.DialogManagerClient)&&void 0!==e?e:new hf(this.glue,this.distributedStoreClient);return globalThis.DialogManagerClient=t,await t.initializeOnce(),t}async sendQueryToDialogInner(e,t,n,r,o){const i=e=>{console.warn(`No response from dialog ${n.windowName} after ${e/1e3} seconds. Check to make sure your dialog is sending back data.`)},s=await this.getControllerInstance();s.moveDialogFromAvailableToOpened(n);const a=`Dialog.${n.windowName}.Show`,l=gf(n.windowName);let u;const c=e.addListener(l,async(e,o)=>{if(e)return void console.log("DialogManagerClient.sendQueryToDialogInner() error from addListener",e);u=setTimeout(i.bind(null,o.data.userInputTimeout),o.data.userInputTimeout);const{err:s,data:a}=await t.showWindow(n,{monitor:r.monitor||"mine",left:"center",top:"center"});if(s||!a){const e=`DialogManagerClient.sendQueryToDialog error showing window ${n.windowName} ${s}`;return void console.error(e)}const l=await this.glue.windows.findById(n.windowName);null==l||l.setOnTop(!0),null==l||l.focus(),c()}),{err:d,response:h}=await e.query(a,r);d&&console.log(`DialogManagerClient.sendQueryToDialogInner() error contacting ${a}`,d),clearTimeout(u),s.moveDialogFromOpenedToAvailable(n),o(d,h.data)}set userInputTimeout(e){var t;(null!==(t=globalThis.DialogManagerClient)&&void 0!==t?t:new hf(this.glue,this.distributedStoreClient)).userInputTimeout=e}get openerMessage(){var e;return(null!==(e=globalThis.DialogManagerClient)&&void 0!==e?e:new hf(this.glue,this.distributedStoreClient)).openerMessage}async sendQueryToDialog(e,t,n){await this.asyncConstructors.ready();const r=t=>{console.warn(`No response from dialog ${e.windowName} after ${t/1e3} seconds. Check to make sure your dialog is sending back data.`)},o=await this.getControllerInstance();o.moveDialogFromAvailableToOpened(e);const i=`Dialog.${e.windowName}.Show`,s=gf(e.windowName);let a;const l=this.router.addListener(s,async(n,o)=>{a=setTimeout(r.bind(null,o.data.userInputTimeout),o.data.userInputTimeout);const{err:i,data:s}=await this.appsClient.showWindow(e,{monitor:t.monitor||"mine",left:"center",top:"center"});if(i||!s){const t=`DialogManagerClient.sendQueryToDialog() error showing window ${e.windowName} ${i}`;return void console.log(t)}const u=await this.glue.windows.findById(e.windowName);null==u||u.setOnTop(!0),null==u||u.focus(),l()}),{err:u,response:c}=await this.router.query(i,t);u&&console.log(`DialogManagerClient.sendQueryToDialog() error contacting ${i}`,u),clearTimeout(a),o.moveDialogFromOpenedToAvailable(e),n(u,c.data)}async spawnDialog(e,t,n,r){var o;this.logStatus("spawnDialog","start",{params:e,inputParams:t}),await this.asyncConstructors.ready();const i=`DialogChannel-${Zp()()}`;e.data={inputParams:t,responseChannel:i},e.left||0===e.left||e.right||0===e.right||(e.left="center"),e.top||0===e.top||e.bottom||0===e.bottom||(e.top="center");const s=this.router.addListener(i,(e,t)=>{n(e,t.data),s()});if("string"==typeof e.url){const t=await wg(this.glue,null==e?void 0:e.monitor),n=mg(this.glue,e,t);n&&await vg(this.glue,n,t);const i={placement:n,mode:"flat",ignoreFromLayouts:!0};return await this.glue.windows.open(null!==(o=e.name)&&void 0!==o?o:"",e.url,i),this.logStatus("spawnDialog","return",{err:null}),null==r||r(null),{err:null}}const{error:a,response:l}=await this.appsClient.spawn("dialogTemplate",e);return a&&n(a,l),this.logStatus("spawnDialog","return",{err:a,data:l}),null==r||r(a,l),{err:a,data:l}}async open(e,t,n){var r;this.logStatus("open","start",{type:e,options:t,onUserInput:n}),await this.asyncConstructors.ready(),e=null!==(r=pf[e])&&void 0!==r?r:e;const o=()=>new Promise(async r=>{(await this.getControllerInstance()).getAvailableDialog(e,e=>{e?(this.sendQueryToDialogInner(this.router,this.appsClient,e,t,n),r(!0)):r(!1)})});if(await o())return this.logStatus("open","return"),null;const i=e=>new Promise(t=>setTimeout(t,e)),{error:s}=await this.appsClient.spawn(e,{options:{customData:{foreign:{clients:{dialogManager:{isDialog:!0}}}}}});if(s)return this.logStatus("open","error",s),`DialogManagerClient.open launching dialog "${e}" error ${s}`;{const t=3e4;for(let e=0;e<15;e++){if(await o())return this.logStatus("open","return",null),null;await i(t/15)}const n=`DialogManagerClient.open error opening dialog "${e}. The dialog launched but didn't register within ${t} ms`;return this.logStatus("open","error",n),n}}async getParametersFromInDialog(){this.logStatus("getParametersFromInDialog","start"),await this.asyncConstructors.ready();const e=await this.getControllerInstance(),{inputParams:t}=e.spawnData;return this.logStatus("getParametersFromInDialog","return",{inputParams:t}),t}async respondAndExitFromInDialog(e){this.logStatus("respondAndExitFromInDialog","start",e),await this.asyncConstructors.ready();const t=await this.getControllerInstance(),{responseChannel:n}=t.spawnData;this.router.transmit(n,e),this.logStatus("respondAndExitFromInDialog","return")}async showDialog(){var e;this.logStatus("showDialog","start"),await this.asyncConstructors.ready();const t=await this.getControllerInstance(),n=this.glue.windows.my();if(!n)return void console.log("Use of showDialog in incompatible window type");const r=gf(n.id);this.router.transmit(r,{userInputTimeout:null!==(e=t.userInputTimeout)&&void 0!==e?e:1e4}),this.logStatus("showDialog","return")}async registerDialogCallback(e){this.logStatus("registerDialogCallback","start"),await this.asyncConstructors.ready();const t=await this.getControllerInstance();t.RESPONDER_CHANNEL&&this.router.addResponder(t.RESPONDER_CHANNEL,(n,r)=>{r&&(t.openerMessage=r),null==e||e(n,r)}),this.logStatus("registerDialogCallback","return")}async respondToOpener(e){var t;this.logStatus("respondToOpener","start",e),await this.asyncConstructors.ready();const n=await this.getControllerInstance();null===(t=n.openerMessage)||void 0===t||t.sendQueryResponse(null,e);const r=this.glue.windows.my();null==r||r.hide(),n.openerMessage=null,this.logStatus("respondToOpener","return")}}class mf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DialogManagerClient",method:e,type:t,data:n})}async open(e,t,n){this.logStatus("open","start",{type:e,options:t,onUserInput:n}),await this.asyncConstructors.ready();const r=this.glue.windows.my();if(!r){const e="Cannot open dialog from within an incompatible window type (e.g. webgroup). You must use the Finsemble dialog implementation";return console.error(e),e}const o=r.showDialog(((e,t)=>{var n,r,o,i,s,a,l,u,c;const d="SingleInputDialog"===e?"Enter value:":"Are you sure?",h=null!==(r=null!==(n=t.question)&&void 0!==n?n:t.inputLabel)&&void 0!==r?r:d;return{type:"YesNoDialog"===e?"YesNoCancel":e,mode:"WindowContainer",title:null!==(o=t.title)&&void 0!==o?o:"Yes/No Question",message:h,messageTitle:"",showAffirmativeButton:null===(i=t.showAffirmativeButton)||void 0===i||i,affirmativeButtonName:null!==(s=t.affirmativeResponseLabel)&&void 0!==s?s:"Yes",showNegativeButton:null===(a=t.showNegativeButton)||void 0===a||a,negativeButtonName:null!==(l=t.negativeResponseLabel)&&void 0!==l?l:"No",showCancelButton:null===(u=t.showCancelButton)||void 0===u||u,cancelButtonName:null!==(c=t.cancelResponseLabel)&&void 0!==c?c:"Cancel",...t,timerDuration:t.timerDuration?t.timerDuration/1e3:void 0}})(e,t));return o.then(e=>{const{action:t,button:r,value:o}=e;n(null,"closed"===t?{choice:"cancel"}:"affirmative"===r?{choice:"affirmative",value:o}:{choice:"negative"})}),this.logStatus("open","return",null),null}}class yf{constructor(e,t,n,r,o,i){this.gluePromise=e,this.asyncConstructors=t,this.finsembleImplementation=new ff(e,t,n,r,o,i),this.glueImplementation=new mf(e,t,i)}set userInputTimeout(e){this.finsembleImplementation.userInputTimeout=e}get openerMessage(){var e;return null!==(e=this.finsembleImplementation.openerMessage)&&void 0!==e?e:null}async sendQueryToDialog(e,t,n){return this.finsembleImplementation.sendQueryToDialog(e,t,n)}async hideModal(){return null}async showModal(){return null}async spawnDialog(e,t,n,r){var o;return null!==(o=this.finsembleImplementation.spawnDialog(e,t,n,r))&&void 0!==o?o:{}}async useGlueDialogs(){var e,t;const n=await this.gluePromise,r=null!==(e=await n.contexts.get(tg))&&void 0!==e?e:{};return!0===(null===(t=null==r?void 0:r.iocd)||void 0===t?void 0:t.iocdDialogs)}async open(e,t,n){var r,o;return await this.useGlueDialogs()?null!==(r=this.glueImplementation.open(e,t,n))&&void 0!==r?r:null:null!==(o=this.finsembleImplementation.open(e,t,n))&&void 0!==o?o:null}async getParametersFromInDialog(){return this.finsembleImplementation.getParametersFromInDialog()}async respondAndExitFromInDialog(e){return this.finsembleImplementation.respondAndExitFromInDialog(e)}async showDialog(){return this.finsembleImplementation.showDialog()}async registerDialogCallback(e){return this.finsembleImplementation.registerDialogCallback(e)}async respondToOpener(e){return this.finsembleImplementation.respondToOpener(e)}}const wf=(e,t)=>null===e?t:(0,Qp.get)(t,e),vf=e=>{let t=null;return e&&e.length>0&&(t=e.join(".")),t};class bf{constructor(e){var t,n;this.params=e,this.values={},this.listeners={},this.funcs=[],this.Dispatcher={register:e=>{this.funcs.push(e)},dispatch:e=>{this.funcs.forEach(t=>t(e))}},this.isGlobal=null!==(t=e.global)&&void 0!==t&&t,this.name=e.store,this.values=null!==(n=e.values)&&void 0!==n?n:{}}async init(){await this.initCore()}addListener(e,t,n){var r;let o="";o=Array.isArray(e)?e.join("."):null!==(r=e.field)&&void 0!==r?r:"";let i=this.listeners[o];i||(i=[],this.listeners[o]=i),i.push(t)}addListeners(e,t,n){var r,o;for(const n of e){let e={field:"",listener:t};if("string"==typeof n?e.field=n:"string"==typeof n.field?e={field:n.field,listener:null!==(r=n.listener)&&void 0!==r?r:t}:Array.isArray(n.field)&&(e={field:n.field.join("."),listener:null!==(o=n.listener)&&void 0!==o?o:t}),!e.listener)throw new Error(`no listener defined for field ${e.field}`);this.addListener({field:e.field},e.listener)}n&&n()}destroy(e){return this.listeners={},this.destroyCore(e)}async get(e,t){const n=vf(e);return{err:void 0,data:this.getValue(n,t)}}async getMultiple(e,t){const n=e.map(e=>vf(e)),r=[];for(const e of n)e&&r.push(e);return{err:null,response:{data:Jp().pick(this.values,r)}}}getAll(e){e(null,this.values)}async getGlobal(e,t){const n=vf(e),r=wf(n,this.values);return null==t||t(null,r),{err:null,data:r}}getValue(e,t){let n=null;null!==e&&(n="string"==typeof e?e:e.field);const r=wf(n,this.values);return null==t||t(null,r),r}async getGlobalValue(e,t){const n=await this.getValue(e,t);return null==t||t(null,n),{err:null,data:n}}async getValues(e,t){const n={};for(const t of null!=e?e:[]){const e=await this.getValue(t);n["string"==typeof t?t:t.field]=e.data}return t&&t(null,n),{err:null,data:n}}async removeListener(e,t,n){var r,o;let i="";i=Array.isArray(e)?e.join("."):null!==(r=e.field)&&void 0!==r?r:"";const s=(null!==(o=this.listeners[i])&&void 0!==o?o:[]).filter(e=>e!==t);this.listeners[i]=s,this.listeners[i].length||delete this.listeners[i]}async removeListeners(e,t,n){const r=Array.isArray(e)?e:[e];await ag(r,async e=>{const t=Array.isArray(e.field)?vf(e.field):e.field;t&&await this.removeListener({field:t},e.listener)}),null==n||n(null)}async remove(e,t){const n=e.join(".");return await this.setValue({field:n,value:null}),{err:null,data:void 0}}async removeMultiple(e,t){return this.setMultiple(e.map(e=>({field:e,value:null})))}removeValue(e,t){var n;return this.setValue({field:null!==(n=e.field)&&void 0!==n?n:e,value:null},t)}removeValues(e,t){const n=e.map(t=>{var n;return{field:null!==(n=e.field)&&void 0!==n?n:e,value:null}});return this.setValues(n)}async set(e,t,n){const r=e.join(".");return await this.setValue({field:r,value:t}),{err:null,data:void 0}}async setMultiple(e,t){return await ag(e,async e=>{await this.set(e.field,e.value)}),null==t||t(null),{err:null}}setValue(e,t){return this.setValueCore(e,t)}async setValues(e,t){for(const t of e)await this.setValue(t);t&&t(null)}initCore(){}destroyCore(e){}setValueCore(e,t){}notifyListeners(e){for(const t of Object.keys(this.listeners)){if(t!==e&&""!==t)continue;const n=""===t?this.values:wf(t,this.values),r=this.listeners[t],o=t;r.forEach(e=>{try{e(null,{field:o,value:n})}catch(e){console.log("DistributedStore notifyListeners error in handler",e)}})}}}const Cf=(e,t)=>{const n={different:[],missing_from_first:[],missing_from_second:[]};return Jp().reduce(e,(n,r,o)=>{if(t.hasOwnProperty(o)){if(Jp().isEqual(r,t[o]))return n;if("object"!=typeof e[o]||"object"!=typeof t[o])return n.different.push(o),n;{const r=Cf(e[o],t[o]);return n.different=n.different.concat(Jp().map(r.different,e=>o+"."+e)),n.missing_from_second=n.missing_from_second.concat(Jp().map(r.missing_from_second,e=>o+"."+e)),n.missing_from_first=n.missing_from_first.concat(Jp().map(r.missing_from_first,e=>o+"."+e)),n}}return n.missing_from_second.push(o),n},n),Jp().reduce(t,function(t,n,r){return e.hasOwnProperty(r)||t.missing_from_first.push(r),t},n),n};class Sf extends bf{constructor(e,t){super(t),this.glue=e,this.sharedContextName=`$FINSEMBLE:DS:${t.store}`}async setValueCore(e,t){const n="string"==typeof e?e:e.field;await this.glue.contexts.setPath(this.sharedContextName,n,e.value),this.values=await this.glue.contexts.get(this.sharedContextName),t&&t(null)}async initCore(){var e,t,n,r;const o=new Kp;await this.glue.contexts.subscribe(this.sharedContextName,e=>{o.resolved||o.resolve(),this.handleUpdate(e)});try{await this.glue.interop.invoke("FSBL.Clients.DistributedStoreClient.init",{store:this.sharedContextName,value:null!==(t=null===(e=this.params)||void 0===e?void 0:e.values)&&void 0!==t?t:{}},"best",{waitTimeoutMs:0})}catch(e){await this.glue.contexts.update(this.sharedContextName,null!==(r=null===(n=this.params)||void 0===n?void 0:n.values)&&void 0!==r?r:{})}await o.promise}async destroyCore(e){try{(await this.glue.contexts.all()).includes(this.sharedContextName)&&this.glue.contexts.destroy(this.sharedContextName)}catch(e){}e&&e(null,void 0)}handleUpdate(e){const t=Cf(this.values,null!=e?e:{}),n=t.different.concat(t.missing_from_first).concat(t.missing_from_second);this.values=e,n.forEach(e=>{this.notifyListeners(e)})}}class If extends bf{constructor(e,t){super(t)}async setValueCore(e,t){const n="string"==typeof e?e:e.field;((e,t,n)=>{(0,Qp.set)(e,t,n)})(this.values,n,e.value),this.notifyListeners(n)}}class kf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.localStores={};const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"DistributedStore",method:e,type:t,data:n})}async createStore(e,t){this.logStatus("createStore","start",e),await this.asyncConstructors.ready();const n=await this.getOrCreateStoreObject(e);return this.logStatus("createStore","return",{err:null}),null==t||t(null,n),{err:null,data:n}}async getStore(e,t){this.logStatus("getStore","start",e),await this.asyncConstructors.ready();const n=await this.getOrCreateStoreObject(e);return this.logStatus("getStore","return",{err:null,data:n}),null==t||t(null,n),{err:null,data:n}}async removeStore(e,t){this.logStatus("removeStore","start",e),await this.asyncConstructors.ready();let n=!1;if(!e.global){const t=this.localStores[e.store];t&&(n=!0,delete this.localStores[e.store],t.destroy())}if(!n){const t=new Sf(this.glue,{store:e.store,global:e.global,values:null});await new Promise(e=>{t.destroy(()=>{e()})})}return this.logStatus("removeStore","return",{err:null,data:!0}),null==t||t(null,!0),{err:null,data:!0}}async getOrCreateStoreObject(e){await this.asyncConstructors.ready();const t=e.global,n="object"==typeof e.values?Vp()({},e.values):e.values;if(t){const t=new Sf(this.glue,{store:e.store,global:e.global,values:n});return await t.init(),t}{let t=this.localStores[e.store];return t||(t=new If(this.glue,{store:e.store,values:n}),t.getGlobalValue=async(e,t)=>(await this.getOrCreateStoreObject({store:e.store,global:!0})).getGlobalValue(e,t),await t.init(),this.localStores[e.store]=t),t}}}var Tf=n(9031),xf=n.n(Tf);class Af{get name(){return this.fin.windowName}focus(){this.fin.focus()}hide(){this.fin.hide()}async getSnapshot(e,t){return this.fin.getSnapshot(e,t)}getZoomFactor(e){this.fin.getZoomFactor(e)}setZoomFactor(e,t){this.fin.setZoomFactor(e,t)}getOptions(e){this.fin.getOptions(e)}constructor(e){this.fin=e}}class Ef{getCurrent(){return new Af(this.fin)}focus(){this.fin.focus()}hide(){this.fin.hide()}async getSnapshot(e,t){return this.fin.getSnapshot(e,t)}constructor(e){this.fin=e}}class Wf{getCommandLineArguments(e){this.fin.getCommandLineArguments(e)}constructor(e){this.fin=e}async openUrlWithBrowser(e,t){await this.fin.openUrlWithBrowser(e,t)}isTitlebarWindow(){return this.fin.isTitlebarWindow()}isBrowserView(){return this.fin.isBrowserView()}}class Of{constructor(e){this.fin=e,this.Window=new Ef(e),this.System=new Wf(e)}}class Df{logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"fin",method:e,type:t,data:n})}constructor(e,t,n,r=null){this.asyncConstructors=t,this.loggerClient=n,this.windowName="Window name not set yet. Please wait for FSBL 'onReady' event before calling getCurrent()",this.myWindow=null;const o=this.asyncConstructors.addConstructor();e.then(e=>{var t,n,i;this.glue=e,this.myWindow=r?null!==(t=this.glue.windows.findById(r))&&void 0!==t?t:null:null!==(i=null===(n=this.glue.windows)||void 0===n?void 0:n.my())&&void 0!==i?i:null,this.myWindow?this.windowName=this.myWindow.id:this.windowName="Not a valid window. Perhaps running in node?",this.asyncConstructors.finishConstructor(o)}),this.desktop=new Of(this)}async focus(){this.logStatus("focus","start"),await this.asyncConstructors.ready(),await new Promise(e=>setTimeout(()=>{var t;null===(t=this.myWindow)||void 0===t||t.focus(),e()},250)),this.logStatus("focus","return")}async hide(){var e;console.log("hide"),this.logStatus("hide","start"),await this.asyncConstructors.ready(),await(null===(e=this.myWindow)||void 0===e?void 0:e.hide()),this.logStatus("hide","return")}isBrowserView(){return!1}isTitlebarWindow(){return!1}async getOptions(e){this.logStatus("getOptions","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getOptions start");const t=this.myWindow;if(t){const n=await xg(t);return null==e||e(n),this.loggerClient.debug("getOptions return"),this.logStatus("getOptions","return",n),n}return this.loggerClient.error("fin getOptions() called on non window"),null==e||e({}),this.logStatus("getOptions","return",{}),{}}async getSnapshot(e,t){var n;if(this.logStatus("getSnapshot","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getSnapshot start"),!this.myWindow)return null==t||t(""),this.logStatus("getSnapshot","return"),"";const r=await this.myWindow.getBounds(),o={size:{height:r.height,keepAspectRatio:!0,width:r.width}},i=await(null===(n=this.myWindow)||void 0===n?void 0:n.capture(o));return this.loggerClient.debug("getSnapshot return"),null==t||t(i),this.logStatus("getSnapshot","return"),i}async getCommandLineArguments(e){var t;this.logStatus("getCommandLineArguments","start"),await this.asyncConstructors.ready(),this.loggerClient.debug("getCommandLineArguments start");const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("T42.GD.Execute",{command:"get-cli-arguments"})),o=xf()(null!==(t=null==r?void 0:r.args)&&void 0!==t?t:[]);n&&this.loggerClient.error("getCommandLineArguments",n),null==e||e(o),this.loggerClient.debug("getCommandLineArguments return",o),this.logStatus("getCommandLineArguments","return",o)}async openUrlWithBrowser(e,t){this.logStatus("openUrlWithBrowser","start"),this.loggerClient.debug("openUrlWithBrowser","start",{url:e}),await this.asyncConstructors.ready();const{err:n}=await Tg(this.glue,e);n&&this.loggerClient.error("openUrlWithBrowser","error",n),null==t||t(n),this.loggerClient.debug("openUrlWithBrowser","return"),this.logStatus("openUrlWithBrowser","return")}async getZoomFactor(e){var t,n;this.logStatus("getZoomFactor","start"),await this.asyncConstructors.ready(),e({zoomFactor:(null!==(n=null===(t=this.myWindow)||void 0===t?void 0:t.zoomFactor)&&void 0!==n?n:100)/100,status:"success"}),this.logStatus("getZoomFactor","return")}static getClosestZoomFactor(e){let t;return(null===globalThis||void 0===globalThis?void 0:globalThis.iodesktop)?({factors:t}=globalThis.iodesktop.settings.zoom):t=[24,33,50,67,75,80,90,100,110,125,150,175,200,250,300,400,500],t.reduce((t,n)=>Math.abs(n-e)<=Math.abs(t-e)?n:t)}async setZoomFactor(e,t){var n,r;this.logStatus("setZoomFactor","start"),await this.asyncConstructors.ready();const o=Df.getClosestZoomFactor(100*e);if((null===(n=this.myWindow)||void 0===n?void 0:n.zoomFactor)===o)return void(null==t||t());const i=new Promise(e=>{var n;null===(n=this.myWindow)||void 0===n||n.onZoomFactorChanged(()=>{null==t||t(),e()})});await(null===(r=this.myWindow)||void 0===r?void 0:r.setZoomFactor(o)),await i,this.logStatus("setZoomFactor","return")}}class _f{constructor(e,t,n){this.asyncConstructors=t,this.fin=new Df(e,this.asyncConstructors,n)}getCurrent(){return this.fin.desktop.Window.getCurrent()}}class Pf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.protocolHandlerEventChannel=null;const r=this.asyncConstructors.addConstructor();this.Window=new _f(e,this.asyncConstructors,this.loggerClient),e.then(e=>{this.glue=e,this.asyncConstructors.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"System",method:e,type:t,data:n})}setTrayIcon(e,t){this.logStatus("setTrayIcon","deprecated"),console.error("setTrayIcon() has been deprecated. See https://docs.interop.io/desktop/getting-started/how-to/rebrand-io-connect/user-interface/index.html#icons-tray")}launchExternalProcess(){this.logStatus("launchExternalProcess","deprecated"),console.error("launchExternalProcess() is no longer supported. Instead, configure an app config that points to the desired path of your executable and call `iop.appManager.application(name).start()`")}terminateExternalProcess(){this.logStatus("terminateExternalProcess","deprecated"),console.error("terminateExternalProcess() is no longer supported.")}async hideSplashScreen(){this.logStatus("hideSplashScreen","start"),await this.asyncConstructors.ready();const{err:e}=await gg(()=>this.glue.interop.invoke("T42.GD.Execute",{command:"hide-splash-screen"}));e&&this.logStatus("hideSplashScreen","error",e),this.logStatus("hideSplashScreen","return")}async exit(){this.logStatus("exit","start"),await this.asyncConstructors.ready(),await this.glue.appManager.exit({showDialog:!1,autoSave:!1}),this.logStatus("exit","return")}async getProcessList(e){var t,n,r,o;this.logStatus("getProcessList","start"),await this.asyncConstructors.ready();const i=(await this.glue.interop.invoke("T42.Telemetry",{command:"GetEvents",config:{stores:!0,system:!0,apps:!0}})).returned,s=(null!==(o=null===(r=null===(n=null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.system)||void 0===n?void 0:n.perfData)||void 0===r?void 0:r.apps)&&void 0!==o?o:[]).map(e=>{var t;return{cpuUsage:null===(t=e.cpu)||void 0===t?void 0:t.percentCPUUsage,name:e.name,type:e.type,peakWorkingSetSize:e.memoryKB,processId:e.pid,workingSetSize:e.memoryKB,webContents:{}}});return null==e||e(s),this.logStatus("getProcessList","return"),s}async clearCache(){var e;this.logStatus("clearCache","start"),await this.asyncConstructors.ready();const t=globalThis;await(null===(e=null==t?void 0:t.glue42gd)||void 0===e?void 0:e.clearCache()),this.logStatus("clearCache","return")}async showDeveloperTools(e,t=!0){this.logStatus("showDeveloperTools","start",{name:e,viewId:t}),await this.asyncConstructors.ready();const n=this.glue.appManager.instances().find(({_id:t})=>t===e);null==n||n.window.showDevTools(),null!==t&&!0!==t&&this.loggerClient.warn("The use of the 'viewId' parameter has been deprecated in showDeveloperTools()."),this.logStatus("showDeveloperTools","return")}async addEventListener(e,t){if(this.logStatus("addEventListener","start",{eventName:e}),await this.asyncConstructors.ready(),"protocol-handler-triggered"===e){this.protocolHandlerEventChannel=Zp()(),this.loggerClient.debug(`FSBL.System.addEventListener("protocol-handler-triggered") channel = ${this.protocolHandlerEventChannel}`),this.glue.interop.register(this.protocolHandlerEventChannel,e=>{null==t||t(e.command)});const{err:e}=await gg(()=>this.glue.interop.invoke("FSBL.Event.add.protocol-handler-triggered",{invoker:this.protocolHandlerEventChannel}));return e&&this.logStatus("addEventListener","error",e),void this.logStatus("addEventListener","return")}this.loggerClient.warn("FSBL.System.addEventListener called for unsupported event",e),this.logStatus("addEventListener","return")}addSelectClientCertificateListener(){this.logStatus("addSelectClientCertificateListener","deprecated"),console.warn("addSelectClientCertificateListener() is deprecated. Client certificate selection is now part of io.CD's UI.")}addCertificateErrorListener(){this.logStatus("addCertificateErrorListener","deprecated"),console.warn("addCertificateErrorListener() is deprecated. Client certificate selection is now part of io.CD's UI.")}async getFEAInfo(e){var t,n,r;this.logStatus("getFEAInfo","start"),await this.asyncConstructors.ready();const o=globalThis,i={"@interopio/desktop":this.glue.version,"io.Connect Desktop":null===(t=o.glue42gd)||void 0===t?void 0:t.version,Electron:null===(n=o.glue42gd)||void 0===n?void 0:n.electron,FEA:null===(r=o.glue42gd)||void 0===r?void 0:r.version,isDevLaunch:!1,sddEnabled:!1,isDevMode:!1};return this.logStatus("getFEAInfo","return",i),null==e||e(i),i}async getUpdateAvailable(e){return this.loggerClient.error("getUpdateAvailable() is not yet implemented in the polyfill."),await this.asyncConstructors.ready(),e(!1),!1}async openUrlWithBrowser(e,t){this.logStatus("openUrlWithBrowser","start",{url:e}),await this.asyncConstructors.ready();const{err:n}=await Tg(this.glue,e);n&&this.logStatus("openUrlWithBrowser","error",n),null==t||t(n),this.logStatus("openUrlWithBrowser","return")}async getProtocolString(e){this.logStatus("getProtocolString","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("FSBL.System.getProtocolString",{}));return t&&this.logStatus("getProtocolString","error",t),null==e||e(null==n?void 0:n.command),this.logStatus("getProtocolString","return",null==n?void 0:n.command),null==n?void 0:n.command}async terminate(){this.logStatus("terminate","start"),await this.exit(),this.logStatus("terminate","return")}async restart(){this.logStatus("restart","start"),await this.asyncConstructors.ready(),await this.glue.appManager.restart({showDialog:!1,autoSave:!1}),this.logStatus("restart","return")}async getEnvironmentVariable(e,t){var n,r;this.logStatus("getEnvironmentVariable","start",{envVar:e}),await this.asyncConstructors.ready();const o=(null!==(r=null===(n=globalThis.glue42gd)||void 0===n?void 0:n.env)&&void 0!==r?r:{})[e];return this.logStatus("getEnvironmentVariable","return",o),null==t||t(o),o}async getHostSpecs(e){var t,n;this.logStatus("getHostSpecs","start"),await this.asyncConstructors.ready();const r=null!==(n=null===(t=null===globalThis||void 0===globalThis?void 0:globalThis.glue42gd)||void 0===t?void 0:t.env)&&void 0!==n?n:{},o={env:r,hostname:r.HOSTNAME};return this.logStatus("getHostSpecs","return",o),null==e||e(o),o}}const Rf={spacebar:"space",bs:"Backspace",bksp:"Backspace",shift:"Shift",shft:"Shift",lshift:"Shift",lshft:"Shift","left shift":"Shift",leftshift:"Shift",rshift:"Shift",rshft:"Shift","right shift":"Shift",rightshift:"Shift",commandorcontrol:"CommandOrControl",alternate:"Alt","space bar":"space",pgup:"PageUp","pg up":"PageUp","page down":"PageDown",pgdn:"PageDown","pg dn":"PageDown",pgdown:"PageDown","left arrow":"Left",left:"Left","up arrow":"Up",up:"Up","right arrow":"Right",right:"Right","down arrow":"Down",down:"Down",print:"PrintScreen",prnt:"PrintScreen","print screen":"PrintScreen",printscreen:"PrintScreen","print scrn":"PrintScreen",printscrn:"PrintScreen","prnt scrn":"PrintScreen",prntscrn:"PrintScreen","prt scrn":"PrintScreen",prtscrn:"PrintScreen","prt scn":"PrintScreen",prtscn:"PrintScreen","prt scr":"PrintScreen",prtscr:"PrintScreen","prt sc":"PrintScreen",prtsc:"PrintScreen","pr sc":"PrintScreen",prsc:"PrintScreen",insert:"Insert",ins:"Insert",delete:"Delete",del:"Delete",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",a:"A",b:"B",c:"C",d:"D",e:"E",f:"F",g:"G",h:"H",i:"I",j:"J",k:"K",l:"L",m:"M",n:"N",o:"O",p:"P",q:"Q",r:"R",s:"S",t:"T",u:"U",v:"V",w:"W",x:"X",y:"Y",z:"Z",windows:"Super","left windows":"Super","right windows":"Super","numpad 0":"num0","numpad 1":"num1","numpad 2":"num2","numpad 3":"num3","numpad 4":"num4","numpad 5":"num5","numpad 6":"num6","numpad 7":"num7","numpad 8":"num8","numpad 9":"num9",f1:"F1",fn1:"F1","function 1":"F1",f2:"F2",fn2:"F2","function 2":"F2",f3:"F3",fn3:"F3","function 3":"F3",f4:"F4",fn4:"F4","function 4":"F4",f5:"F5",fn5:"F5","function 5":"F5",f6:"F6",fn6:"F6","function 6":"F6",f7:"F7",fn7:"F7","function 7":"F7",f8:"F8",fn8:"F8","function 8":"F8",f9:"F9",fn9:"F9","function 9":"F9",f10:"F10",fn10:"F10","function 10":"F10",f11:"F11",fn11:"F11","function 11":"F11",f12:"F12",fn12:"F12","function 12":"F12",f13:"F13",fn:"F13","function 13":"F13",f14:"F14",fn14:"F14","function 14":"F14",f15:"F15",fn15:"F15","function 15":"F15",f16:"F16",fn16:"F16","function 16":"F16","num lock":"Numlock",numlock:"Numlock","number lock":"Numlock","numeric lock":"Numlock","scroll lock":"Scrolllock",sclk:"Scrolllock",scrlk:"Scrolllock",slk:"Scrolllock","*":"*","+":"+","-":"-","/":"/",";":";","=":"=",",":",",".":".","`":"`","[":"[","]":"]","'":"'"},Lf=e=>e.map(e=>{var t;return null!==(t=Rf[e.toString().toLowerCase()])&&void 0!==t?t:e}).join("+").replace(/windows/i,"super").replace(/spacebar/i,"space");class Ff{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"HotkeyClient",method:e,type:t,data:n})}onClose(e){this.removeAllHotkeys(e)}async removeAllHotkeys(e){return this.logStatus("removeAllHotkeys","start"),await this.asyncConstructors.ready(),await this.glue.hotkeys.unregisterAll(),this.logStatus("removeAllHotkeys","return",{err:null}),null==e||e(null),{err:null}}async removeGlobalHotkey(e,t,n){return this.logStatus("removeGlobalHotkey","start",{keyArr:e}),await this.asyncConstructors.ready(),await this.glue.hotkeys.unregister(Lf(e)),this.logStatus("removeGlobalHotkey","return"),null==n||n(null),{err:null}}async addGlobalHotkey(e,t,n){this.logStatus("addGlobalHotkey","start",e),await this.asyncConstructors.ready();const r=Lf(e);return await this.glue.hotkeys.register(r,()=>{this.loggerClient.debug("Got hotkey",r),t()}),this.logStatus("addGlobalHotkey","return"),null==n||n(null),{err:null}}addBrowserHotkey(e,t,n){console.warn("The method addBrowserHotkey() has been deprecated. Use local keypress event handlers instead.")}}class Mf{warn(...e){globalThis.console.warn(...e)}info(...e){globalThis.console.info(...e)}log(...e){globalThis.console.log(...e)}debug(...e){globalThis.console.debug(...e)}error(...e){globalThis.console.error(...e)}verbose(...e){globalThis.console.debug(...e)}deprecated(...e){globalThis.console.error(...e)}}class $f{constructor(e,t){this.asyncConstructors=t,this.queue=[],this.logState={Error:!0,Warn:!0,Log:!0,Info:!1,Debug:!1,Verbose:!1,Console:!1},this.componentSelected=!1,this.centralLoggerReady=!1,this.enableLegacyLoggerRecipe=!1,this.routerClient=null;const n=t.addConstructor();e.then(async e=>{var r,o,i,s;this.glue=e;const a=null!==(i=null===(o=null===(r=this.glue.windows)||void 0===r?void 0:r.my())||void 0===o?void 0:o.name)&&void 0!==i?i:"unknown window";await this.glue.contexts.subscribe("central-logger-component-states",({componentLogState:e,componentFilterState:t})=>{a in e&&a in t&&(this.logState=e[a],this.componentSelected=t[a],this.centralLoggerReady=!0,this.processQueue())});const l=await e.contexts.get(tg);this.enableLegacyLoggerRecipe=null===(s=l.iocd)||void 0===s?void 0:s.enableLegacyLoggerRecipe,t.finishConstructor(n)}),this.system={warn:(...e)=>{this.logIt("system","Warn",e)},info:(...e)=>{this.logIt("system","Info",e)},log:(...e)=>{this.logIt("system","Log",e)},error:(...e)=>{this.logIt("system","Error",e)},debug:(...e)=>{this.logIt("system","Debug",e)},verbose:(...e)=>{this.logIt("system","Verbose",e)},deprecated:(...e)=>{this.logIt("system","Error",e)}},this.perf={warn:(...e)=>{this.logIt("perf","Warn",e)},info:(...e)=>{this.logIt("perf","Info",e)},log:(...e)=>{this.logIt("perf","Log",e)},error:(...e)=>{this.logIt("perf","Error",e)},debug:(...e)=>{this.logIt("perf","Debug",e)},verbose:(...e)=>{this.logIt("perf","Verbose",e)},deprecated:(...e)=>{this.logIt("perf","Error",e)}},this.console=new Mf}logIt(e,t,n){var r,o,i,s;const a={category:e,logType:t,logClientName:null!==(s=null===(i=null===(o=null===(r=this.glue)||void 0===r?void 0:r.windows)||void 0===o?void 0:o.my())||void 0===i?void 0:i.name)&&void 0!==s?s:"",logData:n,logTimestamp:(new Date).valueOf()};this.queue.push(a),this.processQueue()}async processQueue(){var e;if(!this.centralLoggerReady||0===this.queue.length)return;await this.asyncConstructors.ready();const t=this.queue.slice(0);if(this.queue=[],!this.componentSelected)return;const n=t.filter(e=>this.logState[e.logType]);if(n.length){n.forEach(e=>{var t,n,r,o;e.logClientName=null!==(o=null===(r=null===(n=null===(t=this.glue)||void 0===t?void 0:t.windows)||void 0===n?void 0:n.my())||void 0===r?void 0:r.name)&&void 0!==o?o:""});const t=e=>({Error:"error",Log:"log",Debug:"debug",Info:"info",Warn:"warn",Verbose:"debug",Console:"log"}[e]);this.logState.Console&&n.forEach(e=>this.console[t(e.logType)](...e.logData)),await gg(()=>this.glue.interop.invoke("fsbl-logger-service-log-messages",{data:n}));const r=n.filter(e=>"Error"===e.logType||"Warn"===e.logType);this.enableLegacyLoggerRecipe&&r.length&&(null===(e=this.routerClient)||void 0===e||e.transmit("logger.service.logMessages",r.map(e=>({...e,logData:JSON.stringify(e.logData)}))))}}warn(...e){this.logIt("dev","Warn",e)}info(...e){this.logIt("dev","Info",e)}log(...e){this.logIt("dev","Log",e)}debug(...e){this.logIt("dev","Debug",e)}error(...e){this.logIt("dev","Error",e)}verbose(...e){this.logIt("dev","Verbose",e)}deprecated(...e){this.logIt("dev","Error",e)}initialize(e){this.routerClient=e}}class Nf{}class jf{constructor(){this.actions=[],this.isRead=!1,this.isSnoozed=!1,this.isMuted=!1,this.isDeleted=!1,this.actionsHistory=[],this.meta=new Nf,this.stateHistory=[],this.issuedAt="",this.title="",this.devModeOnly=!1}}class Bf{constructor(){this.id="",this.buttonText="",this.type=""}}class qf{constructor(e,t){this.id=e||null,this.filter=t,this.channel=""}}const Uf=(e,t)=>{var n;let r=!0;return e.type&&e.type!==t.type&&(r=!1),e.source&&e.source!==t.source&&(r=!1),e.title&&(e.title!==t.title&&(r=!1),e._text&&t.title.includes(e.title)&&(r=!0)),e.details&&(e.details!==t.body&&(r=!1),e._text&&(null===(n=t.body)||void 0===n?void 0:n.includes(e.details))&&(r=!0)),r};class zf{constructor(){this.include=[],this.exclude=[]}}var Gf;!function(e){e.DISMISS="DISMISS",e.SNOOZE="SNOOZE",e.SPAWN="SPAWN",e.QUERY="QUERY",e.PUBLISH="PUBLISH",e.TRANSMIT="TRANSMIT"}(Gf||(Gf={}));const Hf=(e,t)=>{if(!t)return!0;if(t.exclude){if(t.exclude.find(({type:t})=>t===e.type))return!1;if(t.exclude.find(({source:t})=>t===e.source))return!1}if(t.include&&t.include.length){const n=Object.entries(e);return Object.entries(t.include).some(([t,r])=>Object.entries(r).every(([t,r])=>{if(t.includes(".")){const n=(0,Qp.get)(e,t,void 0);return r===n}return n.some(([e,n])=>t===e&&r===n)}))}return!0},Vf=(e,t)=>({action:`finsemble-notification-polyfill-${e.type}`,title:e.buttonText,interop:{method:"FSBL.Clients.NotificationClient.performAction",arguments:{id:t.id,...e,payload:{notification:t,actionPayload:e.payload}}}}),Qf=(e,t)=>{var n,r;if(!(null==t?void 0:t.types))return e;let o;const i=e.type;if(i&&(null===(n=null==t?void 0:t.types)||void 0===n?void 0:n[i])?o=t.types[i]:(null===(r=null==t?void 0:t.types)||void 0===r?void 0:r.default)&&(o=t.types.default),o&&o.hasOwnProperty("defaults"))for(const[t,n]of Object.entries(o.defaults)){const r=e[t];(null==r||""===r||Array.isArray(r)&&0===r.length)&&(e[t]=n)}return e},Jf=e=>{var t,n,r;const o={title:null!==(t=e.title)&&void 0!==t?t:"Notification"};return o.id=e.id,"details"in e&&(o.body=e.details),"contentLogo"in e&&(o.icon=e.contentLogo),"timeout"in e&&(o.toastExpiry=(null!==(n=e.timeout)&&void 0!==n?n:3e3)/1e3),"actions"in e&&(o.actions=e.actions.flatMap(t=>{const n=Vf(t,e);return n?[n]:[]})),"type"in e&&(o.type=e.type),o.data={...e.meta},"cssClassName"in e&&(o.data.cssClassName=e.cssClassName),o.data.issuedAt=null!==(r=e.issuedAt)&&void 0!==r?r:new Date,o},Kf=(e,t=null)=>{var n,r,o,i,s;const a=e.timestamp?1e3*e.timestamp:(new Date).getTime();let l=new Date(a).toISOString();try{l=new Date(null!==(r=null===(n=e.data)||void 0===n?void 0:n.issuedAt)&&void 0!==r?r:a).toISOString()}catch(e){}const u=null===(o=null==t?void 0:t.muted)||void 0===o?void 0:o.includes(e.source);return JSON.parse(JSON.stringify({actions:[],actionsHistory:[],stateHistory:[],id:null!==(i=e.id)&&void 0!==i?i:Zp()(),issuedAt:l,receivedAt:new Date(a).toISOString(),meta:e.data,title:e.title,source:e.source,details:e.body,contentLogo:e.icon,timeout:e.toastExpiry,type:e.type,cssClassName:null===(s=e.data)||void 0===s?void 0:s.cssClassName,isRead:"Active"!==e.state,isDeleted:"Closed"===e.state,isSnoozed:"Snoozed"===e.state,isMuted:null!=u&&u}))};class Yf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.Notification=jf,this.ActionTypes=Gf,this.Subscription=qf,this.Action=Bf,this.Filter=zf,this.actionTypes=Gf,this.subscriptionMap=new Map,this.notificationServiceConfig={};const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,t.finishConstructor(r),this.initializeNotificationConfig()})}async initializeNotificationConfig(){var e;const t=null!==(e=await this.glue.contexts.get(tg))&&void 0!==e?e:{};this.notificationServiceConfig=(0,Qp.get)(t,"finsemble.servicesConfig.notifications".split("."),{})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"NotificationClient",method:e,type:t,data:n})}async onClose(e){this.unsubscribeAll(),null==e||e()}async getPreferences(){this.logStatus("getPreferences","start"),await this.asyncConstructors.ready();const e=await this.glue.notifications.getConfiguration(),t={disableDotOnToolbarIcon:!1,showDotOnToolbarIconForMutedNotifications:e.showNotificationBadge,informationalNotificationToastPeriodSeconds:e.toastExpiry/1e3,defaultSnoozePeriodSeconds:e.snooze.duration,newNotificationHaloPeriodSeconds:0,toastTimeoutOnActionableNotifications:!0};return this.logStatus("getPreferences","return",t),t}async getMuteFilters(){this.logStatus("getMuteFilters","start"),await this.asyncConstructors.ready();const e=(await this.glue.notifications.getFilter()).muted.map(e=>({source:e}));return this.logStatus("getMuteFilters","return",e),e}async getSources(){return this.logStatus("getSources","start"),await this.asyncConstructors.ready(),console.warn("NotificationClient.getSources() is not available in iocd"),this.logStatus("getSources","return",[]),[]}async unmute(e){this.logStatus("unmute","start",e),await this.asyncConstructors.ready();const t=(Array.isArray(e)?e:[e]).map(e=>e.source),n=await this.glue.notifications.getFilter();n.muted=n.muted.filter(e=>!t.includes(e)),await this.glue.notifications.setFilter(n),this.logStatus("unmute","return")}async mute(e){this.logStatus("mute","start",e),await this.asyncConstructors.ready();const t=(Array.isArray(e)?e:[e]).map(e=>e.source),n=await this.glue.notifications.getFilter();n.muted=n.muted.concat(t),await this.glue.notifications.setFilter(n),this.logStatus("mute","return")}unsubscribeAll(){this.logStatus("unsubscribeAll","start"),this.subscriptionMap.forEach(e=>{e.unsubscribe()}),this.subscriptionMap.clear(),this.logStatus("unsubscribeAll","return")}async unsubscribe(e){var t,n;this.logStatus("unsubscribe","start",e),await this.asyncConstructors.ready(),null===(n=null===(t=this.subscriptionMap.get(e))||void 0===t?void 0:t.unsubscribe)||void 0===n||n.call(t),this.logStatus("unsubscribe","return")}async subscribe(e,t){var n,r,o;this.logStatus("subscribe","start",e),await this.asyncConstructors.ready();const i=this.glue.notifications.onClosed(async e=>{this.logStatus("subscribe","debug",`Received closed for ${e.id}`),e.isDeleted=!0,t(e)}),s=this.glue.notifications.onStateChanged(async(n,r)=>{if(this.logStatus("subscribe","debug",`Received state ${r} for ${n.id}`),"Active"===r)return;const o=(await this.glue.notifications.list()).find(e=>e.id===n.id);if(!o)return void this.logStatus("subscribe","warn","Can't find notification id for state change");o.isDeleted=!0;const i=await this.glue.notifications.getFilter(),s=Kf(o,i);Hf(s,e.filter)?t(s):this.logStatus("subscribe","debug",{message:"Filtered notification",notification:o})}),a=this.glue.notifications.onRaised(async n=>{const r=await this.glue.notifications.getFilter(),o=Kf(n,r);Hf(o,e.filter)?t(o):this.logStatus("subscribe","debug",{message:"Filtered notification",glueNotification:n,finsembleNotification:o})}),l=null!==(n=e.id)&&void 0!==n?n:Zp()();return this.subscriptionMap.set(l,{unsubscribe:()=>{a(),s(),i()}}),this.logStatus("subscribe","return",{id:l,channel:null!==(r=e.channel)&&void 0!==r?r:""}),{id:l,channel:null!==(o=e.channel)&&void 0!==o?o:""}}async notify(e){this.logStatus("notify","start",e),await this.asyncConstructors.ready();const t=Array.isArray(e)?e:[e],n=await this.glue.notifications.list();for(const e of t){const t=Qf(e,this.notificationServiceConfig),r=Jf(t),o=t.id&&n.some(e=>e.id===r.id);o&&await pg(()=>this.glue.notifications.clear(r.id));const{err:i}=await pg(()=>this.glue.notifications.raise(r));i?this.loggerClient.debug(`NotificationClient.Notify:raise ${i}`):this.loggerClient.debug("[FSBL] [NotificationClient.notify] raised notification: ",e," Post-process details",r)}this.logStatus("notify","return")}async deleteNotifications(e){this.logStatus("deleteNotifications","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.clear(e.id)}),this.logStatus("deleteNotifications","return")}async markUnread(e){this.logStatus("markUnread","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.setState(e.id,"Active")}),this.logStatus("markUnread","return")}async markRead(e){this.logStatus("markRead","start",e),await this.asyncConstructors.ready(),await ag(e,async e=>{e.id&&await this.glue.notifications.setState(e.id,"Acknowledged")}),this.logStatus("markRead","return")}async performAction(e,t){this.logStatus("performAction","start",{notifications:e,action:t}),await this.asyncConstructors.ready(),this.logStatus("performAction","debug",{action:t,notifications:e}),await ag(e,async e=>{const n=Vf(t,e);n?await gg(()=>this.glue.interop.invoke(n.interop.method,n.interop.arguments)):this.logStatus("performAction","error",`Unable to parse action ${t}`)}),this.logStatus("performAction","return")}async getLastIssuedAt(e){var t,n;this.logStatus("getLastIssuedAt","start",e),await this.asyncConstructors.ready();const r=await gg(()=>this.glue.interop.invoke("FSBL.Clients.NotificationClient.getLastIssuedAt",{source:e}));return this.logStatus("getLastIssuedAt","return",r),null!==(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.lastIssuedAt)&&void 0!==n?n:""}async fetchHistory(e,t){this.logStatus("fetchHistory","start",{options:e,filter:t}),await this.asyncConstructors.ready();const n="string"==typeof e?{sentAfter:e}:e,r=((null==n?void 0:n.sentBefore)?new Date(null==n?void 0:n.sentBefore):new Date).getTime(),o=((null==n?void 0:n.sentAfter)?new Date(null==n?void 0:n.sentAfter):new Date(0)).getTime(),i=(await this.glue.notifications.list()).filter(e=>{const t=(e.timestamp?new Date(1e3*e.timestamp):new Date).getTime();return!(r&&t>r||o&&t<o)}),s=t?((e,t)=>{const{exclude:n=[],include:r=[]}=t;return e.filter(e=>{let t=!0;return r.length&&(t=!1,r.some(t=>Uf(t,e))&&(t=!0)),n.some(t=>Uf(t,e))&&(t=!1),t})})(i,t):i,a=await this.glue.notifications.getFilter(),l=s.map(e=>Kf(e,a));return this.logStatus("fetchHistory","return",l),l}}class Zf{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n,this.subscriptions={};const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.transmit",method:e,type:t,data:n})}addListener(e,t){this.logStatus("addListener","start",{channel:e});let n=null;return(async()=>{var r;await this.asyncConstructors.ready(),n=await this.glue.bus.subscribe(e,(n,r,o)=>{const{peerId:i="Unknown peer"}=o,s={data:n._data,originatedHere:()=>o.peerId===this.glue.interop.instance.peerId,options:{suppressWarnings:!1},header:{type:"transmit",channel:e,incomingTransportInfo:{lastClient:i,origin:i,transportID:"FinsembleTransport"},lastClient:i,origin:i,originMetadata:{routerConnectionId:"",transportInfo:{transportID:"FinsembleTransport"},windowName:"",appId:"",webContentsName:""}}};t(null,s)}),this.subscriptions[e]=(null!==(r=this.subscriptions[e])&&void 0!==r?r:[]).concat({iocdSubscription:n,eventHandler:t})})(),this.logStatus("addListener","return"),()=>{var t;n&&(this.subscriptions[e]=(null!==(t=this.subscriptions.channel)&&void 0!==t?t:[]).filter(e=>e.iocdSubscription!==n),this.subscriptions[e].length||delete this.subscriptions[e],n.unsubscribe())}}removeListener(e,t){this.logStatus("removeListener","start",{channel:e}),(async()=>{var n,r;await this.asyncConstructors.ready(),(null!==(n=this.subscriptions[e])&&void 0!==n?n:[]).forEach(n=>{t&&n.eventHandler!==t||(n.iocdSubscription.unsubscribe(),this.subscriptions[e]=this.subscriptions[e].filter(e=>e!==n))}),(null===(r=this.subscriptions[e])||void 0===r?void 0:r.length)||delete this.subscriptions[e]})(),this.logStatus("removeListener","return")}async transmit(e,t,n){this.logStatus("transmit","start",{toChannel:e}),await this.asyncConstructors.ready();try{await this.glue.bus.publish(e,{_data:t})}catch(e){console.error("Router transmit() error calling invoke",e)}this.logStatus("transmit","return")}}class Xf{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.lastSubId=0,this.unsubscribeFunctions={},this.catalogue={},this.gate=new og,this.alreadyRegisteredWithIOCD=!1,this.responders=[];const r=t.addConstructor();e.then(e=>{this.glue=e,this.initialize(),t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.pubsub",method:e,type:t,data:n})}async initialize(){await this.glue.contexts.subscribe("finsemble-pubsub-catalogue",e=>{this.catalogue=e})}getLocalResponder(e){const t=this.responders.find(t=>t.topic===e),n=this.responders.find(t=>new RegExp(t.topic).test(e));return null!=t?t:n}handleIncomingPublish(e,t,n){var r;e.publishCallback?e.publishCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===this.glue.interop.instance.peerId,sendNotifyToAllSubscribers:(n,r)=>{var o;n||null===(o=e.updateCallback)||void 0===o||o.call(e,t.topic,r)}}):null===(r=e.updateCallback)||void 0===r||r.call(e,t.topic,t.data)}handleIncomingSubscribe(e,t,n){var r;const o=new Kp;return e.subscribeCallback?(e.subscribeCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===e.peerId,sendNotifyToSubscriber:(t,n)=>{o.resolve({error:t||void 0,data:n?{data:n}:void 0,initialData:e.initialState})}}),o.promise):Promise.resolve({data:void 0,initialData:null!==(r=e.initialState)&&void 0!==r?r:{}})}handleIncomingUnsubscribe(e,t,n){var r;const o=new Kp;return e.unsubscribeCallback?(e.unsubscribeCallback(null,{data:t.data,header:t.header,options:t.options,originatedHere:()=>n.peerId===e.peerId,removeSubscriber:()=>{var t;o.resolve({data:void 0,initialData:null!==(t=e.initialState)&&void 0!==t?t:{}})}}),o.promise):Promise.resolve({data:void 0,initialData:null!==(r=e.initialState)&&void 0!==r?r:{}})}async registerResponder(e,t,n){var r,o,i;const s=e instanceof RegExp?e.source:e;if(this.responders.find(e=>s===e.topic))throw new Error(`Router:registerResponder(): A local responder for topic already exists:'${s}'`);if(this.responders.push({topic:s,initialState:n,updateCallback:(e,t)=>{const n=`finsemble-pubsub-topic-${e}`;this.glue.contexts.set(n,t)},subscribeCallback:null==t?void 0:t.subscribeCallback,unsubscribeCallback:null==t?void 0:t.unsubscribeCallback,publishCallback:null==t?void 0:t.publishCallback,peerId:null!==(r=this.glue.interop.instance.peerId)&&void 0!==r?r:"Unknown peer"}),!this.alreadyRegisteredWithIOCD){const{err:e}=await pg(()=>this.glue.interop.register("finsemble-pubsub-responder",ig(async(e,t)=>{const n=this.getLocalResponder(e.topic);if(n)if("publish"===e.action)this.handleIncomingPublish(n,e,t);else{if("subscribe"===e.action)return this.handleIncomingSubscribe(n,e,t);if("unsubscribe"===e.action)return this.handleIncomingUnsubscribe(n,e,t)}})));if(e)return{err:e};this.alreadyRegisteredWithIOCD=!0}const a=null!==(o=this.glue.interop.instance.peerId)&&void 0!==o?o:"Unknown peer",l=(null!==(i=this.catalogue[a])&&void 0!==i?i:[]).concat({topic:s,isRegex:e instanceof RegExp,peerId:a}),{err:u}=await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[a]:l}));return{err:u}}findRemoteResponder(e){const t=e=>this.glue.interop.servers().find(t=>t.peerId===e),n=Object.keys(this.catalogue).filter(e=>!t(e));if(n){let e={};n.forEach(t=>{e[t]=null,delete this.catalogue[t]}),this.glue.contexts.update("finsemble-pubsub-catalogue",e)}const r=Object.keys(this.catalogue).find(t=>this.catalogue[t].find(t=>!t.isRegex&&t.topic===e)),o=Object.keys(this.catalogue).find(t=>this.catalogue[t].find(t=>t.isRegex&&new RegExp(t.topic).test(e)));return null!=r?r:o}subscribe(e,t){this.logStatus("subscribe","start",{topic:e});const n=""+this.lastSubId++;return(async()=>{var r,o,i,s,a,l;await this.asyncConstructors.ready();const u=this.findRemoteResponder(e),c=`finsemble-pubsub-topic-${e}`;let d=!1;const h=await this.glue.contexts.subscribe(c,(n,r,o,i,s)=>{var a;if(!d)return;const l={data:null!==(a=null==n?void 0:n.envelope)&&void 0!==a?a:n,header:{topic:e,type:"",origin:"",subscribeID:""},originatedHere:()=>!s.updateId};t(void 0,l)}),p=async()=>{h();const{err:t}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{action:"unsubscribe",topic:e,options:{},header:{}},{peerId:u},{waitTimeoutMs:3e4}));t&&this.logStatus("unsubscribe","error",t)};let g=null;if(u){const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{action:"subscribe",topic:e,options:{},header:{}},{peerId:u},{waitTimeoutMs:3e4}));if(g=null!=r?r:null,n)return p(),void t(n,{})}this.unsubscribeFunctions[n]=p;let f=await this.glue.contexts.get(c);0===Object.keys(f).length&&(f=void 0);const m=this.getLocalResponder(e);let y=null;if(null==m?void 0:m.subscribeCallback){const t=new Kp;m.subscribeCallback(null,{data:{topic:e},header:{},options:{suppressWarnings:!1},originatedHere:()=>!0,sendNotifyToSubscriber:(e,n)=>{t.resolve(n)}}),y=await t.promise}const w=null!==(s=null!==(i=null!==(o=null!==(r=null==g?void 0:g.data)&&void 0!==r?r:f)&&void 0!==o?o:null==g?void 0:g.initialData)&&void 0!==i?i:y)&&void 0!==s?s:null==m?void 0:m.initialState;t(void 0,{data:null!==(l=null!==(a=null==w?void 0:w.envelope)&&void 0!==a?a:w)&&void 0!==l?l:{},header:{topic:e,type:"",origin:"",subscribeID:""},originatedHere:()=>!1}),d=!0})(),this.logStatus("subscribe","return"),{subscribeID:n,topic:e}}unsubscribe(e){this.logStatus("unsubscribe","start",{subscribeIDStruct:e});const t=this.unsubscribeFunctions[e.subscribeID];t?t():setTimeout(()=>{this.unsubscribe(e)},100),this.logStatus("unsubscribe","return")}async publish(e,t){this.logStatus("publish","start",{topic:e}),await this.asyncConstructors.ready(),await this.gate.wait(async()=>{let n=this.findRemoteResponder(e);const r={envelope:t,transactionID:Zp()()};if(n){const{err:t}=await gg(()=>this.glue.interop.invoke("finsemble-pubsub-responder",{data:r,action:"publish",topic:e,options:{},header:{}},{peerId:n}));t&&this.logStatus("publish","error",t)}else{const t=`finsemble-pubsub-topic-${e}`;this.glue.contexts.set(t,r)}}),this.logStatus("publish","return")}addPubSubResponder(e,t,n,r){return this.logStatus("addPubSubResponder","start",{topic:e}),(async()=>{await this.asyncConstructors.ready();const{err:o}=await this.registerResponder(e,null!=n?n:{},{envelope:t});o&&this.logStatus("addPubSubResponder","error",{topic:e,err:o}),null==r||r(null!=o?o:void 0,o?void 0:"success"),this.logStatus("addPubSubResponder","return")})()}async removePubSubResponder(e){var t,n;this.logStatus("removePubSubResponder","start",{topic:e}),this.responders=this.responders.filter(t=>t.topic!==e);const r=await this.glue.contexts.get("finsemble-pubsub-catalogue"),o=null!==(t=this.glue.interop.instance.peerId)&&void 0!==t?t:"Unknown peer",i=(null!==(n=r[o])&&void 0!==n?n:[]).filter(t=>t.topic!==e),{err:s}=await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[o]:i}));s&&this.logStatus("removePubSubResponder","error",{err:s}),this.logStatus("removePubSubResponder","return")}trustedMessage(e){return!0}async disconnectAll(){var e;this.logStatus("disconnectAll","start"),await this.asyncConstructors.ready(),Object.values(this.unsubscribeFunctions).forEach(e=>e()),this.unsubscribeFunctions={};const t=null!==(e=this.glue.interop.instance.peerId)&&void 0!==e?e:"Unknown peer";await pg(()=>this.glue.contexts.update("finsemble-pubsub-catalogue",{[t]:null})),await pg(()=>this.glue.interop.unregister("finsemble-pubsub-responder")),this.responders=[],this.logStatus("disconnectAll","return")}calibrateTimeWithRouterService(e){e(0)}}class em{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"Router.queries",method:e,type:t,data:n})}isInteropEndpointRegistered(e){return this.glue.interop.methods().some(t=>t.name===e)}async addResponder(e,t){if(this.logStatus("addResponder","start",{channel:e}),await this.asyncConstructors.ready(),this.isInteropEndpointRegistered(e)){const t=`addResponder failed because responder already added to ${e}`;throw this.logStatus("addResponder","error",t),new Error(t)}await this.glue.interop.register(e,ig(async(n,r)=>{var o,i,s;const a=new Kp,l={origin:null!==(o=r.instance)&&void 0!==o?o:"Unknown origin",type:"query",queryID:"",channel:e,logWhenNoResponder:!1,error:null,subscribeID:e,lastClient:"",incomingTransportInfo:{lastClient:"",origin:null!==(i=r.instance)&&void 0!==i?i:"",transportID:"FinsembleTransport"}},u={data:null!==(s=null==n?void 0:n["#primitives-wrapper"])&&void 0!==s?s:n,header:l,options:{suppressWarnings:!1},sendQueryResponse:(e,t)=>{const n="object"!=typeof t||Array.isArray(t)?{"#primitives-wrapper":t}:t;a.resolve({err:e,data:n})},originatedHere:()=>{var e,t;return r.windowId===(null!==(t=null===(e=this.glue.windows.my())||void 0===e?void 0:e.id)&&void 0!==t?t:"Unknown or incompatible window type")}};return t(null,u),this.logStatus("addResponder","return"),await a.promise}))}removeResponder(e){this.logStatus("removeResponder","start",{responderChannel:e}),this.glue.interop.unregister(e),this.logStatus("removeResponder","return")}async query(e,t,n,r){var o;this.logStatus("query","start",{channel:e}),await this.asyncConstructors.ready();const i="function"==typeof n?n:r,s="object"!=typeof t||Array.isArray(t)?{"#primitives-wrapper":t}:t,a=null==n?void 0:n.timeout,l=a?{methodResponseTimeoutMs:a}:void 0,u={channel:e,topic:e,type:"",origin:"",subscribeID:e,lastClient:"",incomingTransportInfo:{lastClient:"",origin:"",transportID:"FinsembleTransport"},originMetadata:{routerConnectionId:"",transportInfo:{transportID:"FinsembleTransport"},windowName:"",appId:"",webContentsName:""}};if(!this.isInteropEndpointRegistered(e)){const t=`query failed since no responder on ${e}`;return this.logStatus("query","error",t),null==i||i(t,{header:u}),{err:t,response:{header:u}}}const{err:c,data:d}=await gg(()=>this.glue.interop.invoke(e,s,void 0,l)),h={data:null!==(o=null==d?void 0:d["#primitives-wrapper"])&&void 0!==o?o:d,header:u};return this.logStatus("query","return"),null==i||i(c,h),{err:c,response:h}}}class tm{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n,this.transmitter=new Zf(e,this.asyncConstructors,n),this.pubSub=new Xf(e,this.asyncConstructors,n),this.queries=new em(e,this.asyncConstructors,n)}async onReady(e){await this.asyncConstructors.ready(),null==e||e()}async onFailure(e){}addListener(e,t){return this.transmitter.addListener(e,t)}removeListener(e,t){return this.transmitter.removeListener(e,t)}transmit(e,t,n){return this.transmitter.transmit(e,t,n)}addResponder(e,t){this.queries.addResponder(e,t)}removeResponder(e){this.queries.removeResponder(e)}query(e,t,n,r){return this.queries.query(e,t,n,r)}subscribe(e,t){return this.pubSub.subscribe(e,t)}publish(e,t){return this.pubSub.publish(e,t)}addPubSubResponder(e,t,n,r){return this.pubSub.addPubSubResponder(e,t,n,r)}removePubSubResponder(e){return this.pubSub.removePubSubResponder(e)}unsubscribe(e){this.pubSub.unsubscribe(e)}trustedMessage(e){return this.pubSub.trustedMessage(e)}disconnectAll(){var e;null===(e=this.pubSub)||void 0===e||e.disconnectAll()}}class nm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.providers=[];const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"SearchClient",method:e,type:t,data:n})}async invokeProviderAction(e){console.warn("This method is deprecated")}async invokeItemAction(e,t){var n,r;this.logStatus("invokeItemAction","start",{item:e,action:t});const o=`${e.provider}.ActionHandler`,i=t.method?t.method:o,s=t.params?t.params:{item:e,action:t,windowName:null!==(r=null===(n=this.glue.windows.my())||void 0===n?void 0:n.id)&&void 0!==r?r:"Unknown Window"},{err:a}=await gg(()=>this.glue.interop.invoke(i,s,t.target));a&&this.logStatus("invokeItemAction","error",a),this.logStatus("invokeItemAction","return")}async search(e,t){if(this.logStatus("search","start",e),e.text&&""!==e.text)try{const n=await this.glue.search.query({search:e.text}),r=[];n.onError(({error:e})=>{this.logStatus("search","error",e),null==t||t(e)}),n.onResults(e=>{var n,o,i,s;r.push({data:e.results.map(({id:t,displayName:n,type:r,metadata:o,description:i,iconURL:s,action:a,secondaryActions:l})=>{var u,c;const d=(a?[a]:[]).concat(null!=l?l:[]);return{name:null!=n?n:t,type:r.name,score:1,description:i,icon:s?{imageType:"url",path:null!=s?s:""}:null,category:null!==(u=r.displayName)&&void 0!==u?u:r.name,actions:d,...o,provider:null===(c=e.provider)||void 0===c?void 0:c.name}}),provider:{displayName:null!==(o=null===(n=e.provider)||void 0===n?void 0:n.name.replace(Qg,""))&&void 0!==o?o:"Desktop",channel:null!==(s=null===(i=e.provider)||void 0===i?void 0:i.name)&&void 0!==s?s:"Desktop",providerActionCallback:!1,providerActionTitle:void 0}}),this.logStatus("search","return",{err:null,data:r}),null==t||t(null,r)})}catch(e){this.logStatus("search","error",e),null==t||t(e)}else null==t||t(null,[])}async unregister(e,t){this.logStatus("unregister","start",e),await this.asyncConstructors.ready(),await ag(this.providers,async({name:t,provider:n})=>{if(t===e.name){console.debug("FSBL.Clients.SearchClient.unregister removing",t);const e=`${Qg}${t}.ActionHandler`,{err:r}=await pg(()=>this.glue.interop.unregister(e));r&&console.warn("FSBL.Clients.SearchClient.unregister exception unregistering action handler",r),await n.unregister()}}),this.providers=this.providers.filter(({name:t})=>t!==e.name),this.logStatus("unregister","return"),null==t||t()}async register(e,t){this.logStatus("register","start",e),await this.asyncConstructors.ready(),(e.providerActionTitle||e.providerActionCallback)&&console.warn("Search Provider options 'providerActionTitle' and 'providerActionCallback' are deprecated.");const n=await(async(e,t)=>{const n=`${Qg}${t.name}`,r=`${n}.ActionHandler`,o=await e.search.registerProvider({name:n});return await pg(()=>e.interop.register(r,async e=>{console.debug("Action handler received",o.id,e);const n=t.itemActionCallback;n?n(e):console.warn("Action provider not found for",o.id,e)})),o.onQuery(e=>{t.searchCallback({text:e.search},(t,n)=>{const o=Array.isArray(n)?n:[n];t?e.error(t):(o.forEach(t=>{const{name:n,type:o,description:i,actions:s=[],...a}=t,l=s.map(e=>({name:e.name,method:r}));e.sendResult({type:{name:o},description:i,displayName:n,action:l.shift(),secondaryActions:l,metadata:{...a}})}),e.done())})}),{name:t.name,provider:o}})(this.glue,e);return this.providers.push(n),this.logStatus("register","return",{err:null,status:"success"}),null==t||t(null,{status:"success"}),{err:null,data:{status:"success"}}}}class rm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n;const r=this.asyncConstructors.addConstructor();e.then(e=>{this.glue=e,this.asyncConstructors.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"StorageClient",method:e,type:t,data:n})}async clearCache(e,t){this.logStatus("clearCache","start",t),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.clearCache",{...t}),e);return n&&this.logStatus("remove","error",n),this.logStatus("clearCache","return"),{err:n}}async remove(e,t){this.logStatus("remove","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.remove",e),t);return n&&this.logStatus("remove","error",n),this.logStatus("remove","return"),{err:n}}async keys(e,t){this.logStatus("keys","start",e),await this.asyncConstructors.ready();const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.keys",e),t);return n&&this.logStatus("keys","error",n),this.logStatus("keys","return",r),{err:n,data:r}}async getStandardized(e,t){this.logStatus("getStandardized","start",e),await this.asyncConstructors.ready();const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.get",e),t);return n&&this.logStatus("getStandardized","error",n),this.logStatus("getStandardized","return",r),{err:n,data:r}}async getMultiple(e,t){return this.logStatus("getMultiple","deprecated","Not Implemented"),{err:"get multiple is not implemented"}}async save(e,t){this.logStatus("save","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>{var t;return this.glue.interop.invoke("FSBL.Clients.StorageClient.save",{key:null!==(t=e.key)&&void 0!==t?t:e.field,value:e.value,topic:e.topic})},t);return n&&this.logStatus("save","error",n),this.logStatus("save","return"),{err:n}}async setUser(e,t){this.logStatus("setUser","start",e),await this.asyncConstructors.ready();const{err:n}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.StorageClient.setUser",e),t);return n&&this.logStatus("setUser","error",n),this.logStatus("setUser","return"),{err:n}}async get(e,t){this.logStatus("get","start",e);const n=await this.getStandardized(e,t);return this.logStatus("get","return",n),n.data}}class om{async initialize(e){var t,n,r,o,i,s,a;if(!this.glue.windows)return;this.windowIdentifier=await lg(this.glue);const l=null!=e?e:null===(t=this.windowIdentifier)||void 0===t?void 0:t.windowName,u=this.glue.windows.findById(l);if(!u)return void(globalThis.window&&this.loggerClient.warn("INVARIANT: WindowClient cannot find window",l));this.gdwin=u;const c=await(null===(n=this.gdwin)||void 0===n?void 0:n.getContext()),d=null!==(r=await Wg(this.gdwin))&&void 0!==r?r:{};this.spawnData=null!==(o=null==c?void 0:c["#finsemble-spawnData"])&&void 0!==o?o:{},this.options={customData:{...null==d?void 0:d.customProperties,...null===(a=null===(s=null===(i=null==d?void 0:d.customProperties)||void 0===i?void 0:i.appd)||void 0===s?void 0:s.hostManifests)||void 0===a?void 0:a.Finsemble,...this.spawnData,spawnData:this.spawnData}}}constructor(e,t,n,r){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.gate=new og;const o=t.addConstructor();this.loggerClient.debug("WindowClient Constructor"),this.options={customData:{}},e.then(async e=>{this.glue=e,this.initialize(r).finally(()=>{this.loggerClient.debug("WindowClient Initialized"),t.finishConstructor(o)})})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"WindowClient",method:e,type:t,data:n})}async showAtMousePosition(){var e,t,n,r,o,i;this.logStatus("showAtMousePosition","start"),await this.asyncConstructors.ready();const s=await this.glue.displays.getMousePosition(),a=await this.gdwin.getBounds();a.top=(null!==(e=null==s?void 0:s.y)&&void 0!==e?e:0)-(null!==(t=a.height)&&void 0!==t?t:0)+10,a.left=(null!==(n=null==s?void 0:s.x)&&void 0!==n?n:0)-(null!==(r=a.width)&&void 0!==r?r:0)/2,a.right=a.left+(null!==(o=a.width)&&void 0!==o?o:0),a.bottom=a.top+(null!==(i=a.height)&&void 0!==i?i:0),await this.gdwin.show(),await this.gdwin.moveResize(a),await this.gdwin.focus(),this.logStatus("showAtMousePosition","return")}async setWindowTitle(e){this.logStatus("setWindowTitle","start",{title:e}),await this.asyncConstructors.ready(),await this.gdwin.setTitle(e),this.logStatus("setWindowTitle","return")}setTaskbarIconOverlay(e){this.logStatus("setTaskbarIconOverlay","start",{url:e}),console.log("setTaskbarIconOverlay() is not implemented"),this.logStatus("setTaskbarIconOverlay","return")}setShape(e,t){console.log("WindowClient.setShape() is no longer supported.")}async getComponentState(e,t){this.logStatus("getComponentState","start",e),await this.asyncConstructors.ready();const n=(null==e?void 0:e.windowName)?this.glue.windows.findById(e.windowName):this.gdwin,r=await Cg(e,n);return this.logStatus("getComponentState","return",{err:null,data:r}),null==t||t(r.err,r.data),r}async setComponentState(e,t){return await this.gate.wait(async()=>this.setComponentStateInternal(e,t))}async setComponentStateInternal(e,t){this.logStatus("setComponentState","start",e),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await Ig(e,n);return this.logStatus("setComponentState","return",r),null==t||t(r.err,r.data),r}async setAlwaysOnTop(e,t){this.logStatus("setAlwaysOnTop","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.setOnTop(e),t);return this.logStatus("setAlwaysOnTop","return",{err:n}),{err:n}}async retrieveMonitorDimensions(e){this.logStatus("retrieveMonitorDimensions","start"),await this.asyncConstructors.ready();const t=await this.gdwin.getDisplay(),n={left:t.bounds.left*t.scaleFactor,top:t.bounds.top*t.scaleFactor,width:t.bounds.width,height:t.bounds.height};n.right=n.left+n.width,n.bottom=n.top+n.height,this.logStatus("retrieveMonitorDimensions","return",n),e(n)}async restore(e){this.logStatus("restore","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.restore(),e);return this.logStatus("restore","return",{err:t}),{err:t}}async removeFromTabCollection({windowNames:e}){this.logStatus("removeFromTabCollection","start",{windowNames:e}),await this.asyncConstructors.ready(),await sg(e,async e=>{const t=this.glue.windows.findById(e);await(null==t?void 0:t.detachTab({}))}),this.logStatus("removeFromTabCollection","return")}async removeComponentState(e,t){this.logStatus("removeComponentState","start",e),await this.asyncConstructors.ready();const n=e.windowName?this.glue.windows.findById(e.windowName):this.gdwin,r=await kg(e,n);return this.logStatus("removeComponentState","return",r),null==t||t(r.err,r.data),r}async promoteTab(e){this.logStatus("promoteTab","start",{windowName:e}),await this.asyncConstructors.ready();const t=this.glue.windows.findById(e);await(null==t?void 0:t.activate()),this.logStatus("promoteTab","return")}async minimize(e){this.logStatus("minimize","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.minimize(),e);return this.logStatus("minimize","return",{err:t}),{err:t}}async maximize(e){this.logStatus("maximize","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.maximize(),e);return this.logStatus("maximize","return",{err:t}),{err:t}}getWindowIdentifier(){return this.logStatus("getWindowIdentifier","start"),this.logStatus("getWindowIdentifier","return",this.windowIdentifier),this.windowIdentifier}getWindowBounds(){const e="WindowClient.getWindowBounds() is no longer supported. Please use getBounds()";throw console.log(e),new Error(e)}async getWindowTitle(e){this.logStatus("getWindowTitle","start",e),await this.asyncConstructors.ready();const t=e?this.glue.windows.findById(e):this.gdwin,n=null==t?void 0:t.getTitle();return this.logStatus("getWindowTitle","return",n),null!=n?n:"Unknown Window"}async getTabCollectionForWindow({windowName:e},t){var n,r;this.logStatus("getTabCollectionForWindow","start",{windowName:e}),await this.asyncConstructors.ready();const o=this.glue.windows.findById(e);if(!o){const t=`No window found matching id ${e}`;return this.logStatus("getTabCollectionForWindow","error",t),{err:t}}const i={id:o.tabGroupId,windows:o.tabs.map(e=>e.id),promotedWindowName:null!==(r=null===(n=o.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id)&&void 0!==r?r:""};return this.logStatus("getTabCollectionForWindow","return",{err:null,data:i}),null==t||t(null,i),{data:i,err:null}}async getTabCollection({id:e},t){var n;this.logStatus("getTabCollection","start",{id:e}),await this.asyncConstructors.ready();const r=await this.findGlueWindowInTabGroup(e);if(!r){const t=`No window found in tabGroup id ${e}`;return this.logStatus("getTabCollection","error",{err:t}),{err:t}}const o={windows:r.tabs.map(e=>e.id),promotedWindowName:null===(n=r.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id};return null==t||t(null,o),{data:o,err:null}}getSpawnData(){this.logStatus("getSpawnData","start");const e=this.spawnData;return this.logStatus("getSpawnData","return",e),e}async getPromotedTab({tabCollectionId:e},t){var n;this.logStatus("getPromotedTab","start",{tabCollectionId:e}),await this.asyncConstructors.ready();const r=await this.findGlueWindowInTabGroup(e);if(!r){const t=`No window found in tabGroup id ${e}`;return this.logStatus("getPromotedTab","error",{err:t}),{err:t}}const o=null===(n=r.tabs.find(e=>!0===e.isTabSelected))||void 0===n?void 0:n.id;if(o)return this.logStatus("getPromotedTab","return",{err:null,data:o}),null==t||t(null,o),{err:null,data:o};{const n=`No promoted tab found for tab collection ${e}`;return this.logStatus("getPromotedTab","error",{err:n}),null==t||t(n),{err:n}}}async getMonitorInfo(e,t){await this.asyncConstructors.ready();const n=await this.gdwin.getDisplay(),r=qg(n);return r?{err:null,data:r}:{err:"Monitor not found. Check application.log"}}startMovingWindow(){console.log("WindowClient.startMovingWindow() is no longer supported")}stopMovingWindow(){console.log("WindowClient.stopMovingWindow() is no longer supported")}async getBounds(e){this.logStatus("getBounds","start"),await this.asyncConstructors.ready();const t=await this.gdwin.getBounds();return this.logStatus("getBounds","return",{err:null,data:t}),null==e||e(null,t),{err:null,data:t}}async formGroup(){this.logStatus("formGroup","start"),await Sg(this.glue,this.gdwin.id),this.logStatus("formGroup","return")}async fitToDOM(e,t){var n,r,o,i,s,a,l,u;this.logStatus("fitToDOM","start",e),await this.asyncConstructors.ready(),"function"==typeof e&&(t=e,e=null);const c=null!==(r=null===(n=null==e?void 0:e.padding)||void 0===n?void 0:n.height)&&void 0!==r?r:0,d=null!==(i=null===(o=null==e?void 0:e.padding)||void 0===o?void 0:o.width)&&void 0!==i?i:0,h=this.gdwin,p=await h.getBounds();if(!p)return this.logStatus("fitToDOM","return"),void(null==t||t());const g=await h.getDisplay(),f=null!==(s=g.workArea.height)&&void 0!==s?s:1/0,m=null!==(a=g.workArea.width)&&void 0!==a?a:1/0,y=Math.max(p.height-window.innerHeight,0),w=window.innerWidth-document.getElementsByTagName("html")[0].clientWidth,v=window.innerHeight-document.getElementsByTagName("html")[0].clientHeight?1:0,b=document.documentElement.offsetHeight+c+y+v,C=h.isVisible?document.documentElement.scrollWidth:p.width+d+w,S=Math.min(b,null!==(l=null==e?void 0:e.maxHeight)&&void 0!==l?l:b,f),I=Math.min(C,null!==(u=null==e?void 0:e.maxWidth)&&void 0!==u?u:C,m);p.width===I&&p.height===S||await h.moveResize({left:p.left,top:p.top,width:I,height:S}),this.logStatus("fitToDOM","return"),null==t||t()}async createTabCollection({windowNames:e,promotedTab:t}){var n;this.logStatus("createTabCollection","start",{windowNames:e,promotedTab:t}),await this.asyncConstructors.ready();const r=this.glue.windows.findById(null!==(n=e.shift())&&void 0!==n?n:"");await sg(e,async e=>{const n={};e===t&&(n.selected=!0),await(null==r?void 0:r.attachTab(e,n))}),this.logStatus("createTabCollection","return")}async close(e,t){this.logStatus("close","start"),e&&this.loggerClient.system.deprecated("The use of parameters in WindowClient.close() has been deprecated."),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.gdwin.close(),t);return this.logStatus("close","return",{err:n}),{err:n}}async bringToFront(e){this.logStatus("bringToFront","start"),await this.asyncConstructors.ready();const{err:t}=await pg(()=>this.gdwin.show()),{err:n}=await pg(()=>this.gdwin.focus()),r=null!=t?t:n;return r&&this.logStatus("bringToFront","error",r),this.logStatus("bringToFront","return"),{err:r}}async addToTabCollection({windowNames:e,tabCollectionId:t,position:n,promotedTab:r}){this.logStatus("addToTabCollection","start",{windowNames:e,tabCollectionId:t,position:n,promotedTab:r}),await this.asyncConstructors.ready();const o=await this.findGlueWindowInTabGroup(t);o?(await sg(e,async e=>{const t={};e===r&&(t.selected=!0),n&&(t.index=n,n++),await o.attachTab(e,t)}),this.logStatus("addToTabCollection","return")):this.logStatus("addToTabCollection","return")}async findGlueWindowInTabGroup(e){return await this.asyncConstructors.ready(),this.glue.windows.list().find(t=>(null==t?void 0:t.tabGroupId)===e)}addListeners(){console.log("WindowClient.addListeners() is no longer supported")}}function im(...e){let t="";return e.forEach(e=>{t=`${t} ${e}`}),t.replace(/\s(.)/g,e=>e.toUpperCase()).replace(/\s/g,"").replace(/^(.)/,e=>e.toLowerCase())}function sm(e,t){const n=/\(\d+\)$/,r=e.replace(n,"").trim(),o=[...t,e].filter(e=>im(e).includes(im(r))).map(e=>{const t=e.match(n);return null===t?0:Number(t[0].slice(1,-1))}),i=Math.max(...o)+1;return`${r} (${i})`}const am=async(e,t,n)=>{const{err:r,data:o}=await pg(()=>e.layouts.getAll("Global"));if(r||!o)return n.error(r),!1;const i=o.map(e=>e.name);return i.includes(t)?sm(t,i):t};class lm{constructor(e,t,n){this.gluePromise=e,this.asyncConstructors=t,this.loggerClient=n,this.debouncedUpdateLocalMembers=null,this.withoutChanges=null,this.handlers=[],this.activeWorkspace={version:"1.0.0",name:"Default workspace",type:"workspace",groups:{},windows:[]},this.workspaces=[];const r=t.addConstructor();this.loggerClient.debug("WorkspaceClient Constructor"),e.then(async e=>{this.glue=e,this.initialize().finally(()=>{this.loggerClient.debug("WorkspaceClient initialized"),t.finishConstructor(r)})}),this.minimizeAll=this.minimizeAll.bind(this),this.bringWindowsToFront=this.bringWindowsToFront.bind(this),this.autoArrange=this.autoArrange.bind(this)}async triggerWorkspaceEvent(e,t){const{err:n,data:r}=await Jg(this.glue,e,t);return n&&this.loggerClient.error("triggerWorkspaceEvent",e,t,n),{err:n,data:r}}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"WorkspaceClient",method:e,type:t,data:n})}async initialize(){const e=this.registerGlueEventHandlers(),t=this.updateLocalMembers();await eg().allSettled([e,t])}async updateGlobalLayouts(){const{err:e,data:t=[]}=await pg(()=>{var e;return null!==(e=this.glue.layouts.getAll("Global"))&&void 0!==e?e:[]});e&&this.loggerClient.error("WorkspaceClient.updateLocalMembers.getAll()",e),this.workspaces=t.map(e=>e.name)}async updateCurrentLayout(){const{err:e,data:t}=await pg(()=>this.glue.layouts.getCurrentLayout());if(e){if(e.toString().includes("Invocation timeout (30000 ms)"))return;this.loggerClient.error("WorkspaceClient.updateLocalMembers.getCurrentLayout()",e)}t&&(this.activeWorkspace=jg(t))}async updateLocalMembers(){return this.debouncedUpdateLocalMembers||(this.debouncedUpdateLocalMembers=(0,Qp.debounce)(async()=>{this.loggerClient.debug("WorkspaceClient updateLocalMembers");const e=this.updateCurrentLayout(),t=this.updateGlobalLayouts();await eg().allSettled([e,t])},1500)),await this.debouncedUpdateLocalMembers()}async registerGlueEventHandlers(){const e=this.glue.layouts.onAdded(()=>{this.updateLocalMembers()}),t=this.glue.layouts.onChanged(()=>{this.updateLocalMembers()}),n=this.glue.layouts.onRemoved(()=>{this.updateLocalMembers()}),r=this.glue.layouts.onRenamed(()=>{this.updateLocalMembers()}),o=this.glue.layouts.onRestored(()=>{this.updateLocalMembers()});await eg().allSettled([e,t,n,r,o])}async removeEventListener(e,t){this.logStatus("removeEventListener","start",{event:e}),await this.asyncConstructors.ready();const n=this.handlers.findIndex(n=>n.event===e&&n.handler===t);if(-1===n)return;const{uuid:r}=this.handlers[n];this.handlers.splice(n,1);const{err:o}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.removeEventListener",{event:e,id:r}));o&&this.logStatus("removeEventListener","error",o),this.glue.interop.unregister(r),this.logStatus("removeEventListener","return")}async addEventListener(e,t){this.logStatus("addEventListener","start",e),await this.asyncConstructors.ready();const n=Zp()();await this.glue.interop.register(n,ig(async e=>{let n=!1;const r=new Kp;if(t({data:e,wait:()=>{n=!0},done:e=>{r.resolve({action:"done",newData:e})},cancel:()=>{r.resolve({action:"cancel"})}}),n)return await r.promise})),this.handlers.push({event:e,handler:t,uuid:n});const{err:r}=await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.addEventListener",{event:e,uuid:n}));r&&this.logStatus("addEventListener","error",r),this.logStatus("addEventListener","return")}async autoArrange(e,t){this.logStatus("autoArrange","start"),await this.asyncConstructors.ready();const{err:n}=await pg(()=>this.glue.windows.autoArrange());return this.logStatus("autoArrange","return",{err:n}),null==t||t(n),{err:n}}async minimizeAll(e,t){this.logStatus("minimizeAll","start",e),await this.asyncConstructors.ready();const n=await dg(this.glue,e,t);return this.logStatus("minimizeAll","return",n),n}async bringWindowsToFront(e,t){this.logStatus("bringWindowsToFront","start",e),await this.asyncConstructors.ready();const n=await cg(this.glue,e,t);return this.logStatus("bringWindowsToFront","return",n),n}async getActiveWorkspacePreUserStage(){var e,t,n,r,o,i;const{err:s,data:a}=await pg(()=>this.glue.prefs.get("IO.Global.FinsemblePreferences"));s&&this.logStatus("getActiveWorkspace","error",s);const{err:l,data:u}=await pg(()=>this.glue.prefs.get("IO.Global.FinsembleLastWorkspace"));l&&this.logStatus("getActiveWorkspace","error",l);const{err:c,data:d}=await pg(()=>this.glue.contexts.get(tg));c&&this.logStatus("getActiveWorkspace","error",c);const h=null!==(i=null!==(r=null!==(t=null===(e=null==a?void 0:a.data)||void 0===e?void 0:e["finsemble.initialWorkspace"])&&void 0!==t?t:null===(n=null==d?void 0:d.finsemble)||void 0===n?void 0:n.initialWorkspace)&&void 0!==r?r:null===(o=null==u?void 0:u.data)||void 0===o?void 0:o.name)&&void 0!==i?i:"Default Workspace",{err:p,data:g}=await pg(()=>this.glue.layouts.get(h,"Global"));return p&&this.logStatus("getActiveWorkspace","error",p),g?{data:jg(g)}:null}async getActiveWorkspace(e,t){var n,r,o;if(this.logStatus("getActiveWorkspace","start"),await this.asyncConstructors.ready(),null===this.withoutChanges){const e=await this.glue.contexts.get(tg);this.withoutChanges=null!==(r=null===(n=null==e?void 0:e.iocd)||void 0===n?void 0:n.getActiveWorkspaceWithoutChanges)&&void 0!==r&&r}try{const n=await this.glue.layouts.getCurrentLayout();if(!n){const t=await this.getActiveWorkspacePreUserStage();if(t)return this.logStatus("getActiveWorkspace","return",t),null==e||e(null,t),t}if(n&&(null!=t?t:this.withoutChanges)){const t=jg(n);return this.logStatus("getActiveWorkspace","return",{data:t}),null==e||e(null,t),{data:t}}const r=await Gg(this.glue,this.logStatus.bind(this),n),i=r?jg(r):{version:"1.0.0",name:"",type:"workspace",groups:{},windows:[],componentStates:{}};i.name.includes("#internal-tmp")&&(i.name="");const s={...i,name:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:i.name};return this.logStatus("getActiveWorkspace","return",{data:s}),null==e||e(null,s),{data:s}}catch(t){const n=t.toString();throw this.logStatus("getActiveWorkspace","error",n),null==e||e(n),t}}async getWorkspaces(e){this.logStatus("getWorkspaces","start"),await this.asyncConstructors.ready();const t=await this.glue.layouts.getAll("Global"),n=await(async e=>e.sort((e,t)=>{var n,r;const o=null===(n=e.metadata)||void 0===n?void 0:n["iop#position"],i=null===(r=t.metadata)||void 0===r?void 0:r["iop#position"];return void 0===o&&void 0!==i?1:void 0!==o&&void 0===i?-1:void 0===o&&void 0===i?e.name<t.name?-1:e.name>t.name?1:0:o<i?-1:o>i?1:0}))(t),r=n.map(e=>jg(e));return this.logStatus("getWorkspaces","return",r),null==e||e(null,r),r}getWorkspaceActions(e){this.logStatus("getWorkspaceActions","start");const t={NEW_WORKSPACE:"Finsemble.Workspace.NewWorkspace",SAVE:"Finsemble.Workspace.Save",RENAME:"Finsemble.Workspace.Rename",SAVE_AS:"Finsemble.Workspace.SaveAs",SWITCH_TO:"Finsemble.Workspace.SwitchTo",IMPORT:"Finsemble.Workspace.Import",EXPORT:"Finsemble.Workspace.Export",REMOVE:"Finsemble.Workspace.Remove",SAVE_GLOBAL_DATA:"Finsemble.Workspace.SaveGlobalData",SAVE_VIEW_DATA:"Finsemble.Workspace.SaveViewData",GET_GLOBAL_DATA:"Finsemble.Workspace.GetGlobalData",GET_VIEW_DATA:"Finsemble.Workspace.GetViewData",GET_WORKSPACES:"Finsemble.Workspace.GetWorkspaces",GET_WORKSPACE_NAMES:"Finsemble.Workspace.GetWorkspaceNames",SET_WORKSPACE_ORDER:"Finsemble.Workspace.SetWorkspaceOrder",GET_ACTIVE_WORKSPACE:"Finsemble.Workspace.GetActiveWorkspace",GET_ACTIVE_WORKSPACE_DIRTY:"Finsemble.Workspace.GetActiveWorkspaceDirty",GET_TEMPLATES:"Finsemble.Workspace.GetTemplates",IMPORT_TEMPLATE:"Finsemble.Workspace.ImportTemplate",EXPORT_TEMPLATE:"Finsemble.Workspace.ExportTemplate",REMOVE_TEMPLATE:"Finsemble.Workspace.RemoveTemplate",SET_WINDOW_STATE:"Finsemble.Workspace.SetWindowData",GET_WINDOW_STATE:"Finsemble.Workspace.GetWindowData",ADD_WINDOW:"WorkspaceService.addWindow",REMOVE_WINDOW:"WorkspaceService.removeWindow"};return this.logStatus("getWorkspaceActions","return",t),null==e||e(null,t),t}async getWorkspaceNames(e){var t;this.logStatus("getWorkspaceNames","start"),await this.asyncConstructors.ready();const{err:n,data:r}=await pg(()=>this.glue.layouts.getAll("Global")),o=n?`WorkspaceClient.getWorkspaceNames() ${n}`:null;o&&this.loggerClient.error(o);const i=null!==(t=null==r?void 0:r.map(e=>e.name))&&void 0!==t?t:[];return this.logStatus("getWorkspaceNames","return",i),null==e||e(o,i),i}async setWorkspaceOrder(e,t){await this.asyncConstructors.ready();const{workspaces:n}=e,{err:r,data:o}=await pg(()=>this.glue.layouts.getAll("Global"));if(r||!o)return this.loggerClient.error("WorkspaceClient.setWorkspaceOrder()",r),void(null==t||t(r));const i=o.map(e=>{var t;const r=n.findIndex(t=>t.name.name===e.name);return e.metadata=Vp()(null!==(t=e.metadata)&&void 0!==t?t:{},{"iop#position":r}),e});await this.glue.layouts.import(i),null==t||t(null),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.order",{workspaces:n.map(e=>e.name.name)}))}setWorkspaces(e,t){return this.setWorkspaceOrder(e,t)}async remove(e,t){this.logStatus("remove","start",e),await this.asyncConstructors.ready();const{workspace:n,name:r}=e,o=null!=r?r:null==n?void 0:n.name,{err:i}=o?await pg(()=>this.glue.layouts.remove("Global",o)):{err:null};this.logStatus("remove","return"),null==t||t(i),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.remove",{workspaces:[o]}))}async rename(e,t){this.logStatus("rename","start",e),await this.asyncConstructors.ready();const{oldName:n,newName:r}=e,o=await am(this.glue,r,this.loggerClient);if(!o)return void this.logStatus("rename","warn",`Can't get unique name for ${r}`);const{err:i,data:s}=await pg(()=>this.glue.layouts.get(n,"Global"));if(i&&this.loggerClient.error("WorkspaceClient.rename.get()",i),s){const{err:e}=await pg(()=>this.glue.layouts.rename(s,o));e&&this.loggerClient.error("WorkspaceClient.rename.rename()",e)}this.logStatus("rename","return"),await gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.rename",{oldName:n,newName:o})),null==t||t(i)}async saveAs(e,t){if(this.logStatus("saveAs","start",e),await this.asyncConstructors.ready(),!e.force){const{err:n,data:r}=await pg(()=>this.glue.layouts.getAll("Global")),o=`WorkspaceClient:saveAs ${n}`;if(n||!r)return this.loggerClient.error(o),void(null==t||t(o));if(r.some(t=>t.name===e.name)){const n=`Layout ${e.name} already exists. Set force: true to overwrite`;return void(null==t||t(n))}}const{data:n}=await this.triggerWorkspaceEvent("save-requested",e.name);if(null==n?void 0:n.some(e=>"cancel"===(null==e?void 0:e.action)))return void(null==t||t(null));const{data:r}=await pg(()=>this.glue.layouts.getCurrentLayout()),{err:o}=await pg(()=>this.glue.layouts.save({name:e.name,type:"Global",setAsCurrent:!0,metadata:null==r?void 0:r.metadata}));o?(await this.triggerWorkspaceEvent("save-failed",e.name),this.loggerClient.error("WorkspaceClient.saveAs.save",o)):await this.triggerWorkspaceEvent("save-complete",e.name),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[e.name]})),this.logStatus("saveAs","return",e),null==t||t(o)}async save(e){this.logStatus("save","start"),await this.asyncConstructors.ready();const{err:t,data:n}=await pg(()=>this.glue.layouts.getCurrentLayout());if(t&&this.logStatus("save","error",`getCurrentLayout: ${t}`),!n){const n=`No current layout. Use saveAs ${t}`;return this.logStatus("save","error",n),null==e||e(n),{err:n}}const{data:r}=await this.triggerWorkspaceEvent("save-requested",n.name);if(null==r?void 0:r.some(e=>"cancel"===(null==e?void 0:e.action)))return null==e||e(null),{};const{err:o}=await pg(()=>this.glue.layouts.save({name:n.name,type:"Global",setAsCurrent:!1,metadata:null==n?void 0:n.metadata}));return o?(await this.triggerWorkspaceEvent("save-failed",n.name),this.logStatus("save","error",`save: ${o}`)):await this.triggerWorkspaceEvent("save-complete",n.name),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[n.name]})),this.logStatus("save","return",{err:o}),null==e||e(o),{err:o}}async switchTo(e,t){this.logStatus("switchTo","start",e),await this.asyncConstructors.ready();const{err:n}=await(async(e,t)=>{const{data:n}=await pg(()=>e.layouts.getCurrentLayout());(null==n?void 0:n.name)&&await Jg(e,"close-requested",n.name);const{data:r}=await Jg(e,"load-requested",t);if(null==r?void 0:r.some(e=>"cancel"===(null==e?void 0:e.action)))return{err:null};let o=null;if(null==r?void 0:r.length){const t=[];r.forEach(e=>{e.newData&&t.push(e.newData)});const{err:n}=await pg(()=>e.layouts.import(t,"merge"));n&&(o=n)}const{data:i=[]}=await pg(()=>e.channels.all());await ag(i,async t=>pg(()=>e.channels.clearChannelData(t)));const{err:s}=await pg(()=>e.layouts.restore({name:t}));if(s)(null==n?void 0:n.name)&&Jg(e,"close-failed",n.name),Jg(e,"load-failed",t);else{(null==n?void 0:n.name)&&Jg(e,"close-complete",n.name),Jg(e,"load-complete",t);const{data:r}=await pg(()=>e.layouts.getCurrentLayout());await pg(()=>e.layouts.save({name:t,type:"Global",metadata:null==r?void 0:r.metadata})),await pg(()=>e.prefs.setFor("IO.Global.FinsembleLastWorkspace",{name:t}))}return gg(()=>e.interop.invoke("FSBL.Clients.WorkspaceClient.switchTo",{})),{err:o}})(this.glue,e.name);return n&&this.logStatus("switchTo","error",{err:n,message:"Error importing layout from workspace event"}),this.logStatus("switchTo","return",{err:n,data:void 0}),null==t||t(n),{data:void 0}}async isWorkspaceDirty(e){this.logStatus("isWorkspaceDirty","start"),await this.asyncConstructors.ready();const t=await Hg(this.glue,this.logStatus.bind(this));return null==e||e(null,t),t}async createWorkspace(e,t,n){this.logStatus("createWorkspace","start",{workspaceName:e,params:t}),await this.asyncConstructors.ready();const r=await am(this.glue,e,this.loggerClient);if(!r){const e={workspaceName:"An error occurred creating workspace"};return this.logStatus("createWorkspace","error",e),null==n||n("Cannot create unique name",e),e}const o={type:"Global",name:r,components:[]},{err:i,data:s}=await pg(()=>this.glue.layouts.import([o],"merge"));if(i||!s){const e=`WorkspaceClient.createWorkspace.import ${i}`,t={workspaceName:e};return this.logStatus("createWorkspace","error",e),null==n||n(e,t),t}const a="Success"!==s.status?s.status:null,l={workspaceName:r};return!1!==(null==t?void 0:t.switchAfterCreation)&&await this.switchTo({name:r}),gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:[r]})),this.logStatus("createWorkspace","return",{error:a,result:l}),null==n||n(a,l),l}async import(e,t){this.logStatus("import","start",e),await this.asyncConstructors.ready();const{workspaceJSONDefinition:n,force:r}=e,{err:o,data:i}=await pg(()=>this.glue.layouts.getAll("Global"));if(o||!i){const e=`WorkspaceClient.import:getAll() ${o}`;return console.error(e),this.logStatus("import","error",e),null==t||t(e,{}),{}}const s=(a=n,l=(e,t)=>{if(r)return[[e,t]];const n=i.map(e=>e.name);return[[n.includes(e)?sm(e,n):e,t]]},Object.fromEntries(Object.entries(a).flatMap(([e,t])=>l(e,t))));var a,l;const u=Object.entries(s).map(([e,t],n)=>Mg(e,t,n)),{err:c,data:d}=await pg(()=>this.glue.layouts.import(u,"merge"));if(c||!d){const e=`WorkspaceClient.import:getAll() ${c}`;return this.logStatus("import","error",e),null==t||t(e,{}),{}}const h=Object.fromEntries(Object.keys(s).map(e=>[e,Rg(e,d)]));return gg(()=>this.glue.interop.invoke("FSBL.Clients.WorkspaceClient.storageAdapter.save",{workspaces:u.map(e=>e.name)})),this.logStatus("import","return",h),null==t||t(null,h),h}async importWorkspace(e,t){return await this.asyncConstructors.ready(),this.import(e,t)}async export(e,t){this.logStatus("export","start",e),await this.asyncConstructors.ready();const{workspaceName:n}=e,{err:r,data:o}=await pg(()=>this.glue.layouts.get(n,"Global"));if(r&&this.logStatus("export","error",r),r||!o){const e=`Layout ${n} not found`;throw this.logStatus("export","error",e),null==t||t(e),new Error(e)}const i={[n]:jg(o)};return this.logStatus("export","return",i),null==t||t(null,i),i}async exportWorkspace(e,t){return this.export(e,t)}}class um{constructor(e,t,n){this.asyncConstructors=t,this.loggerClient=n;const r=t.addConstructor();e.then(e=>{this.glue=e,t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"SystemManagerClient",method:e,type:t,data:n})}publishCheckpointState(){}async waitForBootStage(e,t,n){this.logStatus("waitForBootStage","start",{stage:e,when:t}),await this.asyncConstructors.ready();const r=`Finsemble:waitForBootStage:${Zp()()}`;await this.glue.interop.register(r,ig(async()=>{this.loggerClient.log(`waitForBootStage ${e}: received signal`),n()}));const{err:o}=await gg(()=>this.glue.interop.invoke("FSBL.SystemManagerClient.waitForBootStage",{channel:r,stage:e,when:t}));o&&this.logStatus("waitForBootStage","error",o.toString()),this.logStatus("waitForBootStage","return")}}class cm{constructor(e){this.gluePromise=e,this.frequencyMap={},this.gluePromise.then(e=>this.glue=e)}toast(e,t,n,r,o){var i,s,a,l;const u="ONCE-SINCE-STARTUP"===t?1:0,c=null!==(s=null!==(i=null==o?void 0:o.maxCount)&&void 0!==i?i:u)&&void 0!==s?s:0;c&&this.frequencyMap[n]>=c||(c&&(this.frequencyMap[n]=c),this.glue.notifications.raise({title:null!==(a=null!=e?e:n)&&void 0!==a?a:"",body:r,panelExpiry:(null!==(l=null==o?void 0:o.duration)&&void 0!==l?l:15e3)/1e3}))}alert(e,t,n,r,o){return this.toast(e,t,n,r,o)}}class dm{constructor(e,t,n){this.gluePromise=e,this.loggerClient=n,this.groupEventListener=null;const r=t.addConstructor();this.gluePromise.then(e=>{this.glue=e,this.setupForeverListeners(),t.finishConstructor(r)})}logStatus(e,t,n){Kg(this.loggerClient,this.glue,{api:"AuthenticationClient",method:e,type:t,data:n})}async checkIfBridgeIsRunning(){return this.glue.interop.methods().some(({name:e})=>"T42.BBG.IsLoggedIn"===e)}async setupForeverListeners(){try{(await this.glue.interop.subscribe("T42.BBG.GroupsChanged")).onData(e=>{this.groupEventListener&&this.groupEventListener(null,{data:{group:e.data}})})}catch(e){}}setEnabled(e,t){console.info("method 'setEnabled' has not been implemented.")}async checkConnection(e){if(this.logStatus("checkConnection","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.IsLoggedIn")),r=null==n?void 0:n.Result;this.logStatus("checkConnection","return",{isConnected:r}),e(t,r)}else e("Unable to connect",!1),this.logStatus("checkConnection","return",{isConnected:!1})}setConnectionEventListener(e){this.logStatus("setConnectionEventListener","deprecated","Not implemented"),console.info("method 'setConnectionEventListener' has not been implemented.")}removeConnectionEventListener(){this.logStatus("removeConnectionEventListener","deprecated","Not implemented"),console.info("method 'removeConnectionEventListener' has not been implemented.")}async runGetAllGroups(e){if(this.logStatus("runGetAllGroups","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetGroupsInfo"));this.logStatus("runGetAllGroups","return",null==n?void 0:n.groups),e(t,{status:!0,groups:null==n?void 0:n.groups})}else e("Unable to connect",null)}async runGetGroupContext(e,t){if(this.logStatus("runGetGroupContext","start"),await this.checkIfBridgeIsRunning()){const n={group:e},{err:r,data:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetGroupContext",n));this.logStatus("runGetGroupContext","return",null==o?void 0:o.result),t(r,{status:!0,group:null==o?void 0:o.result})}else t("Unable to connect",null)}async runSetGroupContext(e,t,n,r){if(this.logStatus("runSetGroupContext","start",{groupName:e,value:t,cookie:n}),await this.checkIfBridgeIsRunning()){const{err:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.SetGroupContext",{group:e,context:t,cookie:n}));this.logStatus("runSetGroupContext","return",{status:!0}),r(o,{status:!0})}else r("Unable to connect",null)}async setGroupEventListener(e){this.logStatus("setGroupEventListener","start"),this.groupEventListener=e,this.logStatus("setGroupEventListener","return")}removeGroupEventListener(){this.logStatus("removeGroupEventListener","start"),this.groupEventListener=null,this.logStatus("removeGroupEventListener","return")}async runGetAllWorksheets(e){if(this.logStatus("runGetAllWorksheets","start"),await this.checkIfBridgeIsRunning()){const{err:t,data:n}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetWorksheets")),r=null==n?void 0:n.worksheets;this.logStatus("runGetAllWorksheets","return",r),e(t,{status:!0,worksheets:r})}else e("Unable to connect",null)}async runGetWorksheet(e,t){if(this.logStatus("runGetWorksheet","start"),await this.checkIfBridgeIsRunning()){const{err:n,data:r}=await gg(()=>this.glue.interop.invoke("T42.BBG.GetWorksheetSecurities",{worksheetId:e}));this.logStatus("runGetWorksheet","return",r),t(n,{status:!0,worksheet:r})}else t("Unable to connect",null)}async runCreateWorksheet(e,t,n){if(this.logStatus("runCreateWorksheet","start",{worksheetName:e,securities:t}),await this.checkIfBridgeIsRunning()){const r={name:e,securities:t},{err:o,data:i}=await gg(()=>this.glue.interop.invoke("T42.BBG.CreateWorksheet",r)),s=null==i?void 0:i.worksheet;this.logStatus("runCreateWorksheet","return",s),n(o,{status:!0,worksheet:s})}else n("Unable to connect",null)}async runReplaceWorksheet(e,t,n){if(this.logStatus("runReplaceWorksheet","start",{worksheetId:e,securities:t}),await this.checkIfBridgeIsRunning()){const{err:r,data:o}=await gg(()=>this.glue.interop.invoke("T42.BBG.SetWorksheetSecurities",{securities:t,worksheetId:e}));this.logStatus("runReplaceWorksheet","return",null==o?void 0:o.worksheet),n(r,{status:!0,worksheet:null==o?void 0:o.worksheet})}else n("Unable to connect",null)}async runBBGCommand(e,t,n,r,o){if(this.logStatus("runBBGCommand","start",{mnemonic:e,securities:t,panel:n,tails:r}),await this.checkIfBridgeIsRunning()){const{err:i}=await gg(()=>this.glue.interop.invoke("T42.BBG.RunFunction",{mnemonic:e,panel:n,securities:t,tails:r}));this.logStatus("runBBGCommand","return"),o(i,{status:!0})}else o("Unable to connect",null)}async runSecurityLookup(e,t){this.logStatus("runSecurityLookup","deprecated","Not Implemented"),await this.checkIfBridgeIsRunning()?console.info("method 'runSecurityLookup' has not been implemented."):t("Unable to connect",null)}}let hm="undefined"==typeof window?n.g:window,pm="undefined"==typeof window?n.g:window;"undefined"==typeof window?n.g:window;const gm={signatureString:"",signatureStringType:"unauthenticated",meta:{name:"Anonymous app",appId:"Anonymous appId"}},fm=e=>{const t=Symbol.for(`com.finsemble.singleton.${e}`);return Object.getOwnPropertySymbols(n.g).indexOf(t)>-1?n.g[t]:null},mm=(e,t,...r)=>{const o=fm(e);if(!o){const o=Symbol.for(`com.finsemble.singleton.${e}`);return n.g[o]=new t(...r),n.g[o]}return o},ym=`Unknown window-${Zp()()}`;class wm{constructor(){this.isReady=!1,this.onReadyListeners=[],this.currentStartupData={authenticationToken:gm,windowName:ym,webContentsName:ym}}static getInstance(){return wm.instance?wm.instance:wm.instance=mm("Startup",wm)}getStartupData(){return this.currentStartupData}setStartupData(e){this.currentStartupData=e}onReady(e){return new Promise(t=>{this.isReady?(e&&setTimeout(e,0),t()):this.onReadyListeners.push(()=>{e&&e(),t()})})}setReady(){this.isReady=!0,this.onReadyListeners.forEach(e=>{e()});try{hm.dispatchEvent&&hm.Event&&hm.dispatchEvent(new hm.Event("FSBLReady"))}catch(e){console.log(e.toString())}}}wm.instance=null;class vm{static createNew(e,t){fin.desktop.Window.createNew(e,t)}static getCurrent(){return fin.desktop.Window.getCurrent()}static wrap(e){if(!this.wrapCache[e]){const t=fin.desktop.Window.wrap(e);t.addEventListener("closed",()=>{delete this.wrapCache[e]}),this.wrapCache[e]=t}return this.wrapCache[e]}}vm.wrapCache={};class bm{static createNew(e,t){t("Cannot create freestanding windows")}static getCurrent(){const{windowName:e}=wm.getInstance().getStartupData();return{name:e,uuid:`${e}-uuid`,getOptions:e=>{null==e||e({})},addEventListener:()=>{},removeEventListener:()=>{},updateOptions:()=>{},close:()=>{},startMovingWindow:()=>{},stopMovingWindow:()=>{},isShowing:()=>{},bringToFront:()=>{},show:()=>{},hide:()=>{},setTaskbarIcon:()=>{}}}static wrap(){return this.getCurrent()}}class Cm{constructor(){return new fin.desktop.System.Clipboard}static writeText(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeText is deprecated"),fin.desktop.System.Clipboard.writeText(e,t,n,r)}static writeHTML(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeHTML is deprecated"),fin.desktop.System.Clipboard.writeHTML(e,t,n,r)}static writeRTF(e,t,n,r){return ry.deprecated("FSBL.System.Clipboard.writeRTF is deprecated"),fin.desktop.System.Clipboard.writeRTF(e,t,n,r)}static readText(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readText is deprecated"),fin.desktop.System.Clipboard.readText(e,t,n)}static readHTML(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readHTML is deprecated"),fin.desktop.System.Clipboard.readHTML(e,t,n)}static readRTF(e,t,n){return ry.deprecated("FSBL.System.Clipboard.readRTF is deprecated"),fin.desktop.System.Clipboard.readRTF(e,t,n)}}class Sm{static get Application(){return{getCurrent:()=>(ry.deprecated("FSBL.System.Application is deprecated"),{restart:()=>{dy.transmit("Application.restart",{})},getWindow:()=>fin.desktop.Window,addEventListener:(e,t,n,r)=>{fin.desktop.Window.addEventListener(e,t,n,r)},close:(e,t,n)=>{fin.desktop.Window.close(e,t,n)},getChildWindows:(e,t)=>{null==e||e([fin.desktop.Window])},getGroups:(e,t)=>{null==e||e([])},getManifest:(e,t)=>{Sm.getManifest(e)},getParentUuid:(e,t)=>{null==e||e("Finsemble")},getInfo:(e,t)=>{Sm.getVersion(e)},getTrayIconInfo:(e,t)=>{null==e||e({})},isRunning:(e,t)=>{null==e||e(!0)},registerUser:(e,t,n,r)=>{null==n||n()},removeEventListener:(e,t,n,r)=>{fin.desktop.Window.removeEventListener(e,t,n,r)},removeTrayIcon:(e,t)=>{fin.desktop.Window.removeTrayIcon(e,t)},run:(e,t)=>{},scheduleRestart:(e,t)=>{null==e||e()},setTrayIcon:(e,t,n,r)=>{fin.desktop.Window.setTrayIcon(e,t,n,r)},terminate:(e,t)=>{Sm.terminate()},wait:(e,t)=>{null==e||e()},window:{name:fin.desktop.Window.name},uuid:"Finsemble"})}}static isFreestanding(){return"undefined"==typeof fin}static get Window(){return Sm.isFreestanding()?bm:vm}static get Notification(){return{send:e=>{fin.desktop.Notification.send(e)}}}static get Clipboard(){return Cm}static getManifest(e){return new Promise(t=>{fin.desktop.System.getManifest(n=>{null==e||e(n),t(n)})})}static async getMousePosition(e){return new Promise((t,n)=>{fin.desktop.System.getMousePosition(n=>{(n.left||0===n.left)&&(n.x=n.left),(n.top||0===n.top)&&(n.y=n.top),null==e||e(null,n),t(n)},t=>{null==e||e(t),n(t)})})}static async deleteAssets(e){return await fin.desktop.System.deleteAssets(e)}static getSDServerInfo(e=Function.prototype){return new Promise(t=>{fin.desktop.System.getSDServerInfo(n=>{t(n),e(n)})})}static getMonitorInfo(e){return new Promise(t=>{fin.desktop.System.getMonitorInfo(n=>{t(n),e&&e(n)})})}static isBrowserView(){return!Sm.isFreestanding()&&fin.isBrowserView()}static getViewId(){return ry.deprecated("FSBL.system.getViewId() is deprecated. Use FSBL.system.getWebContentsId()"),fin.getWebContentsId()}static getWebContentsId(){return fin.getWebContentsId()}static hasBrowserView(){return ry.deprecated("FSBL.system.hasBrowserView() is deprecated. Use FSBL.system.isTitlebarWindow()"),Sm.isTitlebarWindow()}static isTitlebarWindow(){return!Sm.isFreestanding()&&fin.isTitlebarWindow()}static get fin(){return fin||{}}static ready(e){return new Promise(t=>{fin.desktop.main(()=>{e&&e(),t()})})}static setTrayIcon(e,t){fin.desktop.System.setTrayIcon(e,t)}static getHostSpecs(e=Function.prototype){return new Promise(t=>{fin.desktop.System.getHostSpecs(n=>{t(n),e(n)})})}static get InterApplicationBus(){return fin.desktop.InterApplicationBus}static get launchExternalProcess(){return fin.desktop.System.launchExternalProcess}static get terminateExternalProcess(){return fin.desktop.System.terminateExternalProcess}static get exit(){return fin.desktop.System.exit}static async clearCache(e){return fin.desktop.System.clearCache(e)}static get showDeveloperTools(){return fin.desktop.System.showDeveloperTools}static get addEventListener(){return Sm.isFreestanding()?window.addEventListener:fin.desktop.System.addEventListener}static get removeEventListener(){return Sm.isFreestanding()?window.removeEventListener:fin.desktop.System.removeEventListener}static get addSelectClientCertificateListener(){return fin.desktop.System.addSelectClientCertificateListener}static get addCertificateErrorListener(){return fin.desktop.System.addCertificateErrorListener}static getFEAInfo(e){return new Promise(t=>{fin.desktop.System.getFEAInfo(n=>{null==e||e(n),t(n)})})}static get getVersion(){return fin.desktop.System.getVersion}static get getUpdateAvailable(){return fin.desktop.System.getUpdateAvailable}static get openUrlWithBrowser(){return fin.desktop.System.openUrlWithBrowser}static get getProcessList(){return fin.desktop.System.getProcessList}static get getProtocolString(){return fin.desktop.System.getProtocolString}static get hideSplashScreen(){return fin.desktop.System.hideSplashScreen}static notifyLoggerReady(){fin.desktop.System.notifyLoggerReady()}static updateCentralLoggerState(e){fin.desktop.System.updateCentralLoggerState(e)}static startupApplicationHandshake(){fin.desktop.System.startupApplicationHandshake&&fin.desktop.System.startupApplicationHandshake()}static terminate(){fin.desktop.System.terminate()}static restart(){fin.desktop.System.restart()}static getEnvironmentVariable(e,t){return new Promise(n=>{fin.desktop.System.getEnvironmentVariable(e,e=>{null==t||t(e),n(e)})})}}var Im;const km={navigationStart:Date.now()},Tm={now:()=>{var e;return hm.performance?null===(e=hm.performance)||void 0===e?void 0:e.now():Date.now()},timing:(null===(Im=hm.performance)||void 0===Im?void 0:Im.timing)?hm.performance.timing:km},xm=["microkernel","kernel","pre-authentication","authentication","appd-retrieval","system-preuser","preuser","preuser2","preuser3","preuser4","system-earlyuser","earlyuser","user"];function Am(e){return`systemManager.boot.status.${e}`}function Em(e,t){return`systemManager.checkpoint.${e}.${t}`}const Wm=new class{constructor(){this.startedElements={}}publishBootStatus(e,t,n,r){ry.system.debug("publishBootStatus",e,t,n),dy.publish(Am(e),{name:e,type:t,state:n,error:r})}waitForBootStage(e,t,n=Function.prototype){return new Promise((r,o)=>{ry.system.debug("SystemManagerClient.waitForBootStage entry",e,t);const i=xm.indexOf(e);"microkernel"===e&&"stageEntered"===t&&ry.system.error("Cannot wait on `stageEntered` for microkernel because router isn't up yet. So will instead wait for microkernel stage complete.");const s=dy.subscribe("systemManager.boot.stage",(a,l)=>{if(ry.system.debug("SystemManagerClient.waitForBootStage new stage",l.data.stage,s),a)ry.system.error("SystemManagerClient.waitForBootStage subscribe error",a),n(a),o(a);else if(-1===i)a="illegal stage argument",ry.system.debug("SystemManagerClient.waitForBootStage subscribe error",a,e),n(a),o(a);else{const o=xm.indexOf(l.data.stage);ry.system.debug("SystemManagerClient.waitForBootStage new stage",l.data,s),"stageEntered"===t&&o+1>=i?(ry.system.debug("SystemManagerClient.waitForBootStage stageEntered",e,s,n.name),n(),r(),dy.unsubscribe(s)):"stageCompleted"===t&&o>=i?(ry.system.debug("SystemManagerClient.waitForBootStage completed",e,s),n(),r(),dy.unsubscribe(s)):ry.system.debug(`SystemManagerClient.waitForBootStage else currentStageIndex=${o} stageIndex=${i} `,o,i,e,s)}})})}waitForStartup(e,t=Function.prototype){return new Promise((n,r)=>{if(this.startedElements[e])return void n();ry.system.debug(`SystemManagerClient.waitForStartup.${e}`,e);const o=dy.subscribe(Am(e),(i,s)=>{ry.system.debug("SystemManagerClient.waitForStartup subscribe",e,i,s),i?(ry.system.error("SystemManagerClient.waitForStartup subscribe error",i),t(i),this.startedElements[e]=!1,r(i)):s.data.name===e&&"completed"===s.data.state&&(ry.system.debug("SystemManagerClient.waitForStartup completed",e),this.startedElements[e]=!0,t(),n(),dy.unsubscribe(o))})})}publishCheckpointState(e,t,n){ry.system.debug("publishCheckpoint",e,t,n,Em(e,t)),dy.publish(Em(e,t),{windowName:e,checkpointName:t,state:n})}showSystemLog(){ry.system.debug("SystemManagerClient.showSystemLog"),dy.transmit("systemManager.showSystemlog",!0)}hideSystemLog(){ry.system.debug("SystemManagerClient.hideSystemLog"),dy.transmit("systemManager.hideSystemlog",!0)}systemLog(e,t){ry.system.debug("SystemManagerClient.systemLog",e,t),dy.transmit("systemManager.systemlog",{params:e,logMessage:t})}},Om=Wm,Dm=e=>{if(0===e.length)return"";let t=e[0].replace(".","$DOT$");if(1===e.length)return t;for(let n=1;n<e.length;n++)t=`${t}.${e[n].replace(".","$DOT$")}`;return t};class _m{constructor(){this.listeners={},this.subs={}}}let Pm=!1;const Rm=async()=>{Pm||(await Om.waitForStartup("configService"),Pm=!0)},Lm=()=>mm("ConfigClient",_m),Fm="Invalid path - MUST be a path array. e.g. for myObject.property use ['myObj', 'property']",Mm=(e,t)=>{var n;(null!==(n=Lm().listeners[e])&&void 0!==n?n:[]).forEach(n=>{oy.system.debug("ConfigClient.triggerListeners",e,t),n(null,{field:e,value:t})})},$m=(e,t)=>{if(e)oy.system.error("ConfigClient handleChanges() error",e);else{t.data.field||(t.data.field=null);const{field:e,storeData:n,value:r}=t.data;Mm(e||"configService",n||r)}},Nm=async e=>{const t=Lm();if(t.subs||(t.subs={}),!t.subs[e]){t.subs[e]=!0,Rm();const{err:n}=await dy.query("configService.addListener",e);n&&oy.system.error("Error adding listener to config service",n),await dy.subscribe(e,$m)}},jm=async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.getValue is deprecated. Use FSBL.Clients.ConfigClient.get() instead."),"string"==typeof e&&(e={field:e}),!e.field){const e="no field provided";return null==t||t(e),{err:e}}Rm();const{err:n,response:r}=await dy.query("configService.getValue",{field:e.field});return null==t||t(n,r.data),{err:n,data:r.data}},Bm=async(e,t,n)=>{var r;const o=Lm();let i=null;"function"==typeof e&&(t=e,e={field:null}),Array.isArray(e)?i=Dm(e):({field:i}=e);const s="configService"+(i?`.${i}`:"");o.listeners[s]=[t].concat(null!==(r=o.listeners[s])&&void 0!==r?r:[]),Nm(s),null==n||n()},qm=(e,t,n)=>{const r=Lm();let o=null;"function"==typeof e&&(n=t,t=e,e={field:o}),Array.isArray(e)?o=Dm(e):({field:o}=e);const i="configService"+(o?`.${o}`:"");if(r.listeners[i])for(let e=0;e<r.listeners[i].length;e++)if(r.listeners[i][e]===t)return r.listeners[i].splice(e,1),void(null==n||n(null,!0));null==n||n(null,!1)},Um={initialize(){oy.deprecated("There is no need to call ConfigClient.initialize() anymore.")},onReady:e=>{oy.system.deprecated("It is no longer necessary to call ConfigClient.onReady()"),null==e||e()},triggerListeners(e,t){oy.deprecated("Calling ConfigClient.triggerListeners() directly is not legal."),Mm(e,t)},handleChanges(e,t){oy.deprecated("It is illegal to call ConfigClient.handleChanges() directly."),$m(e,t)},async changeSub(e){oy.deprecated("Calling ConfigClient.changeSub() directly is not legal."),Nm(e)},addListener:Bm,addListeners:(e,t,n)=>{var r;const o=Lm();if(!Array.isArray(e))return oy.deprecated("configClient - addListeners() with an object instead of an array is deprecated. Please use addListener() instead."),Bm(e,t,n);const i="function"==typeof t?t:null;for(let t=0;t<e.length;t++){const n=e[t];let s="";"string"==typeof n?s=n:"object"==typeof n&&Array.isArray(n.field)?s=Dm(n.field):"object"==typeof n&&"string"==typeof n.field&&(s=n.field);const a="string"!=typeof n?n.listener:i;if(a){const e="configService"+(s?`.${s}`:"");o.listeners[e]=[a].concat(null!==(r=o.listeners[e])&&void 0!==r?r:[]),Nm(e)}}null==n||n()},getManifest:async e=>{Rm();const{err:t,response:n}=await dy.query("configService.getValues",{fields:null});return null==e||e(t,n.data),{err:t,data:n.data}},getPreferences:async e=>{await Om.waitForBootStage("authentication","stageCompleted");const{err:t,response:n}=await dy.query("PreferencesService.getPreferences",{});return oy.system.debug("PreferencesService.getPreferences response",n),null==e||e(t,n.data),{err:t,data:n.data}},getValue:jm,getValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.getValues is deprecated. Use FSBL.Clients.ConfigClient.getMultiple() instead."),"function"==typeof e&&(t=e,e=null),e&&!Array.isArray(e))return jm(e,t);Rm();const{err:n,response:r}=await dy.query("configService.getValues",{fields:e});return null==t||t(n,r.data),{err:n,data:r.data}},processAndSet:async(e,t)=>{if(oy.system.debug("ConfigClient.processAndSet",e),!e.overwrite&&e.replace){const e="cannot use replace option unless overwrite is also true";return oy.system.warn("ConfigClient.processAndSet:",e),null==t||t(e),{err:e}}{Rm();const{err:n,response:r}=await dy.query("configService.processAndSet",e);return null==t||t(n,r),{err:n,data:r.data}}},removeListener:qm,removeListeners:(e,t,n)=>{const r=Lm();if(!Array.isArray(e))return"function"==typeof e?qm({},e,n):e.field&&t&&qm(e,t,n),null==n?void 0:n(null,!0);const o="function"==typeof t?t:null;e.forEach(e=>{let t="";"string"==typeof e?t=e:"object"==typeof e&&Array.isArray(e.field)?t=Dm(e.field):"object"==typeof e&&"string"==typeof e.field&&(t=e.field);const n="string"!=typeof e?e.listener:o,i="configService"+(t?`.${t}`:"");r.listeners[i]=r.listeners[i].filter(e=>e!==n)}),null==n||n(null,!0)},removeValue:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.removeValue is deprecated. Use FSBL.Clients.ConfigClient.remove() instead."),"string"==typeof e&&(e={field:e}),!(null==e?void 0:e.field)){const e="No field provided";return null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.removeValue",e);return null==t||t(n),{err:n}},removeValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.removeValues is deprecated. Use FSBL.Clients.ConfigClient.removeMultiple() instead."),!e){const e="ConfigClient.removeValues. No params given";return oy.system.error(e),null==t||t(e),{err:e}}if(!Array.isArray(e)){const e="ConfigClient.removeValues. Params must be an array";return oy.system.error(e),null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.removeValues",e);return null==t||t(n),{err:n}},setPreference:async(e,t)=>{const{err:n,response:r}=await dy.query("PreferencesService.setPreference",e);return null==t||t(n,r.data),{err:n,data:r.data}},setValue:async(e,t)=>{oy.system.deprecated("FSBL.Clients.ConfigClient.setValue is deprecated. Use FSBL.Clients.ConfigClient.set() instead.");const n={field:e.field,value:e.value};Rm();const{err:r}=await dy.query("configService.setValue",n);return null==t||t(r),{err:r}},setValues:async(e,t)=>{if(oy.system.deprecated("FSBL.Clients.ConfigClient.setValues is deprecated. Use FSBL.Clients.ConfigClient.setValues() instead."),!e){const e="ConfigClient.SetValues. No params given";return oy.system.error(e),null==t||t(e),{err:e}}if(!Array.isArray(e)){const e="ConfigClient.SetValues. Params must be an array";return oy.system.error(e),null==t||t(e),{err:e}}Rm();const{err:n}=await dy.query("configService.setValues",e);return null==t||t(n),{err:n}},unsetPreference:async(e,t)=>{oy.system.debug("ConfigClient.unsetPreference",e);const{err:n,response:r}=await dy.query("PreferencesService.unsetPreference",e);return null==t||t(n,r.data),{err:n,data:r.data}},get:async(e,t)=>{if(null!==e&&!Array.isArray(e))return null==t||t(Fm),{err:Fm};Rm();const{err:n,response:r}=await dy.query("configService.getValue",e);return null==t||t(n,r.data),{err:n,data:r.data}},getMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.getValues",{fields:e.length?e:null});return null==t||t(n,r.data),{err:n,data:r.data}},set:async(e,t,n)=>{if(!Array.isArray(e))return null==n||n(Fm),{err:Fm};Rm();const r={field:e,value:t},{err:o,response:i}=await dy.query("configService.setValue",r);return null==n||n(o,i.data),{err:o,data:i.data}},setMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.setValues",e);return null==t||t(n,r.data),{err:n,data:r.data}},remove:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};Rm();const{err:n,response:r}=await dy.query("configService.removeValue",e);return null==t||t(n,r.data),{err:n,data:r.data}},removeMultiple:async(e,t)=>{if(!Array.isArray(e))return null==t||t(Fm),{err:Fm};await Om.waitForStartup("configService");const{err:n,response:r}=await dy.query("configService.removeValues",e);return null==t||t(n,r.data),{err:n,data:r.data}}},zm=Um;var Gm=n(7350),Hm=n.n(Gm);const Vm={Error:!0,Warn:!0,Info:!0,Log:!0,Debug:!0,Verbose:!1,LocalOnly:!1};let Qm=5e3;const Jm=`NOTE: LOG ARG STRIPPED since greater than ${Qm/1e3}KB. Check origin's local Console to see output of the complete object.`,Km={console:{Error:!0,Warn:!0,Info:!0,Log:!0,Debug:!0,Verbose:!0,LocalOnly:!1},dev:Vm,system:Vm,perf:Vm},Ym=()=>{const{stack:e}=function(){try{throw Error("")}catch(e){return e}}();let t=6;e.includes("console.error")&&t++;const n=function(e,t,n){return e.split("\n",n).join("\n").length}(e,0,t);return`Log Stack: \n${e.substring(n).substr(1)}`},Zm=e=>{const t=Qm+1,n=[],r=[e];let o=0,i=0;for(;r.length&&i<=t;){i++;const e=r.pop();if("boolean"==typeof e)o+=4;else if("string"==typeof e)o+=2*e.length;else if("number"==typeof e)o+=8;else if("object"==typeof e&&-1===n.indexOf(e)){n.push(e);for(const t in e)r.push(e[t])}}return o},Xm=(e,t,n=0,r=1)=>{const o=Qm/1.5,i=t/2,s=i/2,a="*STRIPPED*",l=e=>{let t=Zm(e);e.length>0&&t>s&&(e[0]=Xm(e[0],i,n,r+1),e[1]=`${a} from size ${e.length}`,e.length=2)};let u=(0,Qp.cloneDeep)(e);if("object"!=typeof u)u=a,n+=Zm(u);else if(Array.isArray(u))l(u),n+=Zm(u);else{let e=Object.getOwnPropertyNames(u);for(let c=0;c<e.length;c++){let d=Zm(u[e[c]]);n>i&&d>100&&r>=3&&c>=1||n>o&&d>=10?u[e[c]]=a:d>s&&(Array.isArray(u[e[c]])?l(u[e[c]]):u[e[c]]=Xm(u[e[c]],t/1.2,n,r+1)),n+=Zm(u[e[c]])}}return u};class ey{constructor(){this.routerClient=null,this.viewId=null,this.isRegistering=!1,this.isRegistered=!1,this.calibratedTimeStampOffset=0,this.newCalibratedTimeStampOffset=0,this.filteredMessagesCounter=0,this.startupTime=0,this.loggerQueue=[],this.loggerClientName=Sm.Window.getCurrent().name,this.onLogStateChangeCallback=[],this.currentLogState=Km,this.skipLargeObjects=!0,this.setRouterClient=e=>{this.routerClient=e},this.system={error:(...e)=>{this.logIt("system","Error",e)},warn:(...e)=>{this.logIt("system","Warn",e)},info:(...e)=>{this.logIt("system","Info",e)},log:(...e)=>{this.logIt("system","Log",e)},debug:(...e)=>{this.logIt("system","Debug",e)},verbose:(...e)=>{this.logIt("system","Verbose",e)},deprecated:(...e)=>{this.logIt("system","Error",e)}},this.perf={error:(...e)=>{this.logIt("perf","Error",e)},warn:(...e)=>{this.logIt("perf","Warn",e)},info:(...e)=>{this.logIt("perf","Info",e)},log:(...e)=>{this.logIt("perf","Log",e)},debug:(...e)=>{this.logIt("perf","Debug",e)},verbose:(...e)=>{this.logIt("perf","Verbose",e)},deprecated:(...e)=>{this.logIt("perf","Error",e)}},this.console={error:(...e)=>{this.logIt("console","Error",e)},warn:(...e)=>{this.logIt("console","Warn",e)},info:(...e)=>{this.logIt("console","Info",e)},log:(...e)=>{this.logIt("console","Log",e)},debug:(...e)=>{this.logIt("console","Debug",e)},verbose:(...e)=>{this.logIt("console","Verbose",e)},deprecated:(...e)=>{this.logIt("console","Error",e)}};const e="routerService"===this.loggerClientName?100:125;this.transmitAndClearQueue=Hm()(()=>{var e;this.loggerQueue.length>0&&(null===(e=this.routerClient)||void 0===e||e.transmit("logger.service.logMessages",this.loggerQueue),this.loggerQueue=[])},e,{leading:!1})}updateQueueBasedOnState(e){const{loggerQueue:t,currentLogState:n,calibratedTimeStampOffset:r}=this;this.system.debug("Logger updateQueueBasedOnState",e,r,"QUEUE LENGTH",t.length,n),this.loggerQueue=t.flatMap(t=>{if(n[t.category][t.logType]){if(!n[t.category].LocalOnly)return e&&(t.logTimestamp=t.logTimestamp+r),[t];globalThis.console.log(t.category,t.logType,t.logTimestamp-Tm.timing.navigationStart,t.logData,"(Previously queued!)")}return[]})}onStateChanged(e){-1===this.onLogStateChangeCallback.indexOf(e)&&this.onLogStateChangeCallback.push(e)}setLogState(e,t){e&&e.dev&&(this.currentLogState=e,this.onLogStateChangeCallback.forEach(t=>{t(e)})),this.updateQueueBasedOnState(t)}addToQueue(e){const{loggerQueue:t}=this;if(t.length<2e4)t.push(e);else{globalThis.console.error("Logging Queue Overflowed! Dumping queue here then continuing",t.length);let e,n=0;for(;e=t.shift();)globalThis.console.log("Message "+n++,e);this.system.error("Logging Queue Overflowed! Dumping queue in client then continuing.")}}callStack(){return Ym()}setting(){return this.currentLogState}outputToConsole(e,t){var n;const r={Debug:globalThis.console.debug,Info:globalThis.console.info,Warn:globalThis.console.warn,Error:null!==(n=globalThis.console.unwrappedError)&&void 0!==n?n:globalThis.console.error,Log:globalThis.console.log,Verbose:globalThis.console.log};try{r[e](...t)}catch(e){r.Warn("Error outputting log to console",e,Ym())}}formatAndQueueMessage(e,t,n){var r;const o="forceObjectsToLogger"===n[0],i=n.flatMap(e=>{const t=Zm(e);if(!o&&t>Qm){if(this.outputToConsole("Warn",[`Message too large to send to the logger. Max message size:${Qm/1e3}KB`,`Approx message size: ${t/1e3}KB`,...n]),this.skipLargeObjects)return[`Log argument greater than ${Qm/1e3}KB. Check local Console to see output of the object.`];{const n=Xm(e,Qm),r=Zm(n);return r>Qm?[`LOG ARG STRIPPED but not logged here still greater than ${Qm/1e3}KB. Check local Console to see output of the object. (Tag:Logging-Drop)`]:[Jm,`OldSize=${t} (Tag:Logging-Strip) NewSize=${r}`,n]}}return e instanceof Error?[e.toString()]:"forceObjectsToLogger"===e?[]:[e]});let s=null;try{s=JSON.stringify(i)}catch(e){s=`*** Logger error can't JSON.stringify: ${Ym()}`}("Error"===t||"Warn"===t||"console"===e)&&!hm.runningInFSBLUnitTest&&this.outputToConsole(t,n);const a=null!==(r=this.viewId)&&void 0!==r?r:Sm.isBrowserView()&&Sm.getWebContentsId(),l={category:"console"===e?"system":e,logType:t,logClientName:a?`${this.loggerClientName}: view-${a}`:this.loggerClientName,logData:s,logTimestamp:Tm.timing.navigationStart+Tm.now()+this.calibratedTimeStampOffset};a&&(l.viewId=a),this.addToQueue(l),this.isRegistered&&this.transmitAndClearQueue()}logIt(e,t,n){var r;if(globalThis.glue42gd)globalThis.FSBL&&(null===(r=globalThis.FSBL.Clients.Logger)||void 0===r||r[t.toLowerCase()](...n));else if(this.currentLogState[e][t])if("Warn"!==t&&"Error"!==t||n.push(Ym()),this.currentLogState[e].LocalOnly){const r=t.toLowerCase();n.unshift(`${e} ${r} (${Tm.now()}):`),this.outputToConsole(t,n)}else this.formatAndQueueMessage(e,t,n)}error(...e){this.logIt("dev","Error",e)}warn(...e){this.logIt("dev","Warn",e)}info(...e){this.logIt("dev","Info",e)}log(...e){this.logIt("dev","Log",e)}debug(...e){this.logIt("dev","Debug",e)}verbose(...e){this.logIt("dev","Verbose",e)}deprecated(...e){this.logIt("dev","Error",e)}completeRegistration(e){zm.get(["finsemble","servicesConfig","logger"],(e,t)=>{var n,r;e||(this.skipLargeObjects=null!==(n=null==t?void 0:t.skipLargeObjects)&&void 0!==n?n:this.skipLargeObjects,Qm=null!==(r=null==t?void 0:t.maxLogMessageSize)&&void 0!==r?r:Qm)}),this.loggerQueue.forEach(e=>{this.viewId&&(e.viewId=this.viewId)}),this.isRegistered=!0,e?"routerService"!==this.loggerClientName?(this.calibratedTimeStampOffset=this.newCalibratedTimeStampOffset,this.setLogState(e,!0)):this.setLogState(e,!1):globalThis.console.error("Logger.startLogger() Initial state not received from logger service"),this.formatAndQueueMessage("system","Debug",["Logger Registered"]),this.transmitAndClearQueue()}registerWithLoggerService(){var e;const{windowName:t,webContentsName:n}=wm.getInstance().getStartupData();this.loggerClientName="undefined"!=typeof window&&window.top!==window?`${t}.Frame`:t;const r=`finsemble.logger.client.${this.loggerClientName}`;!this.viewId&&Sm.isBrowserView()&&(this.viewId=Sm.getWebContentsId()),this.system.debug("logger.service.registering",this.loggerClientName),Sm.Window.getCurrent().getOptions(async e=>{var o,i;const s=null===(i=null===(o=null==e?void 0:e.customData)||void 0===o?void 0:o.component)||void 0===i?void 0:i.centralLoggerNamePrefix;if(!this.routerClient)return;const{err:a,response:l}=await this.routerClient.query("logger.service.register",{clientName:this.loggerClientName,clientChannel:r,displayName:null!=n?n:t,windowName:t,viewId:this.viewId,centralLoggerNamePrefix:s});a?(globalThis.console.warn("Logger service not available. Trying to connect again in 750ms.",a),setTimeout(()=>{this.registerWithLoggerService()},750)):this.completeRegistration(l.data)}),null===(e=this.routerClient)||void 0===e||e.addListener(r,(e,t)=>{this.system.debug("logger.client.setLogState",t.data),this.setLogState(t.data,!1)})}unregisterClient(e,t){var n;this.system.debug("logger.service.unregister",this.loggerClientName,e,this.viewId),this.transmitAndClearQueue();const r=e||{clientName:this.loggerClientName,viewId:this.viewId};null===(n=this.routerClient)||void 0===n||n.query("logger.service.unregister",r,t)}async waitForServiceAndCalibrate(){var e;await Om.waitForStartup("loggerService"),this.system.debug("Logger onReady",this.loggerClientName),null===(e=this.routerClient)||void 0===e||e.calibrateTimeWithRouterService(e=>{this.newCalibratedTimeStampOffset=e,this.isRegistering||(this.isRegistering=!0,this.startupTime=performance.now()-this.startupTime,this.registerWithLoggerService())})}async start(e){this.routerClient=null!=e?e:hy,this.startupTime=performance.now(),await this.waitForServiceAndCalibrate(),Sm.isBrowserView()&&hm.addEventListener&&hm.addEventListener("beforeunload",()=>{this.unregisterClient()})}}const ty={error:(...e)=>mm("LoggerClient",ey).error(...e),warn:(...e)=>mm("LoggerClient",ey).warn(...e),info:(...e)=>mm("LoggerClient",ey).info(...e),log:(...e)=>mm("LoggerClient",ey).log(...e),debug:(...e)=>mm("LoggerClient",ey).debug(...e),verbose:(...e)=>mm("LoggerClient",ey).verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).deprecated(...e),start:e=>{mm("LoggerClient",ey).start(e)},channelFilter:e=>(e=>"logger.service.logMessages"===e||"Finsemble.heartbeat"===e)(e),setting:()=>mm("LoggerClient",ey).setting(),callStack:()=>mm("LoggerClient",ey).callStack(),unregisterClient:(e,t)=>{mm("LoggerClient",ey).unregisterClient(e,t)},setRouterClient:e=>{mm("LoggerClient",ey).setRouterClient(e)},onStateChanged(e){mm("LoggerClient",ey).onStateChanged(e)},system:{error:(...e)=>mm("LoggerClient",ey).system.error(...e),warn:(...e)=>mm("LoggerClient",ey).system.warn(...e),info:(...e)=>mm("LoggerClient",ey).system.info(...e),log:(...e)=>mm("LoggerClient",ey).system.log(...e),debug:(...e)=>mm("LoggerClient",ey).system.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).system.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).system.deprecated(...e)},perf:{error:(...e)=>mm("LoggerClient",ey).perf.error(...e),warn:(...e)=>mm("LoggerClient",ey).perf.warn(...e),info:(...e)=>mm("LoggerClient",ey).perf.info(...e),log:(...e)=>mm("LoggerClient",ey).perf.log(...e),debug:(...e)=>mm("LoggerClient",ey).perf.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).perf.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).perf.deprecated(...e)},console:{error:(...e)=>mm("LoggerClient",ey).console.error(...e),warn:(...e)=>mm("LoggerClient",ey).console.warn(...e),info:(...e)=>mm("LoggerClient",ey).console.info(...e),log:(...e)=>mm("LoggerClient",ey).console.log(...e),debug:(...e)=>mm("LoggerClient",ey).console.debug(...e),verbose:(...e)=>mm("LoggerClient",ey).console.verbose(...e),deprecated:(...e)=>mm("LoggerClient",ey).console.deprecated(...e)}},ny=(globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,globalThis.console.warn,globalThis.console.info,globalThis.console.log,globalThis.console.debug,globalThis.console.error,globalThis.console.debug,globalThis.console.error,ty),ry=ny,oy=ny,iy={},sy={activeTransports:{},liveTransport:null,setTransports(){sy.addTransport("SharedWorkerForCoreServices",iy.SharedWorkerForCoreServicesTransport),sy.addTransport("SharedWorker",iy.SharedWorkerTransport),sy.addTransport("IPCBus",iy.IPCTransport),sy.addTransport("FinsembleTransport",iy.FinsembleTransport)},addTransport(e,t){this.activeTransports[e]=t},getActiveTransports(e){const t=[],n=e=>{-1===t.indexOf(e)&&t.push(e)};return Sm.InterApplicationBus&&n("IPCBus"),n("FinsembleTransport"),SharedWorker&&(n("SharedWorker"),n("SharedWorkerForCoreServices")),n(e.sameDomainTransport),n(e.crossDomainTransport),oy.system.log("getActiveTransports",t),t},getTransport:(e,t,n,r,o,i)=>new Promise((s,a)=>{const l=sy.activeTransports[t];if(l)sy.liveTransport=new l(e,n,r,o,e=>{s(e)},i);else{const e=`routerTransport.getTransport() Unknown router transport name: ${t}`;oy.warn(e),a(e)}}),close(){sy.liveTransport&&(sy.liveTransport.close(),sy.liveTransport=null)}};iy.SharedWorkerForCoreServicesTransport=function(e,t,n,r,o){let i;this.send=function(e,t){1===arguments.length?(t=arguments[0],e=null):(e=arguments[0],t=arguments[1]),oy.system.verbose("SharedWorkerForCoreServicesTransport Outgoing Transport",t);try{i.port.postMessage([e,t])}catch(e){oy.system.error(`SharedWorkerForCoreServicesTransport: post message failed: ${JSON.stringify(e)}`,"Probable cause is sending illegal data type (e.g. function).")}},this.identifier=()=>"SharedWorkerForCoreServices";const s=e.transportSettings.SharedWorker&&e.transportSettings.SharedWorker.workerPath?e.transportSettings.SharedWorker.workerPath:`${e.routerDomainRoot}/routerSharedWorkerForCoreServices.js`;oy.console.log(`SharedWorkerForCoreServices Transport Initializing for ${n} using ${s}`),i=new SharedWorker(s,{name:"Finsemble",credentials:"include"}),i.port.onmessage=e=>{const n=e.data[0],r=e.data[1],o={transportID:this.identifier(),port:n};oy.system.verbose("SharedWorkerForCoreServicesTransport Incoming Transport",o,"Message",r),t(o,r)},i.onerror=e=>{oy.console.error(`SharedWorkerForCoreServicesTransport Transport Error ${JSON.stringify(e)}`)},i.port.start(),"RouterService"===n&&i.port.postMessage({data:"connect",source:"RouterService"}),this.close=()=>i.port.close(),null==o||o(this)},iy.SharedWorkerTransport=function(e,t,n,r,o){let i;this.send=function(e,t){1===arguments.length?(t=arguments[0],e=null):(e=arguments[0],t=arguments[1]),oy.system.verbose("SharedWorkerTransport Outgoing Transport",t);try{i.port.postMessage([e,t])}catch(e){oy.system.error(`SharedWorkerTransport: post message failed: ${JSON.stringify(e)}`,"Probable cause is sending illegal data type (e.g. function).")}},this.identifier=()=>"SharedWorker";const s=e.transportSettings.SharedWorker&&e.transportSettings.SharedWorker.workerPath?e.transportSettings.SharedWorker.workerPath:`${e.routerDomainRoot}/routerSharedWorker.js`;oy.console.log(`SharedWorker Transport Initializing for ${n} using ${s}`),i=new SharedWorker(s,{name:"Finsemble",credentials:"include"}),i.port.onmessage=e=>{const n=e.data[0],r=e.data[1],o={transportID:this.identifier(),port:n};oy.system.verbose("SharedWorkerTransport Incoming Transport",o,"Message",r),t(o,r)},i.onerror=e=>{oy.console.error(`SharedWorkerTransport Transport Error ${JSON.stringify(e)}`)},i.port.start(),"RouterService"===n&&i.port.postMessage({data:"connect",source:"RouterService"}),this.close=()=>i.port.close(),null==o||o(this)},iy.IPCTransport=function(e,t,n,r,o){this.send=function(e,t){let n;1===arguments.length?(n=r,t=arguments[0]):(n=e.name,t=arguments[1]),oy.system.verbose("IPCTransport Outgoing Transport",n,"Message",t),Sm.InterApplicationBus.publish(n,t,()=>{},()=>{})},this.identifier=()=>"IPCBus",oy.console.log(`IPCBus Transport Initializing for ${n}`);const i=Sm.InterApplicationBus.subscribe("*",n,e=>{const n={transportID:this.identifier(),name:e.header.origin};oy.system.verbose("IPCTransport Incoming Transport",n,"Message",e),t(n,e)},()=>{},e=>oy.console.error(`IPCBus Subscribe Failure: ${e}`));this.close=()=>Sm.InterApplicationBus.unsubscribe(i),null==o||o(this)},iy.FinsembleTransport=function(e,t,n,r,o,i){var s,a,l,u,c;const d=`${null!==(c=null!==(l=null===(a=null===(s=null==e?void 0:e.transportSettings)||void 0===s?void 0:s.FinsembleTransport)||void 0===a?void 0:a.serverAddress)&&void 0!==l?l:null===(u=null==e?void 0:e.transportSettings)||void 0===u?void 0:u.serverAddress)&&void 0!==c?c:"ws://127.0.0.1:3376"}/router`;let h,p,g=!0;const f=e=>{if("IAC_KeepaliveHandshake"===e)oy.system.verbose("FinsembleTransport Incoming Message","Message",e),oy.system.verbose("FinsembleTransport keepalive completed"),g=!0;else{const n={transportID:this.identifier(),client:e.clientMessage.header.origin};oy.system.verbose("FinsembleTransport Incoming Transport",n,"Message",e),t(n,e.clientMessage)}},m=()=>{oy.console.log(`FinsembleTransport Transport Initializing for ${n} using ${d} trying to connect to server`),d.startsWith("ws:")||d.startsWith("wss:")||oy.system.error(`Illegal WebSocket address "${d}" (Missing ws:// or wss:// ?)`),h=new hm.WebSocket(d),h.addEventListener("open",()=>{clearInterval(p),oy.console.log("FinsembleTransport connected to server"),h.send(JSON.stringify({dest:"IAC_SERVER",source:n})),"RouterService"!==n&&((()=>{const e=setInterval(()=>{g?(g=!1,h.send(JSON.stringify({dest:"IAC_KEEPALIVE_SERVER",source:n})),oy.system.verbose("FinsembleTransport keepalive sent")):(oy.console.error("FinsembleTransport keepalive handshake failed -- transport is essentially dead",5e3),clearInterval(e),i&&i())},5e3)})(),oy.console.log("FinsembleTransport keep-alive handshake started")),h.addEventListener("message",e=>{const t=JSON.parse(e.data);f(t.message)}),null==o||o(this)}),h.addEventListener("error",e=>{oy.system.error("FinsembleTransport websocket error",e),console.log(`Error connecting to websocket server ${d}`)}),h.addEventListener("close",e=>{oy.system.log("FinsembleTransport websocket close",e),console.log(`Websocket is closed with code ${e.code}`),1006===e.code&&(clearInterval(p),p=setInterval(m,1e4))})};this.send=function(e,t){let n,r;1===arguments.length?(n="ROUTER_SERVICE",r={clientMessage:t=arguments[0]}):(n="ROUTER_CLIENT",t=arguments[1],r={client:e.client,clientMessage:t}),oy.system.verbose("FinsembleTransport Outgoing Transport",n,"NewMessage",r),h.send(JSON.stringify({dest:n,message:r}))},this.identifier=()=>"FinsembleTransport",this.close=()=>{h.close()},p=setInterval(m,1e4),m()};const ay=sy;class ly{constructor(){this.alertOnceSinceStartUp={},this.alertCurrentCount={}}}function uy(e,t={}){if(null===e||"object"!=typeof e)return e;if(e.constructor==Date||e.constructor==RegExp||e.constructor==Function||e.constructor==String||e.constructor==Number||e.constructor==Boolean)return new e.constructor(e);t=t||new e.constructor;for(const n in e)t[n]=void 0===t[n]?uy(e[n],null):t[n];return t}class cy{constructor(){this.queue=[],this.started=!1,this.clientName="RouterClient.clientName not yet set",this.transport=null,this.isRouterReady=!1,this.isTransportFailed=!1,this.parentReadyCallbackQueue=[],this.parentFailureCallbackQueue=[],this.mapListeners={},this.mapQueryResponders={},this.mapPubSubResponders={},this.mapPubSubResponderState={},this.mapPubSubResponderRegEx={},this.pubsubListOfSubscribers={},this.mapSubscribersID={},this.mapSubscribersTopic={},this.mapQueryResponses={},this.mapQueryResponseTimeOut={}}onReadyCallBack(){for(ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient Ready"),this.isRouterReady=!0;this.parentReadyCallbackQueue.length>0;){ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient parentReady invoked");const e=this.parentReadyCallbackQueue.shift();null==e||e()}}sendToRouterService(e){this.transport?this.transport.send(e):(ny.system.info("RouterClient: Queuing message since router initialization not complete",e),this.queue.push(e))}originatedHere(e){return e.header.origin===this.clientName}invokeListeners(e){const{channel:t,origin:n}=e.header,r=this.mapListeners[t]||[];Array.isArray(r)&&0!==r.length?(e.originatedHere=()=>this.originatedHere(e),r.forEach(r=>{ny.channelFilter(t)||ny.system.info("RouterClient: incoming transmit","CHANNEL",t,"FROM",n,"MESSAGE",e),r(null,e)})):ny.system.log(`RouterClient: no listener for incoming transmit on channel ${t} from ${n}. Possibly the listener was removed while this message was in transit.`,e)}invokeResponder(e){const{channel:t,origin:n,queryID:r,error:o}=e.header;ny.system.info("RouterClient: incoming query","CHANNEL",t,"FROM",n,"QUERY MESSAGE",e);const i=(e,n)=>{ny.system.info("RouterClient: outgoing query response","CHANNEL",t,"RESPONSE DATA",n,"QUERY ID",r);let o={header:{origin:this.clientName,queryID:r,type:"queryResponse"},data:n};o.header.error=e?e.toString():null,this.sendToRouterService(o)},s=this.mapQueryResponders[t];if(void 0===s)e.header.logWhenNoResponder&&ny.system.warn(`RouterClient: No query responder defined on channel ${t} for incoming from ${n}.`,e);else if(o)ny.system.warn("RouterClient: queryResponder error",e),s(o),delete this.mapQueryResponders[t];else{const t={...e,originatedHere:()=>this.originatedHere(e),sendQueryResponse:(e,t)=>{i(e,t)}};s(null,t)}}invokeQueryResponse(e){var t;ny.system.info("RouterClient: incoming query response","CHANNEL",e.header.channel,"QUERY ID",e.header.queryID,"message",e);const{queryID:n}=e.header,r=this.mapQueryResponseTimeOut[n];delete this.mapQueryResponseTimeOut[n],r&&clearTimeout(r);const o=this.mapQueryResponses[n];o?(delete this.mapQueryResponses[n],o(null!==(t=e.header.error)&&void 0!==t?t:null,e)):ny.system.warn("Invariant: RouterClient: no handler found for incoming query response.",e)}invokeNotifyCallback(e){const{subscribeID:t,error:n}=e.header,r=this.mapSubscribersID[t];r?n?(ny.system.info("RouterClient: incoming PubSub notify error for subscriberID","SUBSCRIBER ID",t,"NOTIFY MESSAGE",e),r(n,e)):(e.originatedHere=()=>this.originatedHere(e),ny.system.info("RouterClient: incoming PubSub notify","SUBSCRIBER ID",t,"NOTIFY MESSAGE",e),r(null,e)):ny.system.info("RouterClient: no subscription handler defined for incoming notify for subscriberID. Possibly the subscription was removed while this publish was in transit.",t,e)}findResponder(e){const t=this.mapPubSubResponders[e];if(t)return t;for(const t in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[t].test(e))return this.mapPubSubResponders[t]}invokePublishEvent(e){const{topic:t}=e.header;let n=this.findResponder(t);if(n){const r=(e,n,r)=>{var o;n?ny.system.warn("RouterClient: incoming publish rejected by pubsub responder",n,r):(this.mapPubSubResponderState[t]=r,(null!==(o=this.pubsubListOfSubscribers[t])&&void 0!==o?o:[]).forEach(e=>{ny.system.info("RouterClient: sending pubsub notify","TOPIC",t,"NOTIFY DATA",r);const n={header:{origin:this.clientName,type:"notify",topic:t,subscribeID:e},data:r};this.sendToRouterService(n)}))};if(ny.system.info("RouterClient: incoming PubSub publish "+(n.publishCallback?"(publishCallback hook invoked)":""),"TOPIC",t,"PUBLISH MESSAGE",e),n.publishCallback){const t={...e,sendNotifyToAllSubscribers:(t,n)=>{r(e,t,n)}};n.publishCallback(null,t)}else r(e,null,e.data)}else ny.system.warn("RouterClient: no pubsub responder defined for incoming publish","TOPIC",t,"PUBLISH MESSAGE",e)}invokeSubscribeEvent(e){var t;const{topic:n,error:r}=e.header;ny.system.info("RouterClient: PubSub subscribe","TOPIC",n);let o=this.mapPubSubResponders[n];if(!o)for(const e in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[e].test(n)){o=this.mapPubSubResponders[e],this.mapPubSubResponderState[n]=null!==(t=this.mapPubSubResponderState[n])&&void 0!==t?t:this.mapPubSubResponderState[e];break}if(o)if(r)ny.system.warn(`RouterClient: pubsub error received from router service: ${r}`,e);else if(o.subscribeCallback){const t={...e,sendNotifyToSubscriber:(t,n)=>{this.sendNotifyToSubscriber(e,t,n)}};e.data=this.mapPubSubResponderState[n],o.subscribeCallback(null,t)}else this.sendNotifyToSubscriber(e,null,this.mapPubSubResponderState[n]);else ny.system.warn("RouterClient: no pubsub responder defined for incoming subscribe event",e)}invokeUnsubscribeEvent(e){const{topic:t,subscribeID:n}=e.header;let r=this.findResponder(t);if(!r)for(const e in this.mapPubSubResponderRegEx)if(this.mapPubSubResponderRegEx[e].test(t)){r=this.mapPubSubResponders[e];break}if(r)if(ny.system.info("RouterClient: incoming unsubscribe "+(r.unsubscribeCallback?"with unsubscribeCallback hook":""),"TOPIC",t,"UNSUBSCRIBE MESSAGE",e),r.unsubscribeCallback){const o={...e,removeSubscriber:()=>{this.removeSubscribers(t,n)}};r.unsubscribeCallback(null,o)}else this.removeSubscribers(t,n);else ny.system.warn("RouterClient: no pubsub responder defined for incoming unsubscribe event","TOPIC",t,"UNSUBSCRIBE MESSAGE",e)}sendNotifyToSubscriber(e,t,n){const{topic:r,subscribeID:o}=e.header;if(void 0!==n){let e={header:{origin:this.clientName,type:"notify",topic:r,subscribeID:o},data:n};t&&(e.header.error=t),this.sendToRouterService(e)}t?ny.system.warn("RouterClient: incoming subscription rejected by pubsub responder","TOPIC",r,"MESSAGE",this):(r in this.pubsubListOfSubscribers?this.pubsubListOfSubscribers[r].push(o):this.pubsubListOfSubscribers[r]=[o],ny.system.info("RouterClient: incoming subscription added","TOPIC",r,"MESSAGE"))}removeSubscribers(e,t){let n=!1;if(e in this.pubsubListOfSubscribers){const r=this.pubsubListOfSubscribers[e];for(let o=0;o<r.length;o++)if(t===r[o]){r.splice(o,1),0===r.length&&delete this.pubsubListOfSubscribers[e],n=!0,ny.system.info("RouterClient: PubSub removeListener","TOPIC",e,"FROM",t);break}}n||ny.system.warn(`RouterClient: tried to remove non-existent listener on ${e} from ${t}`)}routeIncomingMessage(e){const t=()=>{this.timeCalibrationHandler?this.timeCalibrationHandler(e):setTimeout(()=>{t()},10)};switch(ny.system.verbose("Incoming Message Type",e.header.type,e),e.header.type){case"transmit":this.invokeListeners(e);break;case"query":this.invokeResponder(e);break;case"queryResponse":this.invokeQueryResponse(e);break;case"notify":this.invokeNotifyCallback(e);break;case"publish":this.invokePublishEvent(e);break;case"subscribe":this.invokeSubscribeEvent(e);break;case"unsubscribe":this.invokeUnsubscribeEvent(e);break;case"timeCalibration":t();break;case"initialHandshakeResponse":this.handshakeHandler()}}asyncConnectToEventRouter(e,t,n){ny.system.debug(`Name of transport to establish: ${t}`);let r=null,o=0,i=!1,s=0,a=null;const l=()=>{const t=Number.MAX_SAFE_INTEGER;ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient: sendHandshake",o);const n={header:{origin:this.clientName,type:"initialHandshake"}};this.sendToRouterService(n),o++>t&&(()=>{if(clearInterval(r),s++,s<=3)ny.console.error("WINDOW LIFECYCLE:STARTUP:RouterClient: failure to connect to router service. Retrying...",s,e),null==a||a();else{const t="A cross domain transport has failed to connect. Cross domain components may not work. Please contact your administrator.";ny.console.error(t,e),((e,t,n,r,o)=>{const i=mm("Toast",ly);let s=!1;const a=`toast.${n}`,l=(o=o||{}).duration||864e5;switch(t){case"ONCE-SINCE-STARTUP":a in i.alertOnceSinceStartUp?s=!1:(s=!0,i.alertOnceSinceStartUp[a]=!0);break;case"MAX-COUNT":{let e=0;const t=o.maxCount||1;a in i.alertCurrentCount&&(e=i.alertCurrentCount[a]),i.alertCurrentCount[a]=++e,e<=t&&(s=!0);break}default:s=!0}if(ry.log("toast",e,s,t,n,r,o),s){const t={message:r,timeout:l,...o,devModeOnly:"devModeOnly"===e};t.title||"devModeOnly"!==e||(t.title="Finsemble Developer Notification"),Om.systemLog({notification:!0},`Notification: ${r}`),Sm.Notification.send(t)}})("dev","ONCE-SINCE-STARTUP","FSBL-Internal-Transport-Failure",t)}})()},u=()=>{if(!i){ny.system.debug(`WINDOW LIFECYCLE:STARTUP:RouterClient connected: Starting ${this.clientName} with transport ${this.transport.identifier()}`),i=!0,clearInterval(r);for(let e=0;e<this.queue.length;e++){ny.system.debug("RouterClient: releasing queued msg");const t=this.queue[e];this.transport.send({...t,header:{...t.header,origin:this.clientName}})}null==n||n()}},c=e=>{o=0,ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient:transport ready","TRANSPORT OBJECT",e),this.transport=e,this.handshakeHandler=u,l(),r=setInterval(l,1e3)},d=()=>{for(ny.system.error("RouterClient Transport Failed -- onFailure() callbacks invoked."),this.isTransportFailed=!0;this.parentFailureCallbackQueue.length>0;){ny.system.debug("RouterClient parentFailure invoked");const e=this.parentFailureCallbackQueue.shift();null==e||e()}};a=()=>{ny.system.debug("WINDOW LIFECYCLE:STARTUP:RouterClient:getClientTransport","ROUTER PARAMS:",e),ay.getTransport(e,t,(e,t)=>{t.header.lastClient=this.clientName,t.header.incomingTransportInfo=e,this.routeIncomingMessage(t)},this.clientName,"RouterService",d).then(c).catch(e=>{ny.console.error("RouterClient getTransport error",e)})},a()}addPubSubResponderCallBack(e,t,n,r){const o=e.toString();return!this.mapPubSubResponders[o]&&(e instanceof RegExp&&(this.mapPubSubResponderRegEx[o]=e,ny.system.info(`RouterClient: PubSub RegEx added for topic ${o}`)),this.mapPubSubResponders[o]={subscribeCallback:t,publishCallback:n,unsubscribeCallback:r},!0)}calibrateTimeWithRouterService(e){let t=0,n=0,r=1/0;const o={header:{origin:this.clientName,type:"timeCalibration"},clientBaseTime:[],serviceBaseTime:[]};this.timeCalibrationHandler=o=>{if(t++,t>5)(t=>{const{clientBaseTime:o,serviceBaseTime:i}=t;let s=0;for(let e=1;e<5;e++){const t=o[e-1],a=o[e]-t,l=i[e-1]-(t+a/2);a<r&&(r=a,n=l),s+=l,ny.system.debug("calibrationCalculation Intermediate Values","lastRRT",a,"lastOffset",l,"fastestOffset",n,"fastestRRT",r)}s/=4,ny.system.debug("RouterClient calibrationCalculation","Average Offset",s,"Chosen FastestOffset",n,t),e(n)})(o);else{o.clientBaseTime.push(Tm.timing.navigationStart+Tm.now());const e={header:{origin:this.clientName,type:"timeCalibration"},clientBaseTime:o.clientBaseTime,serviceBaseTime:o.serviceBaseTime};this.sendToRouterService(e)}},this.timeCalibrationHandler(o)}start(e){return new Promise(async t=>{if(this.started){const e="RouterClient.start() called twice. Ignoring second call.";return ny.system.warn(e),t(e)}this.started=!0,this.clientName=`RouterClient.${e.windowName}.${Zp()()}`;const n=`"RouterClient Check: connecting new client for ${this.clientName}`;ny.system.debug(n),console.debug(n),ay.setTransports(),this.asyncConnectToEventRouter(e,e.transportName,()=>{this.onReadyCallBack(),t(null)})})}disconnectFromService(){ny.system.info("RouterClient.disconnectFromService");const e={header:{origin:this.clientName,type:"disconnectFromService"}};this.sendToRouterService(e)}stop(){this.disconnectAll(),ay.close(),this.started=!1,this.disconnectFromService()}onReady(e){return new Promise(t=>{const n=()=>{e&&e(),t()};this.isRouterReady?n():this.parentReadyCallbackQueue.push(n)})}onFailure(e){return new Promise(t=>{const n=()=>{e&&e(),t()};this.isTransportFailed?n():this.parentFailureCallbackQueue.push(n)})}addListener(e,t){ny.system.info("RouterClient.addListener","CHANNEL",e);const n=this.mapListeners[e];if(n&&0!==n.length)n.some(e=>t===e)?ny.debug("RouterClient.addListener() Ignoring duplicate listener with identical callback",e,t):n.push(t);else{this.mapListeners[e]=[t];const n={header:{origin:this.clientName,type:"addListener",channel:e}};this.sendToRouterService(n)}return()=>{this.removeListener(e,t)}}transmit(e,t,n){ny.channelFilter(e)||ny.system.info("RouterClient.transmit","TO CHANNEL",e,"DATA",t);const r={header:{origin:this.clientName,type:"transmit",channel:e},data:t,options:n};this.sendToRouterService(r)}removeListener(e,t){if(ny.system.info("RouterClient.removeListener","CHANNEL",e,"EVENT HANDLER",t),!this.mapListeners[e])return ny.system.debug("Attempt to remove non existent listener",e,t),void console.log("Attempt to remove non existent listener",e,t);if(this.mapListeners[e]=this.mapListeners[e].flatMap(e=>e===t?[]:[e]),!this.mapListeners[e].length){delete this.mapListeners[e];const t={header:{origin:this.clientName,type:"removeListener",channel:e}};this.sendToRouterService(t)}}addResponder(e,t){if(ny.system.info("RouterClient.addResponder","CHANNEL",e),this.mapQueryResponders[e]){const n=`RouterClient.addResponder: Responder already locally defined for channel ${e}`;ny.system.warn(n),t(n)}else{this.mapQueryResponders[e]=t;const n={header:{origin:this.clientName,type:"addResponder",channel:e}};this.sendToRouterService(n)}}query(e,t,n,r){var o,i;const s=`${this.clientName}.${Zp()()}.${e}`,a=Tm.timing.navigationStart+Tm.now(),l=Tm.timing.navigationStart,u=Tm.now();ny.system.info("RouterClient.query","RESPONDER CHANNEL",e,"QUERY EVENT",t,"PARAMS",n,"QUERY ID",s,{timestamp:a,navstart:l,timenow:u});const c=null!=r?r:"function"==typeof n?n:null,d=null!==(o=null==n?void 0:n.timeout)&&void 0!==o?o:2e4,h=null===(i=null==n?void 0:n.logWhenNoResponder)||void 0===i||i;return new Promise(r=>{this.mapQueryResponses[s]=(e,t)=>{null==c||c(e,t),r({err:e,response:t})},!hm.runningInFSBLUnitTest&&d>0&&(this.mapQueryResponseTimeOut[s]=setTimeout(()=>{console.warn(`RouterClient: timeout after ${d} ms waiting on query response on channel ${e} for queryID ${s} from client ${this.clientName}`,"from event",t,"with params",n),delete this.mapQueryResponseTimeOut[s]},d));const o={header:{origin:this.clientName,type:"query",queryID:s,channel:e,logWhenNoResponder:h,timeout:d},data:t};this.sendToRouterService(o)})}removeResponder(e){if(ny.system.info("RouterClient.removeResponder","RESPONDER CHANNEL",e),this.mapQueryResponders[e]){delete this.mapQueryResponders[e];const t={header:{origin:this.clientName,type:"removeResponder",channel:e}};this.sendToRouterService(t)}}addPubSubResponder(e,t,n,r){let o,i;if(ny.system.info("RouterClient.addPubSubResponder","TOPIC",e,"INITIAL STATE",t,"PARAMS",n),void 0===(n=n||{}).subscribeCallback&&void 0===n.publishCallback&&void 0===n.unsubscribeCallback){t=t||{};const n={header:{origin:this.clientName,type:"addPubSubResponder",topic:e.toString(),handleOnServer:!0},data:t};this.sendToRouterService(n),i="success"}else if(this.addPubSubResponderCallBack(e,n.subscribeCallback,n.publishCallback,n.unsubscribeCallback)){t=t||{},this.mapPubSubResponderState[e.toString()]=uy(t);const n={header:{origin:this.clientName,type:"addPubSubResponder",topic:e.toString(),handleOnServer:!1},data:t};this.sendToRouterService(n),i="success"}else o=`RouterClient.addPubSubResponder: Responder already locally defined for topic ${e}`,ny.system.error(o);r&&r(o,i)}removePubSubResponder(e){ny.system.info("RouterClient.removePubSubResponder","TOPIC",e);const t=e.toString();if(this.mapPubSubResponders[t]){delete this.mapPubSubResponders[t],delete this.mapPubSubResponderState[t],delete this.mapPubSubResponderRegEx[t];const n={header:{origin:this.clientName,type:"removePubSubResponder",topic:e}};this.sendToRouterService(n)}else ny.system.warn(`RouterClient.removePubSubResponder failed: Could not find responder for topic ${e}`)}subscribe(e,t){ny.system.info("RouterClient.subscribe","TOPIC",e);const n=`${this.clientName}.${Zp()()}`;this.mapSubscribersID[n]=t,this.mapSubscribersTopic[n]=e;const r={header:{origin:this.clientName,type:"subscribe",subscribeID:n,topic:e}};return this.sendToRouterService(r),{subscribeID:n,topic:e}}publish(e,t){ny.system.info("RouterClient.publish","TOPIC",e,"EVENT",t);const n={header:{origin:this.clientName,type:"publish",topic:e},data:t};this.sendToRouterService(n)}unsubscribe(e){ny.system.info("RouterClient.unsubscribe","SUBSCRIBE ID",e);const{subscribeID:t}=e;if(this.mapSubscribersID[t]){delete this.mapSubscribersID[t],delete this.mapSubscribersTopic[t];const n={header:{origin:this.clientName,type:"unsubscribe",subscribeID:e.subscribeID,topic:e.topic}};this.sendToRouterService(n)}else ny.system.warn(`RouterClient.unsubscribe: Could not find subscribeID for topic ${e.topic}`)}trustedMessage(e){var t;return ny.system.debug("RouterClient.trustedMessage header",e.header),null===(t=e.header.originMetadata)||void 0===t?void 0:t.transportInfo.transportID.includes("SharedWorker")}disconnectAll(){ny.system.info("RouterClient.disconnectAll"),Object.keys(this.mapListeners).forEach(e=>{Array.from(new Set(this.mapListeners[e])).forEach(t=>{this.removeListener(e,t)})}),Object.keys(this.mapQueryResponders).forEach(e=>{this.removeResponder(e)}),Object.keys(this.mapPubSubResponders).forEach(e=>{this.removePubSubResponder(e)}),Object.keys(this.mapSubscribersID).forEach(e=>{const t=this.mapSubscribersTopic[e];this.unsubscribe({topic:t,subscribeID:e})})}}const dy={onReady:e=>(ny.system.deprecated("You no longer need to call RouterClient.onReady()"),mm("RouterClient",cy).onReady(e)),onFailure:e=>mm("RouterClient",cy).onFailure(e),addListener:(e,t)=>mm("RouterClient",cy).addListener(e,t),transmit:(e,t,n)=>{mm("RouterClient",cy).transmit(e,t,n)},removeListener:(e,t)=>{mm("RouterClient",cy).removeListener(e,t)},addResponder:(e,t)=>{mm("RouterClient",cy).addResponder(e,t)},query:(e,t,n,r)=>mm("RouterClient",cy).query(e,t,n,r),removeResponder:e=>{mm("RouterClient",cy).removeResponder(e)},addPubSubResponder:(e,t,n,r)=>{mm("RouterClient",cy).addPubSubResponder(e,t,n,r)},removePubSubResponder:e=>{mm("RouterClient",cy).removePubSubResponder(e)},subscribe:(e,t)=>mm("RouterClient",cy).subscribe(e,t),publish:(e,t)=>{mm("RouterClient",cy).publish(e,t)},unsubscribe:e=>{mm("RouterClient",cy).unsubscribe(e)},trustedMessage:e=>mm("RouterClient",cy).trustedMessage(e),disconnectAll:()=>{mm("RouterClient",cy).disconnectAll()},calibrateTimeWithRouterService:e=>{mm("RouterClient",cy).calibrateTimeWithRouterService(e)}},hy=dy,py={EVENTS:["title-changed","bringToFront","setBounds","alwaysOnTop","setOpacity"]},gy="Finsemble.Application.State",fy="Finsemble.ServiceManager.serviceInitializing",my="Finsemble.ServiceManager.serviceReady",yy="Finsemble.ServiceManager.serviceClosing",wy="Finsemble.ServiceManager.serviceClosed",vy=e=>`Finsemble.ServiceManager.queryReady.${e}`,by=e=>({authenticationClient:"authenticationService",configClient:"configService",distributedStoreClient:"dataStoreService",hotkeyClient:"hotkeysService",linkerClient:"linkerService",logger:"loggerService",searchClient:"searchService",storageClient:"storageService",windowClient:"windowService",workspaceClient:"workspaceService"}[e]),Cy="Finsemble.State.Services";var Sy;!function(e){e[e.NORMAL=0]="NORMAL",e[e.MINIMIZED_WAS_NORMAL=1]="MINIMIZED_WAS_NORMAL",e[e.MAXIMIZED=2]="MAXIMIZED",e[e.MINIMIZED_WAS_MAXIMIZED=3]="MINIMIZED_WAS_MAXIMIZED"}(Sy||(Sy={}));const Iy="Finsemble.Service.Start",ky="Finsemble.Service.Stop",Ty="Finsemble.Event.Interrupt",xy=["close-requested","closed","close-complete","_container-close-handlers"],Ay={DELAYABLE_EVENTS:["close-requested","closed","close-complete","_container-close-handlers"],CANCELABLE_EVENTS:["close-requested"]},Ey={DELAYABLE_EVENTS:["load-requested","close-requested","save-requested"],CANCELABLE_EVENTS:["close-requested"],CLEAN_SHUTDOWN:"Finsemble.Workspace.cleanShutdown",WORKSPACE_UPDATED:"Finsemble.WorkspaceService.update",RELOAD_GROUPS:"Finsemble.WorkspaceService.reloadGroups",STORAGE_TOPIC:"finsemble.workspace",CACHE_STORAGE_TOPIC:"finsemble.workspace.cache",ALL_WORKSPACES:"finsemble.allWorkspaces",ACTIVE_WORKSPACE:"activeWorkspace",LAST_USED_WORKSPACE_TOPIC:"finsemble",LAST_USED_WORKSPACE_NAME:"finsemble.lastUsedWorkspace.name",LAST_USED_WORKSPACE:"finsemble.lastUsedWorkspace",INITIAL_WORKSPACE_PREFERENCE:"finsemble.initialWorkspace",PUBLISH_REASONS:{INIT:"workspace:initialization",LOAD_DATA_RETRIEVED:"workspace:load:dataRetrieved",LOAD_FINISHED:"workspace:load:finished",WINDOW_REMOVED:"window:remove",WINDOW_ADDED:"window:add",LOAD_STARTED:"workspace:load:start",WORKSPACE_REMOVED:"Workspace:remove",WORKSPACE_RENAMED:"rename",SWITCHTO_TERMINATED:"workspace:switchTo:terminated",NEW_WORKSPACE:"new workspace",SAVE_AS:"APPLICATION LIFECYCLE:WORKSPACE LIFECYCLE:SaveAs:Workspace:Save As"},API_CHANNELS:{NEW_WORKSPACE:"Finsemble.Workspace.NewWorkspace",SAVE:"Finsemble.Workspace.Save",RENAME:"Finsemble.Workspace.Rename",SAVE_AS:"Finsemble.Workspace.SaveAs",SWITCH_TO:"Finsemble.Workspace.SwitchTo",IMPORT:"Finsemble.Workspace.Import",EXPORT:"Finsemble.Workspace.Export",REMOVE:"Finsemble.Workspace.Remove",SAVE_GLOBAL_DATA:"Finsemble.Workspace.SaveGlobalData",SAVE_VIEW_DATA:"Finsemble.Workspace.SaveViewData",GET_GLOBAL_DATA:"Finsemble.Workspace.GetGlobalData",GET_VIEW_DATA:"Finsemble.Workspace.GetViewData",GET_WORKSPACES:"Finsemble.Workspace.GetWorkspaces",GET_WORKSPACE_NAMES:"Finsemble.Workspace.GetWorkspaceNames",SET_WORKSPACE_ORDER:"Finsemble.Workspace.SetWorkspaceOrder",GET_ACTIVE_WORKSPACE:"Finsemble.Workspace.GetActiveWorkspace",GET_ACTIVE_WORKSPACE_DIRTY:"Finsemble.Workspace.GetActiveWorkspaceDirty",GET_TEMPLATES:"Finsemble.Workspace.GetTemplates",IMPORT_TEMPLATE:"Finsemble.Workspace.ImportTemplate",EXPORT_TEMPLATE:"Finsemble.Workspace.ExportTemplate",REMOVE_TEMPLATE:"Finsemble.Workspace.RemoveTemplate",SET_WINDOW_STATE:"Finsemble.Workspace.SetWindowData",GET_WINDOW_STATE:"Finsemble.Workspace.GetWindowData",ADD_WINDOW:"WorkspaceService.addWindow",REMOVE_WINDOW:"WorkspaceService.removeWindow",GET_MANY_WINDOW_STATES:"Finsemble.Workspace.GetWindowDataMultiple",SETUP_INITIAL_WORKSPACE:"Finsemble.Workspace.SetupInitialWorkspace"},DEFAULT_WINDOW_PROPS:["name","componentType","windowType","alwaysOnTop","autoShow","minWidth","minHeight","maxWidth","maxHeight","resizable","maximizable","minimizable","opacity","windowState","left","top","width","height","right","bottom","defaultLeft","defaultTop","defaultWidth","defaultHeight","defaultRight","defaultBottom","monitorInfo","icon","cachedBounds","showTaskbarIcon","isEvergreen","launchGroupComponentData","allowAutoArrange"],ADDITIONAL_WINDOW_PROPS:{WebWindow:["url","fullscreen","frame","backgroundColor","transparent","waitForPageLoad","affinity","appUUID"],NativeWindow:["path","alias","arguments","argumentsAsQueryString","isWPF"]}},Wy={REMOTE_FOCUS:"WindowService.remoteFocus",SET_ALWAYS_ON_TOP:"WindowService-Request-setAlwaysOnTop",IS_ALWAYS_ON_TOP:"WindowService-Request-isAlwaysOnTop"},Oy="finsemble.componentStateStorage",Dy="Finsemble.WindowService.HeartbeatTimeout",_y={WINDOW_CLOSED:"LauncherService.WindowClosed"},Py={AERO_KEY:"aero_key",SYSTEM_RESTORED:"system_restored"},Ry=class{constructor(t,n){var r;this.allowDelay=!1,this.delayed=!1,this.allowCancel=!1,this.canceled=!1,this.completed=!1,this.event=t.event,this.source=t.source,this.sourceType=t.sourceType,this.listenerGuid=t.listenerGuid,e[this.sourceType.toUpperCase()]&&e[this.sourceType.toUpperCase()].DELAYABLE_EVENTS.includes(this.event)&&(this.allowDelay=!0),e[this.sourceType.toUpperCase()]&&e[this.sourceType.toUpperCase()].CANCELABLE_EVENTS.includes(this.event)&&(this.allowCancel=!0),this.handler=t.handler,this.queryMessage=n,this.guid=null===(r=null==n?void 0:n.data)||void 0===r?void 0:r.guid,this.internalHandler()}async internalHandler(){var e,t;this.data=null===(t=null===(e=this.queryMessage)||void 0===e?void 0:e.data)||void 0===t?void 0:t.data,this.handler&&await this.handler(this),this.delayed||this.canceled||this.completed||this.done()}cancel(){this.allowCancel&&(this.canceled=!0,this.done())}wait(){var e;this.allowDelay?(this.delayed=!0,null===(e=this.queryMessage)||void 0===e||e.sendQueryResponse(null,{wait:!0})):this.done()}done(e){var t;this.completed=!0,this.delayed?dy.transmit(`Finsemble.Listener.Done.${this.guid}.${this.listenerGuid}`,{canceled:this.canceled,data:e}):null===(t=this.queryMessage)||void 0===t||t.sendQueryResponse(null,{canceled:this.canceled,data:e})}},Ly=class{constructor(e){var t;this.eventList=[],this.cleanedUp=!1,this.openResponders=[],this.closedHandlersExecuted=0,this.handlers=[],this.closeFinalHandler=null,this.name=e.name,this.thisWindowName=window.name,this.sourceType=null!==(t=e.sourceType)&&void 0!==t?t:"undefined",window.addEventListener("beforeunload",()=>{this.cleanup()}),this.currentWindow=Sm.Window.getCurrent()}addListener(e,t){return this.addEventListener(e,t)}removeListener(e,t){return this.removeEventListener(e,t)}closeFinal(e){this.closeFinalHandler=e;const t=`${this.name}_public_${Date.now()}_${Math.random()}`;dy.transmit(`Finsemble.RegisterInterruptibleEvent.${this.name}`,{event:"closed",listenerGuid:t,windowName:this.thisWindowName});const n=(...e)=>{this.howManyClosedHandlers()||(this.closeFinalHandler&&this.closeFinalHandler(...e),this.closeFinalHandler=null)},r=`Finsemble.Interrupt.${t}`;dy.addResponder(r,(e,r)=>{new Ry({source:this.name,sourceType:this.sourceType,listenerGuid:t,handler:n,event:"closed"},r)}),this.openResponders.push(r)}howManyClosedHandlers(){return this.handlers.filter(e=>"closed"===e.event).length}addEventListener(e,t){ry.system.debug("PublicEventManager.addEventListener:",e);const n=`${this.name}_public_${Date.now()}_${Math.random()}`,r="closed"!==e?t:(...e)=>{t(...e),this.closedHandlersExecuted++,this.closedHandlersExecuted===this.howManyClosedHandlers()&&this.closeFinalHandler&&(this.closeFinalHandler(),this.closeFinalHandler=null)};this.handlers.push({event:e,handler:r,listenerGuid:n}),dy.transmit(`Finsemble.RegisterInterruptibleEvent.${this.name}`,{event:e,listenerGuid:n,windowName:this.thisWindowName});const o=`Finsemble.Interrupt.${n}`;return dy.addResponder(o,(t,o)=>{new Ry({source:this.name,sourceType:this.sourceType,listenerGuid:n,handler:r,event:e},o)}),this.openResponders.push(o),"close-requested"===e&&this.currentWindow.addListener("close-requested",r),()=>{this.removeEventListener(e,t)}}removeEventListener(e,t,n=!0){if(ry.system.debug("PublicEventManager.removeEventListener:",e),this.cleanedUp)return;const r=this.handlers.findIndex(n=>n.event===e&&n.handler===t);if(-1===r)return void(n&&ry.system.warn(`PublicEventManager.removeEventListener() attempt to remove unregistered event "${e}"`));const{listenerGuid:o}=this.handlers[r];dy.transmit(`Finsemble.UnregisterInterruptibleEvent.${this.name}`,{event:e,listenerGuid:o,windowName:this.thisWindowName}),dy.removeResponder(`Finsemble.Interrupt.${o}`),"close-requested"===e&&this.currentWindow.removeListener("close-requested",t),this.handlers.splice(r,1)}cleanup(){this.cleanedUp=!0,this.handlers=[],this.openResponders.forEach(e=>{dy.removeResponder(e)})}};function Fy(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map(function(e){return"'"+e+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function My(e){return!!e&&!!e[kw]}function $y(e){var t;return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Tw}(e)||Array.isArray(e)||!!e[Iw]||!!(null===(t=e.constructor)||void 0===t?void 0:t[Iw])||Gy(e)||Hy(e))}function Ny(e){return My(e)||Fy(23,e),e[kw].t}function jy(e,t,n){void 0===n&&(n=!1),0===By(e)?(n?Object.keys:xw)(e).forEach(function(r){n&&"symbol"==typeof r||t(r,e[r],e)}):e.forEach(function(n,r){return t(r,n,e)})}function By(e){var t=e[kw];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:Gy(e)?2:Hy(e)?3:0}function qy(e,t){return 2===By(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Uy(e,t,n){var r=By(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function zy(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function Gy(e){return vw&&e instanceof Map}function Hy(e){return bw&&e instanceof Set}function Vy(e){return e.o||e.t}function Qy(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Aw(e);delete t[kw];for(var n=xw(t),r=0;r<n.length;r++){var o=n[r],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function Jy(e,t){return void 0===t&&(t=!1),Yy(e)||My(e)||!$y(e)||(By(e)>1&&(e.set=e.add=e.clear=e.delete=Ky),Object.freeze(e),t&&jy(e,function(e,t){return Jy(t,!0)},!0)),e}function Ky(){Fy(2)}function Yy(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function Zy(e){var t=Ew[e];return t||Fy(18,e),t}function Xy(){return yw}function ew(e,t){t&&(Zy("Patches"),e.u=[],e.s=[],e.v=t)}function tw(e){nw(e),e.p.forEach(ow),e.p=null}function nw(e){e===yw&&(yw=e.l)}function rw(e){return yw={p:[],l:yw,h:e,m:!0,_:0}}function ow(e){var t=e[kw];0===t.i||1===t.i?t.j():t.g=!0}function iw(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.O||Zy("ES5").S(t,e,r),r?(n[kw].P&&(tw(t),Fy(4)),$y(e)&&(e=sw(t,e),t.l||lw(t,e)),t.u&&Zy("Patches").M(n[kw].t,e,t.u,t.s)):e=sw(t,n,[]),tw(t),t.u&&t.v(t.u,t.s),e!==Sw?e:void 0}function sw(e,t,n){if(Yy(t))return t;var r=t[kw];if(!r)return jy(t,function(o,i){return aw(e,r,t,o,i,n)},!0),t;if(r.A!==e)return t;if(!r.P)return lw(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var o=4===r.i||5===r.i?r.o=Qy(r.k):r.o,i=o,s=!1;3===r.i&&(i=new Set(o),o.clear(),s=!0),jy(i,function(t,i){return aw(e,r,o,t,i,n,s)}),lw(e,o,!1),n&&e.u&&Zy("Patches").N(r,n,e.u,e.s)}return r.o}function aw(e,t,n,r,o,i,s){if(My(o)){var a=sw(e,o,i&&t&&3!==t.i&&!qy(t.R,r)?i.concat(r):void 0);if(Uy(n,r,a),!My(a))return;e.m=!1}else s&&n.add(o);if($y(o)&&!Yy(o)){if(!e.h.D&&e._<1)return;sw(e,o),t&&t.A.l||lw(e,o)}}function lw(e,t,n){void 0===n&&(n=!1),!e.l&&e.h.D&&e.m&&Jy(t,n)}function uw(e,t){var n=e[kw];return(n?Vy(n):e)[t]}function cw(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function dw(e){e.P||(e.P=!0,e.l&&dw(e.l))}function hw(e){e.o||(e.o=Qy(e.t))}function pw(e,t,n){var r=Gy(t)?Zy("MapSet").F(t,n):Hy(t)?Zy("MapSet").T(t,n):e.O?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:Xy(),P:!1,I:!1,R:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=r,i=Ww;n&&(o=[r],i=Ow);var s=Proxy.revocable(o,i),a=s.revoke,l=s.proxy;return r.k=l,r.j=a,l}(t,n):Zy("ES5").J(t,n);return(n?n.A:Xy()).p.push(r),r}function gw(e){return My(e)||Fy(22,e),function e(t){if(!$y(t))return t;var n,r=t[kw],o=By(t);if(r){if(!r.P&&(r.i<4||!Zy("ES5").K(r)))return r.t;r.I=!0,n=fw(t,o),r.I=!1}else n=fw(t,o);return jy(n,function(t,o){r&&function(e,t){return 2===By(e)?e.get(t):e[t]}(r.t,t)===o||Uy(n,t,e(o))}),3===o?new Set(n):n}(e)}function fw(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Qy(e)}var mw,yw,ww="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),vw="undefined"!=typeof Map,bw="undefined"!=typeof Set,Cw="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Sw=ww?Symbol.for("immer-nothing"):((mw={})["immer-nothing"]=!0,mw),Iw=ww?Symbol.for("immer-draftable"):"__$immer_draftable",kw=ww?Symbol.for("immer-state"):"__$immer_state",Tw=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),xw="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Aw=Object.getOwnPropertyDescriptors||function(e){var t={};return xw(e).forEach(function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)}),t},Ew={},Ww={get:function(e,t){if(t===kw)return e;var n=Vy(e);if(!qy(n,t))return function(e,t,n){var r,o=cw(t,n);return o?"value"in o?o.value:null===(r=o.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!$y(r)?r:r===uw(e.t,t)?(hw(e),e.o[t]=pw(e.A.h,r,e)):r},has:function(e,t){return t in Vy(e)},ownKeys:function(e){return Reflect.ownKeys(Vy(e))},set:function(e,t,n){var r=cw(Vy(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var o=uw(Vy(e),t),i=null==o?void 0:o[kw];if(i&&i.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(zy(n,o)&&(void 0!==n||qy(e.t,t)))return!0;hw(e),dw(e)}return e.o[t]===n&&(void 0!==n||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==uw(e.t,t)||t in e.t?(e.R[t]=!1,hw(e),dw(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=Vy(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){Fy(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Fy(12)}},Ow={};jy(Ww,function(e,t){Ow[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Ow.deleteProperty=function(e,t){return Ow.set.call(this,e,t,void 0)},Ow.set=function(e,t,n){return Ww.set.call(this,e[0],t,n,e[0])};var Dw=function(){function e(e){var t=this;this.O=Cw,this.D=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var o=n;n=e;var i=t;return function(e){var t=this;void 0===e&&(e=o);for(var r=arguments.length,s=Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return i.produce(e,function(e){var r;return(r=n).call.apply(r,[t,e].concat(s))})}}var s;if("function"!=typeof n&&Fy(6),void 0!==r&&"function"!=typeof r&&Fy(7),$y(e)){var a=rw(t),l=pw(t,e,void 0),u=!0;try{s=n(l),u=!1}finally{u?tw(a):nw(a)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then(function(e){return ew(a,r),iw(e,a)},function(e){throw tw(a),e}):(ew(a,r),iw(s,a))}if(!e||"object"!=typeof e){if(void 0===(s=n(e))&&(s=e),s===Sw&&(s=void 0),t.D&&Jy(s,!0),r){var c=[],d=[];Zy("Patches").M(e,s,c,d),r(c,d)}return s}Fy(21,e)},this.produceWithPatches=function(e,n){if("function"==typeof e)return function(n){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return t.produceWithPatches(n,function(t){return e.apply(void 0,[t].concat(o))})};var r,o,i=t.produce(e,n,function(e,t){r=e,o=t});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(function(e){return[e,r,o]}):[i,r,o]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){$y(e)||Fy(8),My(e)&&(e=gw(e));var t=rw(this),n=pw(this,e,void 0);return n[kw].C=!0,nw(t),n},t.finishDraft=function(e,t){var n=(e&&e[kw]).A;return ew(n,t),iw(void 0,n)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!Cw&&Fy(20),this.O=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var o=Zy("Patches").$;return My(e)?o(e,t):this.produce(e,function(e){return o(e,t)})},e}(),_w=new Dw;function Pw(e){return Pw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pw(e)}function Rw(e,t,n){return(t=function(e){var t=function(e){if("object"!=Pw(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Pw(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Pw(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lw(Object(n),!0).forEach(function(t){Rw(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lw(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mw(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}_w.produce,_w.produceWithPatches.bind(_w),_w.setAutoFreeze.bind(_w),_w.setUseProxies.bind(_w),_w.applyPatches.bind(_w),_w.createDraft.bind(_w),_w.finishDraft.bind(_w);var $w="function"==typeof Symbol&&Symbol.observable||"@@observable",Nw=function(){return Math.random().toString(36).substring(7).split("").join(".")},jw={INIT:"@@redux/INIT"+Nw(),REPLACE:"@@redux/REPLACE"+Nw(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Nw()}};function Bw(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(Mw(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(Mw(1));return n(Bw)(e,t)}if("function"!=typeof e)throw new Error(Mw(2));var o=e,i=t,s=[],a=s,l=!1;function u(){a===s&&(a=s.slice())}function c(){if(l)throw new Error(Mw(3));return i}function d(e){if("function"!=typeof e)throw new Error(Mw(4));if(l)throw new Error(Mw(5));var t=!0;return u(),a.push(e),function(){if(t){if(l)throw new Error(Mw(6));t=!1,u();var n=a.indexOf(e);a.splice(n,1),s=null}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error(Mw(7));if(void 0===e.type)throw new Error(Mw(8));if(l)throw new Error(Mw(9));try{l=!0,i=o(i,e)}finally{l=!1}for(var t=s=a,n=0;n<t.length;n++)(0,t[n])();return e}return h({type:jw.INIT}),(r={dispatch:h,subscribe:d,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error(Mw(10));o=e,h({type:jw.REPLACE})}})[$w]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(Mw(11));function n(){e.next&&e.next(c())}return n(),{unsubscribe:t(n)}}})[$w]=function(){return this},e},r}function qw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function Uw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error(Mw(15))},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return r=qw.apply(void 0,i)(n.dispatch),Fw(Fw({},n),{},{dispatch:r})}}}function zw(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}var Gw=zw();Gw.withExtraArgument=zw;const Hw=Gw;var Vw,Qw=(Vw=function(e,t){return Vw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Vw(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Vw(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Jw=function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e},Kw=Object.defineProperty,Yw=Object.defineProperties,Zw=Object.getOwnPropertyDescriptors,Xw=Object.getOwnPropertySymbols,ev=Object.prototype.hasOwnProperty,tv=Object.prototype.propertyIsEnumerable,nv=function(e,t,n){return t in e?Kw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},rv=function(e,t){for(var n in t||(t={}))ev.call(t,n)&&nv(e,n,t[n]);if(Xw)for(var r=0,o=Xw(t);r<o.length;r++)n=o[r],tv.call(t,n)&&nv(e,n,t[n]);return e},ov=function(e,t){return Yw(e,Zw(t))},iv="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?qw:qw.apply(null,arguments)};"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;var sv=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return Qw(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Jw([void 0],e[0].concat(this)))):new(t.bind.apply(t,Jw([void 0],e.concat(this))))},t}(Array),av=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return Qw(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Jw([void 0],e[0].concat(this)))):new(t.bind.apply(t,Jw([void 0],e.concat(this))))},t}(Array);function lv(e){var t,n=function(e){return function(e){void 0===e&&(e={});var t=e.thunk,n=void 0===t||t,r=(e.immutableCheck,e.serializableCheck,new sv);return n&&(function(e){return"boolean"==typeof e}(n)?r.push(Hw):r.push(Hw.withExtraArgument(n.extraArgument))),r}(e)},r=e||{},o=r.reducer,i=void 0===o?void 0:o,s=r.middleware,a=void 0===s?n():s,l=r.devTools,u=void 0===l||l,c=r.preloadedState,d=void 0===c?void 0:c,h=r.enhancers,p=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!function(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var n=t;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];"function"==typeof e[o]&&(n[o]=e[o])}var i,s=Object.keys(n);try{!function(e){Object.keys(e).forEach(function(t){var n=e[t];if(void 0===n(void 0,{type:jw.INIT}))throw new Error(Mw(12));if(void 0===n(void 0,{type:jw.PROBE_UNKNOWN_ACTION()}))throw new Error(Mw(13))})}(n)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},a=0;a<s.length;a++){var l=s[a],u=n[l],c=e[l],d=u(c,t);if(void 0===d)throw t&&t.type,new Error(Mw(14));o[l]=d,r=r||d!==c}return(r=r||s.length!==Object.keys(e).length)?o:e}}(i)}var g=a;"function"==typeof g&&(g=g(n));var f=Uw.apply(void 0,g),m=qw;u&&(m=iv(rv({trace:!1},"object"==typeof u&&u)));var y=new av(f),w=y;return Array.isArray(p)?w=Jw([f],p):"function"==typeof p&&(w=p(y)),Bw(t,d,m.apply(void 0,w))}function uv(e,t){function n(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(t){var o=t.apply(void 0,n);if(!o)throw new Error("prepareAction did not return an object");return rv(rv({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:n[0]}}return n.toString=function(){return""+e},n.type=e,n.match=function(t){return t.type===e},n}var cv=["name","message","stack","code"],dv=function(e,t){this.payload=e,this.meta=t},hv=function(e,t){this.payload=e,this.meta=t},pv=function(e){if("object"==typeof e&&null!==e){for(var t={},n=0,r=cv;n<r.length;n++){var o=r[n];"string"==typeof e[o]&&(t[o]=e[o])}return t}return{message:String(e)}};function gv(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}!function(){function e(e,t,n){var r=uv(e+"/fulfilled",function(e,t,n,r){return{payload:e,meta:ov(rv({},r||{}),{arg:n,requestId:t,requestStatus:"fulfilled"})}}),o=uv(e+"/pending",function(e,t,n){return{payload:void 0,meta:ov(rv({},n||{}),{arg:t,requestId:e,requestStatus:"pending"})}}),i=uv(e+"/rejected",function(e,t,r,o,i){return{payload:o,error:(n&&n.serializeError||pv)(e||"Rejected"),meta:ov(rv({},i||{}),{arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===(null==e?void 0:e.name),condition:"ConditionError"===(null==e?void 0:e.name)})}}),s="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign(function(e){return function(a,l,u){var c,d=(null==n?void 0:n.idGenerator)?n.idGenerator(e):function(e){void 0===e&&(e=21);for(var t="",n=e;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t}(),h=new s;function p(e){c=e,h.abort()}var g=function(){return s=this,g=null,f=function(){var s,g,f,m,y,w;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(v){switch(v.label){case 0:return v.trys.push([0,4,,5]),null===(b=m=null==(s=null==n?void 0:n.condition)?void 0:s.call(n,e,{getState:l,extra:u}))||"object"!=typeof b||"function"!=typeof b.then?[3,2]:[4,m];case 1:m=v.sent(),v.label=2;case 2:if(!1===m||h.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return y=new Promise(function(e,t){return h.signal.addEventListener("abort",function(){return t({name:"AbortError",message:c||"Aborted"})})}),a(o(d,e,null==(g=null==n?void 0:n.getPendingMeta)?void 0:g.call(n,{requestId:d,arg:e},{getState:l,extra:u}))),[4,Promise.race([y,Promise.resolve(t(e,{dispatch:a,getState:l,extra:u,requestId:d,signal:h.signal,abort:p,rejectWithValue:function(e,t){return new dv(e,t)},fulfillWithValue:function(e,t){return new hv(e,t)}})).then(function(t){if(t instanceof dv)throw t;return t instanceof hv?r(t.payload,d,e,t.meta):r(t,d,e)})])];case 3:return f=v.sent(),[3,5];case 4:return w=v.sent(),f=w instanceof dv?i(null,d,e,w.payload,w.meta):i(w,d,e),[3,5];case 5:return n&&!n.dispatchConditionRejection&&i.match(f)&&f.meta.condition||a(f),[2,f]}var b})},new Promise(function(e,t){var n=function(e){try{o(f.next(e))}catch(e){t(e)}},r=function(e){try{o(f.throw(e))}catch(e){t(e)}},o=function(t){return t.done?e(t.value):Promise.resolve(t.value).then(n,r)};o((f=f.apply(s,g)).next())});var s,g,f}();return Object.assign(g,{abort:p,requestId:d,arg:e,unwrap:function(){return g.then(gv)}})}},{pending:o,rejected:i,fulfilled:r,typePrefix:e})}e.withTypes=function(){return e}}(),Object.assign;var fv="listenerMiddleware";uv(fv+"/add"),uv(fv+"/removeAll"),uv(fv+"/remove"),"function"==typeof queueMicrotask&&queueMicrotask.bind("undefined"!=typeof window?window:void 0!==n.g?n.g:globalThis);"undefined"!=typeof window&&window.requestAnimationFrame&&window.requestAnimationFrame,function(){function e(e,t){var n=o[e];return n?n.enumerable=t:o[e]=n={configurable:!0,enumerable:t,get:function(){var t=this[kw];return Ww.get(t,e)},set:function(t){var n=this[kw];Ww.set(n,e,t)}},n}function t(e){for(var t=e.length-1;t>=0;t--){var o=e[t][kw];if(!o.P)switch(o.i){case 5:r(o)&&dw(o);break;case 4:n(o)&&dw(o)}}}function n(e){for(var t=e.t,n=e.k,r=xw(n),o=r.length-1;o>=0;o--){var i=r[o];if(i!==kw){var s=t[i];if(void 0===s&&!qy(t,i))return!0;var a=n[i],l=a&&a[kw];if(l?l.t!==s:!zy(a,s))return!0}}var u=!!t[kw];return r.length!==xw(t).length+(u?0:1)}function r(e){var t=e.k;if(t.length!==e.t.length)return!0;var n=Object.getOwnPropertyDescriptor(t,t.length-1);if(n&&!n.get)return!0;for(var r=0;r<t.length;r++)if(!t.hasOwnProperty(r))return!0;return!1}var o={};!function(e,t){Ew[e]||(Ew[e]=t)}("ES5",{J:function(t,n){var r=Array.isArray(t),o=function(t,n){if(t){for(var r=Array(n.length),o=0;o<n.length;o++)Object.defineProperty(r,""+o,e(o,!0));return r}var i=Aw(n);delete i[kw];for(var s=xw(i),a=0;a<s.length;a++){var l=s[a];i[l]=e(l,t||!!i[l].enumerable)}return Object.create(Object.getPrototypeOf(n),i)}(r,t),i={i:r?5:4,A:n?n.A:Xy(),P:!1,I:!1,R:{},l:n,t,k:o,o:null,g:!1,C:!1};return Object.defineProperty(o,kw,{value:i,writable:!0}),o},S:function(e,n,o){o?My(n)&&n[kw].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var n=t[kw];if(n){var o=n.t,i=n.k,s=n.R,a=n.i;if(4===a)jy(i,function(t){t!==kw&&(void 0!==o[t]||qy(o,t)?s[t]||e(i[t]):(s[t]=!0,dw(n)))}),jy(o,function(e){void 0!==i[e]||qy(i,e)||(s[e]=!1,dw(n))});else if(5===a){if(r(n)&&(dw(n),s.length=!0),i.length<o.length)for(var l=i.length;l<o.length;l++)s[l]=!1;else for(var u=o.length;u<i.length;u++)s[u]=!0;for(var c=Math.min(i.length,o.length),d=0;d<c;d++)i.hasOwnProperty(d)||(s[d]=!0),void 0===s[d]&&e(i[d])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):r(e)}})}();const mv={windows:{},dragging:null,tabCollections:{},useDOMBasedMovement:!0,closingTabs:null},yv={clone:uv("windowTitleBar/clone"),close:uv("windowTitleBar/close"),closeTab:uv("windowTitleBar/closeTab"),disableDOMBasedMovement:uv("windowTitleBar/disableDOMBasedMovement"),setMaximize:uv("windowTitleBar/maximize"),minimize:uv("windowTitleBar/minimize"),promoteTab:uv("windowTitleBar/promoteTab"),register:uv("windowTitleBar/register"),removeFromTabCollection:uv("windowTitleBar/removeFromTabCollection"),scroll:uv("windowTitleBar/scrollTabCollection"),setAlwaysOnTop:uv("windowTitleBar/setAlwaysOnTop"),setGrouped:uv("windowTitleBar/setGrouped"),setUserDefinedTitle:uv("windowTitleBar/setUserDefinedTitle"),setDraggingStatus:uv("windowTitlebar/setDraggingStatus"),stopDragging:uv("windowTitlebar/stopDragging"),shiftPromotedTab:uv("windowTitleBar/shiftPromotedTab"),setClosingTabStatus:uv("windowTitleBar/setClosingTabStatus"),removeClosingTabs:uv("windowTitleBar/removeClosingTabs"),createTabCollection:uv("api/createTabCollection"),addTabsToTabCollection:uv("api/addTabsToTabCollection"),removeTabsFromTabCollection:uv("api/removeTabsFromTabCollection"),showScrim:uv("ux/showScrim"),hideScrim:uv("ux/hideScrim"),setScrimSafetyTimeout:uv("ux/setScrimSafetyTimeout"),addLaunchData:uv("main/addLaunchData"),dockingOperation:uv("main/dockingOperation"),loadWorkspace:uv("main/loadWorkspace"),setEmulatedMaximization:uv("main/setEmulatedMaximization"),enableDND:uv("main/enableDND"),loadUserDefinedTitle:uv("main/loadUserDefinedTitle"),saveSpawnTabTitleToWorkspace:uv("main/saveSpawnTabTitleToWorkspace"),setDocumentTitle:uv("main/updatedDocumentTitle"),setAPITitle:uv("main/updatedAPITitle"),updateGroupedWindows:uv("main/updateGroupedWindows"),windowEvent:uv("main/windowEvent"),updateMaximizedBounds:uv("main/updateMaximizedBounds"),workspaceClosing:uv("main/workspaceClosing"),setTabCollectionForEvergreen:uv("main/setTabCollectionForEvergreen"),updateEvergreenAfterWorkspaceLoading:uv("main/updateEvergreenAfterWorkspaceLoading"),createDefaultWindowTitleBar:uv("main/createDefaultWindowTitleBar")};var wv;function vv(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Array.prototype.concat;var bv=Symbol("isCmd"),Cv=(Symbol("dispatch"),Symbol("getState"),"NONE");Object.freeze((vv(wv={},bv,!0),vv(wv,"type",Cv),vv(wv,"simulate",function(){return null}),wv));const Sv=({server:e,slice:t,dispatchOnly:n})=>r=>(o,i)=>{const s=r((e,t)=>("@@finsemble/updateState"===t.type&&(e=t.newState),{...o(e,t)}),i),a={...s,dispatch:t=>(ry.system.debug(`Interop.remote.${t.type}`,s,t),"@@finsemble/updateState"==t.type?s.dispatch(t):t.type?dy.query(e,t):t.then&&t.then(s.dispatch),t)},l=`reduxSlice:${t}:${Date.now()}_${Math.random()}`;return dy.addListener(l,(e,t)=>{if(!e&&t){const e={type:"@@finsemble/updateState",newState:null==t?void 0:t.data};a.dispatch(e)}}),n||dy.query(e,{"@@finsemble/action":"subscribe","@@finsemble/slice":t,"@@finsemble/routerChannel":l},()=>{}),a},Iv=e=>e;var kv=n(8055),Tv=n.n(kv);class xv{constructor(e){var t;this.onLoadHandler=e=>{(null==e?void 0:e.viewId)===this.id&&this.subscriptions.forEach(e=>null==e?void 0:e())},this.win=e.win,this.id=e.id,this.subscriptions=[],this.isVisible=null===(t=e.visible)||void 0===t||t}async remove(e=Function.prototype){this.subscriptions.length>0&&Sm.removeEventListener("browserView-content-loaded",this.onLoadHandler),await this.win.removeBrowserView(this,e)}async setBounds(e,t=Function.prototype){await this.win.setViewBounds({view:this,bounds:e},t)}async bringToFront(e=Function.prototype){await this.win.bringViewToFront(this,e)}async showView(e=Function.prototype){this.isVisible=!0,await this.win.showBrowserView(this,e)}async hideView(e=Function.prototype){this.isVisible=!1,await this.win.hideBrowserView(this,e)}onContentLoaded(e=Function.prototype){this.subscriptions.push(e),1===this.subscriptions.length&&Sm.addEventListener("browserView-content-loaded",this.onLoadHandler)}}class Av extends Ly{constructor(e){super({name:e.name,sourceType:"Window"}),this.types={},this.wrapState=e.wrapState||"initializing",this.componentState={},this.windowState=Sy.NORMAL,this.type=null,this.windowType=null,this.bounds={},this.guid=`${Date.now()}_${Math.random()}`,this.WINDOWSTATE=Sy,this.windowOptions={},this.doConstruction(e),this.componentKey=Ev("activeWorkspace",this.name,this.name),this.windowKey=Ev("activeWorkspace",this.name),Av.bindFunctions(this)}standardizeEventName(e){switch(e){case"bounds-set":case"stoppedMoving":return"bounds-change-end";case"startedMoving":return"bounds-change-start";case"bringToFront":return"broughtToFront";default:return e}}addEventListener(e,t){return e=this.standardizeEventName(e),super.addEventListener(e,t)}removeEventListener(e,t,n=!1){if("closed"!==e||!pm.finsembleWindow||this.name!==pm.finsembleWindow.name)return e=this.standardizeEventName(e),super.removeEventListener(e,t,n)}windowServiceChannelName(e){return`WindowService-Request-${e}`}eventChannelName(e){return`WindowService-Event-${this.name||this.windowName}-${e}`}doConstruction(e){if(e.setWindowType||e.windowType||(e.windowType="WebWindow"),e.windowType)return e.setWindowType=e.windowType,delete e.windowType,new Av(e);if(e)for(const t in e)this[t]=e[t];this.name||(this.name=e.windowName),this.windowType=this.setWindowType}static registerType(e,t){const n=Av;n.types||(n.types={}),n.types[e]=t}static bindFunctions(e){e.eventChannelName=e.eventChannelName.bind(e),e.windowServiceChannelName=e.windowServiceChannelName.bind(e),e.handleWrapRemoveRequest=e.handleWrapRemoveRequest.bind(e),e.reload=e.reload.bind(e)}static async createWrapFromUUIDAndName(e,t){var n;const{uuid:r,windowType:o}=t;if(!1!==t.waitForReady)try{await Av._windowReady(e),t.wrapState="ready"}catch(e){return{err:e}}ry.system.debug("WRAP LIFECYCLE:",e,"All information for wrap passed in, creating wrap locally");const i=Av.cache[e];return i?(ry.system.debug("WRAP LIFECYCLE:",e,"Window found in the cache, returning without going to the Launcher"),{data:i}):{data:(await Av._createWrap({...t,windowIdentifier:null!==(n=t.windowIdentifier)&&void 0!==n?n:{uuid:r,name:e,windowName:e,windowType:o}})).wrap}}static getInstance(e,t){var n;const r=Sm.Window.getCurrent().name,o=null!==(n=null==(e=Tv()(e))?void 0:e.windowName)&&void 0!==n?n:null==e?void 0:e.name;return new Promise(async(n,i)=>{if(!o){const e='"name" is a required param';return null==t||t(e),void i(e)}e.windowName=o;let s=Av.cache[o];if(s)return ry.system.debug("WRAP LIFECYCLE:",o,"Window found in the cache, returning without going to the Launcher"),null==t||t(null,s),void n({wrap:s});if(e.name){const{err:r,data:s}=await Av.createWrapFromUUIDAndName(o,e);return r||!s?(null==t||t(r),void i(r)):(null==t||t(null,s),void n({wrap:s}))}if(!1!==e.waitForReady)try{await Av._windowReady(o),e.wrapState="ready"}catch(a){return null==t||t(a,null),void i(a)}const{err:a,response:l}=await dy.query("WindowService-Request-getWindowIdentifier",{windowName:o,requester:r});if(a)return ry.system.error(a),null==t||t(a,null),void i(a);if(s=Av.cache[o],s)return ry.system.debug("WRAP LIFECYCLE:",e.name,"Information received from launcher, but wrap exists in cache. Returning cached wrap."),null==t||t(null,s),void n({wrap:s});ry.system.debug("WRAP LIFECYCLE:",o,"Information received from launcher. Creating wrap.");const{identifier:u}=l.data;u.windowName&&(u.name=u.windowName),e.retrievedIdentifier=u,({wrap:s}=await Av._createWrap(e)),l.data.descriptor&&(s.descriptor=l.data.descriptor),null==t||t(null,s),n({wrap:s})})}static _createWrap(e){return new Promise(async t=>{const n=e.retrievedIdentifier||e.windowIdentifier;(e.setWindowType||n.windowType)&&"WebApplication"!==n.windowType||(n.windowType="WebWindow");let r={...n};r=Object.assign(r,e),r.setWindowType=r.windowType,delete r.windowType,ry.system.debug("WRAP LIFECYCLE: Placing wrap into the local cache.",n.windowName);let o=new Av(r);Av.cache[n.windowName]=o,o.windowType=n.windowType,o.identifier=n,o.closeFinal(o.handleWrapRemoveRequest),o.addEventListener("maximized",async()=>{o.windowState=Sy.MAXIMIZED,o.windowOptions.windowState=Sy.MAXIMIZED;const{data:e}=await o.getBounds();e&&(o.windowOptions.left=e.left,o.windowOptions.top=e.top,o.windowOptions.height=e.height,o.windowOptions.width=e.width,o.windowOptions.right=e.right,o.windowOptions.bottom=e.bottom,o.windowOptions.opacity=1,o.saveCompleteWindowState(o.windowOptions))}),o.addEventListener("minimized",()=>{o.windowState===Sy.MAXIMIZED?(o.windowState=Sy.MINIMIZED_WAS_MAXIMIZED,o.windowOptions.windowState=Sy.MINIMIZED_WAS_MAXIMIZED):o.windowState===Sy.NORMAL?(o.windowState=Sy.MINIMIZED_WAS_NORMAL,o.windowOptions.windowState=Sy.MINIMIZED_WAS_NORMAL):ry.system.warn("Invalid window state received listening to window minimize",o.windowState)}),o.addEventListener("restored",()=>{o.windowState=Sy.NORMAL,o.windowOptions.windowState=Sy.NORMAL});const i=dy.subscribe(`Finsemble.Component.State.${n.windowName}`,(e,t)=>{if(e)ry.system.error("Finsemble component state change error",e);else{const{state:e}=t.data;o.wrapState=e,dy.unsubscribe(i)}});t({wrap:o})})}static _getRemoveWrapChannel(e){return`${Sm.Window.getCurrent().name}.removeWrap.${e}`}async handleWrapRemoveRequest(e){e&&e.wait(),ry.system.debug("WRAP Destructor. Removing cached window",this.name,"in ",window.name),this.removeListeners&&this.removeListeners(),this.cleanupRouter(),this.cleanup(),this.name!==pm.name&&this.name&&delete Av.cache[this.name],e&&e.done()}static closeAllWraps(){Object.values(Av.cache).forEach(e=>{e.handleWrapRemoveRequest()})}cleanupRouter(){const e=Av._getRemoveWrapChannel(this.name);dy.removeResponder(e)}onReady(e){return new Promise(t=>{if("ready"===this.wrapState)return null==e||e(),void t();this.addEventListener("ready",()=>{null==e||e(),t()})})}queryWindowService(e,t,n=Function.prototype){return"function"==typeof t&&(n=t,t={}),t={...t,windowIdentifier:this.identifier},ry.setting().system.Debug&&(t.callstack=ry.callStack()),new Promise(async(r,o)=>{var i;if("close"!==e&&"ready"!==this.wrapState)return await this.onReady(),this.wrapState="ready",void r(await this.queryWindowService(e,t));ry.system.debug("FinsembleWindow.queryWindowService",this.windowServiceChannelName(e),t);const{err:s,response:a}=await dy.query(this.windowServiceChannelName(e),t);let l=null!==(i=a.data)&&void 0!==i?i:null;if(s){if(ry.system.debug(`WindowService.${e}: failed`,s),console.debug(`WindowService.${e}: failed`,s),"getComponentState"!==e&&"Not found"!==s)return void o(s)}else ry.system.debug(`${this.windowServiceChannelName(e)} successful`,l),console.debug(`${this.windowServiceChannelName(e)} successful`,l);r(l),n(s,l)})}minimize(e=null,t){return new Promise(n=>{this.queryWindowService("minimize",e,e=>{null==t||t(e),n({err:e})})})}maximize(e=null,t){return new Promise(n=>{this.getBounds((r,o)=>{r||!o?ry.system.warn(`Error getting bounds, cached bounds will not be set: ${r}`):this.updateOptions({options:{left:o.left,top:o.top,width:o.width,height:o.height}}),this.queryWindowService("maximize",e,e=>{null==t||t(e),n({err:e})})})})}restore(e=null,t){return new Promise(n=>{this.queryWindowService("restore",e,e=>{null==t||t(e),n({err:e})})})}blur(e=null,t){return new Promise(n=>{this.queryWindowService("blur",e,e=>{null==t||t(e),n({err:e})})})}focus(e=null,t){return new Promise(n=>{this.queryWindowService("focus",e,e=>{null==t||t(e),n({err:e})})})}bringToFront(e=null,t){return new Promise(n=>{this.queryWindowService("bringToFront",e,e=>{null==t||t(e),n({err:e})})})}setAlwaysOnTop(e={alwaysOnTop:!0},t){return new Promise(n=>{this.queryWindowService("setAlwaysOnTop",e,e=>{null==t||t(e),n({err:e})})})}isAlwaysOnTop(e={},t){this.queryWindowService("isAlwaysOnTop",e,t)}isShowing(e={},t){this.queryWindowService("isShowing",e,t)}setIgnoreMouseEvents(e,t,n=Function.prototype){const r={ignore:new Boolean(e).valueOf(),options:new Boolean(t).valueOf()?t:{forward:!1}};this.queryWindowService("setIgnoreMouseEvents",r,n)}setShape(e,t=Function.prototype){this.queryWindowService("setShape",e,t)}async addBrowserView(e,t=Function.prototype){const n=await this.queryWindowService("addBrowserView",e,t);return new xv({id:n,win:this,visible:null==e?void 0:e.visible})}async removeBrowserView(e,t=Function.prototype){await this.queryWindowService("removeBrowserView",{viewId:e.id},t)}async bringViewToFront(e,t=Function.prototype){await this.queryWindowService("bringViewToFront",{viewId:e.id},t)}async showBrowserView(e,t=Function.prototype){await this.queryWindowService("showBrowserView",{viewId:e.id},t)}async hideBrowserView(e,t=Function.prototype){await this.queryWindowService("hideBrowserView",{viewId:e.id},t)}async setViewBounds(e,t=Function.prototype){await this.queryWindowService("setViewBounds",{viewId:e.view.id,bounds:e.bounds},t)}setBounds(e={bounds:{}},t){return new Promise(n=>{"function"==typeof e||e.bounds||(e={bounds:e}),this.queryWindowService("setBounds",e,e=>{null==t||t(e),n({err:e})})})}getBounds(e,t){return new Promise(n=>{const r="function"==typeof e?e:t;this.queryWindowService("getBounds",{},(e,t)=>{null==r||r(e,t),n({err:e,data:t})})})}updateOptions(e,t=Function.prototype){this.queryWindowService("updateOptions",e,t)}hide(e={},t){return new Promise(n=>{this.queryWindowService("hide",e,(e,r)=>{null==t||t(e,r),n({err:e})})})}reload(e={},t=Function.prototype){this.queryWindowService("reload",e,t)}show(e={},t){return new Promise(n=>{this.queryWindowService("show",e,(e,r)=>{null==t||t(e,r),n({err:e})})})}showAt(e={},t=Function.prototype){this.queryWindowService("showAt",e,t)}close(e={},t){return new Promise(n=>{ry.system.debug("WRAP CLOSE. Public close initiated for",this.name,e),this.queryWindowService("close",e,e=>{ry.system.debug("WRAP CLOSE. Public close initiated for",this.name),null==t||t(e),n({err:e})})})}animate(e={},t=Function.prototype){this.queryWindowService("animate",e,t)}registerWithDocking(e={},t){this.onReady(()=>{dy.query("DockingService.registerWindow",e,t)})}showNativeOpenDialog(e={},t){this.queryWindowService("showNativeOpenDialog",e,t)}unRegisterWithDocking(){dy.transmit("DockingService.deregisterWindow",{name:this.windowName})}initializeWindow({manageWindowMovement:e,identifier:t},n=Function.prototype){const r=()=>{dy.publish(`Finsemble.${this.windowName}.componentReady`,{name:this.windowName}),n()};e?this.registerWithDocking(t,r):r()}wrapReady(){dy.publish(`Finsemble.${this.windowName}.wrapReady`,{name:this.windowName,state:"open"})}setOpacity(e,t=Function.prototype){this.queryWindowService("setOpacity",e,t)}startTabTileMonitoring(e={}){ry.system.debug("FinsembleWindow.startTabTileMonitoring",e),dy.transmit("TabTile.startTabTile",{params:e})}stopTabTileMonitoring(e={},t=Function.prototype){ry.system.debug("FinsembleWindow.stopTabTileMonitoring",e),dy.query("TabTile.stopTabTile",{params:e},function(e,n){e?ry.system.warn("TabTile.stopTabTile: query failed",e):ry.system.debug("TabTile.stopTabTile results",n.data);const r=n.data;t?t(e,r,this.defaultStopTrackingAction):this.defaultTabTileAction(r)})}defaultTabTileAction(e){const t=this;switch(ry.system.debug("FinsembleWindow.defaultTabTileAction",e),e.stoppedLocation){case"OutsideWindow":case"TabSection":break;case"InsideWindow":e.tileGroupId?t.Group.addWindow(this.identifier,e.tileGroupId,e.dropCoordinates):t.Group.createGroup(function(n){t.Group.addWindow(this.identifier,n,e.dropCoordinates,{startingWindowIdentifier:e.droppedOnWindowIdentifier})});break;default:ry.system.error("stopTracking returned an unknown stoppedLocation result",e)}}mergeBounds(e){e.right=e.left+e.width;const t={left:e.left,right:e.right,width:e.width,top:e.top,bottom:e.top+e.height,height:e.height},n={defaultLeft:e.left,defaultWidth:e.width,defaultTop:e.top,defaultHeight:e.height};Object.assign(this.windowOptions,t),Object.assign(this.windowOptions,n),this.windowOptions.bounds=t}startMove(e={}){ry.system.debug("FinsembleWindow.startMove",e),e.windowIdentifier=this.identifier,dy.transmit(this.eventChannelName("startedMoving"),{})}stopMove(e={}){ry.system.debug("FinsembleWindow.stopMove",e),e.windowIdentifier=this.identifier,dy.transmit(this.eventChannelName("stoppedMoving"),{})}getMonitor(e){dy.query("DockingService.getMonitorForWindow",{windowIdentifier:this.identifier},(t,n)=>n?e(n.data):e())}getComponentState(e,t){return new Promise(n=>{this.queryWindowService("getComponentState",e,(e,r)=>{null==t||t(e,r),n({err:e,data:r})})})}getWindowState(e,t){this.queryWindowService("getWindowState",e,t)}setComponentState(e,t=()=>{}){this.queryWindowService("setComponentState",e,t)}removeComponentState(e,t=()=>{}){this.queryWindowService("removeComponentState",e,t)}setWindowState(e,t=()=>{}){this.queryWindowService("setWindowState",e,t)}saveCompleteWindowState(e={},t=Function.prototype){this.queryWindowService("saveCompleteWindowState",e,t)}cancelTabTileMonitoring(e={}){ry.system.debug("FinsembleWindow.cancelTabTileMonitoring",e),dy.transmit("TabTile.cancelTabTile",{params:e})}setTitle(e){(({singletonName:e,server:t,slice:r,emptyStore:o,dispatchOnly:i=!1})=>((e,t,...r)=>{const o=fm(e);if(!o){const o=Symbol.for(`com.finsemble.singleton.${e}`);return n.g[o]=t(...r),n.g[o]}return o})(e,()=>(({server:e,slice:t,emptyStore:n,dispatchOnly:r=!1})=>lv({preloadedState:n,reducer:Iv,enhancers:[Sv({server:e,slice:t,dispatchOnly:r})]}))({server:t,slice:r,emptyStore:o,dispatchOnly:i})))({singletonName:"WindowClient::setWindowTitle",server:"@@finsemble/remoteRedux/WindowServiceStore",slice:"windowTitleBar",emptyStore:mv,dispatchOnly:!0}).dispatch(yv.setAPITitle({title:e}))}getOptions(e){return new Promise(t=>{this.queryWindowService("getOptions",{},(n,r)=>{null==e||e(n,r),t({err:n,data:r})})})}formGroup(){dy.transmit("DockingService.formGroup",{windowName:this.name})}ejectFromGroup(){dy.query("DockingService.leaveGroup",{name:this.name},()=>{})}}function Ev(...e){let t="";for(let n=0;n<e.length;n++)t=`${t} ${e[n]}`;return t.replace(/\s(.)/g,e=>e.toUpperCase()).replace(/\s/g,"").replace(/^(.)/,e=>e.toLowerCase())}Av.WINDOWSTATE=Sy,Av.wrap=Av.getInstance,Av.cache={},Av._windowReady=function(e){let t;return ry.system.debug(`windowServiceReady: ${e} starting`),new Promise(async n=>{ry.system.debug(`windowServiceReady: ${e} waiting`),t=dy.subscribe(`Finsemble.Component.State.${e}`,(r,o)=>{const{state:i}=o.data;switch(ry.system.debug(`windowServiceReady: ${e} state change: ${i}`),i){case"ready":case"reloading":case"closing":ry.system.debug(`windowServiceReady: ${e} ${i}`),dy.unsubscribe(t),n()}})})},n(4383),n(2404),n(9132);let Wv,Ov,{fdc3:Dv}=pm,_v=null;const Pv=async()=>{var e,t,n;if(null!==_v)return _v;const r=await Wv.contexts.get(tg),o=null===(e=null==r?void 0:r.iocd)||void 0===e?void 0:e.persistFDC3Context,i=await Wg(Wv.windows.my()),s=null===(t=null==i?void 0:i.customProperties)||void 0===t?void 0:t.persistFDC3Context;return _v=null===(n=null!=s?s:o)||void 0===n||n,Ov.debug("FDC3 context persistence enabled?",_v),_v},Rv=async e=>{var t;if(!e)return;if(!await Pv())return;const n=`#finsemble-persistedContext-${e.type}`;Ov.debug("Persisting FDC3 context",n,e),await(null===(t=Wv.windows.my())||void 0===t?void 0:t.updateContext({[n]:e}))},Lv=async(e,t)=>{var n,r,o,i;if(!await Pv())return;const s=null!==(r=await(null===(n=Wv.windows.my())||void 0===n?void 0:n.getContext()))&&void 0!==r?r:{},a=`#finsemble-persistedContext-${e}`,l=null!==(o=s[a])&&void 0!==o?o:null===(i=s["#finsemble-componentState"])||void 0===i?void 0:i[a];l&&Ov.debug("Restoring FDC3 context",a,l),l&&await t(l)},Fv=[],Mv=()=>{if(!globalThis.fdc3)return void console.log("No fdc3 object found on global path. Skipping monkey patch.");const e=Dv.addContextListener,t=Dv.broadcast,n=Dv.addIntentListener,r=Dv.raiseIntent,o=Dv.open,i=Dv.getUserChannels;Dv.addContextListener=async(t,n)=>{(Ov||console).log("intercepted addContextListener",t),n||(n=t,t=null);const r=null!=n?n:t,o=(e,t)=>(Rv(e),r(e,t));return"string"==typeof t&&(Wv?await Lv(t,r):Fv.push(()=>{Lv(t,r)})),n?await e(t,o):await e(o)},Dv.broadcast=async e=>{if(Wv)return Rv(e),await t(e);Fv.push(()=>{Dv.broadcast(e)})},Dv.addIntentListener=async(e,t)=>await n(e,async(e,n)=>(Rv(e),await t(e,n))),Dv.leaveChannel=async e=>{var t;Wv&&await Wv.channels.leave(null===(t=Wv.windows.my())||void 0===t?void 0:t.id,e)},Dv.getCurrentChannels=async()=>{var e;if(!Wv)return null;const t=null!==(e=Wv.channels.current())&&void 0!==e?e:"",n=t?t.split("+++"):[];return(await Dv.getUserChannels()).filter(e=>n.includes(e.id))};const s=async e=>{let t=e;const n="string"==typeof e?e:(null==e?void 0:e.name)?e.name:void 0;if(n){const e=(await Wv.appManager.applications()).find(e=>{var t,r;return(null===(r=null===(t=e.userProperties)||void 0===t?void 0:t.appd)||void 0===r?void 0:r.name)===n});e&&(t={appId:e.name})}return t};Dv.getSystemChannels=async()=>(await i()).sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:0),Dv.getUserChannels=async()=>(await i()).sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:0),Dv.raiseIntent=async(e,t,n)=>r(e,t,await s(n)),Dv.open=async(e,t)=>o(await s(e),t)},$v=(e,t)=>{globalThis.fdc3&&(Wv=e,Ov=t,Ov.debug("Monkey patching fdc3. Queued broadcasts:",Fv.length),Fv.forEach(e=>{e()}))},Nv=(new Date).getTime();if(globalThis.window){console.debug("FSBL preload running");const e=null===globalThis||void 0===globalThis?void 0:globalThis.glue42gd;e&&(e.gwURL=e.gwURL.replace("localhost","127.0.0.1"))}const jv={appManager:"full",layouts:{mode:"full",autoSaveWindowContext:["Workspace","Global"]},windows:!0,bus:!0,channels:!0,contexts:!0,libraries:[pc,Gp]},Bv=(e,t)=>{Mv();const n=new Kp,r=e(null!=t?t:jv),o=new Dg,i=new $f(r,o),s=new tm(r,o,i);i.initialize(s),Zg.setStaticInstances(r,i);const a=new Df(r,o,i),l=new ef(r,o,s,i),u=new kf(r,o,i),c=new Zg(r,o),d=new om(r,o,i),h=new rm(r,o,i),p=new tf(r,o,i,s,h),g=new Pf(r,o,i),f=new lm(r,o,i),m=new df(r,o,s,i),y=new yf(r,o,s,l,u,i),w={addEventListener:async(e,t)=>{"onReady"===e&&(await n.promise,t())},Clients:{AppsClient:l,AuthenticationClient:p,DialogManager:y,SearchClient:new nm(r,o,i),RouterClient:s,WorkspaceClient:f,ConfigClient:m,LauncherClient:l,WindowClient:d,DistributedStoreClient:u,StorageClient:h,HotkeyClient:new Ff(r,o,i),NotificationClient:new Yf(r,o,i),Logger:i,BloombergBridgeClient:new dm(r,o,i)},SystemManagerClient:new um(r,o,i),getFSBLInfo:async e=>{const t=await g.getFEAInfo(),n={FSBLVersion:t["io.Connect Desktop"],gitHash:"","io.Connect Desktop":t["io.Connect Desktop"],"@interopio/desktop":t["@interopio/desktop"],Electron:t.Electron,FEA:t.FEA,isDevLaunch:!1,isDevMode:!1,sddEnabled:!1};return null==e||e(n),n},UserNotification:new cm(r),componentType:"",publishReady:()=>{r.then(async e=>{const{err:t}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"signal-app-ready"}));t&&console.error("Error occurred signaling ready",t)})},restartApplication:async e=>new Promise(t=>{r.then(n=>{(async(e,t,n,r)=>{await Vg(e,t,n,!0,r)||await e.appManager.restart({autoSave:!1,showDialog:!1})})(n,y.open.bind(y),f.save.bind(f),e).then(t)})}),shutdownApplication:()=>{r.then(e=>{(async(e,t,n)=>{await Vg(e,t,n,!1,void 0)||await e.appManager.exit({autoSave:!1,showDialog:!1})})(e,y.open.bind(y),f.save.bind(f))})},onShutdown:()=>{},System:g,glue:r,version:"0.0.1",FinsembleWindow:Zg};return console.debug("FSBL preload: Glue API initializing"),i.debug("FSBL preload: Glue API initializing"),r.then(async e=>{var t,r,a,l,u,c,d,h,g,f,m,y;if(console.debug("FSBL preload: Glue API ready"),i.debug("FSBL preload: Glue API ready"),"Toolbar"===(null===(t=e.windows.my())||void 0===t?void 0:t.name)){const{err:t}=await gg(()=>e.interop.invoke("T42.GD.Execute",{command:"signal-app-ready"}));t&&console.error("Error occurred signaling Toolbar ready",t)}await Promise.all([o.ready()]),i.debug("FSBL preload: All clients are ready"),globalThis.iop=null!==(r=globalThis.iop)&&void 0!==r?r:e;const v=null===(u=null===(l=null===(a=e.windows)||void 0===a?void 0:a.my())||void 0===l?void 0:l.application)||void 0===u?void 0:u.type;v&&(w.componentType=v),null===(d=null===(c=e.windows)||void 0===c?void 0:c.my())||void 0===d||d.onRefreshing(async t=>{var n;const r=await e.contexts.get(tg);!1===(null===(n=null==r?void 0:r["finsemble-electron-adapter"])||void 0===n?void 0:n.reloadWindowHotkey)&&t()}),null===(g=null===(h=e.windows)||void 0===h?void 0:h.my())||void 0===g||g.onFocusChanged(e=>{e.isFocused?document.documentElement.classList.add("desktop-active"):document.documentElement.classList.remove("desktop-active")}),"sso-application"===(null===(m=null===(f=e.windows)||void 0===f?void 0:f.my())||void 0===m?void 0:m.name)&&(e.interop.register("Finsemble.Clients.AuthenticationClient.publishAuthorization.backChannel",ig(async(e,t)=>{console.debug("Received backChannel credentials from application",t.applicationName),p.publishAuthorization(null==e?void 0:e.user,null==e?void 0:e.credentials)})),(async e=>{var t;const n=await Wg(e.windows.my());(null==n?void 0:n.details.hidden)&&(null===(t=e.windows.my())||void 0===t||t.hide())})(e),s.publish("AuthorizationState",{state:"starting"}).then(()=>{s.publish("AuthorizationState",{state:"waiting"})})),(async e=>{var t;const n=await(async e=>{var t,n,r;if(!e.windows)return!1;const o=await Wg(e.windows.my());return!!(null===(t=null==o?void 0:o.customProperties)||void 0===t?void 0:t.component)||"(Menu) "===(null===(n=e.windows.my())||void 0===n?void 0:n.name.substring(0,7))||["custom-tray","finsemble-decorator-window","web-group-application"].includes(null===(r=globalThis.glue42gd)||void 0===r?void 0:r.applicationName)})(e);if(!n)return;const r=await e.contexts.get(tg);(e=>{if(e){const o=Zp()(),i=`${r=e,"/"===r.slice(-1)?r:`${r}/`}assets/css/theme.css?${o}`,s=document.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("type","text/css"),s.setAttribute("href",i),n=s,(t=document.body).firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}var t,n,r})(null===(t=null==r?void 0:r.finsemble)||void 0===t?void 0:t.documentRoot),(async e=>{let t=null;if(!e.themes)return;const n=e=>{var n,r;const o=document.getElementsByTagName("html");t&&(null===(n=o[0])||void 0===n||n.classList.remove(t.name)),t=e,null===(r=o[0])||void 0===r||r.classList.add(t.name)};t=await e.themes.getCurrent(),n(t),e.themes.onChanged(e=>{n(e)})})(e)})(e),$v(e,i),i.debug(`FSBL preload ready ${(new Date).getTime()-Nv}ms`),n.resolve();const b=new Event("FSBLReady");null===(y=globalThis.dispatchEvent)||void 0===y||y.call(globalThis,b),Wg(e.windows.my()).then(t=>{(null==t?void 0:t.details.backgroundThrottling)&&(async e=>{const t=e.windows.my();if(!t)return;const{id:n,name:r}=t;setInterval(async()=>{const{err:t}=await gg(()=>e.interop.invoke("Finsemble.heartbeat",{type:"component",windowName:`${r}:${n}`,componentType:"finsemble",isBrowserView:!0}));t&&console.error("Error occurred sending heartbeat",t)},1e4)})(e)})}),{FSBL:w,finsembleWindow:c,fin:a}};if("undefined"!=typeof window){const e=window.Glue;if(e){const t=Bv(e);Object.keys(t).forEach(e=>{window[e]=t[e]}),console.debug("FSBL preload loaded")}}})(),{}})());
3
3
  //# sourceMappingURL=fsbl-polyfill.umd.js.map