UNPKG

@interopio/browser

Version:

IOConnect Browser client application package

1 lines 289 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).browser=e.browser||{},e.browser.min=t())}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}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)};var n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function s(e,t,n){return e.concat(t).map(function(e){return i(e,n)})}function r(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 o(e,t){try{return t in e}catch(e){return!1}}function a(e,t,n){var s={};return n.isMergeableObject(e)&&r(e).forEach(function(t){s[t]=i(e[t],n)}),r(t).forEach(function(r){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(o(e,r)&&n.isMergeableObject(t[r])?s[r]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(r,n)(e[r],t[r],n):s[r]=i(t[r],n))}),s}function c(e,n,r){(r=r||{}).arrayMerge=r.arrayMerge||s,r.isMergeableObject=r.isMergeableObject||t,r.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(n);return o===Array.isArray(e)?o?r.arrayMerge(e,n,r):a(e,n,r):i(n,r)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return c(e,n,t)},{})};var d=e(c),l=function(e){return{ok:!0,result:e}},h=function(e){return{ok:!1,error:e}},u=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:l(e(t.result,n.result))},p=function(e,t){return!0===t.ok?t:h(e(t.error))},g=function(){return g=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},g.apply(this,arguments)};function m(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(!m(e[n],t[n]))return!1;return!0}var i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(n=0;n<i.length;n++){if(!t.hasOwnProperty(i[n]))return!1;if(!m(e[i[n]],t[i[n]]))return!1}return!0}}var f=function(e){return Array.isArray(e)},b=function(e){return"object"==typeof e&&null!==e&&!f(e)},y=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)},w=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},v=function(e,t){var n=t.at,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(n[i[s]]=e[i[s]])}return n}(t,["at"]);return g({at:e+(n||"")},i)},C=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return p(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?l(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,i){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(i)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?l(e):h({message:y("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?l(e):h({message:y("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?l(e):h({message:y("a boolean",e)})})},e.constant=function(t){return new e(function(e){return m(e,t)?l(t):h({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(b(e)&&t){var n={};for(var i in t)if(t.hasOwnProperty(i)){var s=t[i].decode(e[i]);if(!0!==s.ok)return void 0===e[i]?h({message:"the key '"+i+"' is required but was not present"}):h(v("."+i,s.error));void 0!==s.result&&(n[i]=s.result)}return l(n)}return b(e)?l(e):h({message:y("an object",e)})})},e.array=function(t){return new e(function(e){if(f(e)&&t){return e.reduce(function(e,n,i){return u(function(e,t){return e.concat([t])},e,function(e,n){return p(function(e){return v("["+n+"]",e)},t.decode(e))}(n,i))},l([]))}return f(e)?l(e):h({message:y("an array",e)})})},e.tuple=function(t){return new e(function(e){if(f(e)){if(e.length!==t.length)return h({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],i=0;i<t.length;i++){var s=t[i].decode(e[i]);if(!s.ok)return h(v("["+i+"]",s.error));n[i]=s.result}return l(n)}return h({message:y("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.oneOf.apply(e,[t,n].concat(i))},e.intersection=function(t,n){for(var i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];return new e(function(e){return[t,n].concat(i).reduce(function(t,n){return u(Object.assign,t,n.decode(e))},l({}))})},e.anyJson=function(){return new e(function(e){return l(e)})},e.unknownJson=function(){return new e(function(e){return l(e)})},e.dict=function(t){return new e(function(e){if(b(e)){var n={};for(var i in e)if(e.hasOwnProperty(i)){var s=t.decode(e[i]);if(!0!==s.ok)return h(v("."+i,s.error));n[i]=s.result}return l(n)}return h({message:y("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?l(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=[],i=0;i<t.length;i++){var s=t[i].decode(e);if(!0===s.ok)return s;n[i]=s.error}var r=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return h({message:'expected a value matching one of the decoders, got the errors ["'+r+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return l(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 i=e,s=0;s<t.length;s++){if(void 0===i)return h({at:w(t.slice(0,s+1)),message:"path does not exist"});if("string"==typeof t[s]&&!b(i))return h({at:w(t.slice(0,s+1)),message:y("an object",i)});if("number"==typeof t[s]&&!f(i))return h({at:w(t.slice(0,s+1)),message:y("an array",i)});i=i[t[s]]}return p(function(e){return void 0===i?{at:w(t),message:"path does not exist"}:v(w(t),e)},n.decode(i))})},e.succeed=function(t){return new e(function(e){return l(t)})},e.fail=function(t){return new e(function(e){return h({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),I=C.string,S=C.number,_=C.boolean,x=C.anyJson;C.unknownJson;var k=C.constant,R=C.object,A=C.array;C.tuple,C.dict;var P=C.optional,T=C.oneOf,O=C.union,E=C.intersection;C.withDefault,C.valueAt,C.succeed,C.fail;var M=C.lazy;const D={gateway:{webPlatform:{}},libraries:[],exposeAPI:!0},j={awaitFactory:!0,enable:!1,timeout:5e3,restoreLastKnownPosition:!0},N={alerts:{enabled:!1},dialogs:{enabled:!1},awaitFactory:!0,timeout:5e3},F={enable:!1,timeout:5e3,awaitFactory:!0},$={name:"platformUnload"},L={name:"transportSwitchRequest"},W={name:"transportSwitchResponse"},q={name:"getCurrentTransport"},U={name:"getCurrentTransportResponse"},G={name:"checkPreferredLogic"},B={name:"checkPreferredConnection"},J={name:"checkPreferredLogicResponse"},H={name:"checkPreferredConnectionResponse"},z="web-platform",K="latest_fdc3_type",V=new MessageChannel,Z=2147483647,Q={configurable:!1,enumerable:!0,writable:!1},X=e=>"string"==typeof e?e:e?.message?"string"==typeof e.message?e.message:JSON.stringify(e.message):JSON.stringify(e),Y=(e,t)=>{try{return e.runWithException(t)}catch(e){return se.raiseError(e,!0)}},ee=e=>Object.keys(e).filter(t=>e[t].execute),te=(e,t)=>({isSupported:e.some(e=>e.toLowerCase()===t.toLowerCase())}),ne=e=>Math.min(e,Z),ie=()=>{let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}};const se=new class{raiseError(e,t){const n=X(e);if(V.port1.postMessage(n),t)throw e;throw new Error(n)}},re=["name","title","version","customProperties","icon","caption","type"],oe=["appId","name","type","details","version","title","tooltip","lang","description","categories","icons","screenshots","contactEmail","moreInfo","publisher","customConfig","hostManifests","interop","localizedVersions"];var ae=function(e){return{ok:!0,result:e}},ce=function(e){return{ok:!1,error:e}},de=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:ae(e(t.result,n.result))},le=function(e,t){return!0===t.ok?t:ce(e(t.error))},he=function(){return he=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},he.apply(this,arguments)};function ue(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(!ue(e[n],t[n]))return!1;return!0}var i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(n=0;n<i.length;n++){if(!t.hasOwnProperty(i[n]))return!1;if(!ue(e[i[n]],t[i[n]]))return!1}return!0}}var pe=function(e){return Array.isArray(e)},ge=function(e){return"object"==typeof e&&null!==e&&!pe(e)},me=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)},fe=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},be=function(e,t){var n=t.at,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(n[i[s]]=e[i[s]])}return n}(t,["at"]);return he({at:e+(n||"")},i)},ye=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return le(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?ae(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,i){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(i)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?ae(e):ce({message:me("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?ae(e):ce({message:me("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?ae(e):ce({message:me("a boolean",e)})})},e.constant=function(t){return new e(function(e){return ue(e,t)?ae(t):ce({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(ge(e)&&t){var n={};for(var i in t)if(t.hasOwnProperty(i)){var s=t[i].decode(e[i]);if(!0!==s.ok)return void 0===e[i]?ce({message:"the key '"+i+"' is required but was not present"}):ce(be("."+i,s.error));void 0!==s.result&&(n[i]=s.result)}return ae(n)}return ge(e)?ae(e):ce({message:me("an object",e)})})},e.array=function(t){return new e(function(e){if(pe(e)&&t){return e.reduce(function(e,n,i){return de(function(e,t){return e.concat([t])},e,function(e,n){return le(function(e){return be("["+n+"]",e)},t.decode(e))}(n,i))},ae([]))}return pe(e)?ae(e):ce({message:me("an array",e)})})},e.tuple=function(t){return new e(function(e){if(pe(e)){if(e.length!==t.length)return ce({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],i=0;i<t.length;i++){var s=t[i].decode(e[i]);if(!s.ok)return ce(be("["+i+"]",s.error));n[i]=s.result}return ae(n)}return ce({message:me("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.oneOf.apply(e,[t,n].concat(i))},e.intersection=function(t,n){for(var i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];return new e(function(e){return[t,n].concat(i).reduce(function(t,n){return de(Object.assign,t,n.decode(e))},ae({}))})},e.anyJson=function(){return new e(function(e){return ae(e)})},e.unknownJson=function(){return new e(function(e){return ae(e)})},e.dict=function(t){return new e(function(e){if(ge(e)){var n={};for(var i in e)if(e.hasOwnProperty(i)){var s=t.decode(e[i]);if(!0!==s.ok)return ce(be("."+i,s.error));n[i]=s.result}return ae(n)}return ce({message:me("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?ae(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=[],i=0;i<t.length;i++){var s=t[i].decode(e);if(!0===s.ok)return s;n[i]=s.error}var r=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return ce({message:'expected a value matching one of the decoders, got the errors ["'+r+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return ae(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 i=e,s=0;s<t.length;s++){if(void 0===i)return ce({at:fe(t.slice(0,s+1)),message:"path does not exist"});if("string"==typeof t[s]&&!ge(i))return ce({at:fe(t.slice(0,s+1)),message:me("an object",i)});if("number"==typeof t[s]&&!pe(i))return ce({at:fe(t.slice(0,s+1)),message:me("an array",i)});i=i[t[s]]}return le(function(e){return void 0===i?{at:fe(t),message:"path does not exist"}:be(fe(t),e)},n.decode(i))})},e.succeed=function(t){return new e(function(e){return ae(t)})},e.fail=function(t){return new e(function(e){return ce({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),we=ye.string,ve=ye.number,Ce=ye.boolean,Ie=ye.anyJson;ye.unknownJson;var Se=ye.constant,_e=ye.object,xe=ye.array;ye.tuple;var ke=ye.dict,Re=ye.optional,Ae=ye.oneOf;ye.union,ye.intersection,ye.withDefault,ye.valueAt,ye.succeed,ye.fail,ye.lazy;const Pe=we().where(e=>e.length>0,"Expected a non-empty string"),Te=ve().where(e=>e>=0,"Expected a non-negative number"),Oe=Ie().andThen(e=>e instanceof RegExp?Ie():fail("expected a regex, got a "+typeof e)),Ee=_e({name:Pe,displayName:Re(we()),contexts:Re(xe(we())),customConfig:Re(_e())}),Me=Ae(Se("web"),Se("native"),Se("citrix"),Se("onlineNative"),Se("other")),De=_e({url:Pe}),je=_e({src:Pe,size:Re(Pe),type:Re(Pe)}),Ne=_e({src:Pe,size:Re(Pe),type:Re(Pe),label:Re(Pe)}),Fe=_e({contexts:xe(Pe),displayName:Re(Pe),resultType:Re(Pe),customConfig:Re(Ie())}),$e=_e({listensFor:Re(ke(Fe)),raises:Re(ke(xe(Pe)))}),Le=_e({broadcasts:Re(xe(Pe)),listensFor:Re(xe(Pe))}),We=_e({name:Pe,description:Re(Pe),broadcasts:Re(xe(Pe)),listensFor:Re(xe(Pe))}),qe=_e({intents:Re($e),userChannels:Re(Le),appChannels:Re(xe(We))}),Ue=_e({url:Re(Pe),top:Re(ve()),left:Re(ve()),width:Re(Te),height:Re(Te)}),Ge=_e({name:Re(Pe),type:Re(Pe.where(e=>"window"===e,"Expected a value of window")),title:Re(Pe),version:Re(Pe),customProperties:Re(Ie()),icon:Re(we()),caption:Re(we()),details:Re(Ue),intents:Re(xe(Ee)),hidden:Re(Ce())}),Be=_e({name:Pe,appId:Pe,title:Re(Pe),version:Re(Pe),manifest:Pe,manifestType:Pe,tooltip:Re(Pe),description:Re(Pe),contactEmail:Re(Pe),supportEmail:Re(Pe),publisher:Re(Pe),images:Re(xe(_e({url:Re(Pe)}))),icons:Re(xe(_e({icon:Re(Pe)}))),customConfig:Ie(),intents:Re(xe(Ee))}),Je=_e({appId:Re(Pe),name:Re(Pe),details:Re(De),version:Re(Pe),title:Re(Pe),tooltip:Re(Pe),lang:Re(Pe),description:Re(Pe),categories:Re(xe(Pe)),icons:Re(xe(je)),screenshots:Re(xe(Ne)),contactEmail:Re(Pe),supportEmail:Re(Pe),moreInfo:Re(Pe),publisher:Re(Pe),customConfig:Re(xe(Ie())),hostManifests:Re(Ie()),interop:Re(qe)}),He=_e({appId:Pe,name:Re(Pe),type:Me,details:De,version:Re(Pe),title:Re(Pe),tooltip:Re(Pe),lang:Re(Pe),description:Re(Pe),categories:Re(xe(Pe)),icons:Re(xe(je)),screenshots:Re(xe(Ne)),contactEmail:Re(Pe),supportEmail:Re(Pe),moreInfo:Re(Pe),publisher:Re(Pe),customConfig:Re(xe(Ie())),hostManifests:Re(Ie()),interop:Re(qe),localizedVersions:Re(ke(Je))}),ze=Ae(Be,He),Ke=e=>`${e.kind} at ${e.at}: ${JSON.stringify(e.input)}. Reason - ${e.message}`;class Ve{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=ze.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:Ke(t.error)}}parseToBrowserBaseAppData(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const i=ze.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(i.error)}`);const s=this.getUserPropertiesFromDefinition(e,n),r={url:this.getUrl(e,n)},o={name:e.appId,type:"window",createOptions:r,userProperties:{...s,intents:"1.2"===n?s.intents:this.getIntentsFromV2AppDefinition(e),details:r},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 o;const c=Ge.run(a);if(!c.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(c.error)}`);return Object.keys(c.result).length?this.mergeBaseAppDataWithGlueManifest(o,c.result):o}parseToDesktopAppConfig(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const i=ze.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(i.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 s=e,r={name:s.appId,type:this.fdc3ToDesktopDefinitionType[s.type],details:s.details,version:s.version,title:s.title,tooltip:s.tooltip,caption:s.description,icon:this.getIconFromDefinition(s,"2.0"),intents:this.getIntentsFromV2AppDefinition(s),fdc3:{...s,definitionVersion:"2.0"}},o=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!o)return r;if("object"!=typeof o||Array.isArray(o))throw new Error(`Invalid '${e.hostManifests.ioConnect?"hostManifests.ioConnect":"hostManifests['Glue42']"}' key`);return this.mergeDesktopConfigWithGlueManifest(r,o)}getUserPropertiesFromDefinition(e,t){return"1.2"===t?Object.fromEntries(Object.entries(e).filter(([e])=>!re.includes(e))):Object.fromEntries(Object.entries(e).filter(([e])=>!re.includes(e)&&!oe.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;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.customProperties&&(n.userProperties={...e.userProperties,...t.customProperties}),t.details){const i={...e.createOptions,...t.details};n.createOptions=i,n.userProperties.details=i}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 Ze={common:{nonEmptyStringDecoder:Pe,nonNegativeNumberDecoder:Te,regexDecoder:Oe},fdc3:{allDefinitionsDecoder:ze,v1DefinitionDecoder:Be,v2DefinitionDecoder:He}};var Qe;!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"}(Qe||(Qe={}));const Xe=new class{_fdc3;_decoders=Ze;_errors={intents:Qe};get fdc3(){return this._fdc3||(this._fdc3=(new Ve).toApi()),this._fdc3}get decoders(){return this._decoders}get errors(){return this._errors}};Xe.fdc3;const Ye=Xe.decoders;Xe.errors;const et=I().where(e=>e.length>0,"Expected a non-empty string"),tt=S().where(e=>e>=0,"Expected a non-negative number"),nt=P(et),it=T(k("system"),k("windows"),k("appManager"),k("layouts"),k("intents"),k("notifications"),k("channels"),k("extension"),k("themes"),k("prefs"),k("ui")),st=T(k("openWindow"),k("windowHello"),k("windowAdded"),k("windowRemoved"),k("getBounds"),k("getFrameBounds"),k("getUrl"),k("moveResize"),k("focus"),k("close"),k("getTitle"),k("setTitle"),k("focusChange"),k("getChannel"),k("notifyChannelsChanged"),k("setZoomFactor"),k("zoomFactorChange"),k("refresh"),k("operationCheck")),rt=T(k("appHello"),k("appDirectoryStateChange"),k("instanceStarted"),k("instanceStopped"),k("applicationStart"),k("instanceStop"),k("clear"),k("operationCheck")),ot=T(k("layoutAdded"),k("layoutChanged"),k("layoutRemoved"),k("layoutRenamed"),k("get"),k("getAll"),k("export"),k("import"),k("remove"),k("rename"),k("clientSaveRequest"),k("getGlobalPermissionState"),k("checkGlobalActivated"),k("requestGlobalPermission"),k("getDefaultGlobal"),k("setDefaultGlobal"),k("clearDefaultGlobal"),k("updateMetadata"),k("operationCheck"),k("getCurrent"),k("defaultLayoutChanged"),k("layoutRestored")),at=T(k("raiseNotification"),k("requestPermission"),k("notificationShow"),k("notificationClick"),k("getPermission"),k("list"),k("notificationRaised"),k("notificationClosed"),k("click"),k("clear"),k("clearAll"),k("configure"),k("getConfiguration"),k("configurationChanged"),k("setState"),k("clearOld"),k("activeCountChange"),k("stateChange"),k("operationCheck"),k("getActiveCount")),ct=T(k("getEnvironment"),k("getBase"),k("platformShutdown"),k("isFdc3DataWrappingSupported"),k("clientError"),k("systemHello"),k("operationCheck")),dt=T(k("top"),k("left"),k("right"),k("bottom")),lt=R({top:S(),left:S(),width:tt,height:tt}),ht=P(R({top:P(S()),left:P(S()),width:P(tt),height:P(tt),context:P(x()),relativeTo:P(et),relativeDirection:P(dt),windowId:P(et),layoutComponentId:P(et)})),ut=R({name:et,url:et,options:ht}),pt=R({windowId:P(et)}),gt=R({windowId:et,name:et}),mt=R({windowId:et}),ft=R({windows:A(gt),isWorkspaceFrame:_()}),bt=R({windowId:et,title:I()}),yt=R({windowId:et,hasFocus:_()}),wt=R({windowId:et,top:P(S()),left:P(S()),width:P(tt),height:P(tt),relative:P(_())}),vt=R({windowId:et,bounds:R({top:S(),left:S(),width:tt,height:tt})}),Ct=R({bounds:R({top:S(),left:S(),width:tt,height:tt})}),It=R({windowId:et,url:et}),St=R({windowId:et,factorIndex:tt}),_t=x(),xt=R({top:P(S()),left:P(S()),width:P(tt),height:P(tt)}),kt=R({id:et,applicationName:et}),Rt=R({flags:I()}),At=R({flags:I()}),Pt=R({windowId:et,channelsNames:A(et)}),Tt=R({enabled:_()}),Ot=R({url:et,top:P(S()),left:P(S()),width:P(tt),height:P(tt),workspacesSandbox:P(At),channelSelector:P(Tt),iframePermissionsPolicy:P(Rt)}),Et=R({name:et,displayName:P(I()),contexts:P(A(I())),customConfig:P(R()),resultType:P(I())}),Mt=R({name:et,type:et.where(e=>"window"===e,"Expected a value of window"),title:P(et),version:P(et),customProperties:P(x()),icon:P(I()),caption:P(I()),details:Ot,intents:P(A(Et)),hidden:P(_()),fdc3:P(Ye.fdc3.v2DefinitionDecoder)}),Dt=R({name:et}),jt=R({definitions:A(Mt)}),Nt=R({name:et,type:et.where(e=>"window"===e,"Expected a value of window"),instances:A(kt),userProperties:P(x()),title:P(et),version:P(et),icon:P(I()),caption:P(et)}),Ft=R({name:et,type:et.where(e=>"window"===e,"Expected a value of window"),userProperties:x(),title:P(et),version:P(et),icon:P(I()),caption:P(et)}),$t=R({appsAdded:A(Ft),appsChanged:A(Ft),appsRemoved:A(Ft)}),Lt=R({apps:A(Nt),initialChannelId:P(et)}),Wt=R({id:et}),qt=T(k("Global"),k("Activity"),k("ApplicationDefault"),k("Swimlane"),k("Workspace")),Ut=T(k("application"),k("activity")),Gt=R({context:P(x()),bounds:lt,createArgs:R({name:P(et),url:P(et),context:P(x())}),windowState:P(et),restoreState:P(et),instanceId:et,isCollapsed:P(_()),isSticky:P(_()),restoreSettings:R({groupId:P(et),groupZOrder:P(S())}),channelId:P(et)}),Bt=R({type:k("window"),componentType:P(Ut),application:et,state:Gt}),Jt=R({type:k("window"),config:R({appName:et,url:P(et),title:P(I()),allowExtract:P(_()),allowReorder:P(_()),showCloseButton:P(_()),isMaximized:P(_())})}),Ht=R({type:k("group"),config:x(),children:A(T(Jt))}),zt=R({type:k("column"),config:x(),children:A(T(Ht,Jt,M(()=>zt),M(()=>Kt)))}),Kt=R({type:k("row"),config:x(),children:A(T(zt,Ht,Jt,M(()=>Kt)))}),Vt=R({config:x(),context:x(),children:A(T(Kt,zt,Ht,Jt))}),Zt=R({type:k("Workspace"),application:P(et),state:Vt}),Qt=R({bounds:lt,instanceId:et,selectedWorkspace:tt,workspaces:A(Vt),windowState:P(et),restoreState:P(et),context:P(x())}),Xt=R({type:k("workspaceFrame"),application:et,componentType:P(Ut),state:Qt}),Yt=R({name:et,type:qt,token:P(et),components:A(T(Bt,Zt,Xt)),context:P(x()),metadata:P(x()),version:P(S())}),en=R({name:et,type:qt,token:P(et),components:A(T(Bt,Zt,Xt)),context:P(x()),metadata:P(x()),version:P(S()),prevName:et}),tn=R({name:et,context:P(x()),metadata:P(x()),instances:P(A(et)),ignoreInstances:P(A(et)),setAsCurrent:P(_())}),nn=R({name:et,context:P(x()),closeRunningInstance:P(_()),closeMe:P(_()),timeout:P(tt)}),sn=R({name:et,type:qt,context:P(x()),metadata:P(x())}),rn=R({name:et,type:qt}),on=R({layout:tn}),an=R({layout:Yt,newName:et}),cn=R({status:et}),dn=R({layout:Yt}),ln=R({layout:nn}),hn=R({type:qt}),un=R({layouts:A(Yt)}),pn=P(R({name:et})),gn=T(k("replace"),k("merge")),mn=R({layouts:A(Yt),mode:gn,skipManagerRequest:P(_())}),fn=R({summaries:A(sn)}),bn=R({layout:Yt}),yn=R({layout:P(Yt)}),wn=R({name:et}),vn=T(k("findIntent"),k("getIntents"),k("getIntentsByHandler"),k("raise"),k("filterHandlers")),Cn=R({applicationName:et,applicationTitle:P(I()),applicationDescription:P(I()),applicationIcon:P(I()),type:T(k("app"),k("instance")),displayName:P(I()),contextTypes:P(A(et)),instanceId:P(I()),instanceTitle:P(I()),resultType:P(I()),customConfig:P(R())});R({applicationName:I(),applicationIcon:P(I()),instanceId:P(I())}),R({intent:et,handler:Cn});const In=R({name:et,handlers:A(Cn)}),Sn=T(k("startNew"),k("reuse"),R({app:P(et),instance:P(et)})),_n=R({type:P(et),data:P(x())}),xn=A(In),kn=R({intents:xn}),Rn=R({name:P(et),contextType:P(et),resultType:P(et)}),An=T(et,Rn),Pn=R({filter:P(Rn)}),Tn=R({top:P(S()),left:P(S()),width:P(tt),height:P(tt),relativeTo:P(et),relativeDirection:P(dt),waitForAGMReady:P(_()),channelId:P(et)}),On=R({intent:et,target:P(Sn),context:P(_n),options:P(Tn),handlers:P(A(Cn)),timeout:P(tt),waitUserResponseIndefinitely:P(_()),clearSavedHandler:P(_())}),En=R({interopInstance:et,name:P(et)}),Mn=R({originApp:En,intentRequest:P(On)}),Dn=R({name:et,waitForAGMReady:_(),id:P(et),context:P(x()),top:P(S()),left:P(S()),width:P(tt),height:P(tt),relativeTo:P(et),relativeDirection:P(dt),forceChromeTab:P(_()),layoutComponentId:P(et),channelId:P(et),startReason:Mn}),jn=T(et,On),Nn=R({enabled:_(),appName:et,waitResponseTimeout:S()}),Fn=T(R({applicationName:et}),R({instanceId:et})),$n=R({title:P(et),openResolver:P(_()),timeout:P(tt),intent:P(et),contextTypes:P(A(et)),resultType:P(et),applicationNames:P(A(et)),excludeList:P(A(Fn))}),Ln=R({enabled:_(),initialCaller:R({instanceId:et})}),Wn=R({intentRequest:On,resolverConfig:Nn,embeddedResolverConfig:P(Ln)}),qn=R({request:On,handler:Cn,result:x()}),Un=R({handlers:A(Cn)}),Gn=R({filterHandlersRequest:$n,resolverConfig:Nn,embeddedResolverConfig:P(Ln)}),Bn=R({intent:et,contextTypes:P(A(et)),displayName:P(I()),icon:P(I()),description:P(I()),resultType:P(I()),customConfig:P(R())}),Jn=T(et,Bn),Hn=R({intent:et,contextTypes:P(A(et)),description:P(et),displayName:P(et),icon:P(et),resultType:P(et)}),zn=R({intents:A(Hn)}),Kn=e=>et.where(t=>e.includes(t),"Expected a valid channel name"),Vn=R({contextType:P(et)}),Zn=P(T(et,R({name:P(et),fdc3:P(_())}))),Qn=R({windowId:nt,channel:nt}),Xn=x().where(e=>"string"==typeof e.type,"Expected a valid FDC3 Context with compulsory 'type' field"),Yn=R({method:et,arguments:P(x()),target:P(T(k("all"),k("best")))}),ei=R({action:I(),title:et,icon:P(I()),interop:P(Yn)}),ti=T(k("Active"),k("Acknowledged"),k("Seen"),k("Closed"),k("Stale"),k("Snoozed"),k("Processing")),ni=R({count:S()}),ii=R({badge:P(I()),body:P(I()),data:P(x()),dir:P(T(k("auto"),k("ltr"),k("rtl"))),icon:P(I()),image:P(I()),lang:P(I()),renotify:P(_()),requireInteraction:P(_()),silent:P(_()),tag:P(I()),timestamp:P(tt),vibrate:P(A(S()))}),si=R({title:et,clickInterop:P(Yn),actions:P(A(ei)),focusPlatformOnDefaultClick:P(_()),badge:P(I()),body:P(I()),data:P(x()),dir:P(T(k("auto"),k("ltr"),k("rtl"))),icon:P(I()),image:P(I()),lang:P(I()),renotify:P(_()),requireInteraction:P(_()),silent:P(_()),tag:P(I()),timestamp:P(tt),vibrate:P(A(S())),severity:P(T(k("Low"),k("None"),k("Medium"),k("High"),k("Critical"))),showToast:P(_()),showInPanel:P(_()),state:P(ti)}),ri=R({id:et,state:ti});R().where(e=>!e.fdc3||"string"==typeof e.fdc3.type,"Expected a valid FDC3 Context with compulsory 'type' field");const oi=R({color:P(et),icon:P(et),name:P(et),glyph:P(et)}),ai=R({id:et,displayMetadata:P(oi)}),ci=R({color:et,fdc3:P(ai)}),di=R({name:et,meta:ci,data:P(R())}),li=R({path:et,value:x()}),hi=A(li),ui=R({name:et}),pi=R({name:et,read:_(),write:_(),windowId:P(et)}),gi=R({name:et,read:_(),write:_(),windowId:et}),mi=R({config:gi}),fi=R({channels:A(pi)}),bi=R({windowId:et}),yi=R({read:_(),write:_(),windowId:P(et)}),wi=R({restrictions:yi}),vi=R({settings:si,id:et}),Ci=R({settings:si}),Ii=R({permissionGranted:_()}),Si=R({permission:T(k("default"),k("granted"),k("denied"))}),_i=R({definition:ii,action:P(I()),id:P(et)}),xi=R({allowed:P(A(et)),blocked:P(A(et))}),ki=R({enable:P(_()),enableToasts:P(_()),sourceFilter:P(xi),showNotificationBadge:P(_())}),Ri=R({configuration:ki}),Ai=R({configuration:R({enable:_(),enableToasts:_(),sourceFilter:R({allowed:A(et),blocked:A(et)})})}),Pi=R({layoutType:T(k("Global"),k("Workspace")),layoutName:et,context:P(x())}),Ti=R({windowContext:P(x())}),Oi=R({state:T(k("prompt"),k("denied"),k("granted"))}),Ei=R({isAvailable:_()}),Mi=R({itemId:et}),Di=R({isSupported:_()}),ji=R({operation:et}),Ni=R({bounds:lt}),Fi=R({displayName:et,name:et}),$i=R({theme:Fi}),Li=R({themes:A(Fi)}),Wi=R({name:et}),qi=R({id:et,title:et,clickInterop:P(Yn),actions:P(A(ei)),focusPlatformOnDefaultClick:P(_()),badge:P(I()),body:P(I()),data:P(x()),dir:P(T(k("auto"),k("ltr"),k("rtl"))),icon:P(I()),image:P(I()),lang:P(I()),renotify:P(_()),requireInteraction:P(_()),silent:P(_()),tag:P(I()),timestamp:P(tt),vibrate:P(A(S())),severity:P(T(k("Low"),k("None"),k("Medium"),k("High"),k("Critical"))),showToast:P(_()),showInPanel:P(_()),state:P(ti)}),Ui=R({notification:qi}),Gi=R({notifications:A(qi)}),Bi=R({id:et}),Ji=R({channel:et}),Hi=R({windowIds:A(et)}),zi=T(k("appHello"),k("addChannel"),k("getMyChannel"),k("getWindowIdsOnChannel"),k("getWindowIdsWithChannels"),k("joinChannel"),k("restrict"),k("getRestrictions"),k("restrictAll"),k("notifyChannelsChanged"),k("leaveChannel"),k("getMode"),k("operationCheck")),Ki=T(k("single"),k("multi")),Vi=R({mode:Ki}),Zi=R({windowId:et}),Qi=R({mode:Ki,channels:A(et),restrictions:A(pi)}),Xi=R({channel:P(et)}),Yi=R({application:P(et),channels:P(A(et)),windowIds:P(A(et))}),es=R({filter:P(Yi)}),ts=R({windowIdsWithChannels:A(R({application:et,channel:P(et),windowId:et}))}),ns=P(x()),is=P(R({top:P(S()),left:P(S()),width:P(tt),height:P(tt),relativeTo:P(et),relativeDirection:P(dt),waitForAGMReady:P(_()),channelId:P(et),reuseId:P(et),originIntentRequest:P(On)})),ss=R({channel:et,windowId:et}),rs=R({windowId:et,channelName:P(et)}),os=R({windowId:et,channelNames:A(et)}),as=R({channel:P(et)}),cs=T(k("clear"),k("clearAll"),k("get"),k("getAll"),k("set"),k("update"),k("prefsChanged"),k("prefsHello"),k("operationCheck"),k("registerSubscriber")),ds=R({app:et,data:R(),lastUpdate:P(et)}),ls=R({app:et}),hs=R({prefs:ds}),us=R({all:A(ds)}),ps=R({interopId:et,appName:P(et)}),gs=R({app:et,data:R()}),ms=R({platform:R({app:et}),validNonExistentApps:P(A(et))}),fs=R({message:et}),bs=R({isClientErrorOperationSupported:_()}),ys=Ye.common.nonEmptyStringDecoder,ws=Ye.common.nonNegativeNumberDecoder,vs=R({bundle:ys,styles:A(ys),fonts:P(A(ys))}),Cs=R({bundle:ys,styles:A(ys),fonts:P(A(ys))}),Is=R({bundle:ys,styles:A(ys),fonts:P(A(ys))}),Ss=T(k("directional"),k("default")),_s=R({type:P(Ss),enable:P(_())}),xs=T(k("top-left"),k("top-center"),k("top-right"),k("center-left"),k("center-right"),k("bottom-left"),k("bottom-center"),k("bottom-right")),ks=T(k("all"),k("fdc3")),Rs=R({selector:P(_s),displayMode:P(ks)}),As=R({channels:P(Rs),position:P(xs),displayInWorkspace:P(_()),restoreLastKnownPosition:P(_())}),Ps=R({enable:_(),awaitFactory:P(_()),timeout:P(ws),channels:P(Rs),position:P(xs),displayInWorkspace:P(_()),restoreLastKnownPosition:P(_())}),Ts=R({alerts:P(R({enabled:_()})),dialogs:P(R({enabled:_()})),awaitFactory:P(_()),timeout:P(ws)}),Os=T(k("getResources"),k("operationCheck"),k("showAlert"),k("showDialog"),k("alertInteropAction"),k("showResolver")),Es=R({origin:ys}),Ms=R({blockedOrigin:k(!0)}),Ds=O(Ms,R({blockedOrigin:k(!1),config:As,sources:vs})),js=O(Ms,R({blockedOrigin:k(!1),sources:Cs})),Ns=O(Ms,R({blockedOrigin:k(!1),sources:Is})),Fs=R({widget:P(Ds),modals:P(js),intentResolver:P(Ns)}),$s=R({resources:Fs}),Ls=R({method:ys,arguments:P(x()),target:P(T(k("best"),k("all"),ys))}),Ws=T(k("Global"),k("WindowContainer"),ys),qs=R({instance:ys,container:P(T(k("Global"),k("WindowContainer")))}),Us=R({variant:T(k("default"),k("success"),k("critical"),k("info"),k("warning")),text:ys,showCloseButton:P(_()),clickInterop:P(Ls),onCloseInterop:P(Ls),actions:P(A(R({id:ys,title:ys,clickInterop:Ls}))),data:P(x()),ttl:P(ws),target:P(Ws)}),Gs=R({config:Us,target:qs}),Bs=R({templateName:ys,variables:x(),target:P(Ws),timer:P(R({duration:ws})),size:P(R({width:ws,height:ws})),movable:P(_()),transparent:P(_())}),Js=R({isExpired:P(_()),isClosed:P(_()),isEnterPressed:P(_()),responseButtonClicked:P(R({id:ys,text:ys})),inputs:P(A(R({type:T(k("checkbox"),k("email"),k("number"),k("password"),k("text")),id:ys,checked:P(_()),value:P(I())})))});R({result:Js});const Hs=R({config:Bs,target:qs}),zs=R({id:ys}),Ks=R({id:ys,responsePromise:x()}),Vs=R({response:Js}),Zs=R({name:ys,settings:Ls}),Qs=R({interopAction:Zs}),Xs=R({interopAction:Zs}),Ys=R({enable:_(),awaitFactory:P(_()),timeout:P(ws)}),er=R({id:ys}),tr=R({preserveChoice:_()}),nr=R({intent:ys,handler:Cn,userSettings:tr}),ir=R({isExpired:P(_()),isClosed:P(_()),userChoice:P(nr)}),sr=R({response:ir}),rr=E(O(R({intentRequest:On}),R({handlerFilter:$n})),R({timeout:ws})),or=R({config:rr}),ar=R({result:ir}),cr={openWindow:{name:"openWindow",dataDecoder:ut,resultDecoder:gt},windowHello:{name:"windowHello",dataDecoder:pt,resultDecoder:ft},windowAdded:{name:"windowAdded",dataDecoder:gt},windowRemoved:{name:"windowRemoved",dataDecoder:mt},getBounds:{name:"getBounds",dataDecoder:mt,resultDecoder:vt},getFrameBounds:{name:"getFrameBounds",dataDecoder:mt,resultDecoder:Ct},getUrl:{name:"getUrl",dataDecoder:mt,resultDecoder:It},moveResize:{name:"moveResize",dataDecoder:wt},focus:{name:"focus",dataDecoder:mt},close:{name:"close",dataDecoder:mt},getTitle:{name:"getTitle",dataDecoder:mt,resultDecoder:bt},setTitle:{name:"setTitle",dataDecoder:bt},focusChange:{name:"focusChange",dataDecoder:yt},getChannel:{name:"getChannel",dataDecoder:mt,resultDecoder:as},notifyChannelsChanged:{name:"notifyChannelsChanged",dataDecoder:os},setZoomFactor:{name:"setZoomFactor",dataDecoder:St},zoomFactorChange:{name:"zoomFactorChange",dataDecoder:St},refresh:{name:"refresh",dataDecoder:mt},operationCheck:{name:"operationCheck"}};function dr(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 i(n,i){var s=n instanceof Error?n:new Error(n);if(t)t(s);else{var r='[ERROR] callback-registry: User callback for key "'+i+'" failed: '+s.stack;if(e)switch(e.errorHandling){case"log":return console.error(r);case"silent":return;case"throw":throw new Error(r)}console.error(r)}}return{add:function(e,t,s){var r=n[e];return r||(r=[],n[e]=r),r.push(t),s&&setTimeout(function(){s.forEach(function(s){var r;if(null===(r=n[e])||void 0===r?void 0:r.includes(t))try{Array.isArray(s)?t.apply(void 0,s):t.apply(void 0,[s])}catch(t){i(t,e)}})},0),function(){var i=n[e];i&&(0===(i=i.reduce(function(e,n,i){return n===t&&e.length===i||e.push(n),e},[])).length?delete n[e]:n[e]=i)}},execute:function(e){for(var t=[],s=1;s<arguments.length;s++)t[s-1]=arguments[s];var r=n[e];if(!r||0===r.length)return[];var o=[];return r.forEach(function(n){try{var s=n.apply(void 0,t);o.push(s)}catch(t){o.push(void 0),i(t,e)}}),o},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}dr.default=dr;var lr=e(dr);const hr=Object.freeze({0:24,1:33,2:50,3:67,4:75,5:80,6:90,7:100,8:110,9:125,10:150,11:175,12:200,13:250,14:300,15:400,16:500});class ur{_id;_name;_bridge;_logger;registry=lr();myCtxKey;ctxUnsubscribe;zoomFactorIndex=7;me;constructor(e,t,n,i){this._id=e,this._name=t,this._bridge=n,this._logger=i,this.myCtxKey=`___window___${this.id}`}get id(){return this._id.slice()}get name(){return this._name.slice()}get zoomFactor(){return hr[this.zoomFactorIndex]}clean(){this.ctxUnsubscribe&&this.ctxUnsubscribe()}processSelfFocusEvent(e){this.me.isFocused=e,this.registry.execute("focus-change",this.me)}processChannelsChangedEvent(e){this.registry.execute("channels-changed",e)}processSelfZoomFactorChangedEvent(e){this.zoomFactorIndex=e,this.registry.execute("zoom-factor-changed",this.me)}async toApi(){return this.ctxUnsubscribe=await this._bridge.contextLib.subscribe(this.myCtxKey,e=>this.registry.execute("context-updated",e)),this.me={id:this.id,name:this.name,isFocused:!1,zoomFactor:this.zoomFactor,getURL:this.getURL.bind(this),moveResize:this.moveResize.bind(this),resizeTo:this.resizeTo.bind(this),moveTo:this.moveTo.bind(this),focus:this.focus.bind(this),close:this.close.bind(this),getTitle:this.getTitle.bind(this),setTitle:this.setTitle.bind(this),getBounds:this.getBounds.bind(this),getContext:this.getContext.bind(this),updateContext:this.updateContext.bind(this),setContext:this.setContext.bind(this),refresh:this.refresh.bind(this),onContextUpdated:this.onContextUpdated.bind(this),onFocusChanged:this.onFocusChanged.bind(this),getChannel:this.getChannel.bind(this),onChannelsChanged:this.onChannelsChanged.bind(this),zoomIn:this.zoomIn.bind(this),zoomOut:this.zoomOut.bind(this),setZoomFactor:this.setZoomFactor.bind(this),onZoomFactorChanged:this.onZoomFactorChanged.bind(this)},Object.defineProperties(this.me,{id:Q,name:Q,zoomFactor:{get:()=>this.zoomFactor,enumerable:!0}}),this.me}async getURL(){return(await this._bridge.send("windows",cr.getUrl,{windowId:this.id})).url}onFocusChanged(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!"):this.registry.add("focus-change",e)}async moveResize(e){const t=Y(xt,e),n=Object.assign({},t,{windowId:this.id,relative:!1});return await this._bridge.send("windows",cr.moveResize,n),this.me}async resizeTo(e,t){if(void 0===e&&void 0===t)return this.me;void 0!==e&&Y(tt,e),void 0!==t&&Y(tt,t);const n=Object.assign({},{width:e,height:t},{windowId:this.id,relative:!0});return await this._bridge.send("windows",cr.moveResize,n),this.me}async moveTo(e,t){if(void 0===e&&void 0===t)return this.me;void 0!==e&&Y(S(),e),void 0!==t&&Y(S(),t);const n=Object.assign({},{top:e,left:t},{windowId:this.id,relative:!0});return await this._bridge.send("windows",cr.moveResize,n),this.me}async focus(){return"Platform"===this.name?window.open(void 0,this.id):await this._bridge.send("windows",cr.focus,{windowId:this.id}),this.me}async close(){return await this._bridge.send("windows",cr.close,{windowId:this.id}),this.me}async getTitle(){return(await this._bridge.send("windows",cr.getTitle,{windowId:this.id})).title}async setTitle(e){const t=Y(et,e);return await this._bridge.send("windows",cr.setTitle,{windowId:this.id,title:t}),this.me}async getBounds(){return(await this._bridge.send("windows",cr.getBounds,{windowId:this.id})).bounds}async getContext(){const e=await this._bridge.contextLib.get(this.myCtxKey),{___io___:t,...n}=e;return n}async updateContext(e){const t=Y(_t,e);return await this._bridge.contextLib.update(this.myCtxKey,t),this.me}async setContext(e){const t=Y(_t,e),n=await this._bridge.contextLib.get(this.myCtxKey),i=n.___io___?{...t,___io___:n.___io___}:t;return await this._bridge.contextLib.set(this.myCtxKey,i),this.me}onContextUpdated(e){if("function"!=typeof e)return se.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!");return this.registry.add("context-updated",t=>{const{___io___:n,...i}=t;e(i,this.me)})}async getChannel(){return(await this._bridge.send("windows",cr.getChannel,{windowId:this.id},void 0,{includeOperationCheck:!0})).channel}onChannelsChanged(e){return this.registry.add("channels-changed",e)}getClosestZoomFactorIndex(e){const t=Object.entries(hr).reduce((t,[n,i])=>Math.abs(i-e)<=Math.abs(hr[t]-e)?parseInt(n):t,0),n=hr[t];return n!==e&&this._logger.warn(`Zoom factor ${e} is not available, using closest value ${n} instead.`),t}async zoom(e){e!==this.zoomFactorIndex&&e in hr&&(await this._bridge.send("windows",cr.setZoomFactor,{windowId:this.id,factorIndex:e},void 0,{includeOperationCheck:!0}),this.zoomFactorIndex=e)}async zoomIn(){return await this.zoom(this.zoomFactorIndex+1),this.me}async zoomOut(){return await this.zoom(this.zoomFactorIndex-1),this.me}async setZoomFactor(e){const t=Y(S(),e),n=this.getClosestZoomFactorIndex(t);return await this.zoom(n),this.me}onZoomFactorChanged(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to zoom factor changes, because the provided callback is not a function!"):this.registry.add("zoom-factor-changed",e)}async refresh(){return await this._bridge.send("windows",cr.refresh,{windowId:this.id},void 0,{includeOperationCheck:!0}),this.me}}const pr={operationCheck:{name:"operationCheck",dataDecoder:ji,resultDecoder:Di},getWorkspaceWindowFrameBounds:{name:"getWorkspaceWindowFrameBounds",resultDecoder:Ni,dataDecoder:Mi}},gr=(e,t,n)=>new Promise((i,s)=>{let r=!0;const o=setTimeout(()=>{if(!r)return;r=!1;s(n||`Promise timeout hit: ${t}`)},t);e().then(e=>{r&&(r=!1,clearTimeout(o),i(e))}).catch(e=>{r&&(r=!1,clearTimeout(o),s(e))})}),mr=(e,t,n)=>new Promise((i,s)=>{const r=setTimeout(()=>{s(n||`Promise timeout hit: ${t}`)},t);new Promise(e).then(e=>{clearTimeout(r),i(e)}).catch(e=>{clearTimeout(r),s(e)})});class fr{supportedOperationsNames=[];focusEventHandler;registry=lr();platformRegistration;ioc;bridge;publicWindowId;allWindowProjections=[];me;logger;isWorkspaceFrame;instanceId;channelsController;async start(e,t){this.logger=e.logger.subLogger("windows.controller.web"),this.logger.trace("starting the web windows controller"),this.publicWindowId=t.publicWindowId,this.addWindowOperationExecutors(),this.ioc=t,this.bridge=t.bridge,this.instanceId=e.interop.instance.instance,this.channelsController=t.channelsController,this.logger.trace(`set the public window id: ${this.publicWindowId}, set the bridge operations and ioc, registering with the platform now`),this.platformRegistration=this.registerWithPlatform(),await this.platformRegistration,await this.initializeFocusTracking(),this.logger.trace("registration with the platform successful, attaching the windows property to glue and returning");const n=this.toApi();e.windows=n}handlePlatformShutdown(){this.registry.clear(),this.allWindowProjections=[],this.focusEventHandler&&(document.removeEventListener("visibilityChange",this.focusEventHandler),window.removeEventListener("focus",this.focusEventHandler),window.removeEventListener("blur",this.focusEventHandler))}async handleBridgeMessage(e){await this.platformRegistration;const t=Y(st,e.operation),n=cr[t];if(!n.execute)return;let i=e.data;return n.dataDecoder&&(i=Y(n.dataDecoder,e.data)),await n.execute(i)}async open(e,t,n){Y(et,e),Y(et,t);const i=Y(ht,n),s=await this.bridge.send("windows",cr.openWindow,{name:e,url:t,options:i});return this.waitForWindowAdded(s.windowId)}list(){return this.allWindowProjections.map(e=>e.api)}findById(e){return Y(et,e),this.allWindowProjections.find(t=>t.id===e)?.api}toApi(){return{open:this.open.bind(this),my:this.my.bind(this),list:this.list.bind(this),findById:this.findById.bind(this),onWindowAdded:this.onWindowAdded.bind(this),onWindowRemoved:this.onWindowRemoved.bind(this),onWindowGotFocus:this.onWindowGotFocus.bind(this),onWindowLostFocus:this.onWindowLostFocus.bind(this)}}addWindowOperationExecutors(){cr.focusChange.execute=this.handleFocusChangeEvent.bind(this),cr.windowAdded.execute=this.handleWindowAdded.bind(this),cr.windowRemoved.execute=this.handleWindowRemoved.bind(this),cr.getBounds.execute=this.handleGetBounds.bind(this),cr.getFrameBounds.execute=this.handleGetBounds.bind(this),cr.getTitle.execute=this.handleGetTitle.bind(this),cr.getUrl.execute=this.handleGetUrl.bind(this),cr.moveResize.execute=this.handleMoveResize.bind(this),cr.setTitle.execute=this.handleSetTitle.bind(this),cr.getChannel.execute=this.handleGetChannel.bind(this),cr.notifyChannelsChanged.execute=this.handleChannelsChanged.bind(this),cr.setZoomFactor.execute=this.handleSetZoomFactor.bind(this),cr.zoomFactorChange.execute=this.handleZoomFactorChanged.bind(this),cr.refresh.execute=this.handleRefresh.bind(this),cr.operationCheck.execute=async e=>te(this.supportedOperationsNames,e.operation),this.supportedOperationsNames=ee(cr)}my(){return Object.assign({},this.me)}onWindowAdded(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to window added, because the provided callback is not a function!"):this.registry.add("window-added",e)}onWindowRemoved(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to window removed, because the provided callback is not a function!"):this.registry.add("window-removed",e)}onWindowGotFocus(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to onWindowGotFocus, because the provided callback is not a function!"):this.registry.add("window-got-focus",e)}onWindowLostFocus(e){return"function"!=typeof e?se.raiseError("Cannot subscribe to onWindowLostFocus, because the provided callback is not a function!"):this.registry.add("window-lost-focus",e)}async sayHello(){return await this.bridge.send("windows",cr.windowHello,{windowId:this.publicWindowId})}async registerWithPlatform(){const{windows:e,isWorkspaceFrame:t}=await this.sayHello();if(this.isWorkspaceFrame=t,this.logger.trace("the platform responded to the hello message"),!this.isWorkspaceFrame&&this.publicWindowId){this.logger.trace("i am not treated as a workspace frame, setting my window");const t=e.find(e=>e.windowId===this.publicWindowId);if(!t){const t=e.map(e=>`${e.windowId}:${e.name}`).join(", ");return se.raiseError(`Cannot initialize the window library, because I received no information about me -> id: ${this.publicWindowId} name: ${window.name} from the platform: known windows: ${t}`)}const n=await this.ioc.