@luigi-project/client 2.29.1-dev.20260530107 → 2.29.1-dev.20260550059

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/luigi-client.js CHANGED
@@ -1,2 +1,2 @@
1
- !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).LuigiClient=t()}(this,function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n){return t=o(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,[],o(e).constructor):t.apply(e,n))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,v(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function g(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}var f=function(){return i(function e(){n(this,e),this.promises={}},[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])}(),h=function(){return i(function e(){n(this,e),this.listeners=[],this.origin="";var t=function(e){if((!this.origin||"*"===this.origin||e.origin===this.origin)&&e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter(function(e){return e.name===t.id}).map(function(e){return e.eventFn(t,e.listenerId)})}else this.listeners.filter(function(t){return t.name===e.data.msg}).map(function(t){return t.eventFn(e,t.listenerId)})}.bind(this);window.addEventListener("message",t)},[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:n}),n}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find(function(t){return t.listenerId===e}))&&(this.listeners=this.listeners.filter(function(t){return t.listenerId!==e}),!0)}},{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce(function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e},{})}},{key:"deSanitizeParam",value:function(){return String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}])}(),m=new h,p=function(e){function r(){var e;return n(this,r),(e=t(this,r)).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce(function(e,t){return e[t]={},e},{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return a(r,e),i(r,[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"_isTpcCheckDisabled",value:function(){var e,t,n;return window.document.head.hasAttribute("disable-tpc-check")||(null===(e=this.currentContext)||void 0===e||null===(t=e.internal)||void 0===t||null===(n=t.thirdPartyCookieCheck)||void 0===n?void 0:n.disabled)}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var i=e.defaultContextKeys[n];try{"string"==typeof t[i]&&(t[i]=JSON.parse(t[i]))}catch(e){console.info("unable to parse luigi context data for",i,t[i],e)}}e.setCurrentContext(t)},n=function(t){t&&(e.authData=t)};m.addEventListener("luigi.init",function(i){t(i.data),n(i.data.authData),m.setLuigiCoreDomain(i.origin),e.luigiInitialized=!0,e._notifyInit(i.origin),e._tpcCheck(),m.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})}),m.addEventListener("luigi-client.inactive-microfrontend",function(t){e._notifyInactive(t.origin)}),m.addEventListener("luigi.auth.tokenIssued",function(e){n(e.data.authData)}),m.addEventListener("luigi.navigate",function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var i=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==i&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),m.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})}),window.parent.postMessage({msg:"luigi.get-context",clientVersion:"2.29.0"},"*")}}},{key:"_tpcCheck",value:function(){if(!this._isTpcCheckDisabled()){var e,t="enabled",n=document.cookie;n&&(e=n.split(";").map(function(e){return e.trim()}).find(function(e){return"luigiCookie=true"===e})),"luigiCookie=true"===e&&(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure"),document.cookie="luigiCookie=true; SameSite=None; Secure",(n=document.cookie)&&(e=n.split(";").map(function(e){return e.trim()}).find(function(e){return"luigiCookie=true"===e})),"luigiCookie=true"===e?(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*")):(t="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*"),console.warn("Third party cookies are not supported!"))}}},{key:"_callAllFns",value:function(e,t,n){for(var i in e)e.hasOwnProperty(i)&&m.isFunction(e[i])&&e[i](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e,t){var n=m.getRandomId();return this._onInitFns[n]=e,t&&document.head.setAttribute("disable-tpc-check",""),this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context,m.getLuigiCoreDomain()),n}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=m.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=m.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return m.addEventListener(e,function(e,n){return t(e,n)})}},{key:"removeCustomMessageListener",value:function(e){return m.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){var e;return null!==(e=this.currentContext.internal.activeFeatureToggleList)&&void 0!==e?e:[]}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?m.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t,preventLuigiConfigUpdate:n})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){m.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=m.convertCustomMessageUserToInternal(e);m.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}},{key:"setViewGroupData",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setVGData",data:e})}}])}(f),y=new p,k=function(e){function r(e){var i;n(this,r),(i=t(this,r)).validSplitViewEvents=["expand","collapse","resize","close"],i.splitView={exists:!0,size:40,collapsed:!1},Object.assign(i.splitView,e);return i.splitView.listeners=[m.addEventListener("luigi.navigation.splitview.internal",function(e){Object.assign(i.splitView,e.data.data)})],i.on("resize",function(e){i.splitView.size=e}),i.on("close",function(){i.splitView.listeners.forEach(function(e){return m.removeEventListener(e)})}),i}return a(r,e),i(r,[{key:"sendSplitViewEvent",value:function(e,t){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=m.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)});return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return m.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}])}(f),C=function(e){function r(e){var i;return n(this,r),i=t(this,r),Object.assign(i,e),i.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},i}return a(r,e),i(r,[{key:"navigate",value:function(e,t,n,i,r,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&r&&o&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(i||r||o))console.warn("Navigation with an absolute path prevented.");else{var s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:m.hasIntent(e),modal:i,splitView:r,drawer:o})};m.sendPostMessageToLuigiCore(s)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var i={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};m.sendPostMessageToLuigiCore(i)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="#?intent=";if(i+=e,n&&null!==(t=Object.keys(n))&&void 0!==t&&t.length){var r=Object.entries(n);if(r.length>0){i+="?";var o,a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(r);try{for(a.s();!(o=a.n()).done;){var s=d(o.value,2);i+=s[0]+"="+s[1]+"&"}}catch(e){a.e(e)}finally{a.f()}i=i.slice(0,-1)}}this.navigate(i)}},{key:"openAsModal",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};m.addEventListener("luigi.navigation.modal.close",function(e,n){var i,r=t.getPromise("modal");r&&(r.resolveFn(l(l({},e.data),{},{goBackValue:null===(i=e.data)||void 0===i?void 0:i.data})),t.setPromise("modal",void 0));m.removeEventListener(n)});var i={};return i.promise=new Promise(function(e,t){i.resolveFn=e,i.rejectFn=t}),this.setPromise("modal",i),this.navigate(e,0,!0,n),i.promise}},{key:"updateModalSettings",value:function(){var e={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},addHistoryEntry:arguments.length>1&&void 0!==arguments[1]&&arguments[1]};m.sendPostMessageToLuigiCore(e)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new k(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){var e;return(null===(e=this.currentContext)||void 0===e?void 0:e.context.parentNavigationContexts.length)>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return m.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=m.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),m.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var i=e.data.data,r=this.getPromise("pathExistsPromises")||{};i.correlationId===t&&(r[i.correlationId]&&(r[i.correlationId].resolveFn(i.pathExists),delete r[i.correlationId],this.setPromise("pathExistsPromises",r)),m.removeEventListener(n))}.bind(this));var i={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:m.hasIntent(e),relative:"/"!==e[0]})};return m.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=m.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),m.addEventListener("luigi.navigation.currentRoute.answer",function(n,i){var r=n.data.data,o=e.getPromise("getCurrentRoute")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.route),delete o[r.correlationId],e.setPromise("getCurrentRoute",o)),m.removeEventListener(i)),m.removeEventListener(i)}),m.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}])}(f),w=new(function(e){function r(){var e;return n(this,r),e=t(this,r),m.addEventListener("luigi.current-locale-changed",function(e){var t;e.data.currentLocale&&null!==(t=y.currentContext)&&void 0!==t&&t.internal&&(y.currentContext.internal.currentLocale=e.data.currentLocale,y._notifyUpdate())}),e}return a(r,e),i(r,[{key:"showLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;m.addEventListener("luigi.ux.confirmationModal.hide",function(e,n){t.hideConfirmationModal(e.data.data),m.removeEventListener(n)}),m.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise(function(e,t){n.resolveFn=e,n.rejectFn=t}),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;e.id=m.getRandomId(),m.addEventListener("luigi.ux.alert.hide",function(n,i){n.data.id===e.id&&(t.hideAlert(n.data),m.removeEventListener(i))}),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),m.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise(function(t){n[e.id].resolveFn=t}),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,i=this.getPromise("alerts");t&&i[t]&&(i[t].resolveFn(n||t),delete i[t],this.setPromise("alerts",i))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&m.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}},{key:"getCSSVariables",value:function(){var e,t;return(null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables)||{}}},{key:"applyCSS",value:function(){var e,t;document.querySelectorAll("head style[luigi-injected]").forEach(function(e){e.remove()});var n=null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables;if(n){var i=":root {\n";Object.keys(n).forEach(function(e){var t=n[e];i+=(e.startsWith("--")?"":"--")+e+":"+t+";\n"}),i+="}";var r=document.createElement("style");r.setAttribute("luigi-injected",!0),r.innerHTML=i,document.head.appendChild(r)}}}])}(f)),P=new Map,b=function(e){function r(){var e;return n(this,r),(e=t(this,r)).storageEventProcessor=new x,m.addEventListener("storage",function(t,n){return e.storageEventProcessor.processEvent(t,n)}),e}return a(r,e),i(r,[{key:"setItem",value:function(e,t){var n=this;return new Promise(function(i,r){n.storageEventProcessor.execute(i,r,"setItem",{key:e,value:t})})}},{key:"getItem",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"getItem",{key:e})})}},{key:"removeItem",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"removeItem",{key:e})})}},{key:"clear",value:function(){var e=this;return new Promise(function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})})}},{key:"has",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"has",{key:e})})}},{key:"getAllKeys",value:function(){var e=this;return new Promise(function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})})}}])}(f),x=function(){return i(function e(){n(this,e)},[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!P.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=P.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),P.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);){if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication"}var n=syncOperation.get(e);return P.delete(e),n}},{key:"execute",value:function(e,t,n,i){var r=m.getRandomId();this.createPendingOperation(r,e,t),this.sendMessage(r,n,i)}},{key:"createPendingOperation",value:function(e,t,n){P.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){m.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}])}(),L=new b,I=function(){return i(function e(){n(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};m.sendPostMessageToLuigiCore(t)}))},[{key:"addInitListener",value:function(e,t){return y.addInitListener(e,t)}},{key:"removeInitListener",value:function(e){return y.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return y.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return y.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return y.getToken()}},{key:"getEventData",value:function(){return y.getEventData()}},{key:"getContext",value:function(){return y.getContext()}},{key:"addNodeParams",value:function(e,t){return y.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return y.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return y.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return y.getPathParams()}},{key:"getCoreSearchParams",value:function(){return y.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t,n){return y.addCoreSearchParams(e,t,n)}},{key:"getClientPermissions",value:function(){return y.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return y.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return y.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return y.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return y.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return y.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return y.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return y.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return y.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return y.luigiClientInit()}},{key:"getAnchor",value:function(){return y.getAnchor()}},{key:"setAnchor",value:function(e){return y.setAnchor(e)}},{key:"setViewGroupData",value:function(e){return y.setViewGroupData(e)}},{key:"linkManager",value:function(){return new C({currentContext:y.currentContext})}},{key:"uxManager",value:function(){return w}},{key:"lifecycleManager",value:function(){return y}},{key:"storageManager",value:function(){return L}}])}();return I=new I});
1
+ !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).LuigiClient=t()}(this,function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n){return t=o(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,[],o(e).constructor):t.apply(e,n))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,v(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function g(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}var f=function(){return i(function e(){n(this,e),this.promises={}},[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])}(),h=function(){return i(function e(){n(this,e),this.listeners=[],this.origin="";var t=function(e){if((!this.origin||"*"===this.origin||e.origin===this.origin)&&e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter(function(e){return e.name===t.id&&e.isCustomMessage}).map(function(e){return e.eventFn(t,e.listenerId)})}else this.listeners.filter(function(t){return t.name===e.data.msg}).map(function(t){return t.eventFn(e,t.listenerId)})}.bind(this);window.addEventListener("message",t)},[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:i,isCustomMessage:n}),i}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find(function(t){return t.listenerId===e}))&&(this.listeners=this.listeners.filter(function(t){return t.listenerId!==e}),!0)}},{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce(function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e},{})}},{key:"deSanitizeParam",value:function(){return String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}])}(),m=new h,p=function(e){function r(){var e;return n(this,r),(e=t(this,r)).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce(function(e,t){return e[t]={},e},{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return a(r,e),i(r,[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"_isTpcCheckDisabled",value:function(){var e,t,n;return window.document.head.hasAttribute("disable-tpc-check")||(null===(e=this.currentContext)||void 0===e||null===(t=e.internal)||void 0===t||null===(n=t.thirdPartyCookieCheck)||void 0===n?void 0:n.disabled)}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var i=e.defaultContextKeys[n];try{"string"==typeof t[i]&&(t[i]=JSON.parse(t[i]))}catch(e){console.info("unable to parse luigi context data for",i,t[i],e)}}e.setCurrentContext(t)},n=function(t){t&&(e.authData=t)};m.addEventListener("luigi.init",function(i){t(i.data),n(i.data.authData),m.setLuigiCoreDomain(i.origin),e.luigiInitialized=!0,e._notifyInit(i.origin),e._tpcCheck(),m.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})}),m.addEventListener("luigi-client.inactive-microfrontend",function(t){e._notifyInactive(t.origin)}),m.addEventListener("luigi.auth.tokenIssued",function(e){n(e.data.authData)}),m.addEventListener("luigi.navigate",function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var i=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==i&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),m.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})}),window.parent.postMessage({msg:"luigi.get-context",clientVersion:"2.29.0"},"*")}}},{key:"_tpcCheck",value:function(){if(!this._isTpcCheckDisabled()){var e,t="enabled",n=document.cookie;n&&(e=n.split(";").map(function(e){return e.trim()}).find(function(e){return"luigiCookie=true"===e})),"luigiCookie=true"===e&&(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure"),document.cookie="luigiCookie=true; SameSite=None; Secure",(n=document.cookie)&&(e=n.split(";").map(function(e){return e.trim()}).find(function(e){return"luigiCookie=true"===e})),"luigiCookie=true"===e?(document.cookie="luigiCookie=; Max-Age=-99999999; SameSite=None; Secure",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*")):(t="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:t},"*"),console.warn("Third party cookies are not supported!"))}}},{key:"_callAllFns",value:function(e,t,n){for(var i in e)e.hasOwnProperty(i)&&m.isFunction(e[i])&&e[i](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e,t){var n=m.getRandomId();return this._onInitFns[n]=e,t&&document.head.setAttribute("disable-tpc-check",""),this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context,m.getLuigiCoreDomain()),n}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=m.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&m.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=m.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return m.addEventListener(e,function(e,n){return t(e,n)},!0)}},{key:"removeCustomMessageListener",value:function(e){return m.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){var e;return null!==(e=this.currentContext.internal.activeFeatureToggleList)&&void 0!==e?e:[]}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?m.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e&&m.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t,preventLuigiConfigUpdate:n})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){m.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=m.convertCustomMessageUserToInternal(e);m.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}},{key:"setViewGroupData",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.setVGData",data:e})}}])}(f),y=new p,k=function(e){function r(e){var i;n(this,r),(i=t(this,r)).validSplitViewEvents=["expand","collapse","resize","close"],i.splitView={exists:!0,size:40,collapsed:!1},Object.assign(i.splitView,e);return i.splitView.listeners=[m.addEventListener("luigi.navigation.splitview.internal",function(e){Object.assign(i.splitView,e.data.data)})],i.on("resize",function(e){i.splitView.size=e}),i.on("close",function(){i.splitView.listeners.forEach(function(e){return m.removeEventListener(e)})}),i}return a(r,e),i(r,[{key:"sendSplitViewEvent",value:function(e,t){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=m.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)});return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return m.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}])}(f),C=function(e){function r(e){var i;return n(this,r),i=t(this,r),Object.assign(i,e),i.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},i}return a(r,e),i(r,[{key:"navigate",value:function(e,t,n,i,r,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&r&&o&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(i||r||o))console.warn("Navigation with an absolute path prevented.");else{var s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:m.hasIntent(e),modal:i,splitView:r,drawer:o})};m.sendPostMessageToLuigiCore(s)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var i={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};m.sendPostMessageToLuigiCore(i)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="#?intent=";if(i+=e,n&&null!==(t=Object.keys(n))&&void 0!==t&&t.length){var r=Object.entries(n);if(r.length>0){i+="?";var o,a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(r);try{for(a.s();!(o=a.n()).done;){var s=d(o.value,2);i+=s[0]+"="+s[1]+"&"}}catch(e){a.e(e)}finally{a.f()}i=i.slice(0,-1)}}this.navigate(i)}},{key:"openAsModal",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};m.addEventListener("luigi.navigation.modal.close",function(e,n){var i,r=t.getPromise("modal");r&&(r.resolveFn(l(l({},e.data),{},{goBackValue:null===(i=e.data)||void 0===i?void 0:i.data})),t.setPromise("modal",void 0));m.removeEventListener(n)});var i={};return i.promise=new Promise(function(e,t){i.resolveFn=e,i.rejectFn=t}),this.setPromise("modal",i),this.navigate(e,0,!0,n),i.promise}},{key:"updateModalSettings",value:function(){var e={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},addHistoryEntry:arguments.length>1&&void 0!==arguments[1]&&arguments[1]};m.sendPostMessageToLuigiCore(e)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new k(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){var e;return(null===(e=this.currentContext)||void 0===e?void 0:e.context.parentNavigationContexts.length)>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return m.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=m.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),m.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var i=e.data.data,r=this.getPromise("pathExistsPromises")||{};i.correlationId===t&&(r[i.correlationId]&&(r[i.correlationId].resolveFn(i.pathExists),delete r[i.correlationId],this.setPromise("pathExistsPromises",r)),m.removeEventListener(n))}.bind(this));var i={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:m.hasIntent(e),relative:"/"!==e[0]})};return m.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=m.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),m.addEventListener("luigi.navigation.currentRoute.answer",function(n,i){var r=n.data.data,o=e.getPromise("getCurrentRoute")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.route),delete o[r.correlationId],e.setPromise("getCurrentRoute",o)),m.removeEventListener(i)),m.removeEventListener(i)}),m.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}])}(f),w=new(function(e){function r(){var e;return n(this,r),e=t(this,r),m.addEventListener("luigi.current-locale-changed",function(e){var t;e.data.currentLocale&&null!==(t=y.currentContext)&&void 0!==t&&t.internal&&(y.currentContext.internal.currentLocale=e.data.currentLocale,y._notifyUpdate())}),e}return a(r,e),i(r,[{key:"showLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){m.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){m.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;m.addEventListener("luigi.ux.confirmationModal.hide",function(e,n){t.hideConfirmationModal(e.data.data),m.removeEventListener(n)}),m.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise(function(e,t){n.resolveFn=e,n.rejectFn=t}),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;e.id=m.getRandomId(),m.addEventListener("luigi.ux.alert.hide",function(n,i){n.data.id===e.id&&(t.hideAlert(n.data),m.removeEventListener(i))}),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),m.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise(function(t){n[e.id].resolveFn=t}),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,i=this.getPromise("alerts");t&&i[t]&&(i[t].resolveFn(n||t),delete i[t],this.setPromise("alerts",i))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&m.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}},{key:"getCSSVariables",value:function(){var e,t;return(null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables)||{}}},{key:"applyCSS",value:function(){var e,t;document.querySelectorAll("head style[luigi-injected]").forEach(function(e){e.remove()});var n=null===(e=y.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.cssVariables;if(n){var i=":root {\n";Object.keys(n).forEach(function(e){var t=n[e];i+=(e.startsWith("--")?"":"--")+e+":"+t+";\n"}),i+="}";var r=document.createElement("style");r.setAttribute("luigi-injected",!0),r.innerHTML=i,document.head.appendChild(r)}}}])}(f)),P=new Map,b=function(e){function r(){var e;return n(this,r),(e=t(this,r)).storageEventProcessor=new x,m.addEventListener("storage",function(t,n){return e.storageEventProcessor.processEvent(t,n)}),e}return a(r,e),i(r,[{key:"setItem",value:function(e,t){var n=this;return new Promise(function(i,r){n.storageEventProcessor.execute(i,r,"setItem",{key:e,value:t})})}},{key:"getItem",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"getItem",{key:e})})}},{key:"removeItem",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"removeItem",{key:e})})}},{key:"clear",value:function(){var e=this;return new Promise(function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})})}},{key:"has",value:function(e){var t=this;return new Promise(function(n,i){t.storageEventProcessor.execute(n,i,"has",{key:e})})}},{key:"getAllKeys",value:function(){var e=this;return new Promise(function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})})}}])}(f),x=function(){return i(function e(){n(this,e)},[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!P.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=P.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),P.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);){if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication"}var n=syncOperation.get(e);return P.delete(e),n}},{key:"execute",value:function(e,t,n,i){var r=m.getRandomId();this.createPendingOperation(r,e,t),this.sendMessage(r,n,i)}},{key:"createPendingOperation",value:function(e,t,n){P.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){m.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}])}(),L=new b,I=function(){return i(function e(){n(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};m.sendPostMessageToLuigiCore(t)}))},[{key:"addInitListener",value:function(e,t){return y.addInitListener(e,t)}},{key:"removeInitListener",value:function(e){return y.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return y.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return y.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return y.getToken()}},{key:"getEventData",value:function(){return y.getEventData()}},{key:"getContext",value:function(){return y.getContext()}},{key:"addNodeParams",value:function(e,t){return y.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return y.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return y.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return y.getPathParams()}},{key:"getCoreSearchParams",value:function(){return y.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t,n){return y.addCoreSearchParams(e,t,n)}},{key:"getClientPermissions",value:function(){return y.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return y.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return y.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return y.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return y.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return y.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return y.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return y.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return y.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return y.luigiClientInit()}},{key:"getAnchor",value:function(){return y.getAnchor()}},{key:"setAnchor",value:function(e){return y.setAnchor(e)}},{key:"setViewGroupData",value:function(e){return y.setViewGroupData(e)}},{key:"linkManager",value:function(){return new C({currentContext:y.currentContext})}},{key:"uxManager",value:function(){return w}},{key:"lifecycleManager",value:function(){return y}},{key:"storageManager",value:function(){return L}}])}();return I=new I});
2
2
  //# sourceMappingURL=luigi-client.js.map