UNPKG

@interopio/browser

Version:

IOConnect Browser client application package

1 lines 279 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)},w=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)},y=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:w("a string",e)})}))},e.number=function(){return new e((function(e){return"number"==typeof e?l(e):h({message:w("a number",e)})}))},e.boolean=function(){return new e((function(e){return"boolean"==typeof e?l(e):h({message:w("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:w("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:w("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:w("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:w("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:y(t.slice(0,s+1)),message:"path does not exist"});if("string"==typeof t[s]&&!b(i))return h({at:y(t.slice(0,s+1)),message:w("an object",i)});if("number"==typeof t[s]&&!f(i))return h({at:y(t.slice(0,s+1)),message:w("an array",i)});i=i[t[s]]}return p((function(e){return void 0===i?{at:y(t),message:"path does not exist"}:v(y(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,T=C.array;C.tuple,C.dict;var A=C.optional,P=C.oneOf,M=C.union,O=C.intersection;C.withDefault,C.valueAt,C.succeed,C.fail;var E=C.lazy;const D={gateway:{webPlatform:{}},libraries:[],exposeAPI:!0},j={awaitFactory:!0,enable:!1,timeout:5e3},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,Q=2147483647,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 ie.raiseError(e,!0)}},Z=e=>Object.keys(e).filter((t=>e[t].execute)),ee=(e,t)=>({isSupported:e.some((e=>e.toLowerCase()===t.toLowerCase()))}),te=e=>Math.min(e,Q),ne=()=>{let e,t;return{promise:new Promise(((n,i)=>{e=n,t=i})),resolve:e,reject:t}};const ie=new class{raiseError(e,t){const n=X(e);if(V.port1.postMessage(n),t)throw e;throw new Error(n)}},se=["name","title","version","customProperties","icon","caption","type"],re=["appId","name","type","details","version","title","tooltip","lang","description","categories","icons","screenshots","contactEmail","moreInfo","publisher","customConfig","hostManifests","interop","localizedVersions"];var oe=function(e){return{ok:!0,result:e}},ae=function(e){return{ok:!1,error:e}},ce=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:oe(e(t.result,n.result))},de=function(e,t){return!0===t.ok?t:ae(e(t.error))},le=function(){return le=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},le.apply(this,arguments)};function he(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(!he(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(!he(e[i[n]],t[i[n]]))return!1}return!0}}var ue=function(e){return Array.isArray(e)},pe=function(e){return"object"==typeof e&&null!==e&&!ue(e)},ge=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)},me=function(e){return e.map((function(e){return"string"==typeof e?"."+e:"["+e+"]"})).join("")},fe=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 le({at:e+(n||"")},i)},be=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return de((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?oe(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?oe(e):ae({message:ge("a string",e)})}))},e.number=function(){return new e((function(e){return"number"==typeof e?oe(e):ae({message:ge("a number",e)})}))},e.boolean=function(){return new e((function(e){return"boolean"==typeof e?oe(e):ae({message:ge("a boolean",e)})}))},e.constant=function(t){return new e((function(e){return he(e,t)?oe(t):ae({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})}))},e.object=function(t){return new e((function(e){if(pe(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]?ae({message:"the key '"+i+"' is required but was not present"}):ae(fe("."+i,s.error));void 0!==s.result&&(n[i]=s.result)}return oe(n)}return pe(e)?oe(e):ae({message:ge("an object",e)})}))},e.array=function(t){return new e((function(e){if(ue(e)&&t){return e.reduce((function(e,n,i){return ce((function(e,t){return e.concat([t])}),e,function(e,n){return de((function(e){return fe("["+n+"]",e)}),t.decode(e))}(n,i))}),oe([]))}return ue(e)?oe(e):ae({message:ge("an array",e)})}))},e.tuple=function(t){return new e((function(e){if(ue(e)){if(e.length!==t.length)return ae({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 ae(fe("["+i+"]",s.error));n[i]=s.result}return oe(n)}return ae({message:ge("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 ce(Object.assign,t,n.decode(e))}),oe({}))}))},e.anyJson=function(){return new e((function(e){return oe(e)}))},e.unknownJson=function(){return new e((function(e){return oe(e)}))},e.dict=function(t){return new e((function(e){if(pe(e)){var n={};for(var i in e)if(e.hasOwnProperty(i)){var s=t.decode(e[i]);if(!0!==s.ok)return ae(fe("."+i,s.error));n[i]=s.result}return oe(n)}return ae({message:ge("an object",e)})}))},e.optional=function(t){return new e((function(e){return null==e?oe(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 ae({message:'expected a value matching one of the decoders, got the errors ["'+r+'"]'})}))},e.withDefault=function(t,n){return new e((function(e){return oe(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 ae({at:me(t.slice(0,s+1)),message:"path does not exist"});if("string"==typeof t[s]&&!pe(i))return ae({at:me(t.slice(0,s+1)),message:ge("an object",i)});if("number"==typeof t[s]&&!ue(i))return ae({at:me(t.slice(0,s+1)),message:ge("an array",i)});i=i[t[s]]}return de((function(e){return void 0===i?{at:me(t),message:"path does not exist"}:fe(me(t),e)}),n.decode(i))}))},e.succeed=function(t){return new e((function(e){return oe(t)}))},e.fail=function(t){return new e((function(e){return ae({message:t})}))},e.lazy=function(t){return new e((function(e){return t().decode(e)}))},e}(),we=be.string,ye=be.number,ve=be.boolean,Ce=be.anyJson;be.unknownJson;var Ie=be.constant,Se=be.object,_e=be.array;be.tuple;var xe=be.dict,ke=be.optional,Re=be.oneOf;be.union,be.intersection,be.withDefault,be.valueAt,be.succeed,be.fail,be.lazy;const Te=we().where((e=>e.length>0),"Expected a non-empty string"),Ae=ye().where((e=>e>=0),"Expected a non-negative number"),Pe=Se({name:Te,displayName:ke(we()),contexts:ke(_e(we())),customConfig:ke(Se())}),Me=Re(Ie("web"),Ie("native"),Ie("citrix"),Ie("onlineNative"),Ie("other")),Oe=Se({url:Te}),Ee=Se({src:Te,size:ke(Te),type:ke(Te)}),De=Se({src:Te,size:ke(Te),type:ke(Te),label:ke(Te)}),je=Se({contexts:_e(Te),displayName:ke(Te),resultType:ke(Te),customConfig:ke(Ce())}),Ne=Se({listensFor:ke(xe(je)),raises:ke(xe(_e(Te)))}),Fe=Se({broadcasts:ke(_e(Te)),listensFor:ke(_e(Te))}),$e=Se({name:Te,description:ke(Te),broadcasts:ke(_e(Te)),listensFor:ke(_e(Te))}),Le=Se({intents:ke(Ne),userChannels:ke(Fe),appChannels:ke(_e($e))}),We=Se({url:ke(Te),top:ke(ye()),left:ke(ye()),width:ke(Ae),height:ke(Ae)}),qe=Se({name:ke(Te),type:ke(Te.where((e=>"window"===e),"Expected a value of window")),title:ke(Te),version:ke(Te),customProperties:ke(Ce()),icon:ke(we()),caption:ke(we()),details:ke(We),intents:ke(_e(Pe)),hidden:ke(ve())}),Ue=Se({name:Te,appId:Te,title:ke(Te),version:ke(Te),manifest:Te,manifestType:Te,tooltip:ke(Te),description:ke(Te),contactEmail:ke(Te),supportEmail:ke(Te),publisher:ke(Te),images:ke(_e(Se({url:ke(Te)}))),icons:ke(_e(Se({icon:ke(Te)}))),customConfig:Ce(),intents:ke(_e(Pe))}),Ge=Se({appId:ke(Te),name:ke(Te),details:ke(Oe),version:ke(Te),title:ke(Te),tooltip:ke(Te),lang:ke(Te),description:ke(Te),categories:ke(_e(Te)),icons:ke(_e(Ee)),screenshots:ke(_e(De)),contactEmail:ke(Te),supportEmail:ke(Te),moreInfo:ke(Te),publisher:ke(Te),customConfig:ke(_e(Ce())),hostManifests:ke(Ce()),interop:ke(Le)}),Be=Se({appId:Te,name:ke(Te),type:Me,details:Oe,version:ke(Te),title:ke(Te),tooltip:ke(Te),lang:ke(Te),description:ke(Te),categories:ke(_e(Te)),icons:ke(_e(Ee)),screenshots:ke(_e(De)),contactEmail:ke(Te),supportEmail:ke(Te),moreInfo:ke(Te),publisher:ke(Te),customConfig:ke(_e(Ce())),hostManifests:ke(Ce()),interop:ke(Le),localizedVersions:ke(xe(Ge))}),Je=Re(Ue,Be),He=e=>`${e.kind} at ${e.at}: ${JSON.stringify(e.input)}. Reason - ${e.message}`;class ze{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=Je.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:He(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=Je.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${He(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=qe.run(a);if(!c.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${He(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=Je.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${He(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])=>!se.includes(e)))):Object.fromEntries(Object.entries(e).filter((([e])=>!se.includes(e)&&!re.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 Ke={common:{nonEmptyStringDecoder:Te,nonNegativeNumberDecoder:Ae},fdc3:{allDefinitionsDecoder:Je,v1DefinitionDecoder:Ue,v2DefinitionDecoder:Be}};var Ve;!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"}(Ve||(Ve={}));const Qe=new class{_fdc3;_decoders=Ke;_errors={intents:Ve};get fdc3(){return this._fdc3||(this._fdc3=(new ze).toApi()),this._fdc3}get decoders(){return this._decoders}get errors(){return this._errors}};Qe.fdc3;const Xe=Qe.decoders;Qe.errors;const Ye=I().where((e=>e.length>0),"Expected a non-empty string"),Ze=S().where((e=>e>=0),"Expected a non-negative number"),et=A(Ye),tt=P(k("system"),k("windows"),k("appManager"),k("layouts"),k("intents"),k("notifications"),k("channels"),k("extension"),k("themes"),k("prefs"),k("ui")),nt=P(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("operationCheck")),it=P(k("appHello"),k("appDirectoryStateChange"),k("instanceStarted"),k("instanceStopped"),k("applicationStart"),k("instanceStop"),k("clear"),k("operationCheck")),st=P(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")),rt=P(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")),ot=P(k("getEnvironment"),k("getBase"),k("platformShutdown"),k("isFdc3DataWrappingSupported"),k("clientError"),k("systemHello"),k("operationCheck")),at=P(k("top"),k("left"),k("right"),k("bottom")),ct=R({top:S(),left:S(),width:Ze,height:Ze}),dt=A(R({top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),context:A(x()),relativeTo:A(Ye),relativeDirection:A(at),windowId:A(Ye),layoutComponentId:A(Ye)})),lt=R({name:Ye,url:Ye,options:dt}),ht=R({windowId:A(Ye)}),ut=R({windowId:Ye,name:Ye}),pt=R({windowId:Ye}),gt=R({windows:T(ut),isWorkspaceFrame:_()}),mt=R({windowId:Ye,title:I()}),ft=R({windowId:Ye,hasFocus:_()}),bt=R({windowId:Ye,top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),relative:A(_())}),wt=R({windowId:Ye,bounds:R({top:S(),left:S(),width:Ze,height:Ze})}),yt=R({bounds:R({top:S(),left:S(),width:Ze,height:Ze})}),vt=R({windowId:Ye,url:Ye}),Ct=x(),It=R({top:A(S()),left:A(S()),width:A(Ze),height:A(Ze)}),St=R({id:Ye,applicationName:Ye}),_t=R({flags:I()}),xt=R({flags:I()}),kt=R({windowId:Ye,channelsNames:T(Ye)}),Rt=R({enabled:_()}),Tt=R({url:Ye,top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),workspacesSandbox:A(xt),channelSelector:A(Rt),iframePermissionsPolicy:A(_t)}),At=R({name:Ye,displayName:A(I()),contexts:A(T(I())),customConfig:A(R())}),Pt=R({name:Ye,type:Ye.where((e=>"window"===e),"Expected a value of window"),title:A(Ye),version:A(Ye),customProperties:A(x()),icon:A(I()),caption:A(I()),details:Tt,intents:A(T(At)),hidden:A(_()),fdc3:A(Xe.fdc3.v2DefinitionDecoder)}),Mt=P(Pt,Xe.fdc3.v2DefinitionDecoder,Xe.fdc3.v1DefinitionDecoder);R({definitions:T(Mt),mode:P(k("replace"),k("merge"))});const Ot=R({name:Ye}),Et=R({definitions:T(Pt)}),Dt=R({name:Ye,type:Ye.where((e=>"window"===e),"Expected a value of window"),instances:T(St),userProperties:A(x()),title:A(Ye),version:A(Ye),icon:A(Ye),caption:A(Ye)}),jt=R({name:Ye,type:Ye.where((e=>"window"===e),"Expected a value of window"),userProperties:x(),title:A(Ye),version:A(Ye),icon:A(Ye),caption:A(Ye)}),Nt=R({appsAdded:T(jt),appsChanged:T(jt),appsRemoved:T(jt)}),Ft=R({apps:T(Dt),initialChannelId:A(Ye)}),$t=R({id:Ye}),Lt=P(k("Global"),k("Activity"),k("ApplicationDefault"),k("Swimlane"),k("Workspace")),Wt=P(k("application"),k("activity")),qt=R({context:A(x()),bounds:ct,createArgs:R({name:A(Ye),url:A(Ye),context:A(x())}),windowState:A(Ye),restoreState:A(Ye),instanceId:Ye,isCollapsed:A(_()),isSticky:A(_()),restoreSettings:R({groupId:A(Ye),groupZOrder:A(S())})}),Ut=R({type:k("window"),componentType:A(Wt),application:Ye,state:qt}),Gt=R({type:k("window"),config:R({appName:Ye,url:A(Ye),title:A(I()),allowExtract:A(_()),allowReorder:A(_()),showCloseButton:A(_()),isMaximized:A(_())})}),Bt=R({type:k("group"),config:x(),children:T(P(Gt))}),Jt=R({type:k("column"),config:x(),children:T(P(Bt,Gt,E((()=>Jt)),E((()=>Ht))))}),Ht=R({type:k("row"),config:x(),children:T(P(Jt,Bt,Gt,E((()=>Ht))))}),zt=R({config:x(),context:x(),children:T(P(Ht,Jt,Bt,Gt))}),Kt=R({type:k("Workspace"),application:A(Ye),state:zt}),Vt=R({bounds:ct,instanceId:Ye,selectedWorkspace:Ze,workspaces:T(zt),windowState:A(Ye),restoreState:A(Ye),context:A(x())}),Qt=R({type:k("workspaceFrame"),application:Ye,componentType:A(Wt),state:Vt}),Xt=R({name:Ye,type:Lt,token:A(Ye),components:T(P(Ut,Kt,Qt)),context:A(x()),metadata:A(x()),version:A(S())}),Yt=R({name:Ye,type:Lt,token:A(Ye),components:T(P(Ut,Kt,Qt)),context:A(x()),metadata:A(x()),version:A(S()),prevName:Ye}),Zt=R({name:Ye,context:A(x()),metadata:A(x()),instances:A(T(Ye)),ignoreInstances:A(T(Ye))}),en=R({name:Ye,context:A(x()),closeRunningInstance:A(_()),closeMe:A(_()),timeout:A(Ze)}),tn=R({name:Ye,type:Lt,context:A(x()),metadata:A(x())}),nn=R({name:Ye,type:Lt}),sn=R({layout:Zt}),rn=R({layout:Xt,newName:Ye}),on=R({status:Ye}),an=R({layout:Xt}),cn=R({layout:en}),dn=R({type:Lt}),ln=R({layouts:T(Xt)}),hn=A(R({name:Ye})),un=P(k("replace"),k("merge")),pn=R({layouts:T(Xt),mode:un,skipManagerRequest:A(_())}),gn=R({summaries:T(tn)}),mn=R({layout:Xt}),fn=R({layout:A(Xt)}),bn=R({name:Ye}),wn=P(k("findIntent"),k("getIntents"),k("getIntentsByHandler"),k("raise"),k("filterHandlers")),yn=R({applicationName:Ye,applicationTitle:A(I()),applicationDescription:A(I()),applicationIcon:A(I()),type:P(k("app"),k("instance")),displayName:A(I()),contextTypes:A(T(Ye)),instanceId:A(I()),instanceTitle:A(I()),resultType:A(I())});R({applicationName:I(),applicationIcon:A(I()),instanceId:A(I())}),R({intent:Ye,handler:yn});const vn=R({name:Ye,handlers:T(yn)}),Cn=P(k("startNew"),k("reuse"),R({app:A(Ye),instance:A(Ye)})),In=R({type:A(Ye),data:A(x())}),Sn=T(vn),_n=R({intents:Sn}),xn=R({name:A(Ye),contextType:A(Ye),resultType:A(Ye)}),kn=P(Ye,xn),Rn=R({filter:A(xn)}),Tn=R({top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),relativeTo:A(Ye),relativeDirection:A(at),waitForAGMReady:A(_()),channelId:A(Ye)}),An=R({intent:Ye,target:A(Cn),context:A(In),options:A(Tn),handlers:A(T(yn)),timeout:A(Ze),waitUserResponseIndefinitely:A(_()),clearSavedHandler:A(_())}),Pn=R({interopInstance:Ye,name:A(Ye)}),Mn=R({originApp:Pn,intentRequest:A(An)}),On=R({name:Ye,waitForAGMReady:_(),id:A(Ye),context:A(x()),top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),relativeTo:A(Ye),relativeDirection:A(at),forceChromeTab:A(_()),layoutComponentId:A(Ye),channelId:A(Ye),startReason:Mn}),En=P(Ye,An),Dn=R({enabled:_(),appName:Ye,waitResponseTimeout:S()}),jn=R({title:A(Ye),openResolver:A(_()),timeout:A(Ze),intent:A(Ye),contextTypes:A(T(Ye)),resultType:A(Ye),applicationNames:A(T(Ye))}),Nn=R({enabled:_(),initialCaller:R({instanceId:Ye})}),Fn=R({intentRequest:An,resolverConfig:Dn,embeddedResolverConfig:A(Nn)}),$n=R({request:An,handler:yn,result:x()}),Ln=R({handlers:T(yn)}),Wn=R({filterHandlersRequest:jn,resolverConfig:Dn,embeddedResolverConfig:A(Nn)}),qn=R({intent:Ye,contextTypes:A(T(Ye)),displayName:A(I()),icon:A(I()),description:A(I()),resultType:A(I())}),Un=P(Ye,qn),Gn=R({intent:Ye,contextTypes:A(T(Ye)),description:A(Ye),displayName:A(Ye),icon:A(Ye),resultType:A(Ye)}),Bn=R({intents:T(Gn)}),Jn=e=>Ye.where((t=>e.includes(t)),"Expected a valid channel name"),Hn=R({contextType:A(Ye)}),zn=A(P(Ye,R({name:A(Ye),fdc3:A(_())}))),Kn=R({windowId:et,channel:et}),Vn=x().where((e=>"string"==typeof e.type),"Expected a valid FDC3 Context with compulsory 'type' field"),Qn=R({method:Ye,arguments:A(x()),target:A(P(k("all"),k("best")))}),Xn=R({action:I(),title:Ye,icon:A(I()),interop:A(Qn)}),Yn=P(k("Active"),k("Acknowledged"),k("Seen"),k("Closed"),k("Stale"),k("Snoozed"),k("Processing")),Zn=R({count:S()}),ei=R({badge:A(I()),body:A(I()),data:A(x()),dir:A(P(k("auto"),k("ltr"),k("rtl"))),icon:A(I()),image:A(I()),lang:A(I()),renotify:A(_()),requireInteraction:A(_()),silent:A(_()),tag:A(I()),timestamp:A(Ze),vibrate:A(T(S()))}),ti=R({title:Ye,clickInterop:A(Qn),actions:A(T(Xn)),focusPlatformOnDefaultClick:A(_()),badge:A(I()),body:A(I()),data:A(x()),dir:A(P(k("auto"),k("ltr"),k("rtl"))),icon:A(I()),image:A(I()),lang:A(I()),renotify:A(_()),requireInteraction:A(_()),silent:A(_()),tag:A(I()),timestamp:A(Ze),vibrate:A(T(S())),severity:A(P(k("Low"),k("None"),k("Medium"),k("High"),k("Critical"))),showToast:A(_()),showInPanel:A(_()),state:A(Yn)}),ni=R({id:Ye,state:Yn});R().where((e=>!e.fdc3||"string"==typeof e.fdc3.type),"Expected a valid FDC3 Context with compulsory 'type' field");const ii=R({color:A(Ye),icon:A(Ye),name:A(Ye),glyph:A(Ye)}),si=R({id:Ye,displayMetadata:A(ii)}),ri=R({color:Ye,fdc3:A(si)}),oi=R({name:Ye,meta:ri,data:A(R())}),ai=R({path:Ye,value:x()}),ci=T(ai),di=R({name:Ye}),li=R({name:Ye,read:_(),write:_(),windowId:A(Ye)}),hi=R({name:Ye,read:_(),write:_(),windowId:Ye}),ui=R({config:hi}),pi=R({channels:T(li)}),gi=R({windowId:Ye}),mi=R({read:_(),write:_(),windowId:A(Ye)}),fi=R({restrictions:mi}),bi=R({settings:ti,id:Ye}),wi=R({settings:ti}),yi=R({permissionGranted:_()}),vi=R({permission:P(k("default"),k("granted"),k("denied"))}),Ci=R({definition:ei,action:A(I()),id:A(Ye)}),Ii=R({allowed:A(T(Ye)),blocked:A(T(Ye))}),Si=R({enable:A(_()),enableToasts:A(_()),sourceFilter:A(Ii),showNotificationBadge:A(_())}),_i=R({configuration:Si}),xi=R({configuration:R({enable:_(),enableToasts:_(),sourceFilter:R({allowed:T(Ye),blocked:T(Ye)})})}),ki=R({layoutType:P(k("Global"),k("Workspace")),layoutName:Ye,context:A(x())}),Ri=R({windowContext:A(x())}),Ti=R({state:P(k("prompt"),k("denied"),k("granted"))}),Ai=R({isAvailable:_()}),Pi=R({itemId:Ye}),Mi=R({isSupported:_()}),Oi=R({operation:Ye}),Ei=R({bounds:ct}),Di=R({displayName:Ye,name:Ye}),ji=R({theme:Di}),Ni=R({themes:T(Di)}),Fi=R({name:Ye}),$i=R({id:Ye,title:Ye,clickInterop:A(Qn),actions:A(T(Xn)),focusPlatformOnDefaultClick:A(_()),badge:A(I()),body:A(I()),data:A(x()),dir:A(P(k("auto"),k("ltr"),k("rtl"))),icon:A(I()),image:A(I()),lang:A(I()),renotify:A(_()),requireInteraction:A(_()),silent:A(_()),tag:A(I()),timestamp:A(Ze),vibrate:A(T(S())),severity:A(P(k("Low"),k("None"),k("Medium"),k("High"),k("Critical"))),showToast:A(_()),showInPanel:A(_()),state:A(Yn)}),Li=R({notification:$i}),Wi=R({notifications:T($i)}),qi=R({id:Ye}),Ui=R({channel:Ye}),Gi=R({windowIds:T(Ye)}),Bi=P(k("addChannel"),k("getMyChannel"),k("getWindowIdsOnChannel"),k("getWindowIdsWithChannels"),k("joinChannel"),k("restrict"),k("getRestrictions"),k("restrictAll"),k("notifyChannelsChanged"),k("leaveChannel"),k("getMode"),k("operationCheck")),Ji=R({mode:P(k("single"),k("multi"))}),Hi=R({channel:A(Ye)}),zi=R({application:A(Ye),channels:A(T(Ye)),windowIds:A(T(Ye))}),Ki=R({filter:A(zi)}),Vi=R({windowIdsWithChannels:T(R({application:Ye,channel:A(Ye),windowId:Ye}))}),Qi=A(x()),Xi=A(R({top:A(S()),left:A(S()),width:A(Ze),height:A(Ze),relativeTo:A(Ye),relativeDirection:A(at),waitForAGMReady:A(_()),channelId:A(Ye),reuseId:A(Ye),originIntentRequest:A(An)})),Yi=R({channel:Ye,windowId:Ye}),Zi=R({windowId:Ye,channelName:A(Ye)}),es=R({windowId:Ye,channelNames:T(Ye)}),ts=R({channel:A(Ye)}),ns=P(k("clear"),k("clearAll"),k("get"),k("getAll"),k("set"),k("update"),k("prefsChanged"),k("prefsHello"),k("operationCheck"),k("registerSubscriber")),is=R({app:Ye,data:R(),lastUpdate:A(Ye)}),ss=R({app:Ye}),rs=R({prefs:is}),os=R({all:T(is)}),as=R({interopId:Ye}),cs=R({app:Ye,data:R()}),ds=R({platform:R({app:Ye}),validNonExistentApps:A(T(Ye))}),ls=R({message:Ye}),hs=R({isClientErrorOperationSupported:_()}),us=Xe.common.nonEmptyStringDecoder,ps=Xe.common.nonNegativeNumberDecoder,gs=R({bundle:us,styles:T(us),fonts:A(T(us))}),ms=R({bundle:us,styles:T(us),fonts:A(T(us))}),fs=R({bundle:us,styles:T(us),fonts:A(T(us))}),bs=P(k("directional"),k("default")),ws=R({type:A(bs),enable:A(_())}),ys=P(k("top"),k("bottom"),k("left"),k("right")),vs=P(k("default"),k("compact")),Cs=P(k("all"),k("fdc3")),Is=R({selector:A(ws),displayMode:A(Cs)}),Ss=R({channels:A(Is),position:A(ys),mode:A(vs),displayInWorkspace:A(_())}),_s=R({enable:_(),awaitFactory:A(_()),timeout:A(ps),channels:A(Is),position:A(ys),mode:A(vs),displayInWorkspace:A(_())}),xs=R({alerts:A(R({enabled:_()})),dialogs:A(R({enabled:_()})),awaitFactory:A(_()),timeout:A(ps)}),ks=P(k("getResources"),k("operationCheck"),k("showAlert"),k("showDialog"),k("alertInteropAction"),k("showResolver")),Rs=R({origin:us}),Ts=R({blockedOrigin:k(!0)}),As=M(Ts,R({blockedOrigin:k(!1),config:Ss,sources:gs})),Ps=M(Ts,R({blockedOrigin:k(!1),sources:ms})),Ms=M(Ts,R({blockedOrigin:k(!1),sources:fs})),Os=R({widget:A(As),modals:A(Ps),intentResolver:A(Ms)}),Es=R({resources:Os}),Ds=R({method:us,arguments:A(x()),target:A(P(k("best"),k("all"),us))}),js=P(k("Global"),k("WindowContainer"),us),Ns=R({instance:us,container:A(P(k("Global"),k("WindowContainer")))}),Fs=R({variant:P(k("default"),k("success"),k("critical"),k("info"),k("warning")),text:us,showCloseButton:A(_()),clickInterop:A(Ds),onCloseInterop:A(Ds),actions:A(T(R({id:us,title:us,clickInterop:Ds}))),data:A(x()),ttl:A(ps),target:A(js)}),$s=R({config:Fs,target:Ns}),Ls=R({templateName:us,variables:x(),target:A(js),timer:A(R({duration:ps})),size:A(R({width:ps,height:ps})),movable:A(_()),transparent:A(_())}),Ws=R({isExpired:A(_()),isClosed:A(_()),isEnterPressed:A(_()),responseButtonClicked:A(R({id:us,text:us})),inputs:A(T(R({type:P(k("checkbox"),k("email"),k("number"),k("password"),k("text")),id:us,checked:A(_()),value:A(I())})))});R({result:Ws});const qs=R({config:Ls,target:Ns}),Us=R({id:us}),Gs=R({id:us,responsePromise:x()}),Bs=R({response:Ws}),Js=R({name:us,settings:Ds}),Hs=R({interopAction:Js}),zs=R({interopAction:Js}),Ks=R({enable:_(),awaitFactory:A(_()),timeout:A(ps)}),Vs=R({id:us}),Qs=R({preserveChoice:_()}),Xs=R({intent:us,handler:yn,userSettings:Qs}),Ys=R({isExpired:A(_()),isClosed:A(_()),userChoice:A(Xs)}),Zs=R({response:Ys}),er=O(M(R({intentRequest:An}),R({handlerFilter:jn})),R({timeout:ps})),tr=R({config:er}),nr=R({result:Ys}),ir={openWindow:{name:"openWindow",dataDecoder:lt,resultDecoder:ut},windowHello:{name:"windowHello",dataDecoder:ht,resultDecoder:gt},windowAdded:{name:"windowAdded",dataDecoder:ut},windowRemoved:{name:"windowRemoved",dataDecoder:pt},getBounds:{name:"getBounds",dataDecoder:pt,resultDecoder:wt},getFrameBounds:{name:"getFrameBounds",dataDecoder:pt,resultDecoder:yt},getUrl:{name:"getUrl",dataDecoder:pt,resultDecoder:vt},moveResize:{name:"moveResize",dataDecoder:bt},focus:{name:"focus",dataDecoder:pt},close:{name:"close",dataDecoder:pt},getTitle:{name:"getTitle",dataDecoder:pt,resultDecoder:mt},setTitle:{name:"setTitle",dataDecoder:mt},focusChange:{name:"focusChange",dataDecoder:ft},getChannel:{name:"getChannel",dataDecoder:pt,resultDecoder:ts},notifyChannelsChanged:{name:"notifyChannelsChanged",dataDecoder:es},operationCheck:{name:"operationCheck"}};function sr(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]}}}sr.default=sr;var rr=e(sr);class or{_id;_name;_bridge;registry=rr();myCtxKey;ctxUnsubscribe;me;constructor(e,t,n){this._id=e,this._name=t,this._bridge=n,this.myCtxKey=`___window___${this.id}`}get id(){return this._id.slice()}get name(){return this._name.slice()}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)}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,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),onContextUpdated:this.onContextUpdated.bind(this),onFocusChanged:this.onFocusChanged.bind(this),getChannel:this.getChannel.bind(this),onChannelsChanged:this.onChannelsChanged.bind(this)},this.me}async getURL(){return(await this._bridge.send("windows",ir.getUrl,{windowId:this.id})).url}onFocusChanged(e){return"function"!=typeof e?ie.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(It,e),n=Object.assign({},t,{windowId:this.id,relative:!1});return await this._bridge.send("windows",ir.moveResize,n),this.me}async resizeTo(e,t){if(void 0===e&&void 0===t)return this.me;void 0!==e&&Y(Ze,e),void 0!==t&&Y(Ze,t);const n=Object.assign({},{width:e,height:t},{windowId:this.id,relative:!0});return await this._bridge.send("windows",ir.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",ir.moveResize,n),this.me}async focus(){return"Platform"===this.name?window.open(void 0,this.id):await this._bridge.send("windows",ir.focus,{windowId:this.id}),this.me}async close(){return await this._bridge.send("windows",ir.close,{windowId:this.id}),this.me}async getTitle(){return(await this._bridge.send("windows",ir.getTitle,{windowId:this.id})).title}async setTitle(e){const t=Y(Ye,e);return await this._bridge.send("windows",ir.setTitle,{windowId:this.id,title:t}),this.me}async getBounds(){return(await this._bridge.send("windows",ir.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(Ct,e);return await this._bridge.contextLib.update(this.myCtxKey,t),this.me}async setContext(e){const t=Y(Ct,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 ie.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",ir.getChannel,{windowId:this.id},void 0,{includeOperationCheck:!0})).channel}onChannelsChanged(e){return this.registry.add("channels-changed",e)}}const ar={operationCheck:{name:"operationCheck",dataDecoder:Oi,resultDecoder:Mi},getWorkspaceWindowFrameBounds:{name:"getWorkspaceWindowFrameBounds",resultDecoder:Ei,dataDecoder:Pi}},cr=(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))}))})),dr=(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 lr{supportedOperationsNames=[];focusEventHandler;registry=rr();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(nt,e.operation),n=ir[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(Ye,e),Y(Ye,t);const i=Y(dt,n),s=await this.bridge.send("windows",ir.openWindow,{name:e,url:t,options:i});return this.waitForWindowAdded(s.windowId)}list(){return this.allWindowProjections.map((e=>e.api))}findById(e){return Y(Ye,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(){ir.focusChange.execute=this.handleFocusChangeEvent.bind(this),ir.windowAdded.execute=this.handleWindowAdded.bind(this),ir.windowRemoved.execute=this.handleWindowRemoved.bind(this),ir.getBounds.execute=this.handleGetBounds.bind(this),ir.getFrameBounds.execute=this.handleGetBounds.bind(this),ir.getTitle.execute=this.handleGetTitle.bind(this),ir.getUrl.execute=this.handleGetUrl.bind(this),ir.moveResize.execute=this.handleMoveResize.bind(this),ir.setTitle.execute=this.handleSetTitle.bind(this),ir.getChannel.execute=this.handleGetChannel.bind(this),ir.notifyChannelsChanged.execute=this.handleChannelsChanged.bind(this),ir.operationCheck.execute=async e=>ee(this.supportedOperationsNames,e.operation),this.supportedOperationsNames=Z(ir)}my(){return Object.assign({},this.me)}onWindowAdded(e){return"function"!=typeof e?ie.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?ie.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?ie.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?ie.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",ir.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 ie.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.buildWebWindow(this.publicWindowId,t.name);this.me=n.api,this.allWindowProjections.push(n)}const n=await Promise.all(e.filter((e=>e.windowId!==this.publicWindowId)).map((e=>this.ioc.buildWebWindow(e.windowId,e.name))));this.logger.trace("all windows projections are completed, building the list collection"),this.allWindowProjections.push(...n)}async handleFocusChangeEvent(e){const t=this.allWindowProjections.find((t=>t.id===e.windowId));if(!t)return;t.model.processSelfFocusEvent(e.hasFocus);const n=e.hasFocus?"window-got-focus":"window-lost-focus";this.registry.execute(n,t.api)}async handleWindowAdded(e){if(this.allWindowProjections.some((t=>t.id===e.windowId)))return;const t=await this.ioc.buildWebWindow(e.windowId,e.name);this.allWindowProjections.push(t),this.registry.execute("window-added",t.api)}async handleWindowRemoved(e){const t=this.allWindowProjections.find((t=>t.id===e.windowId));t&&(this.allWindowProjections=this.allWindowProjections.filter((t=>t.id!==e.windowId)),t.model.clean(),this.registry.execute("window-removed",t.api))}async handleGetBounds(){return this.me||this.isWorkspaceFrame?{windowId:this.isWorkspaceFrame?"noop":this.me.id,bounds:{top:window.screenTop,left:window.screenLeft,width:window.innerWidth,height:window.innerHeight}}:ie.raiseError("This window cannot report it's bounds, because it is not a Glue Window, most likely because it is an iframe")}async handleGetTitle(){return this.me?{windowId:this.me.id,title:document.title}:ie.raiseError("This window cannot report it's title, because it is not a Glue Window, most likely because it is an iframe")}async handleGetUrl(){return this.me?{windowId:this.me.id,url:window.location.href}:ie.raiseError("This window cannot report it's url, because it is not a Glue Window, most likely because it is an iframe")}async handleMoveResize(e){const t="number"==typeof e.top?e.top:e.relative?0:window.screenTop,n="number"==typeof e.left?e.left:e.relative?0:window.screenLeft,i="number"==typeof e.height?e.height:e.relative?0:window.innerHeight,s="number"==typeof e.width?e.width:e.relative?0:window.innerWidth,r=e.relative?window.moveBy:window.moveTo,o=e.relative?window.resizeBy:window.resizeTo;r(n,t),o(s,i)}async handleSetTitle(e){document.title=e.title}async initializeFocusTracking(){if(this.isWorkspaceF