File: //opt/netdata/usr/local/local/share/netdata/web/v3/3185.71b01f7ec374985395c0.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:"4feb900574abdd30667a599041aadc4fc9f8ac80"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1a9468db-ddf3-4aea-91b5-99d19db9b1cd",e._sentryDebugIdIdentifier="sentry-dbid-1a9468db-ddf3-4aea-91b5-99d19db9b1cd")}catch(e){}}(),(globalThis.webpackChunkcloud_frontend=globalThis.webpackChunkcloud_frontend||[]).push([[3185],{73185(e,t,a){a.r(t),a.d(t,{default:()=>G});var n=a(96540),r=a(38429),o=a(10444),s=a(882);const l=(0,s.default)(r.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,s.default)(r.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,r.getColor)("secondaryHighlight"));a(98992),a(54520);var c=a(74848);const d=e=>{let{state:t,setState:a}=e;const{firstName:o,lastName:s,company:l}=t||{},[i,d]=(0,r.useTouchedState)({}),[u,p]=(0,r.useTouchedState)({}),[m,b]=(0,r.useTouchedState)({}),h=(0,n.useCallback)(e=>t=>{a(a=>({...a,[e]:t.target.value}))},[a]);return(0,c.jsxs)(r.Flex,{column:!0,gap:2,children:[(0,c.jsx)(r.TextInput,{label:"First name",value:o||"",placeholder:"Enter your first name",onChange:h("firstName"),size:"small",touched:i,onBlur:d,error:i&&!o?"Provide your first name":""}),(0,c.jsx)(r.TextInput,{label:"Last name",value:s||"",placeholder:"Enter your last name",onChange:h("lastName"),size:"small",touched:u,onBlur:p,error:u&&!s?"Provide your last name":""}),(0,c.jsx)(r.TextInput,{label:"Company",value:l||"",placeholder:"Enter your company name",onChange:h("company"),size:"small",touched:m,onBlur:b,error:m&&!l?"Provide your company name":""})]})};a(81454);var u=a(63950),p=a.n(u),m=a(94404),b=a(41395),h=a(74891);const g=(0,m.A)((0,h.A)(i)),f=e=>{let{id:t,slug:a,name:r,isEligible:o,reason:s,isDisabled:l,onSpaceSelection:i=p()}=e;const d=(0,n.useCallback)(()=>{o&&i({spaceId:t,spaceSlug:a})},[t,a,o,i]),u=l?"Please fill in the required fields":!o&&s?(0,b.Zr)(s):null;return(0,c.jsx)(g,{feature:"LabraSpaceSelect",payload:{spaceId:t},disabled:!o||l,tooltip:u,tooltipProps:{align:"bottom"},onClick:d,children:r})},x=function(){let{state:e,setState:t,eligible:a=[],nonEligible:o=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{firstName:s,lastName:l,company:i}=e||{},d=!s||!l||!i,u=(0,n.useCallback)(e=>{let{spaceId:a}=e;t(e=>({...e,spaceId:a}))},[t]);return(0,c.jsxs)(r.Flex,{column:!0,gap:4,children:[(0,c.jsx)(r.Text,{children:"Select a space to connect to your marketplace subscription."}),(0,c.jsxs)(r.Flex,{column:!0,gap:2,justifyContent:"center",children:[a.map(e=>(0,c.jsx)(f,{onSpaceSelection:u,isDisabled:d,...e},e.id)),o.map(e=>(0,c.jsx)(f,{...e},e.id))]})]})};var y=a(79748);const j={ErrSubscriptionAlreadyAttached:()=>(0,c.jsx)(r.Text,{lineHeight:1.5,children:"This subscription is already attached to a Netdata space / account."}),FETimeout:()=>(0,c.jsxs)(r.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)(r.Text,{children:"Something went wrong."})},v=e=>{let{errorKey:t,error:a}=e;const n=a?()=>(0,c.jsx)(r.Text,{children:a}):j[t]||j.default;return(0,c.jsx)(r.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)(r.Flex,{children:(0,c.jsx)(r.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:o,spaces:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const l=s.filter(e=>{let{isEligible:t}=e;return t}),i=s.filter(e=>{let{isEligible:t}=e;return!t});return l.length?a?(0,c.jsxs)(r.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:o})]}):(0,c.jsxs)(r.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:r,initialTimeLeft:o,spacesLoadable:s={},error:l}=e;const{loaded:i,value:d={},hasError:u,error:p}=s;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:r,initialTimeLeft:o,...d}):(0,c.jsx)(S.A,{height:50,padding:[4],title:"Loading spaces..."})};var L=a(24609);const k=e=>{let{state:t,forceHiddenConfirmation:a,onConfirm:n,onDecline:o}=e;const{spaceId:s}=t||{},l=(0,L.ns)(s,"name");return s&&!a?(0,c.jsx)(r.ConfirmationDialog,{confirmLabel:"Yes, select space",declineLabel:"No","data-testid":"subscribeSpaceToAWSDialog",handleConfirm:n,handleDecline:o,hideIcon:!0,isConfirmPositive:!0,message:(0,c.jsxs)(r.Flex,{gap:2,column:!0,children:[(0,c.jsxs)(r.TextBig,{children:["You are about to tie your subscription to ",(0,c.jsx)(r.TextBig,{strong:!0,children:l})," space."]}),(0,c.jsx)(r.TextBig,{children:"Are you sure you want to select this space?"})]}),title:"Select space"}):null};var w=a(76667),_=a(52035),A=a(34843),E=a(18790),N=a(25316),P=a(91130),F=a(15505);var D=a(63872),B=a(57377);const M=(0,E.I)(e=>{let{url:t}=e;return(0,_.eU)(()=>(e=>e?P.A.get(e,{transform:e=>(0,F.bn)(e)}):Promise.resolve({}))(t))},B.Ay),H=["labra_subscription_id","cloud_product_id","cloud_customer_id","cloud_provider","aws_customer_id","aws_product_id"],R=()=>{const e=(0,w.Zp)(),t=(0,L.ap)("slug"),[a,r]=(0,w.ok)();return(0,n.useCallback)(n=>{a&&(H.forEach(e=>a.delete(e)),r(a)),n?window.location.href=`/spaces/${t}`:e(`/spaces/${t}`)},[a,r,e,t])},K=e=>{let{subscriptionId:t}=e;const[,a]=(0,D.A)();return(0,n.useCallback)(e=>{let{firstName:n,lastName:r,company:o,spaceId:s}=e;return(e=>{let{firstName:t,lastName:a,company:n,spaceId:r,subscriptionId:o}=e;return P.A.patch(`/api/v2/spaces/${r}/billing/labra/subscription`,{first_name:t,last_name:a,company:n,subscription_id:o})})({firstName:n,lastName:r,company:o,spaceId:s,subscriptionId:t}).catch(a).finally(()=>Promise.resolve())},[t])},W=(0,m.A)(r.Button),$=e=>{let{isLoading:t}=e;const a=R();return(0,c.jsx)(r.ModalFooter,{children:(0,c.jsx)(W,{feature:"LabraSpacesSelectorClose",label:"Close",flavour:"hollow",onClick:a,disabled:t})})};var z=a(18739),Y=a(91539),J=a(47809);const Z=function(){let{enabled:e,onReceive:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=(0,L.vt)();(0,Y.A)(()=>({enabled:e,polling:!0,fetch:()=>(0,J.PE)(a),onReceive:t,force:!0,pollingOptions:{pollingInterval:1e3}}),[a,e,t])},q=function(){let{state:e,hasConfirmed:t,onReceive:a,onProgress:r,onStopPolling:o,waitFor:s=6e4}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{spaceId:l}=e||{};Z({enabled:t,onReceive:a}),(0,n.useEffect)(()=>{let e=!0,a=null,n=s;return l&&t&&(a=setInterval(()=>{n-=1e3,r?.({timeLeft:n}),0==n&&(o?.(),clearInterval(a),a=null)},1e3)),()=>{e=!1,a&&(clearInterval(a),a=null)}},[l,t])};var O=a(6304),U=a(60908);const V=3e5,G=e=>{let{subCallback:t}=e;const a=(0,o.J)(),[s,i]=(0,n.useState)(),[d,u]=(0,n.useState)({}),[p,m]=(0,n.useState)(),[b,,h]=(0,O.A)(),[g,,f]=(0,O.A)(),[x,y]=(0,n.useState)(V),j=(e=>{let{url:t}=e;const a=(0,A.md)((0,N.A)(M({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=K({subscriptionId:S}),I=R(),{refresh:L}=(0,z.JN)(),w=(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]),E=(0,n.useCallback)(()=>{m({errorKey:"FETimeout"}),i(!1)},[m,i]);q({state:d,hasConfirmed:g,onReceive:w,onProgress:_,onStopPolling:E,waitFor:V});const P=(0,n.useCallback)(()=>{i(!0),f(),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)(r.Modal,{"data-testid":"aws-modal",backdropProps:{backdropBlur:!0},children:(0,c.jsx)(U.Ay,{feature:"LabraSpacesSelector",children:(0,c.jsxs)(l,{isMobile:a,children:[(0,c.jsx)(r.ModalHeader,{children:(0,c.jsxs)(r.Flex,{gap:2,alignItems:"center",children:[(0,c.jsx)(r.Icon,{name:"netdataPress",color:"text"}),(0,c.jsx)(r.H4,{children:"Welcome to Netdata!"})]})}),(0,c.jsx)(r.ModalBody,{padding:[4,4,8,4],children:(0,c.jsx)(T,{state:d,setState:u,spacesLoadable:j,isLoading:s,timeLeft:x,initialTimeLeft:V,error:p})}),(0,c.jsx)($,{isLoading:s})]})})}),(0,c.jsx)(k,{state:d,forceHiddenConfirmation:b,onConfirm:P,onDecline:F})]})}}}]);