import{a as _e,b as S,c as N,d as b,e as P,f as T,g as V}from"./chunk-JDXJCS6O.js";import{a as d,b as Ce,d as Oe,f as Te,g as we}from"./chunk-VHX2MOBG.js";import{c as De}from"./chunk-DGJ2KY2B.js";import{f as Re}from"./chunk-SGVVBT4Z.js";import{c as Me,e as xe}from"./chunk-WYC34PD4.js";import{oc as Ie}from"./chunk-OD6CMNJH.js";import{a as Ee,b as Ae}from"./chunk-XEI2TUSN.js";import{C as ve,G as Pe,H as ye,U as H}from"./chunk-Y4LLAK7R.js";import{a as A}from"./chunk-MTSPOHEH.js";import{l as be,n as $}from"./chunk-O2KDIBGD.js";import{D as c,a as fe,b as Se,c as y}from"./chunk-QUA65JBC.js";import{f as ge}from"./chunk-XVNYO3OV.js";import{Ca as J,Fa as M,Gc as x,Hc as E,Ic as me,J as R,K as oe,L as ne,Ma as O,Pa as ae,Sa as u,Sc as W,Vd as o,Wd as pe,Xd as Y,Za as ce,a as p,b as g,ba as z,ec as de,ed as j,gb as le,l as v,nd as he,o as K,ob as ue,qb as L,s as se}from"./chunk-NRAZ4AKM.js";var je={title:"Protejeaz\u0103-\u021Bi deviceul cu o asigurare",description:"Po\u021Bi alege dintre dou\u0103 tipuri de asigur\u0103ri: Basic sau Premium. Costul lunar al acestora \u0219i valoarea asigurat\u0103 depind de pre\u021Bul standard al device-ului cump\u0103rat. Tariful asigur\u0103rii alese, f\u0103r\u0103 TVA, va fi inclus pe factur\u0103 ta Orange lunar\u0103.",authBannerDescription:"Pentru a verifica dac\u0103 ai deviceuri ce pot fi asigurate, te rug\u0103m s\u0103 te autentifici.",errorMessage:"Ne pare r\u0103u dar a intervenit o eroare, te rug\u0103m revii mai t\xE2rziu.",emptyStateTitle:"Nu sunt disponibile oferte de asigur\u0103ri",emptyStateMessage:"\xCEn prezent, nu exist\u0103 oferte de asigurare disponibile. Te rug\u0103m s\u0103 revino mai t\xE2rziu."},Xe=["telefoane","tablete","smartwatches","obiecte-conectate"];var qe={items:[],selectedItem:null,category:[],selectedCategoryItem:null,status:c.initial,selection:{selectedSlug:null,activeTab:S.Basic,products:[],selectedOption:null,imei:"",orderId:void 0,deviceOaCode:void 0,status:c.initial},insuranceProductCustomDetails:{categoryMappedProducts:null,notSellableReason:null},insurableProducts:null,product:null,error:null},Q=new ae("InsuranceState",{factory:()=>qe});function G(t,s){s?.injector||le(G);let C=s?.injector??u(ue),e=C.get(L),i=new se,r=t(i).subscribe();e.onDestroy(()=>r.unsubscribe());let a=l=>{let h;de(l)?h=Se(l,{injector:C}):ne(l)?h=l:h=R(l);let I=h.subscribe(_=>i.next(_));return r.add(I),I};return a.unsubscribe=r.unsubscribe.bind(r),a}var Ne=t=>t.replace(" ","-").toLowerCase();var w="https://storage.googleapis.com/orangero-assets/orange-eshop/insurance",B={phone:`${w}/phones-insurance.svg`,tablet:`${w}/tablet-insurance.svg`,watch:`${w}/watch-insurance.svg`,connectedObjects:`${w}/connected-object-insurance.svg`},k={phone:`${w}/phones-insurance-imei.svg`,tablet:`${w}/tablet-insurance-imei.svg`,watch:`${w}/watch-insurance-imei.svg`,connectedObjects:`${w}/connected-object-insurance-imei.svg`};var Be=t=>{switch(t){case b.Phone:return B.phone;case b.Tablet:return B.tablet;case b.Smartwatch:return B.watch;case b.ConnectedObject:return B.connectedObjects}},ke=t=>{switch(t){case b.Phone:return k.phone;case b.Tablet:return k.tablet;case b.Smartwatch:return k.watch;case b.ConnectedObject:return k.connectedObjects}};var Z=t=>({categoryId:t.categoryId,slug:Ne(t.title),icon:Be(t.title),imeiIcon:ke(t.title),subTitle:t.subTitle,title:t.title,startingPrice:t.startingPrice});var Fe=t=>{switch(t){case P.Phone:return b.Phone;case P.Tablet:return b.Tablet;case P.Smartwatch:return b.Smartwatch;case P.ConnectedObject:return b.ConnectedObject}},gt=t=>{switch(t){case A.phones:return P.Phone;case A.tablets:return P.Tablet;case A.connected:case A.modems:case A.tvs:return P.ConnectedObject}};var Ue=(()=>{let s=class s{checkImeiAndInitiatePurchase(e,i){return v(this,null,function*(){try{let r=this.findInsurableProductByImei(e,i);return r?this.canInitiatePurchase(r)?this.getAvailableOption(r)?!0:(console.warn("No available purchase options for IMEI:",e),!1):(console.warn("Cannot initiate purchase for IMEI:",{imei:e,productState:r.state,availableOptions:r.options?.filter(l=>l?.state==="CAN_BUY").length||0}),!1):(console.log("Current IMEI not found in processed data"),!1)}catch(r){throw console.error("Error in checkImeiAndInitiatePurchase:",{currentImei:e,error:r instanceof Error?r.message:"Unknown error"}),r}})}extractInsurableProductByImei(e,i){if(!e?.trim())return console.warn("No current IMEI provided for extraction"),null;if(!i?.categoryMappedProducts?.length)return console.warn("No category mapped products available for extraction"),null;for(let r of i.categoryMappedProducts){if(!r?.product?.insurableProducts?.length)continue;let a=r?.product.insurableProducts.find(l=>l.imei===e);if(a)return a}return null}findInsurableProductByImei(e,i){if(!e||!i?.categoryMappedProducts)return null;for(let r of i.categoryMappedProducts){let a=r.product?.insurableProducts?.find(l=>l.imei===e);if(a)return a}return null}canInitiatePurchase(e){return!!(e.state==="CAN_BUY"&&e.options?.some(i=>i?.state==="CAN_BUY"))}getAvailableOption(e){return e.options?.find(i=>i?.state==="CAN_BUY")||null}};s.\u0275fac=function(i){return new(i||s)},s.\u0275prov=O({token:s,factory:s.\u0275fac,providedIn:"root"});let t=s;return t})();var ze=Ce({providedIn:"root"},we(()=>u(Q)),Oe(({items:t,selection:s,insuranceProductCustomDetails:C})=>{let e=o(()=>s().selectedSlug),i=o(()=>{let n=e();return n?Fe(n):null}),r=o(()=>{let n=i();return t().find(f=>f.title===n)}),a=o(()=>{let n=r();return n?Z(n):null}),l=o(()=>C()?.categoryMappedProducts||[]),h=o(()=>{let n=r();if(!n)return null;let f=l()?.find(F=>F?.categoryId===n?.categoryId)?.product;return f||null}),I=o(()=>{let f=h()?.insurableProducts;return f||null}),_=o(()=>t().map(n=>Z(n))),m=o(()=>{let n=C();if(!n)return null;let f=(n.categoryMappedProducts||[]).filter(U=>U!=null),F=f.filter(U=>U.state===_e.CanBuy);return{categoryMappedProducts:f,notSellableReason:n.notSellableReason||null,isAvailable:F.length>0&&!n.notSellableReason,availableProducts:F}}),D=o(()=>m()?.notSellableReason||null),$e=o(()=>D()!==null),He=o(()=>{let n=D();if(!n)return null;if(n.message)return n.message;switch(n.reason){case N.RequestedTierNotAvailableForPurchase:return"Nu s-a g\u0103sit nici o asigurare, pentru acest tip de asigurare.";case N.NoInsuranceFound:return"Nu s-a g\u0103sit nici o asigurare";default:return"A intervenit o eroare"}}),te=o(()=>m()?.availableProducts||[]),Ve=o(()=>te().length>0),ie=o(()=>{let n=r();return n?!!(n&&n.options?.BASIC&&n.options.BASIC.length>0||n&&n.children?.some(f=>f?.options?.BASIC&&f.options.BASIC.length>0)):!1}),re=o(()=>{let n=r();return n?!!(n&&n.options?.PREMIUM&&n.options.PREMIUM.length>0||n&&n.children?.some(f=>f?.options?.PREMIUM&&f.options.PREMIUM.length>0)):!1}),Ge=o(()=>[ie()?S.Basic:null,re()?S.Premium:null]);return{selectedItem:r,selectedCategoryItem:a,product:h,category:_,insurableProducts:I,selectedSlug:e,processedProductDetails:m,notSellableReason:D,isNotSellable:$e,notSellableMessage:He,availableProducts:te,hasAvailableProducts:Ve,availableTiers:Ge,hasBasicTier:ie,hasPremiumTier:re}}),Te((t,s=u(V),C=u(Ue),e=u($),i=y(e.getWithSelector(H)))=>({loadCategoryOfferings:G(K(M(()=>d(t,{status:c.loading,error:null})),J(()=>s.fetchCategoryOfferings().pipe(M({next:r=>{if(!r)throw new Error("Empty response received from server");let a=r.items;if(a.length===0){d(t,{items:[],status:c.success});return}d(t,{items:a,status:c.success,error:null})},error:r=>{d(t,{error:r,status:c.error})}}),z(r=>{let a={message:je.errorMessage||"Unable to load insurance offerings. Please try again.",code:"LOAD_OFFERINGS_FAILED",timestamp:new Date().toISOString()};return d(t,{error:a,status:c.error}),R(null)}))))),loadProductCustomDetails:G(K(M(r=>{d(t,{selection:g(p({},t.selection()),{status:c.loading}),error:null})}),J(r=>s.getInsuranceProductCustomDetails(r).pipe(M({next:a=>v(void 0,null,function*(){if(!a.success){let m=a.errors?.[0]?.message||"Failed to load product details";d(t,{selection:g(p({},t.selection()),{status:c.error}),error:{message:m,code:a.errors?.[0]?.code||"API_ERROR",timestamp:new Date().toISOString()},status:c.error});return}let l=a.data?.getInsuranceProductCustomDetails,h=s.processInsuranceProductDetails(l),I=t.selection().imei,_=t.selection().selectedOption===T.Custom;if(d(t,{selection:g(p({},t.selection()),{status:c.success}),error:null,status:t.status()===c.loading?c.success:t.status(),insuranceProductCustomDetails:l||void 0}),_&&I&&h)try{if(yield C.checkImeiAndInitiatePurchase(I,h)){let D=C.extractInsurableProductByImei(I,l);s.addInsurance(t.selection().selectedOption,D,i(),I,t.selection().activeTab)}}catch(m){console.error("Auto-purchase failed:",m)}h.notSellableReason&&console.warn("\u26A0\uFE0F Product not sellable:",{reason:h.notSellableReason.reason,message:h.notSellableReason.message})}),error:a=>{console.error("Failed to load product details:",a);let l=a.errors?.[0]?.message||"Unable to load product details. Please try again.";d(t,{selection:g(p({},t.selection()),{status:c.error}),error:{message:l,code:a.errors?.[0]?.code||"LOAD_FAILED",timestamp:new Date().toISOString()},status:c.error})}}),z(a=>(console.error("Unhandled error in loadProductCustomDetails:",a),d(t,{selection:g(p({},t.selection()),{status:c.error}),error:{message:"A ap\u0103rut o eroare nea\u0219teptat\u0103. Te rug\u0103m s\u0103 \xEEncerci din nou.",code:"UNEXPECTED_ERROR",timestamp:new Date().toISOString()},status:c.error}),R(null))))))),getInsuranceProductCustomDetails(r){return d(t,{selection:g(p({},t.selection()),{status:c.loading})}),s.getInsuranceProductCustomDetails(r).pipe(z(a=>(console.error("Error fetching insurance product details:",a),d(t,{error:a,status:c.error}),oe(()=>a))),M(({data:a,errors:l})=>{let h=l?l[0].message:"A intervenit o eroare.";d(t,{selection:g(p({},t.selection()),{status:c.success}),error:l?h:null,status:l?c.error:t.status(),insuranceProductCustomDetails:a?.getInsuranceProductCustomDetails||void 0})}))},setSelectedCategorySlug(r){d(t,{selection:g(p({},t.selection()),{selectedSlug:r})})},setActiveTab(r){d(t,{selection:g(p({},t.selection()),{activeTab:r})})},setSelectedOption(r){d(t,{selection:g(p({},t.selection()),{selectedOption:r})})},setImei(r){d(t,{selection:g(p({},t.selection()),{imei:r})})},setOrderId(r){d(t,{selection:g(p({},t.selection()),{orderId:r})})},setDeviceOaCodeId(r){d(t,{selection:g(p({},t.selection()),{deviceOaCode:r})})},goWithBasic(){d(t,{selection:g(p({},t.selection()),{activeTab:S.Basic})})},clearError:()=>d(t,{error:null}),resetStore:()=>{let r=u(Q);d(t,r)}})));var ee=t=>t.length>=15&&t.length<=16,Le=t=>t.length>=5&&t.length<=20;var We=(()=>{let s=class s{constructor(){this.dialogRef=u(Me),this.domSanitizer=u(ge),this.matIconRegistry=u(Ee),this.loadIcons()}confirm(){this.dialogRef.close({action:"confirm"})}cancel(){this.dialogRef.close({action:"cancel"})}loadIcons(){this.matIconRegistry.addSvgIconLiteral("ico_close_icon",this.domSanitizer.bypassSecurityTrustHtml(De))}};s.\u0275fac=function(i){return new(i||s)},s.\u0275cmp=ce({type:s,selectors:[["oro-premium-option-unavailable-modal"]],standalone:!0,features:[he],decls:14,vars:0,consts:[[1,"premium-option-unavailable"],[1,"premium-option-unavailable__header"],[1,"premium-option-unavailable__title"],["aria-label","Close",1,"premium-option-unavailable__close",3,"click"],["aria-hidden","false","svgIcon","ico_close_icon",1,"premium-option-unavailable__close-icon"],[1,"premium-option-unavailable__body"],[1,"premium-option-unavailable__text"],[1,"premium-option-unavailable__action"],[1,"premium-option-unavailable__action-button",3,"click"],[1,"premium-option-unavailable__action-button","premium-option-unavailable__action-button--primary",3,"click"]],template:function(i,r){i&1&&(x(0,"div",0)(1,"div",1)(2,"h3",2),j(3," Planul Premium nu este disponibil "),E(),x(4,"button",3),W("click",function(){return r.cancel()}),me(5,"mat-icon",4),E()(),x(6,"div",5)(7,"p",6),j(8," Pentru acest produs planul Premium nu este disponibil. Po\u021Bi s\u0103 mergi mai departe folosind planul Basic. "),E()(),x(9,"div",7)(10,"button",8),W("click",function(){return r.cancel()}),j(11," \xCEnchide "),E(),x(12,"button",9),W("click",function(){return r.confirm()}),j(13," Continu\u0103 cu Basic "),E()()())},dependencies:[Ae],styles:[".premium-option-unavailable[_ngcontent-%COMP%]{display:flex;flex-direction:column}.premium-option-unavailable__header[_ngcontent-%COMP%]{border-bottom:1px solid rgb(224,224,224);display:flex;justify-content:space-between;align-items:center;padding-bottom:1rem}.premium-option-unavailable__title[_ngcontent-%COMP%]{color:#000;font-size:21px;font-weight:700;letter-spacing:-.26px;margin:0}.premium-option-unavailable__close[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;max-width:40px;max-height:40px;padding:0;margin:0;border:none;background:transparent}.premium-option-unavailable__close-icon[_ngcontent-%COMP%]{height:20px!important;width:20px!important}.premium-option-unavailable__body[_ngcontent-%COMP%]{border-bottom:1px solid rgb(224,224,224);padding:1rem 0}@media screen and (min-width: 768px){.premium-option-unavailable__body[_ngcontent-%COMP%]{padding:20px 0}}.premium-option-unavailable__text[_ngcontent-%COMP%]{font-size:17px;font-weight:400;letter-spacing:-.21px;margin:0}.premium-option-unavailable__number-wrap[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;gap:7px;padding:1rem 0;margin:0;list-style:none}.premium-option-unavailable__number[_ngcontent-%COMP%]{border-radius:100%;background:#d8d8d8;text-align:center;width:43px;height:43px;display:flex;justify-content:center;align-items:center;color:#000;font-size:40px;font-weight:700;letter-spacing:-.5px}.premium-option-unavailable__action[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;padding-top:1rem;margin-top:auto;gap:1rem}.premium-option-unavailable__action-button[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;border:2px solid rgb(0,0,0);font-size:14px;font-weight:700;text-align:center;line-height:32px;width:100%;max-width:150px;background:#fff}.premium-option-unavailable__action-button--primary[_ngcontent-%COMP%]{border-color:#ff7900;background:#ff7900;color:#fff}.premium-option-unavailable__action-button--primary[_ngcontent-%COMP%]:hover{border-color:#f16e00;background:#f16e00}"]});let t=s;return t})();var X=(()=>{let s=class s{constructor(){this.STORAGE_KEY="insurance_selection",this.EXPIRY_DURATION=24*60*60*1e3}saveSelection(e){try{let i={selectedSlug:e.selectedSlug??null,activeTab:e.activeTab??S.Basic,selectedOption:e.selectedOption??null,imei:e.imei??"",orderId:e.orderId,deviceOaCode:e.deviceOaCode,timestamp:Date.now()};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(i))}catch(i){console.warn(this.getErrorMessage("save"),i)}}loadSelection(){try{let e=localStorage.getItem(this.STORAGE_KEY);if(!e)return null;let i=JSON.parse(e);return this.isExpired(i.timestamp)?(this.clearSelection(),null):this.isValidSelection(i)?i:(this.clearSelection(),null)}catch(e){return console.warn(this.getErrorMessage("load"),e),this.clearSelection(),null}}clearSelection(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn(this.getErrorMessage("clear"),e)}}shouldPersistSelection(e){return!!(e?.selectedSlug||e?.selectedOption||e?.imei&&e.imei.length>0)}updatePartialSelection(e){let i=this.loadSelection();if(!i&&this.shouldPersistSelection(e))return;let r=g(p(p({},i),e),{timestamp:Date.now()});this.saveSelection(r)}isExpired(e){return Date.now()-e>this.EXPIRY_DURATION}isValidSelection(e){return e&&typeof e=="object"&&typeof e.timestamp=="number"&&(e.activeTab===S.Basic||e.activeTab===S.Premium)}getErrorMessage(e){switch(e){case"save":return"Failed to save insurance selection to localStorage:";case"load":return"Failed to load insurance selection from localStorage:";case"clear":return"Failed to clear insurance selection from localStorage:";default:return"Insurance localStorage error"}}};s.\u0275fac=function(i){return new(i||s)},s.\u0275prov=O({token:s,factory:s.\u0275fac,providedIn:"root"});let t=s;return t})();var Ye=(()=>{let s=class s{constructor(){this.persistenceService=u(X)}restorePersistedSelection(e){let i=this.persistenceService.loadSelection();if(!i)return!1;try{return pe(()=>{i.selectedSlug&&e.setSelectedCategorySlug(i.selectedSlug),i.activeTab&&e.setActiveTab(i.activeTab),i.selectedOption&&e.setSelectedOption(i.selectedOption),i.imei&&e.setImei(i.imei),i.orderId&&e.setOrderId(i.orderId),i.deviceOaCode&&e.setDeviceOaCodeId(i.deviceOaCode)}),!0}catch(r){return console.error("Failed to restore persisted insurance selection:",r),this.persistenceService.clearSelection(),!1}}persistCurrentSelection(e){this.persistenceService.saveSelection(e)}clearPersistedData(){this.persistenceService.clearSelection()}};s.\u0275fac=function(i){return new(i||s)},s.\u0275prov=O({token:s,factory:s.\u0275fac,providedIn:"root"});let t=s;return t})();var fi=(()=>{let s=class s{constructor(){this.storeSelector=u($),this.insuranceStore=u(ze),this.dialog=u(xe),this.destroyRef=u(L),this.snackBar=u(Re),this.insuranceService=u(V),this.selectionSyncService=u(Ye),this.persistenceService=u(X),this.isAuthenticated=y(this.storeSelector.getWithSelector(be)),this.cartIsLoading=y(this.storeSelector.getWithSelector(Ie)),this.activeMsisdn=y(this.storeSelector.getWithSelector(H)),this.activeProfileIsAdmin=y(this.storeSelector.getWithSelector(ve)),this.activeProfileIsPrepay=y(this.storeSelector.getWithSelector(Pe)),this.activeProfileIsExplorer=y(this.storeSelector.getWithSelector(ye)),this.items=this.insuranceStore.items,this.status=this.insuranceStore.status,this.error=this.insuranceStore.error,this.isInitial=o(()=>this.status()===c.initial),this.isLoading=o(()=>this.status()===c.loading),this.hasError=o(()=>this.status()===c.error),this.isSuccess=o(()=>this.status()===c.success),this.isPhonePage=o(()=>this.selectedItemCategoryId()===1),this.isSmartWatchCategory=o(()=>this.selectedSlug()===P.Smartwatch),this.isConnectedObjectCategory=o(()=>this.selectedSlug()===P.ConnectedObject),this.hasAvailableCategoryOfferings=o(()=>this.categoryOfferings().length>0),this.shouldShowEmptyState=o(()=>this.isSuccess()&&!this.hasError()&&this.items().length===0),this.selection=this.insuranceStore.selection,this.selectedSlug=this.insuranceStore.selectedSlug,this.selectionStatus=this.insuranceStore.selection.status,this.activeTab=o(()=>this.isSmartWatchCategory()?S.Premium:this.selection().activeTab),this.selectedOption=o(()=>this.selection().selectedOption),this.imei=o(()=>this.selection().imei),this.orderId=o(()=>this.selection().orderId),this.deviceOaCode=o(()=>this.selection().deviceOaCode),this.selectionIsInitial=o(()=>this.selectionStatus()===c.initial),this.selectionIsLoading=o(()=>this.selectionStatus()===c.loading),this.selectionHasError=o(()=>this.selectionStatus()===c.error),this.selectionIsSuccess=o(()=>this.selectionStatus()===c.success),this.showFromPrice=o(()=>this.selectedOption()===null||this.selectedOption()===T.Custom),this.selectedItem=this.insuranceStore.selectedItem,this.selectedItemCategoryId=o(()=>this.selectedItem()?.categoryId),this.selectedCategoryItem=this.insuranceStore.selectedCategoryItem,this.product=this.insuranceStore.product,this.categoryOfferings=this.insuranceStore.category,this.insurableProducts=this.insuranceStore.insurableProducts,this.selectedInsurableProduct=o(()=>this.insurableProducts()?.find(e=>e.oaCode===this.selectedOption())||null),this.insuranceProductCustomDetails=this.insuranceStore.insuranceProductCustomDetails,this.categoryMappedProducts=o(()=>this.insuranceProductCustomDetails()?.categoryMappedProducts||[]),this.notSellableReason=this.insuranceStore.notSellableReason,this.reason=o(()=>this.notSellableReason()?.reason||null),this.canViewDetails=o(()=>!!this.isAuthenticated()),this.isNotSellable=this.insuranceStore.isNotSellable,this.notSellableMessage=this.insuranceStore.notSellableMessage,this.availableProducts=this.insuranceStore.availableProducts,this.hasAvailableProducts=this.insuranceStore.hasAvailableProducts,this.availableTiers=this.insuranceStore.availableTiers,this.hasPremiumTier=this.insuranceStore.hasPremiumTier,this.hasBasicTier=this.insuranceStore.hasBasicTier,this.isTierNotAvailable=o(()=>this.isConnectedObjectCategory()&&this.selectedOption()===T.Custom&&this.reason()===N.RequestedTierNotAvailableForPurchase),this.isCurrentTierAvailable=o(()=>{let e=this.activeTab();return this.availableTiers().includes(e)}),this.shouldShowOtyPassword=o(()=>!this.activeProfileIsAdmin()&&!this.activeProfileIsPrepay()&&!this.activeProfileIsExplorer()),this.canNotProceedWithPurchase=o(()=>!!(this.isAuthenticated()&&this.selectedOption()===null||this.isAuthenticated()&&this.selectedOption()===T.Custom&&this.isPhonePage()&&!ee(this.imei())||this.isAuthenticated()&&this.selectedOption()===T.Custom&&!this.isPhonePage()&&!Le(this.imei())||this.cartIsLoading())),this.purchaseBlockedReason=o(()=>this.isNotSellable()?this.selectedOption()?this.imei().length===0?`Te rug\u0103m s\u0103 introduci ${this.isPhonePage()?"IMEI-ul":"SM-ul"} dispozitivului`:null:"Te rug\u0103m s\u0103 selectezi o op\u021Biune de asigurare":this.notSellableMessage()),this.persistSelectionEffect=Y(()=>{let e=this.selection(),i={selectedSlug:this.selectedSlug(),activeTab:e.activeTab,selectedOption:e.selectedOption,imei:e.imei,orderId:e.orderId,deviceOaCode:e.deviceOaCode};this.persistenceService.shouldPersistSelection(i)&&this.persistenceService.saveSelection(i)},{allowSignalWrites:!0}),this.tierNotAvailableEffect=Y(()=>{this.isTierNotAvailable()&&this.showTierNotAvailableAlert()}),this.autoClearErrorEffect=Y(()=>{let e=this.isSuccess(),i=this.hasError();e&&i&&setTimeout(()=>{this.clearError()},3e3)})}initializeLoadInsuranceItems(){return v(this,null,function*(){try{this.restorePersistedSelection(),yield this.loadInsuranceItems()}catch(e){throw console.error("Failed to initialize Insurance Facade:",e),e}})}restorePersistedSelection(){return this.selectionSyncService.restorePersistedSelection(this.insuranceStore)}clearPersistedSelection(){this.selectionSyncService.clearPersistedData()}loadInsuranceItems(){return v(this,null,function*(){try{this.insuranceStore.loadCategoryOfferings()}catch(e){throw console.error("Failed to initiate insurance offerings load:",e),e}})}selectCategory(e){this.insuranceStore.setSelectedCategorySlug(e)}selectTier(e){if(!this.availableTiers().includes(e)){this.showTierNotAvailableAlert();return}this.insuranceStore.setActiveTab(e)}selectOption(e){this.insuranceStore.setSelectedOption(e)}setDeviceImei(e){this.insuranceStore.setImei(e)}setOrderId(e){this.insuranceStore.setOrderId(e)}setDeviceOaCode(e){this.insuranceStore.setDeviceOaCodeId(e)}selectBasicTier(){this.selectTier(S.Basic)}initiatePurchase(){return v(this,null,function*(){try{this.insuranceService.addInsurance(this.selectedOption(),this.selectedInsurableProduct(),this.activeMsisdn(),this.imei(),this.activeTab()),this.clearPersistedSelection()}catch(e){throw console.error("Purchase failed:",e),e}})}clearError(){this.insuranceStore.clearError()}resetSelection(){this.insuranceStore.setSelectedCategorySlug(null),this.insuranceStore.setActiveTab(S.Basic),this.insuranceStore.setSelectedOption(null),this.insuranceStore.setImei(""),this.insuranceStore.setOrderId(void 0),this.clearPersistedSelection()}initializeLoadProductDetails(){return v(this,null,function*(){try{this.restorePersistedSelection(),yield this.loadProductDetails()}catch(e){throw console.error("Failed to initialize Product Details Facade:",e),e}})}loadProductDetails(){return v(this,null,function*(){let e=this.selectedOption(),i=this.activeMsisdn(),r=this.selectedItemCategoryId(),a=this.activeTab(),l=this.imei(),h=this.deviceOaCode(),I=this.orderId();if(!a){console.warn("Cannot load product details: missing required parameters");return}let _={selectedOption:e,msisdn:i,deviceCategoryId:r,tier:a,imei:l,deviceOaCode:h,orderId:I};if(!this.canViewDetails()){let m=new Error("Insufficient permissions to view product details");throw console.warn("Permission denied for loading product details:",m),m}try{this.validateProductDetailsParams(_)}catch(m){throw console.error("Parameter validation failed:",m),m}try{let m=this.insuranceService.buildInsuranceProductDetailsRequest(e,i,r,a,l,h,I);this.insuranceStore.loadProductCustomDetails(m)}catch(m){throw console.error("Failed to load product details:",m),m}})}retryLoadProductDetails(){return v(this,null,function*(){try{yield this.loadProductDetails()}catch(e){throw e}})}preparePurchaseData(){return{deviceCategoryId:void 0,tier:this.activeTab(),deviceImei:void 0,imei:this.imei(),orderId:this.orderId(),userId:void 0}}showTierNotAvailableAlert(){this.dialog.open(We,{autoFocus:!1,disableClose:!1,minHeight:"170px",maxWidth:"650px"}).afterClosed().pipe(fe(this.destroyRef)).subscribe(i=>{i?.action==="confirm"&&(this.selectOption(null),this.selectBasicTier(),this.loadProductDetails())})}showErrorAlert(e){this.snackBar.open(e,"Close",{duration:5e3,panelClass:["error-snackbar"]})}showSuccessAlert(e){this.snackBar.open(e,"Close",{duration:3e3,panelClass:["success-snackbar"]})}validateProductDetailsParams(e){if(e.selectedOption===T.Custom&&e.imei&&this.isPhonePage()&&!ee(e.imei))throw new Error("Invalid IMEI format for phone device")}};s.\u0275fac=function(i){return new(i||s)},s.\u0275prov=O({token:s,factory:s.\u0275fac,providedIn:"root"});let t=s;return t})();export{je as a,Xe as b,k as c,gt as d,fi as e};