"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[7904],{617904:(e,t,E)=>{E.r(t),E.d(t,{default:()=>z});var n=E(296540),a=E(469733),i=E(352190),l=E(217439),I=E(74750),c=E(618983),o=E(998837),r=E(951272),_=E(896405),A=E(709690),s=E(71479),C=E(459449),m=E(126457),d=E(566723),O=E(398300),T=E(845030),S=E(563092),V=E(455643),u=E(532419),R=E(870443),D=E(874807),N=E(569299),M=E(705426),p=E(294303),f=E(855019),g=E(388151);const v={1:"DEVICE_ESIM_ACTIVATION_ERROR_1",2:"DEVICE_ESIM_ACTIVATION_ERROR_2",4:"DEVICE_ESIM_ACTIVATION_ERROR_4",104:"DEVICE_ESIM_ACTIVATION_ERROR_104",106:"DEVICE_ESIM_ACTIVATION_ERROR_106",109:"DEVICE_ESIM_ACTIVATION_ERROR_109",113:"DEVICE_ESIM_ACTIVATION_ERROR_113",124:"DEVICE_ESIM_ACTIVATION_ERROR_124",126:"DEVICE_ESIM_ACTIVATION_ERROR_126",209:"DEVICE_ESIM_ACTIVATION_ERROR_209",214:"DEVICE_ESIM_ACTIVATION_ERROR_214",300:"DEVICE_ESIM_ACTIVATION_ERROR_300",301:"DEVICE_ESIM_ACTIVATION_ERROR_300",601:"DEVICE_ESIM_ACTIVATION_ERROR_601"},b="DEVICE_ESIM_PROFILE_UNAVAILABLE";var h;!function(e){e[e.ACTIVATION=0]="ACTIVATION",e[e.SUCCESS=1]="SUCCESS"}(h||(h={}));const L=(0,s.A)(M.A)`
  height: ${({step:e})=>e===h.SUCCESS?"unset":"320px"};
