File: //opt/netdata/usr/share/netdata/web/v3/3185.d832064e25f7e6a6fe9a.chunk.js
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"2dc1ac04d42d5596a31408e611f22d6247611f89"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b52573fe-8600-4249-9749-d1cf31df3a40",e._sentryDebugIdIdentifier="sentry-dbid-b52573fe-8600-4249-9749-d1cf31df3a40")}catch(e){}}(),(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[3185],{73185(e,t,r){r.r(t),r.d(t,{default:()=>se});var n=r(64467),o=(r(98992),r(54520),r(3949),r(62953),r(96540)),a=r(42358),s=r(10444),i=r(51510);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}const c=(0,i.default)(a.ModalContent).attrs((e=>{let{isMobile:t}=e;return{width:t?{base:"95vw"}:{min:120,max:160}}})).withConfig({displayName:"styled__AwsModalContent",componentId:"sc-1dvnaf6-0"})([""]),d=(0,i.default)(a.Flex).attrs((e=>function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){(0,n.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({border:{side:"all",color:"primary"},color:"primary",padding:[2],justifyContent:"center",round:!0,cursor:"pointer",opacity:e.disabled?"0.4":"1"},e))).withConfig({displayName:"styled__StyledSpaceSelector",componentId:"sc-1dvnaf6-1"})(["pointer-events:",";&:hover{background-color:",";color:#00cd51;text-decoration:none;}"],(e=>{let{disabled:t}=e;return t?"none":"auto"}),(0,a.getColor)("secondaryHighlight"));var u=r(74848);function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){(0,n.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const f=e=>{let{state:t,setState:r}=e;const{firstName:n,lastName:s,company:i}=t||{},[l,c]=(0,a.useTouchedState)({}),[d,p]=(0,a.useTouchedState)({}),[f,g]=(0,a.useTouchedState)({}),m=(0,o.useCallback)((e=>t=>{r((r=>b(b({},r),{},{[e]:t.target.value})))}),[r]);return(0,u.jsxs)(a.Flex,{column:!0,gap:2,children:[(0,u.jsx)(a.TextInput,{label:"First name",value:n||"",placeholder:"Enter your first name",onChange:m("firstName"),size:"small",touched:l,onBlur:c,error:l&&!n?"Provide your first name":""}),(0,u.jsx)(a.TextInput,{label:"Last name",value:s||"",placeholder:"Enter your last name",onChange:m("lastName"),size:"small",touched:d,onBlur:p,error:d&&!s?"Provide your last name":""}),(0,u.jsx)(a.TextInput,{label:"Company",value:i||"",placeholder:"Enter your company name",onChange:m("company"),size:"small",touched:f,onBlur:g,error:f&&!i?"Provide your company name":""})]})};r(81454);var g=r(63950),m=r.n(g),h=r(94404),y=r(41395),j=r(74891);const O=(0,h.A)((0,j.A)(d)),v=e=>{let{id:t,slug:r,name:n,isEligible:a,reason:s,isDisabled:i,onSpaceSelection:l=m()}=e;const c=(0,o.useCallback)((()=>{a&&l({spaceId:t,spaceSlug:r})}),[t,r,a,l]),d=i?"Please fill in the required fields":!a&&s?(0,y.Zr)(s):null;return(0,u.jsx)(O,{feature:"LabraSpaceSelect",payload:{spaceId:t},disabled:!a||i,tooltip:d,tooltipProps:{align:"bottom"},onClick:c,children:n})};function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach((function(t){(0,n.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const w=function(){let{state:e,setState:t,eligible:r=[],nonEligible:n=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{firstName:s,lastName:i,company:l}=e||{},c=!s||!i||!l,d=(0,o.useCallback)((e=>{let{spaceId:r}=e;t((e=>P(P({},e),{},{spaceId:r})))}),[t]);return(0,u.jsxs)(a.Flex,{column:!0,gap:4,children:[(0,u.jsx)(a.Text,{children:"Select a space to connect to your marketplace subscription."}),(0,u.jsxs)(a.Flex,{column:!0,gap:2,justifyContent:"center",children:[r.map((e=>(0,u.jsx)(v,P({onSpaceSelection:d,isDisabled:c},e),e.id))),n.map((e=>(0,u.jsx)(v,P({},e),e.id)))]})]})};var S=r(79748);const C={ErrSubscriptionAlreadyAttached:()=>(0,u.jsx)(a.Text,{lineHeight:1.5,children:"This subscription is already attached to a Netdata space / account."}),FETimeout:()=>(0,u.jsxs)(a.Text,{lineHeight:1.5,children:["The subscription could not be validated. Please try again in sometime by refreshing the page. If it does not work, please reach out to"," ",(0,u.jsx)(S.A,{href:"mailto:support@netdata.cloud",as:"a",cursor:"pointer",textDecoration:"underline",color:"main",children:"support@netdata.cloud"})," ","and retry setting up the account from the AWS Marketplace"]}),default:()=>(0,u.jsx)(a.Text,{children:"Something went wrong."})},I=e=>{let{errorKey:t,error:r}=e;const n=r?()=>(0,u.jsx)(a.Text,{children:r}):C[t]||C.default;return(0,u.jsx)(a.Flex,{alignItems:"center",justifyContent:"center",height:30,padding:[0,8],children:(0,u.jsx)(n,{})})};var k=r(55093);const E=e=>{let{timeLeft:t,initialTimeLeft:r}=e;const n=100-t/r*100;return(0,u.jsx)(a.Flex,{children:(0,u.jsx)(a.ProgressBar,{background:"borderSecondary",border:"none",color:["green","netdata"],containerWidth:"100%","data-testid":"marketplace-subscription-progress-bar",height:2,width:"".concat(n,"%")})})},D=function(){let{state:e,setState:t,isLoading:r,timeLeft:n,initialTimeLeft:o,spaces:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=s.filter((e=>{let{isEligible:t}=e;return t})),l=s.filter((e=>{let{isEligible:t}=e;return!t}));return i.length?r?(0,u.jsxs)(a.Flex,{column:!0,gap:2,children:[(0,u.jsx)(k.A,{height:50,padding:[4],title:"Validating your Subscription. Please Wait.",body:"This may take upto 5 minutes."}),(0,u.jsx)(E,{timeLeft:n,initialTimeLeft:o})]}):(0,u.jsxs)(a.Flex,{column:!0,gap:8,children:[(0,u.jsx)(f,{state:e,setState:t}),(0,u.jsx)(w,{state:e,setState:t,eligible:i,nonEligible:l})]}):(0,u.jsx)(I,{error:"No eligible spaces found."})};function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}const T=e=>{let{state:t,setState:r,isLoading:o,timeLeft:a,initialTimeLeft:s,spacesLoadable:i={},error:l}=e;const{loaded:c,value:d={},hasError:p,error:b}=i;return c?p?(0,u.jsx)(I,{errorKey:b}):l?(0,u.jsx)(I,{errorKey:l.errorKey}):(0,u.jsx)(D,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){(0,n.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({state:t,setState:r,isLoading:o,timeLeft:a,initialTimeLeft:s},d)):(0,u.jsx)(k.A,{height:50,padding:[4],title:"Loading spaces..."})};var A=r(24609);const _=e=>{let{state:t,forceHiddenConfirmation:r,onConfirm:n,onDecline:o}=e;const{spaceId:s}=t||{},i=(0,A.ns)(s,"name");return s&&!r?(0,u.jsx)(a.ConfirmationDialog,{confirmLabel:"Yes, select space",declineLabel:"No","data-testid":"subscribeSpaceToAWSDialog",handleConfirm:n,handleDecline:o,hideIcon:!0,isConfirmPositive:!0,message:(0,u.jsxs)(a.Flex,{gap:2,column:!0,children:[(0,u.jsxs)(a.TextBig,{children:["You are about to tie your subscription to ",(0,u.jsx)(a.TextBig,{strong:!0,children:i})," space."]}),(0,u.jsx)(a.TextBig,{children:"Are you sure you want to select this space?"})]}),title:"Select space"}):null};r(9391);var N=r(41344),F=r(52035),B=r(34843),M=r(18790),H=r(25316),R=r(91130),K=r(15505);var W=r(63872),z=r(57377);const Y=(0,M.I)((e=>{let{url:t}=e;return(0,F.eU)((()=>(e=>e?R.A.get(e,{transform:e=>(0,K.bn)(e)}):Promise.resolve({}))(t)))}),z.Ay),J=["labra_subscription_id","cloud_product_id","cloud_customer_id","cloud_provider","aws_customer_id","aws_product_id"],Z=()=>{const e=(0,N.Zp)(),t=(0,A.ap)("slug"),[r,n]=(0,N.ok)();return(0,o.useCallback)((o=>{r&&(J.forEach((e=>r.delete(e))),n(r)),o?window.location.href="/spaces/".concat(t):e("/spaces/".concat(t))}),[r,n,e,t])},q=e=>{let{subscriptionId:t}=e;const[,r]=(0,W.A)();return(0,o.useCallback)((e=>{let{firstName:n,lastName:o,company:a,spaceId:s}=e;return(e=>{let{firstName:t,lastName:r,company:n,spaceId:o,subscriptionId:a}=e;return R.A.patch("/api/v2/spaces/".concat(o,"/billing/labra/subscription"),{first_name:t,last_name:r,company:n,subscription_id:a})})({firstName:n,lastName:o,company:a,spaceId:s,subscriptionId:t}).catch(r).finally((()=>Promise.resolve()))}),[t])},U=(0,h.A)(a.Button),V=e=>{let{isLoading:t}=e;const r=Z();return(0,u.jsx)(a.ModalFooter,{children:(0,u.jsx)(U,{feature:"LabraSpacesSelectorClose",label:"Close",flavour:"hollow",onClick:r,disabled:t})})};var G=r(18739),Q=r(91539),X=r(47809);const $=function(){let{enabled:e,onReceive:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=(0,A.vt)();(0,Q.A)((()=>({enabled:e,polling:!0,fetch:()=>(0,X.PE)(r),onReceive:t,force:!0,pollingOptions:{pollingInterval:1e3}})),[r,e,t])},ee=function(){let{state:e,hasConfirmed:t,onReceive:r,onProgress:n,onStopPolling:a,waitFor:s=6e4}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{spaceId:i}=e||{};$({enabled:t,onReceive:r}),(0,o.useEffect)((()=>{let e=!0,r=null,o=s;return i&&t&&(r=setInterval((()=>{o-=1e3,null===n||void 0===n||n({timeLeft:o}),0==o&&(null===a||void 0===a||a(),clearInterval(r),r=null)}),1e3)),()=>{e=!1,r&&(clearInterval(r),r=null)}}),[i,t])};var te=r(6304),re=r(60908);function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function oe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(r),!0).forEach((function(t){(0,n.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const ae=3e5,se=e=>{let{subCallback:t}=e;const r=(0,s.J)(),[n,i]=(0,o.useState)(),[l,d]=(0,o.useState)({}),[p,b]=(0,o.useState)(),[f,,g]=(0,te.A)(),[m,,h]=(0,te.A)(),[y,j]=(0,o.useState)(ae),O=(e=>{var t,r;let{url:n}=e;const o=(0,B.md)((0,H.A)(Y({url:n})));return{loaded:"loading"!==o.state,value:null===(t=o.data)||void 0===t?void 0:t.data,hasError:"hasError"===o.state,error:null===(r=o.error)||void 0===r||null===(r=r.response)||void 0===r||null===(r=r.data)||void 0===r?void 0:r.errorMsgKey}})({url:t}),{value:v={}}=O||{},{subscriptionId:x}=v,P=q({subscriptionId:x}),w=Z(),{refresh:S}=(0,G.JN)(),C=(0,o.useCallback)((function(){let{data:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{trialEndsAt:t}=e||{};e&&!t&&(S(),setTimeout((()=>{w()}),1e3))}),[w,S]),I=(0,o.useCallback)((e=>{let{timeLeft:t}=e;j(t)}),[j]),k=(0,o.useCallback)((()=>{b({errorKey:"FETimeout"}),i(!1)}),[b,i]);ee({state:l,hasConfirmed:m,onReceive:C,onProgress:I,onStopPolling:k,waitFor:ae});const E=(0,o.useCallback)((()=>{i(!0),h(),P(l),g()}),[i,P,g,l]),D=(0,o.useCallback)((()=>{d((e=>oe(oe({},e),{},{spaceId:void 0})))}),[d]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Modal,{"data-testid":"aws-modal",backdropProps:{backdropBlur:!0},children:(0,u.jsx)(re.Ay,{feature:"LabraSpacesSelector",children:(0,u.jsxs)(c,{isMobile:r,children:[(0,u.jsx)(a.ModalHeader,{children:(0,u.jsxs)(a.Flex,{gap:2,alignItems:"center",children:[(0,u.jsx)(a.Icon,{name:"netdataPress",color:"text"}),(0,u.jsx)(a.H4,{children:"Welcome to Netdata!"})]})}),(0,u.jsx)(a.ModalBody,{padding:[4,4,8,4],children:(0,u.jsx)(T,{state:l,setState:d,spacesLoadable:O,isLoading:n,timeLeft:y,initialTimeLeft:ae,error:p})}),(0,u.jsx)(V,{isLoading:n})]})})}),(0,u.jsx)(_,{state:l,forceHiddenConfirmation:f,onConfirm:E,onDecline:D})]})}}}]);