/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=9)}([function(e,t){e.exports=__kbnSharedDeps__.EmotionReact},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t){e.exports=__kbnSharedDeps__.KbnI18n},function(e,t,n){e.exports=n(11)(1466)},function(e,t){e.exports=__kbnSharedDeps__.Rxjs},function(e,t){e.exports=__kbnSharedDeps__.KbnI18nReact},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(12),o=n(2),s=i.__importDefault(n(13));t.default=function(e,t){var n=o.useState(t),i=n[0],r=n[1];return s.default((function(){var t=e.subscribe(r);return function(){return t.unsubscribe()}}),[e]),i}},function(e,t,n){n.r(t);var i=__kbnBundles__.get("plugin/kibanaReact/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(i))},function(e,t,n){n(10),__kbnBundles__.define("plugin/cloudLinks/public",n,14)},function(e,t,n){n.p=window.__kbnPublicPath__.cloudLinks},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t){e.exports=__kbnSharedDeps__.TsLib},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o="undefined"!=typeof window?i.useLayoutEffect:i.useEffect;t.default=o},function(e,t,n){"use strict";n.r(t),n.d(t,"plugin",(function(){return M}));var i=n(2),o=n.n(i),s=n(6),r=n(5),u=n(3),a=n(0),l=n(1);n(4);var c=n(7),d=n.n(c);const p=o.a.createContext(null),f=({children:e,...t})=>Object(a.jsx)(p.Provider,{value:t},e),b=({children:e,...t})=>{const{core:{notifications:n,theme:i},security:{userProfiles:o},toMountPoint:s}=t;return Object(a.jsx)(f,{userProfileApiClient:o,notifySuccess:({title:e,text:t},o)=>{const r={};null!=o&&o.durationMs&&(r.toastLifeTimeMs=o.durationMs),n.toasts.addSuccess({title:e,text:t?s(t,{theme$:i.theme$}):void 0},r)}},e)},g={notificationSuccess:{title:u.i18n.translate("userProfileComponents.updateUserProfile.notification.submitSuccessTitle",{defaultMessage:"Profile updated"}),pageReloadText:u.i18n.translate("userProfileComponents.updateUserProfile.notification.requiresPageReloadDescription",{defaultMessage:"One or more settings require you to reload the page to take effect."})}};var k=n(8);const h=({uiSettingsClient:e})=>{const[t,n]=Object(i.useState)(!1),o=e.isOverridden("theme:darkMode"),{userProfileData:s,isLoading:r,update:c}=(({notificationSuccess:e={},pageReloadChecker:t}={})=>{const{userProfileApiClient:n,notifySuccess:o}=function(){const e=Object(i.useContext)(p);if(!e)throw new Error("UserProfilesContext is missing. Ensure your component or React root is wrapped with or .");return e}(),{userProfile$:s}=n,{enabled:r=!0,title:c=g.notificationSuccess.title,pageReloadText:f=g.notificationSuccess.pageReloadText}=e,[b,k]=Object(i.useState)(!1),h=d()(s),x=Object(i.useRef)(),j=Object(i.useCallback)((({isRefreshRequired:e=!1}={})=>{e?o({title:c,text:Object(a.jsx)(l.EuiFlexGroup,{justifyContent:"flexEnd",gutterSize:"s"},Object(a.jsx)(l.EuiFlexItem,{grow:!1},Object(a.jsx)("p",null,f),Object(a.jsx)(l.EuiButton,{size:"s",onClick:()=>window.location.reload(),"data-test-subj":"windowReloadButton"},u.i18n.translate("userProfileComponents.updateUserProfile.notification.requiresPageReloadButtonLabel",{defaultMessage:"Reload page"}))))},{durationMs:3e5}):o({title:c})}),[c,o,f]),M=Object(i.useCallback)((e=>{if(k(!1),r){const n=null==t?void 0:t(x.current,e);j({isRefreshRequired:n})}}),[r,j,t]);return{update:Object(i.useCallback)((e=>(x.current=h,k(!0),n.update(e).then((()=>M(e))))),[n,M,h]),showSuccessNotification:j,userProfileData:h,isLoading:b}})({notificationSuccess:{title:u.i18n.translate("xpack.cloudLinks.userMenuLinks.darkMode.successNotificationTitle",{defaultMessage:"Color theme updated"}),pageReloadText:u.i18n.translate("xpack.cloudLinks.userMenuLinks.darkMode.successNotificationText",{defaultMessage:"Reload the page to see the changes"})},pageReloadChecker:(e,t)=>{var n,i;return(null==e||null===(n=e.userSettings)||void 0===n?void 0:n.darkMode)!==(null===(i=t.userSettings)||void 0===i?void 0:i.darkMode)}}),{userSettings:{darkMode:f}={darkMode:void 0}}=null!=s?s:{},b=Object(i.useCallback)((e=>{r||c({userSettings:{darkMode:e?"dark":"light"}})}),[r,c]);return Object(i.useEffect)((()=>{let t=!1;var i;t="string"!=typeof f?null!==(i=e.get("theme:darkMode"))&&void 0!==i&&i:"dark"===f,n(t)}),[f,e]),{isVisible:!o&&Boolean(s),toggle:b,isDarkModeOn:t,colorScheme:f}},x=({security:e,core:t})=>Object(a.jsx)(b,{core:t,security:e,toMountPoint:k.toMountPoint},Object(a.jsx)(j,{uiSettingsClient:t.uiSettings}));function j({uiSettingsClient:e}){const t=Object(l.useGeneratedHtmlId)({prefix:"toggleTextSwitch"}),{euiTheme:n}=Object(l.useEuiTheme)(),{isVisible:i,toggle:o,isDarkModeOn:s,colorScheme:r}=h({uiSettingsClient:e});return i?Object(a.jsx)(l.EuiFlexGroup,{alignItems:"center",justifyContent:"spaceBetween",gutterSize:"xs"},Object(a.jsx)(l.EuiFlexItem,null,Object(a.jsx)(l.EuiContextMenuItem,{icon:"dark"===r?"moon":"sun",size:"s",onClick:()=>{o("light"===r)},"data-test-subj":"darkModeToggle"},u.i18n.translate("xpack.cloudLinks.userMenuLinks.darkModeToggle",{defaultMessage:"Dark mode"}))),Object(a.jsx)(l.EuiFlexItem,{grow:!1,css:Object(a.css)({paddingRight:n.size.m},"","")},Object(a.jsx)(l.EuiSwitch,{label:s?u.i18n.translate("xpack.cloudLinks.userMenuLinks.darkModeOnLabel",{defaultMessage:"on"}):u.i18n.translate("xpack.cloudLinks.userMenuLinks.darkModeOffLabel",{defaultMessage:"off"}),showLabel:!1,checked:s,onChange:e=>{o(e.target.checked)},"aria-describedby":t,"data-test-subj":"darkModeToggleSwitch",compressed:!0}))):null}class plugin_CloudLinksPlugin{setup(){}start(e,{cloud:t,security:n,guidedOnboarding:i}){var o;null!=t&&t.isCloudEnabled&&!e.http.anonymousPaths.isAnonymous(window.location.pathname)&&(null!=i&&null!==(o=i.guidedOnboardingApi)&&void 0!==o&&o.isEnabled&&e.chrome.registerGlobalHelpExtensionMenuLink({linkType:"custom",href:e.http.basePath.prepend("/app/home#/getting_started"),content:Object(a.jsx)(s.FormattedMessage,{id:"xpack.cloudLinks.setupGuide",defaultMessage:"Setup guides"}),"data-test-subj":"cloudOnboardingSetupGuideLink",priority:1e3}),n&&function({core:e,security:t,cloud:n}){const i=Object(r.defer)((()=>t.authc.getCurrentUser())).pipe(Object(r.map)((e=>e.elastic_cloud_user)),Object(r.catchError)((()=>Object(r.of)(!0))),Object(r.filter)((e=>!0===e)),Object(r.map)((()=>{n.deploymentUrl&&e.chrome.setCustomNavLink({title:u.i18n.translate("xpack.cloudLinks.deploymentLinkLabel",{defaultMessage:"Manage this deployment"}),euiIconType:"logoCloud",href:n.deploymentUrl});const i=(({core:e,cloud:t,security:n})=>{const{profileUrl:i,billingUrl:o,organizationUrl:s}=t,r=[];return i&&r.push({label:u.i18n.translate("xpack.cloudLinks.userMenuLinks.profileLinkText",{defaultMessage:"Profile"}),iconType:"user",href:i,order:100,setAsProfile:!0}),o&&r.push({label:u.i18n.translate("xpack.cloudLinks.userMenuLinks.billingLinkText",{defaultMessage:"Billing"}),iconType:"visGauge",href:o,order:200}),s&&r.push({label:u.i18n.translate("xpack.cloudLinks.userMenuLinks.organizationLinkText",{defaultMessage:"Organization"}),iconType:"gear",href:s,order:300}),r.push({content:Object(a.jsx)(x,{core:e,security:n}),order:400,label:"",iconType:"",href:""}),r})({core:e,cloud:n,security:t});t.navControlService.addUserMenuLinks(i)}))),o=e.chrome.getHelpSupportUrl$();n.isCloudEnabled&&Object(r.combineLatest)({user:i,helpSupportUrl:o}).subscribe((({helpSupportUrl:t})=>{const n=(({docLinks:e,helpSupportUrl:t})=>[{title:u.i18n.translate("xpack.cloudLinks.helpMenuLinks.documentation",{defaultMessage:"Documentation"}),href:e.links.elasticStackGetStarted},{title:u.i18n.translate("xpack.cloudLinks.helpMenuLinks.support",{defaultMessage:"Support"}),href:t},{title:u.i18n.translate("xpack.cloudLinks.helpMenuLinks.giveFeedback",{defaultMessage:"Give feedback"}),href:e.links.kibana.feedback}])({docLinks:e.docLinks,helpSupportUrl:t});e.chrome.setHelpMenuLinks(n)}))}({core:e,security:n,cloud:t}))}stop(){}}function M(){return new plugin_CloudLinksPlugin}}]);