1import{a as he,b as pe}from"./chunk-N3DO3S3Y.js";import{a as fe}from"./chunk-IOQVRS36.js";import{c as ce}from"./chunk-NIUMCPWT.js";import{c as le}from"./chunk-D5E4GUI3.js";import{a as de}from"./chunk-NVHIAWJ2.js";import{a as ae}from"./chunk-FTWGXGFU.js";import{$ as Z,A as c,Aa as re,Ca as oe,E as W,F as o,G as I,H as T,I as R,J as V,Ja as se,K as D,L as q,M as z,N as K,Na as ue,O,P as l,Q as d,R as k,S as P,T as x,V as A,W as Q,X as C,Y,Z as h,_ as X,a as g,aa as J,b as v,ba as ee,ca as te,ea as S,fa as u,ga as E,ha as m,ia as ie,ja as p,ka as f,l as L,na as B,oa as M,pa as ne,q as N,r as H,t as b,u as _,v as y,w as $}from"./chunk-LDW7NW6L.js";function j(n,e){return n==="INVALID_REQUEST"||n==="WAUB02001"?null:n==="INTERNAL_ERROR"||n==="WAUT02001"?"verify.errors.WAUT02001":n==="EXTERNAL_ERROR"||n==="WAUT02002"?null:n==="INVALID_OTP"||n==="WAUB02005"?"verify.errors.INVALID_OTP":n==="TOO_MANY_REQUESTS"||n==="WAUB02006"?"verify.errors.TOO_MANY_REQUESTS":n==="OTP_EXPIRED"||n==="WAUB02007"?"verify.errors.OTP_EXPIRED":e??null}function me(n){let e=Math.floor(n/60),t=n%60;return`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`}function ge(n,e){return`sessionExpiry=${`expiry=${Math.floor((Date.now()+n*1e3)/1e3)}&sessinToken=${e}`}; path=/; SameSite=Lax; Max-Age=${n}`}var be=new H("",{factory:()=>_e}),_e="always";var Ve=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=T({type:n});static \u0275inj=N({})}return n})();var ye=(()=>{class n{static withConfig(t){return{ngModule:n,providers:[{provide:be,useValue:t.callSetDisabledState??_e}]}}static \u0275fac=function(i){return new(i||n)};static \u0275mod=T({type:n});static \u0275inj=N({imports:[Ve]})}return n})();var Ae=["otpDigit"],Ee=()=>[0,1,2,3,4,5];function Me(n,e){if(n&1){let t=A();P(0,"input",5,0),Y("input",function(r){let s=_(t).$implicit,a=h();return y(a.onInput(r,s))})("keydown",function(r){let s=_(t).$implicit,a=h();return y(a.onKeyDown(r,s))})("paste",function(r){_(t);let s=h();return y(s.onPaste(r))}),x()}if(n&2){let t=e.$implicit,i=h();S("bg-blue-50",i.digits()[t]&&!i.error())("border-red-500",i.error())("bg-red-50",i.error())("disabled:bg-gray-100",i.isDisabled())("disabled:cursor-not-allowed",i.isDisabled()),Q("type",t===0?"text":"tel")("value",i.digits()[t]||"")("disabled",i.isDisabled()),R("autocomplete",t===0?"one-time-code":null)}}function we(n,e){if(n&1&&(P(0,"p",4),u(1),x()),n&2){let t=h();o(),E(t.error())}}var F=class n{label=M("Masukkan kode OTP");length=M(6);error=M(null);isDisabled=M(!1);autofocus=M(!1);otpChange=B();completed=B();digits=c(Array(6).fill(""));inputRefs=ne("otpDigit");ngAfterViewInit(){!this.autofocus()||this.isDisabled()||queueMicrotask(()=>this.focusFirst())}focusFirst(){if(this.isDisabled())return;let e=this.inputRefs();e.length>0&&e[0].nativeElement.focus()}onInput(e,t){let i=e.target,r=i.value.replace(/\D/g,"");if(r.length===0){let w=[...this.digits()];w[t]="",this.digits.set(w),i.value="",this.emitValue();return}let s=this.digits()[t]||"";if(s!==""&&r.length===2&&r.startsWith(s)){let w=r.charAt(1);this.setDigit(t,w),i.value=w;return}if(r.length>1){i.value="",this.fillFromString(r);return}let G=r.charAt(0);this.setDigit(t,G),i.value=G}setDigit(e,t){let i=[...this.digits()];if(i[e]=t,this.digits.set(i),this.emitValue(),i.every(r=>r)){this.inputRefs().forEach(s=>s.nativeElement.blur()),this.completed.emit();return}if(e<this.length()-1){let r=this.inputRefs();r[e+1]&&r[e+1].nativeElement.focus()}}onKeyDown(e,t){if(!(e.ctrlKey||e.metaKey)&&(!/^[0-9]$/.test(e.key)&&e.key!=="Backspace"&&e.key!=="Delete"&&e.key!=="Tab"&&e.key!=="ArrowLeft"&&e.key!=="ArrowRight"&&e.key!=="Home"&&e.key!=="End"&&e.preventDefault(),/^[0-9]$/.test(e.key)&&this.digits().every(i=>i)&&this.digits()[t]&&e.preventDefault(),e.key==="Backspace"&&!this.digits()[t]&&t>0)){let i=this.inputRefs();i[t-1]&&i[t-1].nativeElement.focus()}}onPaste(e){e.preventDefault();let t=e.clipboardData?.getData("text").replace(/\D/g,"").slice(0,this.length());t&&this.fillFromString(t)}onDocumentPaste(e){if(this.isDisabled()||!this.isFocusInside())return;let t=e.clipboardData?.getData("text").replace(/\D/g,"").slice(0,this.length());t&&(e.preventDefault(),this.fillFromString(t))}isFocusInside(){let e=document.activeElement;return e?this.inputRefs().some(t=>t.nativeElement===e):!1}fillFromString(e){let t=Array(this.length()).fill("");for(let a=0;a<e.length&&a<this.length();a++)t[a]=e[a];this.digits.set(t);let i=this.inputRefs();for(let a=0;a<i.length;a++)i[a].nativeElement.value=t[a]||"";this.emitValue();let r=t.filter(a=>a).length;
1if(r===this.length()){i.forEach(a=>a.nativeElement.blur()),this.completed.emit();return}let s=Math.min(r,this.length()-1);i[s]&&i[s].nativeElement.focus()}emitValue(){this.otpChange.emit(this.digits().join(""))}clear(){this.digits.set(Array(this.length()).fill("")),this.focusFirst()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=I({type:n,selectors:[["app-otp-input"]],viewQuery:function(t,i){t&1&&ee(i.inputRefs,Ae,5),t&2&&te()},hostBindings:function(t,i){t&1&&C("paste",function(s){return i.onDocumentPaste(s)},W)},inputs:{label:[1,"label"],length:[1,"length"],error:[1,"error"],isDisabled:[1,"isDisabled"],autofocus:[1,"autofocus"]},outputs:{otpChange:"otpChange",completed:"completed"},decls:5,vars:2,consts:[["otpDigit",""],[1,"flex","flex-col","items-center","gap-2"],[1,"flex","gap-4"],["inputmode","numeric","pattern","[0-9]*",1,"w-11","h-11","text-center","text-xl","font-semibold","border","border-[#DAE0E9]","rounded-xl","outline-none","focus:outline-none","transition-all","bg-white",3,"type","bg-blue-50","border-red-500","bg-red-50","disabled:bg-gray-100","disabled:cursor-not-allowed","value","disabled"],[1,"text-xs","sm:text-sm","text-red-600","text-center","m-0","font-poppins-regular"],["inputmode","numeric","pattern","[0-9]*",1,"w-11","h-11","text-center","text-xl","font-semibold","border","border-[#DAE0E9]","rounded-xl","outline-none","focus:outline-none","transition-all","bg-white",3,"input","keydown","paste","type","value","disabled"]],template:function(t,i){t&1&&(P(0,"div",1)(1,"div",2),z(2,Me,2,14,"input",3,q),x(),V(4,we,2,1,"p",4),x()),t&2&&(o(2),K(ie(1,Ee)),o(2),D(i.error()?4:-1))},dependencies:[ye],encapsulation:2,changeDetection:0})};function xe(n,e){n&1&&($(),l(0,"svg",15),k(1,"path",16),d())}function Se(n,e){n&1&&(u(0),p(1,"translate")),n&2&&m(" ",f(1,1,"verify.retry")," ")}function Fe(n,e){n&1&&(u(0),p(1,"translate")),n&2&&m(" ",f(1,1,"verify.submit")," ")}function Ie(n,e){if(n&1){let t=A();l(0,"button",14),C("click",function(){_(t);let r=h();return y(r.onSubmit())}),V(1,xe,2,0,":svg:svg",15)(2,Se,2,3)(3,Fe,2,3),d()}if(n&2){let t=h();S("bg-[#ED0226]",t.canSubmit())("text-white",t.canSubmit())("cursor-pointer",t.canSubmit())("hover:opacity-90",t.canSubmit()),O("disabled",!t.canSubmit()||t.vm().isLoading||t.vm().isLocked),o(),D(t.vm().isLoading?1:t.hasFailedAttempt()&&!t.vm().isLocked?2:3)}}function Oe(n,e){if(n&1){let t=A();l(0,"p",17),u(1),p(2,"translate"),l(3,"strong"),u(4,"00:00"),d()(),l(5,"button",18),C("click",function(){_(t);let r=h();return y(r.onResend())}),u(6),p(7,"translate"),d()}n&2&&(o(),m(" ",f(2,2,"verify.validUntil")," "),o(5),m(" ",f(7,4,"verify.resend")," "))}function Pe(n,e){if(n&1&&(l(0,"p",17),u(1),p(2,"translate"),l(3,"strong"),u(4),d()(),l(5,"p",19),u(6),p(7,"translate"),d()),n&2){let t=h();o(),m(" ",f(2,3,"verify.validUntil")," "),o(3),E(t.formatCountdown(t.countdown())),o(2),m(" ",f(7,5,"verify.waitToResend")," ")}}function Ne(n,e){if(n&1&&(l(0,"p",17),u(1),p(2,"translate"),l(3,"strong"),u(4),d()(),l(5,"p",19),u(6),p(7,"translate"),d()),n&2){let t=h();o(),m(" ",f(2,3,"verify.validUntil")," "),o(3),E(t.formatCountdown(t.countdown())),o(2),m(" ",f(7,5,"verify.waitToResend")," ")}}function Te(n,e){if(n&1){let t=A();l(0,"p",17),u(1),p(2,"translate"),l(3,"strong"),u(4,"00:00"),d()(),l(5,"button",18),C("click",function(){_(t);let r=h();return y(r.onResend())}),u(6),p(7,"translate"),d()}n&2&&(o(),m(" ",f(2,2,"verify.validUntil")," "),o(5),m(" ",f(7,4,"verify.resend")," "))}function Re(n,e){if(n&1){let t=A();l(0,"app-popup-bottom",20),C("closed",function(){_(t);let r=h();return y(r.showOtpSentPopup.set(!1))}),d()}if(n&2){let t=h();O("message",t.otpSentPopupVm().message)("icon",t.otpSentPopupVm().icon??"")}}var U=3,Ce=class n{authFacade=b(ae);router=b(oe);route=b(re);postMessageService=b(ue);language=b(ce);gtm=b(de);otpInput;vm=c({serviceLabel:"",maskedIdentifier:"",subtitleKey:he,otpCode:"",attempts:0,maxAttempts:U,isLocked:!1,lockoutMinutes:0,isResendAvailable:!1,resendCooldownSeconds:0,isLoading:!1,error:null,success:!1,expiresAt:""});selectedService=c(null);otpCode=c("");countdown=c(0);hasFailedAttempt=c(!1);isRateLimited=c(!1);otpExpiresAt=c(null);lastErrorCode=c(null);isOtpExpiredFromVerify=c(!1);showOtpSentPopup=c(!1);otpSentPopupVm=c({message:"",icon:"assets/icons/info.svg"});countdownSubscription;stateSubscription;ngOnInit(){if(this.stateSubscription=this.authFacade.state$.subscribe(t=>{this.updateVM(t)}
1),this.route.snapshot.queryParamMap.get("otpSent")==="true"){let{otpExpiresAt:t}=this.authFacade.getSnapshot();t!=null&&Date.now()>=t?this.router.navigate([],{queryParams:{otpSent:null},queryParamsHandling:"merge",replaceUrl:!0}):(this.otpSentPopupVm.set({message:"verify.otpSent"}),this.showOtpSentPopup.set(!0),setTimeout(()=>{this.showOtpSentPopup.set(!1)},5e3))}}ngOnDestroy(){this.countdownSubscription?.unsubscribe(),this.stateSubscription?.unsubscribe()}ngAfterViewInit(){this.postMessageService.sendPage("VERIFY")}onResend(){this.hasFailedAttempt.set(!1),this.isRateLimited.set(!1),this.otpCode.set(""),this.otpInput.clear();let e=this.selectedService();(e==="indihome"?this.authFacade.requestOtpIndihome():e==="orbit"?this.authFacade.requestOtpOrbit():this.authFacade.requestOtp()).subscribe({next:i=>{i.success?(this.isOtpExpiredFromVerify.set(!1),this.vm.update(r=>v(g({},r),{error:null})),this.startOtpExpirationCountdown(i.expired*1e3),this.otpSentPopupVm.set({message:"verify.otpSent"}),this.showOtpSentPopup.set(!0),this.router.navigate([],{queryParams:{otpSent:"true"},queryParamsHandling:"merge",replaceUrl:!0}),setTimeout(()=>{this.showOtpSentPopup.set(!1)},5e3)):(this.vm.update(r=>v(g({},r),{error:this.resolveError(j(i.errorCode,i.errorMessage),i.errorMessage)})),e!=="indihome"&&i.errorCode&&this.postMessageService.sendError(i.errorCode,i.errorMessage??void 0))},error:()=>{let i=this.language.instant("common.connectionError");this.vm.update(r=>v(g({},r),{error:i})),e!=="indihome"&&this.postMessageService.sendError("REQUEST_OTP_FAILED",i)}})}formatCountdown(e){return me(e)}canSubmit(){return this.otpCode().length===6&&!this.vm().isLoading&&!this.vm().isLocked}isExpired(){let e=this.otpExpiresAt();return e?Date.now()>e:!1}onOTPChange(e){e.length<this.otpCode().length&&(this.hasFailedAttempt.set(!1),this.vm().error&&this.vm.update(t=>v(g({},t),{error:null}))),this.otpCode.set(e)}onSubmit(){if(this.hasFailedAttempt()&&!this.vm().isLocked&&this.gtm.trackEvent("button_click",{button_name:"Retry",button_purpose:`Popup Verification OTP - ${this.vm().serviceLabel}`}),this.hasFailedAttempt()&&!this.vm().isLocked&&!this.isExpired()){this.lastErrorCode()!=="WAUT02001"&&this.lastErrorCode()!=="INTERNAL_ERROR"&&(this.otpCode.set(""),this.otpInput.clear()),this.hasFailedAttempt.set(!1),this.vm.update(r=>v(g({},r),{error:null}));return}let e=this.otpCode();if(e.length!==6)return;this.hasFailedAttempt()||this.gtm.trackEvent("button_click",{button_name:"Verification",button_purpose:`Popup Verification OTP - ${this.vm().serviceLabel}`}),this.vm.update(r=>v(g({},r),{isLoading:!0,error:null}));let t=this.selectedService();(t==="indihome"?this.authFacade.verifyOtpIndihome(e):t==="orbit"?this.authFacade.verifyOtpOrbit(e):this.authFacade.verifyOtp(e)).subscribe({next:r=>{r.success?(this.gtm.setUserIdentity(r.xUser??"",this.selectedService(),r.expired),document.cookie=ge(r.expired,r.sessionLogin),this.router.navigate(["/success"],{queryParamsHandling:"merge"})):(this.hasFailedAttempt.set(!0),this.lastErrorCode.set(r.errorCode??null),(r.errorCode==="OTP_EXPIRED"||r.errorCode==="WAUB02007")&&(this.otpExpiresAt.set(Date.now()-1),this.hasFailedAttempt.set(!1),this.isOtpExpiredFromVerify.set(!0)),(r.errorCode==="TOO_MANY_REQUESTS"||r.errorCode==="WAUB02006")&&this.isRateLimited.set(!0),this.vm.update(s=>v(g({},s),{isLoading:!1,error:this.resolveError(j(r.errorCode,r.errorMessage),r.errorMessage),attempts:s.attempts+1})),r.errorCode&&this.postMessageService.sendError(r.errorCode,r.errorMessage??void 0))},error:()=>{this.vm.update(r=>v(g({},r),{isLoading:!1})),this.postMessageService.sendError("VERIFY_OTP_FAILED",this.language.instant("common.connectionError"))}})}resolveError(e,t){return e?e.includes(".")?this.language.instant(e):e||(t??null):null}updateVM(e){if(!e.selectedService)return;this.selectedService.set(e.selectedService),e.otpExpiresAt&&this.otpExpiresAt.set(e.otpExpiresAt);let t=Date.now(),i=e.attempts>=U,r=e.otpExpiresAt!==null&&t>=e.otpExpiresAt,s=e.otpExpiresAt===null?0:Math.max(0,Math.ceil((e.otpExpiresAt-t)/1e3));if(this.vm.set({serviceLabel:le(e.selectedService)?.label||"",maskedIdentifier:e.dis
1playedIdentifier??"",subtitleKey:pe(e.selectedService,e.verificationMethod),otpCode:"",attempts:e.attempts,maxAttempts:U,isLocked:i,lockoutMinutes:i?5:0,isResendAvailable:r,resendCooldownSeconds:s,isLoading:!1,error:null,success:!1,expiresAt:ke(e.otpExpiresAt)}),e.otpExpiresAt&&e.attempts<3){let a=Math.floor((e.otpExpiresAt-Date.now())/1e3);a>0&&this.startCountdown(a)}}startCountdown(e){this.countdownSubscription?.unsubscribe(),this.countdown.set(e),this.countdownSubscription=L(1e3).subscribe(()=>{let t=this.countdown();t<=1?(this.countdown.set(0),this.otpExpiresAt.set(Date.now()-1),this.countdownSubscription?.unsubscribe(),this.vm.update(i=>v(g({},i),{isResendAvailable:!0})),this.router.navigate([],{queryParams:{otpSent:null},queryParamsHandling:"merge",replaceUrl:!0})):this.countdown.set(t-1)})}startOtpExpirationCountdown(e){let t=Date.now()+e;this.otpExpiresAt.set(t);let i=Math.floor(e/1e3);this.startCountdown(i)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=I({type:n,selectors:[["app-verify"]],viewQuery:function(t,i){if(t&1&&X(F,5),t&2){let r;Z(r=J())&&(i.otpInput=r.first)}},decls:24,vars:16,consts:[[1,"flex","flex-col","gap-4"],[1,"container","pt-14","pb-6","bg-white","rounded-3xl","max-w-[640px]","mx-auto"],[1,"flex","flex-col","items-center","gap-4","sm:gap-6","p-4","sm:p-6"],[1,"w-auto","h-[134.21px]","sm:h-[200px]","flex","items-center","justify-center"],["src","assets/images/number-verification.png","alt","Number Verification",1,"h-full","object-contain"],[1,"flex","flex-col","items-center","gap-1","sm:gap-2","w-full"],[1,"text-base","sm:text-[20px]","sm:leading-7","text-black","font-poppins-semibold","sm:font-poppins-bold","m-0","text-center","tracking-[-0.01em]"],[1,"text-sm","sm:text-base","sm:leading-6","text-[#757F90]","font-poppins-regular","m-0","text-center","leading-6","max-w-[525px]"],[1,"font-poppins-semibold"],[1,"w-full","flex","flex-col","items-center","gap-6"],[3,"otpChange","label","autofocus","error","isDisabled"],["type","button",1,"w-full","py-3","px-4","text-base","font-poppins-semibold","rounded-full","transition-all","flex","items-center","justify-center","gap-2","bg-[#DAE0E9]","text-[#9CA9B9]","cursor-not-allowed",3,"bg-[#ED0226]","text-white","cursor-pointer","hover:opacity-90","disabled"],[1,"flex","flex-col","items-center","gap-1","w-full"],[3,"message","icon"],["type","button",1,"w-full","py-3","px-4","text-base","font-poppins-semibold","rounded-full","transition-all","flex","items-center","justify-center","gap-2","bg-[#DAE0E9]","text-[#9CA9B9]","cursor-not-allowed",3,"click","disabled"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"animate-spin","w-6","h-6"],["d","M7.5 4.20577C7.22386 3.72748 7.38612 3.11083 7.88959 2.88381C9.61967 2.10372 11.5432 1.82919 13.4349 2.10349C15.6579 2.4258 17.7076 3.48713 19.2537 5.11645C20.7999 6.74578 21.7525 8.84822 21.958 11.085C22.1636 13.3217 21.6101 15.5626 20.3867 17.4464C19.1633 19.3302 17.3414 20.7473 15.2144 21.4693C13.0874 22.1913 10.7793 22.1762 8.66194 21.4264C6.54458 20.6766 4.74132 19.2358 3.54272 17.3361C2.52269 15.7195 1.99113 13.8506 2.0001 11.9528C2.00271 11.4006 2.50004 11.0015 3.0493 11.0592C3.59856 11.117 3.99043 11.6101 4.00163 12.1623C4.03103 13.6115 4.45401 15.0324 5.23418 16.2689C6.19306 17.7887 7.63567 18.9413 9.32955 19.5411C11.0234 20.141 12.8699 20.1531 14.5715 19.5754C16.2731 18.9978 17.7307 17.8642 18.7094 16.3571C19.6881 14.8501 20.1309 13.0574 19.9664 11.268C19.802 9.47857 19.0399 7.79663 17.803 6.49316C16.5661 5.1897 14.9263 4.34064 13.1479 4.08279C11.701 3.873 10.2309 4.06452 8.895 4.62713C8.38601 4.84149 7.77614 4.68406 7.5 4.20577Z","fill","white"],[1,"text-xs","sm:text-sm","text-[#757F90]","font-poppins-regular","m-0","text-center","leading-5"],["type","button",1,"text-xs","sm:text-[14px]","font-poppins-semibold","m-0","text-center","leading-5","text-[#0050AE]","bg-transparent","border-none","cursor-pointer","hover:opacity-80",3,"click"],[1,"text-xs","sm:text-sm","text-[#9CA9B9]","font-poppins-regular","m-0","text-center","leading-5"],[3,"closed","message","icon"]],template:function(t,i){t&1&&(l(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3),k(4,"img",4),d(),l(5,"div",5)(6,"h1",6),u(7),p(8,"translate"),d(),l(9,"p",7),u(10),p(11,"translate"),l(12,"span",8),u(13),d()()(),l(14,"div",9)(15,"app-otp-input",10),p(16,"translate"),C("otpChange",function(s){return i.onOTPChange(s)}),d()(),V(17,Ie,4,10,"button",11),l(18,"div",12),V(19,Oe,8,6)(20,Pe,8,7)(21,Ne,8,7)(22,Te,8,6),d(),V(23,Re,1,2,"app-popup-bottom",13),d()()()),t&2&&(o(7),m(" ",f(8,10,"verify.title")," "),o(3),m(" ",f(11,12,i.vm().subtitleKey)," "),o(3),E(i.vm().maskedIdentifier),o(2),O("label",f(16,14,"verify.otpLabel"))("autofocus",!0)("error",i.vm().error)("isDisabled",i.vm().isLoading||i.vm(
1).isLocked),o(2),D(!i.isRateLimited()&&!i.isOtpExpiredFromVerify()?17:-1),o(2),D(i.isExpired()?19:i.vm().isLocked?20:i.countdown()>0?21:22),o(4),D(i.showOtpSentPopup()?23:-1))},dependencies:[F,fe,se],encapsulation:2,changeDetection:0})};function ke(n){if(n===null)return"01:00";let e=new Date(n),t=e.getHours().toString().padStart(2,"0"),i=e.getMinutes().toString().padStart(2,"0");return`${t}:${i}`}export{Ce as VerifyPageComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.