File: //opt/netdata/usr/local/share/netdata/web/v3/3185.27949608f15eac8a89fe.chunk.js
try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="782efedb-3ff4-4a1d-b97e-055053e00aeb",e._sentryDebugIdIdentifier="sentry-dbid-782efedb-3ff4-4a1d-b97e-055053e00aeb")}()}catch(e){}!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"24860f4888408c3529c668460cb7600d59ef7ae7"}}catch(e){}}(),(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[3185],{73185:(e,t,a)=>{a.r(t),a.d(t,{default:()=>V});var n=a(96540),o=a(63766),s=a(10444),r=a(33185);const l=(0,r.default)(o.ModalContent).attrs((e=>{let{isMobile:t}=e;return{width:t?{base:"95vw"}:{min:120,max:160}}})).withConfig({displayName:"styled__AwsModalContent",componentId:"sc-1dvnaf6-0"})([""]),i=(0,r.default)(o.Flex).attrs((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,o.getColor)("secondaryHighlight"));a(98992),a(54520);var c=a(74848);const d=e=>{let{state:t,setState:a}=e;const{firstName:s,lastName:r,company:l}=t||{},[i,d]=(0,o.useTouchedState)({}),[u,p]=(0,o.useTouchedState)({}),[f,m]=(0,o.useTouchedState)({}),h=(0,n.useCallback)((e=>t=>{a((a=>({...a,[e]:t.target.value})))}),[a]);return(0,c.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,c.jsx)(o.TextInput,{label:"First name",value:s||"",placeholder:"Enter your first name",onChange:h("firstName"),size:"small",touched:i,onBlur:d,error:i&&!s?"Provide your first name":""}),(0,c.jsx)(o.TextInput,{label:"Last name",value:r||"",placeholder:"Enter your last name",onChange:h("lastName"),size:"small",touched:u,onBlur:p,error:u&&!r?"Provide your last name":""}),(0,c.jsx)(o.TextInput,{label:"Company",value:l||"",placeholder:"Enter your company name",onChange:h("company"),size:"small",touched:f,onBlur:m,error:f&&!l?"Provide your company name":""})]})};a(81454);var u=a(63950),p=a.n(u),f=a(94404),m=a(41395),h=a(74891);const b=(0,f.A)((0,h.A)(i)),g=e=>{let{id:t,slug:a,name:o,isEligible:s,reason:r,isDisabled:l,onSpaceSelection:i=p()}=e;const d=(0,n.useCallback)((()=>{s&&i({spaceId:t,spaceSlug:a})}),[t,a,s,i]),u=l?"Please fill in the required fields":!s&&r?(0,m.Zr)(r):null;return(0,c.jsx)(b,{feature:"LabraSpaceSelect",payload:{spaceId:t},disabled:!s||l,tooltip:u,tooltipProps:{align:"bottom"},onClick:d,children:o})},x=function(){let{state:e,setState:t,eligible:a=[],nonEligible:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{firstName:r,lastName:l,company:i}=e||{},d=!r||!l||!i,u=(0,n.useCallback)((e=>{let{spaceId:a}=e;t((e=>({...e,spaceId:a})))}),[t]);return(0,c.jsxs)(o.Flex,{column:!0,gap:4,children:[(0,c.jsx)(o.Text,{children:"Select a space to connect to your marketplace subscription."}),(0,c.jsxs)(o.Flex,{column:!0,gap:2,justifyContent:"center",children:[a.map((e=>(0,c.jsx)(g,{onSpaceSelection:u,isDisabled:d,...e},e.id))),s.map((e=>(0,c.jsx)(g,{...e},e.id)))]})]})};var y=a(79748);const j={ErrSubscriptionAlreadyAttached:()=>(0,c.jsx)(o.Text,{lineHeight:1.5,children:"This subscription is already attached to a Netdata space / account."}),FETimeout:()=>(0,c.jsxs)(o.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,c.jsx)(y.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,c.jsx)(o.Text,{children:"Something went wrong."})},v=e=>{let{errorKey:t,error:a}=e;const n=a?()=>(0,c.jsx)(o.Text,{children:a}):j[t]||j.default;return(0,c.jsx)(o.Flex,{alignItems:"center",justifyContent:"center",height:30,padding:[0,8],children:(0,c.jsx)(n,{})})};var S=a(55093);const C=e=>{let{timeLeft:t,initialTimeLeft:a}=e;const n=100-t/a*100;return(0,c.jsx)(o.Flex,{children:(0,c.jsx)(o.ProgressBar,{background:"borderSecondary",border:"none",color:["green","netdata"],containerWidth:"100%","data-testid":"marketplace-subscription-progress-bar",height:2,width:`${n}%`})})},I=function(){let{state:e,setState:t,isLoading:a,timeLeft:n,initialTimeLeft:s,spaces:r=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const l=r.filter((e=>{let{isEligible:t}=e;return t})),i=r.filter((e=>{let{isEligible:t}=e;return!t}));return l.length?a?(0,c.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,c.jsx)(S.A,{height:50,padding:[4],title:"Validating your Subscription. Please Wait.",body:"This may take upto 5 minutes."}),(0,c.jsx)(C,{timeLeft:n,initialTimeLeft:s})]}):(0,c.jsxs)(o.Flex,{column:!0,gap:8,children:[(0,c.jsx)(d,{state:e,setState:t}),(0,c.jsx)(x,{state:e,setState:t,eligible:l,nonEligible:i})]}):(0,c.jsx)(v,{error:"No eligible spaces found."})},T=e=>{let{state:t,setState:a,isLoading:n,timeLeft:o,initialTimeLeft:s,spacesLoadable:r={},error:l}=e;const{loaded:i,value:d={},hasError:u,error:p}=r;return i?u?(0,c.jsx)(v,{errorKey:p}):l?(0,c.jsx)(v,{errorKey:l.errorKey}):(0,c.jsx)(I,{state:t,setState:a,isLoading:n,timeLeft:o,initialTimeLeft:s,...d}):(0,c.jsx)(S.A,{height:50,padding:[4],title:"Loading spaces..."})};var L=a(24609);const w=e=>{let{state:t,forceHiddenConfirmation:a,onConfirm:n,onDecline:s}=e;const{spaceId:r}=t||{},l=(0,L.ns)(r,"name");return r&&!a?(0,c.jsx)(o.ConfirmationDialog,{confirmLabel:"Yes, select space",declineLabel:"No","data-testid":"subscribeSpaceToAWSDialog",handleConfirm:n,handleDecline:s,hideIcon:!0,isConfirmPositive:!0,message:(0,c.jsxs)(o.Flex,{gap:2,column:!0,children:[(0,c.jsxs)(o.TextBig,{children:["You are about to tie your subscription to ",(0,c.jsx)(o.TextBig,{strong:!0,children:l})," space."]}),(0,c.jsx)(o.TextBig,{children:"Are you sure you want to select this space?"})]}),title:"Select space"}):null};var k=a(88934),_=a(52035),E=a(34843),A=a(84929),N=a(91130),P=a(15505);var F=a(63872),D=a(57377);const B=(0,A.Iz)((e=>{let{url:t}=e;return(0,_.eU)((()=>(e=>e?N.A.get(e,{transform:e=>(0,P.bn)(e)}):Promise.resolve({}))(t)))}),D.Ay),M=["labra_subscription_id","cloud_product_id","cloud_customer_id","cloud_provider","aws_customer_id","aws_product_id"],R=()=>{const e=(0,k.Zp)(),t=(0,L.ap)("slug"),[a,o]=(0,k.ok)();return(0,n.useCallback)((n=>{a&&(M.forEach((e=>a.delete(e))),o(a)),n?window.location.href=`/spaces/${t}`:e(`/spaces/${t}`)}),[a,o,e,t])},H=e=>{let{subscriptionId:t}=e;const[,a]=(0,F.A)();return(0,n.useCallback)((e=>{let{firstName:n,lastName:o,company:s,spaceId:r}=e;return(e=>{let{firstName:t,lastName:a,company:n,spaceId:o,subscriptionId:s}=e;return N.A.patch(`/api/v2/spaces/${o}/billing/labra/subscription`,{first_name:t,last_name:a,company:n,subscription_id:s})})({firstName:n,lastName:o,company:s,spaceId:r,subscriptionId:t}).catch(a).finally((()=>Promise.resolve()))}),[t])},K=(0,f.A)(o.Button),W=e=>{let{isLoading:t}=e;const a=R();return(0,c.jsx)(o.ModalFooter,{children:(0,c.jsx)(K,{feature:"LabraSpacesSelectorClose",label:"Close",flavour:"hollow",onClick:a,disabled:t})})};var z=a(18739),$=a(91539),Y=a(47809);const q=function(){let{enabled:e,onReceive:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=(0,L.vt)();(0,$.A)((()=>({enabled:e,polling:!0,fetch:()=>(0,Y.PE)(a),onReceive:t,force:!0,pollingOptions:{pollingInterval:1e3}})),[a,e,t])},J=function(){let{state:e,hasConfirmed:t,onReceive:a,onProgress:o,onStopPolling:s,waitFor:r=6e4}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{spaceId:l}=e||{};q({enabled:t,onReceive:a}),(0,n.useEffect)((()=>{let e=!0,a=null,n=r;return l&&t&&(a=setInterval((()=>{n-=1e3,o?.({timeLeft:n}),0==n&&(s?.(),clearInterval(a),a=null)}),1e3)),()=>{e=!1,a&&(clearInterval(a),a=null)}}),[l,t])};var Z=a(6304),O=a(60908);const U=3e5,V=e=>{let{subCallback:t}=e;const a=(0,s.J)(),[r,i]=(0,n.useState)(),[d,u]=(0,n.useState)({}),[p,f]=(0,n.useState)(),[m,,h]=(0,Z.A)(),[b,,g]=(0,Z.A)(),[x,y]=(0,n.useState)(U),j=(e=>{let{url:t}=e;const a=(0,E.md)((0,A.Rq)(B({url:t})));return{loaded:"loading"!==a.state,value:a.data?.data,hasError:"hasError"===a.state,error:a.error?.response?.data?.errorMsgKey}})({url:t}),{value:v={}}=j||{},{subscriptionId:S}=v,C=H({subscriptionId:S}),I=R(),{refresh:L}=(0,z.JN)(),k=(0,n.useCallback)((function(){let{data:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{trialEndsAt:t}=e||{};e&&!t&&(L(),setTimeout((()=>{I()}),1e3))}),[I,L]),_=(0,n.useCallback)((e=>{let{timeLeft:t}=e;y(t)}),[y]),N=(0,n.useCallback)((()=>{f({errorKey:"FETimeout"}),i(!1)}),[f,i]);J({state:d,hasConfirmed:b,onReceive:k,onProgress:_,onStopPolling:N,waitFor:U});const P=(0,n.useCallback)((()=>{i(!0),g(),C(d),h()}),[i,C,h,d]),F=(0,n.useCallback)((()=>{u((e=>({...e,spaceId:void 0})))}),[u]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(o.Modal,{"data-testid":"aws-modal",backdropProps:{backdropBlur:!0},children:(0,c.jsx)(O.Ay,{feature:"LabraSpacesSelector",children:(0,c.jsxs)(l,{isMobile:a,children:[(0,c.jsx)(o.ModalHeader,{children:(0,c.jsxs)(o.Flex,{gap:2,alignItems:"center",children:[(0,c.jsx)(o.Icon,{name:"netdataPress",color:"text"}),(0,c.jsx)(o.H4,{children:"Welcome to Netdata!"})]})}),(0,c.jsx)(o.ModalBody,{padding:[4,4,8,4],children:(0,c.jsx)(T,{state:d,setState:u,spacesLoadable:j,isLoading:r,timeLeft:x,initialTimeLeft:U,error:p})}),(0,c.jsx)(W,{isLoading:r})]})})}),(0,c.jsx)(w,{state:d,forceHiddenConfirmation:m,onConfirm:P,onDecline:F})]})}}}]);