`,x=({pending:e,onTimeout:t})=>n.createElement(p.A,{flexDirection:"column",flex:1,alignItems:"center",gap:d.Ln},n.createElement(g.A,{name:"activation_code",label:n.createElement(p.A,{alignItems:"center",gap:d.YC},n.createElement(l.A,{variant:"inherit"},n.createElement(C.sA,{id:"DEVICE_ESIM_ACTIVATION_CODE"})),n.createElement(_.A,{description:n.createElement(C.sA,{id:"DEVICE_ENTER_ACTIVATION_CODE_TOOLTIP"})},n.createElement("span",null,n.createElement(A.A,{isActive:!0,size:"original"})))),type:"input",variant:"secondary",full:!0,validateOnBlur:!0,disabled:e}),e?n.createElement(p.A,{width:"100%",flexDirection:"column",gap:d.YC,flex:1,justifyContent:"flex-end"},n.createElement(V.A,{size:8,duration:140,onComplete:t}),n.createElement(l.A,{color:"text-3",size:"small"},n.createElement(C.sA,{id:"DEVICE_DOWNLOADING_ESIM_PROFILES"}))):n.createElement(g.A,{name:"confirmation_code",label:n.createElement(p.A,{alignItems:"center",gap:d.YC},n.createElement(l.A,{variant:"inherit"},n.createElement(C.sA,{id:"DEVICE_ESIM_CONFIRMATION_CODE"})),n.createElement(_.A,{description:n.createElement(C.sA,{id:"DEVICE_ESIM_CONFIRMATION_CODE_TOOLTIP"})},n.createElement("span",null,n.createElement(A.A,{isActive:!0,size:"original"})))),type:"input",variant:"secondary",full:!0,disabled:e})),k=()=>{const{motifPalette:{green06:e,uBlue06:t}}=(0,o.u)();return n.createElement(p.A,{flexDirection:"column",flex:1,alignItems:"center",gap:d.Ln},n.createElement(p.A,{position:"relative"},n.createElement(i.A,{transparent:!0,size:"header",color:t}),n.createElement(p.A,{position:"absolute",right:0,bottom:0,alignItems:"center",justifyContent:"center"},n.createElement(c.A,{size:"original",variant:"fill",color:e}))),n.createElement(p.A,{flexDirection:"column",gap:d.kc,alignItems:"center"},n.createElement(l.A,{color:"text-1",weight:"bold"},n.createElement(C.sA,{id:"DEVICE_ESIM_ACTIVATED"})),n.createElement(l.A,{color:"text-2"},n.createElement(C.sA,{id:"DEVICE_ESIM_ACTIVATED_DESCRIPTION"}))))},y=({onClose:e,mac:t,slot:E})=>{const i=(0,a.useDispatch)(),{formatMessage:l}=(0,C.tz)(),{values:{activation_code:c,confirmation_code:o},setFieldError:_,isValid:A}=(0,r.j7)(),{mbb:s={}}=(0,a.useSelector)((0,n.useMemo)(()=>(0,u.tG)(t),[t])),V=(0,n.useMemo)(()=>s.esim&&(0,N.n8)(s.esim),[s.esim]),R=(0,n.useMemo)(()=>s.esim&&(0,N.q5)(s.esim,s.sim?.[E]),[s.esim,s.sim,E]),[D,M]=(0,n.useState)(V),[g,y]=(0,n.useState)(h.ACTIVATION),U=(0,n.useCallback)(()=>{i((0,m.AS)()),e?.()},[e,i]),P=(0,n.useCallback)(()=>{U()},[U]),z=(0,n.useCallback)(()=>{if(!D&&!V){M(!0);try{i((0,S.Mw)({mac:t,activation_code:c,...o?{confirmation_code:o}:{}}))}catch(e){_("activation_code",l({id:"DEVICE_ESIM_PROFILE_UNAVAILABLE"})),M(!1)}}},[D,V,i,t,c,o,_,l]),w=(0,n.useCallback)(()=>{M(!1),_("activation_code",l({id:b}))},[l,_]);return(0,n.useEffect)(()=>{R&&y(h.SUCCESS)},[R]),(0,n.useEffect)(()=>{const e=s.esim?.last_operation?.code;switch(e){case void 0:case 0:return;default:_("activation_code",l({id:v[e]??b}))}M(!1)},[l,s.esim?.last_operation?.code,_]),n.createElement(L,{title:g!==h.SUCCESS?n.createElement(C.sA,{id:"DEVICE_ADD_ESIM"}):void 0,onRequestClose:P,size:"small",step:g,actions:g!==h.SUCCESS?[{type:"button",text:n.createElement(C.sA,{id:"COMMON_ACTION_NEXT"}),onClick:z,variant:"primary",disabled:D||!A,loader:D?"loading":void 0}]:void 0,footer:g===h.SUCCESS?n.createElement(p.A,{alignItems:"center",justifyContent:"center",padding:d.Ln,paddingTop:d.YC},n.createElement(I.A,{onPress:()=>{i((0,T.XP)({type:O.H.DEVICE,id:t,tab:f.BC.SETTINGS,subId:E.toString()})),U()}},n.createElement(C.sA,{id:"DEVICE_MANAGE_DEVICES"}))):void 0},g===h.ACTIVATION?n.createElement(x,{pending:D,onTimeout:w}):null,g===h.SUCCESS?n.createElement(k,null):null)},U=R.A.object().shape({activation_code:R.A.string().label("DEVICE_ESIM_ACTIVATION_CODE").matches(/^((1|2)|(LPA:(1|2)))\$(.*)?\$[a-zA-Z0-9-]+$/,{message:n.createElement(C.sA,{id:"DEVICE_ESIM_INVALID_ACTIVATION_CODE"})}).required(),confirmation_code:R.A.string().label("DEVICE_ESIM_CONFIRMATION_CODE").optional()}),P={activation_code:""},z=e=>n.createElement(r.l1,{initialValues:P,onSubmit:D.Ay,validationSchema:U,validateOnMount:!0},n.createElement(y,{...e}))}}]);