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