import{B as q,a as De,b as d,c as N,d as b,e as I,f as T}from"./chunk-27I6KFKF.js";import{c as ze}from"./chunk-2AHUEYL3.js";import{a as u,b as Ae,d as xe,f as Ee,g as Re}from"./chunk-7CJK7ZV7.js";import{c as Fe}from"./chunk-DGJ2KY2B.js";import{f as Ue}from"./chunk-C2VXQ6L5.js";import{c as Be,e as je}from"./chunk-PHTMXYHJ.js";import{Jb as Te}from"./chunk-CA2IRDIV.js";import{a as Ne,b as ke}from"./chunk-EPGXKNXA.js";import{C as we,G as _e,H as Me,U as G}from"./chunk-C2EV7IAO.js";import{a as M}from"./chunk-XS3VT6OI.js";import{m as Oe,o as V}from"./chunk-JJTPXY4D.js";import{D as c,a as Pe,b as ye,c as C,s as Ce}from"./chunk-ALDBR463.js";import{f as ve}from"./chunk-H45JNRUV.js";import{Ba as B,Cc as A,Dc as x,Ec as fe,F as D,H as ue,Ia as O,La as de,Oa as l,Oc as $,Qb as Y,Rd as s,Sd as Ie,Td as H,Va as me,Z as te,a as h,ac as ge,ad as j,b as g,cb as he,cd as re,dd as Se,h as P,jd as be,k as ee,kb as pe,mb as W,o as le,ya as ie}from"./chunk-V6BPA3D7.js";var Le={title:"Protejeaz\u0103-\u021Bi dispozitivul cu o asigurare",description:"Po\u021Bi alege \xEEntre dou\u0103 tipuri de asigurare: Basic sau Premium \u0219i po\u021Bi activa asigurarea, oric\xE2nd, \xEEn primele 120 de zile calendaristice de la data achizi\u021Biei. Costul lunar al acesteia \u0219i valoarea asigurat\u0103 depind de pre\u021Bul standard al dispozitivului cump\u0103rat.",secondDescription:"\u021Aine cont c\u0103 asigurarea nu este purt\u0103toare de TVA, astfel c\u0103, tariful asigur\u0103rii alese, va fi inclus pe factura 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."},et=["telefon","tableta","smartwatch","obiect-conectat"];var We=t=>{switch(t){case I.Phone:return b.Phone;case I.Tablet:return b.Tablet;case I.Smartwatch:return b.Smartwatch;case I.ConnectedObject:return b.ConnectedObject}},st=t=>{switch(t){case M.phones:return I.Phone;case M.tablets:return I.Tablet;case M.smartwatches:return I.Smartwatch;case M.connected:case M.modems:case M.tvs:return I.ConnectedObject}};var Ze={items:[],selectedItem:null,category:[],selectedCategoryItem:null,status:c.initial,selection:{selectedSlug:null,activeTab:d.Basic,products:[],selectedOption:null,imei:"",orderId:void 0,deviceOaCode:void 0,isRedirectedAsConsole:!1,deviceCategoryId:void 0,status:c.initial},insuranceProductCustomDetails:{categoryMappedProducts:null,notSellableReason:null},insurableProducts:null,product:null,error:null},se=new de("InsuranceState",{factory:()=>Ze});function X(t,y){y?.injector||he(X);let e=y?.injector??l(pe),i=e.get(W),n=new le,r=t(n).subscribe();i.onDestroy(()=>r.unsubscribe());let a=m=>{let f;ge(m)?f=ye(m,{injector:e}):ue(m)?f=m:f=D(m);let v=f.subscribe(p=>n.next(p));return r.add(v),v};return a.unsubscribe=r.unsubscribe.bind(r),a}var Ye=t=>t.replace(" ","-").toLowerCase();var w="https://storage.googleapis.com/orangero-assets/orange-eshop/insurance",k={phone:`${w}/phones-insurance.svg`,tablet:`${w}/tablet-insurance.svg`,watch:`${w}/watch-insurance.svg`,connectedObjects:`${w}/connected-object-insurance.svg`},F={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 $e=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}},He=t=>{switch(t){case b.Phone:return F.phone;case b.Tablet:return F.tablet;case b.Smartwatch:return F.watch;case b.ConnectedObject:return F.connectedObjects}};var oe=t=>({categoryId:t.categoryId,slug:Ye(t.title),icon:$e(t.title),imeiIcon:He(t.title),subTitle:t.subTitle,title:t.title,startingPrice:t.startingPrice});var Ve=(()=>{class t{checkImeiAndInitiatePurchase(e,i){return P(this,null,function*(){try{let n=this.findInsurableProductByImei(e,i);return n?this.canInitiatePurchase(n)?this.getAvailableOption(n)?!0:(console.warn("No available purchase options for IMEI:",e),!1):(console.warn("Cannot initiate purchase for IMEI:",{imei:e,productState:n.state,availableOptions:n.options?.filter(a=>a?.state==="CAN_BUY").length||0}),!1):(console.log("Current IMEI not found in processed data"),!1)}catch(n){throw console.error("Error in checkImeiAndInitiatePurchase:",{currentImei:e,error:n instanceof Error?n.message:"Unknown error"}),n}})}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 n of i.categoryMappedProducts){if(!n?.product?.insurableProducts?.length)continue;let r=n?.product.insurableProducts.find(a=>a.imei===e);if(r)return r}return null}findInsurableProductByImei(e,i){if(!e||!i?.categoryMappedProducts)return null;for(let n of i.categoryMappedProducts){let r=n.product?.insurableProducts?.find(a=>a.imei===e);if(r)return r}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}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275prov=O({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Ge=Ae({providedIn:"root"},Re(()=>l(se)),xe(({items:t,selection:y,insuranceProductCustomDetails:e})=>{let i=s(()=>y().selectedSlug),n=s(()=>{let o=i();return o?We(o):null}),r=s(()=>{let o=n();return t().find(S=>S.title===o)}),a=s(()=>{let o=r();return o?oe(o):null}),m=s(()=>e()?.categoryMappedProducts||[]),f=s(()=>{let o=r();if(!o)return null;let S=m()?.find(z=>z?.categoryId===o?.categoryId)?.product;return S||null}),v=s(()=>{let S=f()?.insurableProducts;return S||null}),p=s(()=>t().map(o=>oe(o))),E=s(()=>{let o=e();if(!o)return null;let S=(o.categoryMappedProducts||[]).filter(L=>L!=null),z=S.filter(L=>L.state===De.CanBuy);return{categoryMappedProducts:S,notSellableReason:o.notSellableReason||null,isAvailable:z.length>0&&!o.notSellableReason,availableProducts:z}}),R=s(()=>E()?.notSellableReason||null),U=s(()=>R()!==null),Q=s(()=>{let o=R();if(!o)return null;if(o.message)return o.message;switch(o.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"}}),_=s(()=>E()?.availableProducts||[]),Z=s(()=>_().length>0),ae=s(()=>{let o=r();return o?!!(o&&o.options?.BASIC&&o.options.BASIC.length>0||o&&o.children?.some(S=>S?.options?.BASIC&&S.options.BASIC.length>0)):!1}),ce=s(()=>{let o=r();return o?!!(o&&o.options?.PREMIUM&&o.options.PREMIUM.length>0||o&&o.children?.some(S=>S?.options?.PREMIUM&&S.options.PREMIUM.length>0)):!1}),Qe=s(()=>[ae()?d.Basic:null,ce()?d.Premium:null]);return{selectedItem:r,selectedCategoryItem:a,product:f,category:p,insurableProducts:v,selectedSlug:i,processedProductDetails:E,notSellableReason:R,isNotSellable:U,notSellableMessage:Q,availableProducts:_,hasAvailableProducts:Z,availableTiers:Qe,hasBasicTier:ae,hasPremiumTier:ce}}),Ee((t,y=l(q),e=l(Ve),i=l(V),n=C(i.getWithSelector(G)))=>({loadCategoryOfferings:X(ee(B(()=>u(t,{status:c.loading,error:null})),ie(()=>y.fetchCategoryOfferings().pipe(B({next:r=>{if(!r)throw new Error("Empty response received from server");let a=r.items;if(a.length===0){u(t,{items:[],status:c.success});return}u(t,{items:a,status:c.success,error:null})},error:r=>{u(t,{error:r,status:c.error})}}),te(r=>{let a={message:Le.errorMessage||"Unable to load insurance offerings. Please try again.",code:"LOAD_OFFERINGS_FAILED",timestamp:new Date().toISOString()};return u(t,{error:a,status:c.error}),D(null)}))))),loadProductCustomDetails:X(ee(B(r=>{u(t,{selection:g(h({},t.selection()),{status:c.loading}),error:null})}),ie(r=>y.getInsuranceProductCustomDetails(r).pipe(B({next:a=>P(void 0,null,function*(){if(!a.success){let _=a.errors?.[0]?.message||"Failed to load product details";u(t,{selection:g(h({},t.selection()),{status:c.error}),error:{message:_,code:a.errors?.[0]?.code||"API_ERROR",timestamp:new Date().toISOString()},status:c.error});return}let m=a.data?.getInsuranceProductCustomDetails,f=y.processInsuranceProductDetails(m),v=t.selection().imei,p=t.selection().selectedOption===T.Custom,E=t.insuranceProductCustomDetails()?.categoryMappedProducts,R=m?.categoryMappedProducts,U=y.getCategoryMappedProducts(p,E,R),Q=U||m?.notSellableReason?{categoryMappedProducts:U,notSellableReason:m?.notSellableReason}:void 0;if(u(t,{selection:g(h({},t.selection()),{status:c.success}),error:null,status:t.status()===c.loading?c.success:t.status(),insuranceProductCustomDetails:Q}),p&&v&&f)try{if(yield e.checkImeiAndInitiatePurchase(v,f)){let Z=e.extractInsurableProductByImei(v,m);y.addInsurance(t.selection().selectedOption,Z,n(),v,t.selection().selectedSlug?.toLowerCase()==="smartwatch"?d.Premium:t.selection().activeTab)}}catch(_){console.error("Auto-purchase failed:",_)}f.notSellableReason&&console.warn("\u26A0\uFE0F Product not sellable:",{reason:f.notSellableReason.reason,message:f.notSellableReason.message})}),error:a=>{console.error("Failed to load product details:",a);let m=a.errors?.[0]?.message||"Unable to load product details. Please try again.";u(t,{selection:g(h({},t.selection()),{status:c.error}),error:{message:m,code:a.errors?.[0]?.code||"LOAD_FAILED",timestamp:new Date().toISOString()},status:c.error})}}),te(a=>(console.error("Unhandled error in loadProductCustomDetails:",a),u(t,{selection:g(h({},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}),D(null))))))),setSelectedCategorySlug(r){u(t,{selection:g(h({},t.selection()),{selectedSlug:r})})},setActiveTab(r){u(t,{selection:g(h({},t.selection()),{activeTab:r})})},setSelectedOption(r){u(t,{selection:g(h({},t.selection()),{selectedOption:r})})},setImei(r){u(t,{selection:g(h({},t.selection()),{imei:r})})},setOrderId(r){u(t,{selection:g(h({},t.selection()),{orderId:r})})},setDeviceOaCodeId(r){u(t,{selection:g(h({},t.selection()),{deviceOaCode:r})})},setDeviceCategoryId(r){u(t,{selection:g(h({},t.selection()),{deviceCategoryId:r})})},goWithBasic(){u(t,{selection:g(h({},t.selection()),{activeTab:d.Basic})})},setRedirectedAsConsole(r){u(t,{selection:g(h({},t.selection()),{isRedirectedAsConsole:r})})},clearError:()=>u(t,{error:null}),resetStore:()=>{let r=l(se);u(t,r)}})));var ne=t=>t.length>=1&&t.length<=20,qe=t=>t.length>=5&&t.length<=20;var Xe=(()=>{class t{constructor(){this.dialogRef=l(Be),this.domSanitizer=l(ve),this.matIconRegistry=l(Ne),this.facade=l(Ke),this.InsuranceTier=d,this.loadIcons()}confirm(){this.dialogRef.close({action:"confirm"})}cancel(){this.dialogRef.close({action:"cancel"})}loadIcons(){this.matIconRegistry.addSvgIconLiteral("ico_close_icon",this.domSanitizer.bypassSecurityTrustHtml(Fe))}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=me({type:t,selectors:[["oro-premium-option-unavailable-modal"]],standalone:!0,features:[be],decls:14,vars:4,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,n){i&1&&(A(0,"div",0)(1,"div",1)(2,"h3",2),j(3),x(),A(4,"button",3),$("click",function(){return n.cancel()}),fe(5,"mat-icon",4),x()(),A(6,"div",5)(7,"p",6),j(8),x()(),A(9,"div",7)(10,"button",8),$("click",function(){return n.cancel()}),j(11," \xCEnchide "),x(),A(12,"button",9),$("click",function(){return n.confirm()}),j(13),x()()()),i&2&&(Y(3),re(" Planul ",n.facade.activeTab()===n.InsuranceTier.Basic?"Basic":"Premium"," nu este disponibil "),Y(5),Se(" Pentru acest produs planul ",n.facade.activeTab()===n.InsuranceTier.Basic?"Basic":"Premium"," nu este disponibil. Po\u021Bi s\u0103 mergi mai departe folosind planul ",n.facade.activeTab()===n.InsuranceTier.Basic?"Premium":"Basic",". "),Y(5),re(" Continu\u0103 cu ",n.facade.activeTab()===n.InsuranceTier.Basic?"Premium":"Basic"," "))},dependencies:[ke],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;flex-direction:column;padding-top:1rem;margin-top:auto;gap:1rem}@media screen and (min-width: 768px){.premium-option-unavailable__action[_ngcontent-%COMP%]{flex-direction:row}}.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%;padding:0 2rem;max-width:210px;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}"]})}}return t})();var J=(()=>{class t{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??d.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 n=g(h(h({},i),e),{timestamp:Date.now()});this.saveSelection(n)}isExpired(e){return Date.now()-e>this.EXPIRY_DURATION}isValidSelection(e){return e&&typeof e=="object"&&typeof e.timestamp=="number"&&(e.activeTab===d.Basic||e.activeTab===d.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"}}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275prov=O({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Je=(()=>{class t{constructor(){this.persistenceService=l(J)}restorePersistedSelection(e){let i=this.persistenceService.loadSelection();if(!i)return!1;try{return Ie(()=>{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(n){return console.error("Failed to restore persisted insurance selection:",n),this.persistenceService.clearSelection(),!1}}persistCurrentSelection(e){this.persistenceService.saveSelection(e)}clearPersistedData(){this.persistenceService.clearSelection()}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275prov=O({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var Ke=(()=>{class t{constructor(){this.store=l(Ce),this.storeSelector=l(V),this.insuranceStore=l(Ge),this.dialog=l(je),this.destroyRef=l(W),this.snackBar=l(Ue),this.insuranceService=l(q),this.selectionSyncService=l(Je),this.persistenceService=l(J),this.isAuthenticated=C(this.storeSelector.getWithSelector(Oe)),this.cartIsLoading=C(this.storeSelector.getWithSelector(Te)),this.activeMsisdn=C(this.storeSelector.getWithSelector(G)),this.activeProfileIsAdmin=C(this.storeSelector.getWithSelector(we)),this.activeProfileIsPrepay=C(this.storeSelector.getWithSelector(_e)),this.activeProfileIsExplorer=C(this.storeSelector.getWithSelector(Me)),this.items=this.insuranceStore.items,this.status=this.insuranceStore.status,this.error=this.insuranceStore.error,this.isInitial=s(()=>this.status()===c.initial),this.isLoading=s(()=>this.status()===c.loading),this.hasError=s(()=>this.status()===c.error),this.isSuccess=s(()=>this.status()===c.success),this.isPhonePage=s(()=>this.selectedItemCategoryId()===1),this.isSmartWatchCategory=s(()=>this.selectedSlug()===I.Smartwatch),this.isConnectedObjectCategory=s(()=>this.selectedSlug()===I.ConnectedObject),this.hasAvailableCategoryOfferings=s(()=>this.categoryOfferings().length>0),this.shouldShowEmptyState=s(()=>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=s(()=>this.isSmartWatchCategory()?d.Premium:this.selection().activeTab),this.selectedOption=s(()=>this.selection().selectedOption),this.imei=s(()=>this.selection().imei),this.orderId=s(()=>this.selection().orderId),this.deviceOaCode=s(()=>this.selection().deviceOaCode),this.deviceCategoryId=s(()=>this.selection().deviceCategoryId),this.isRedirectedAsConsole=s(()=>this.selection().isRedirectedAsConsole),this.selectionIsInitial=s(()=>this.selectionStatus()===c.initial),this.selectionIsLoading=s(()=>this.selectionStatus()===c.loading),this.selectionHasError=s(()=>this.selectionStatus()===c.error),this.selectionIsSuccess=s(()=>this.selectionStatus()===c.success),this.showFromPrice=s(()=>this.selectedOption()===null||this.selectedOption()===T.Custom),this.selectedItem=this.insuranceStore.selectedItem,this.selectedItemCategoryId=s(()=>this.selectedItem()?.categoryId||this.deviceCategoryId()),this.selectedCategoryItem=this.insuranceStore.selectedCategoryItem,this.product=this.insuranceStore.product,this.categoryOfferings=this.insuranceStore.category,this.insurableProducts=this.insuranceStore.insurableProducts,this.selectedInsurableProduct=s(()=>this.insurableProducts()?.find(e=>e.oaCode===this.selectedOption())||null),this.insuranceProductCustomDetails=this.insuranceStore.insuranceProductCustomDetails,this.categoryMappedProducts=s(()=>this.insuranceProductCustomDetails()?.categoryMappedProducts||[]),this.notSellableReason=this.insuranceStore.notSellableReason,this.reason=s(()=>this.notSellableReason()?.reason||null),this.canViewDetails=s(()=>!!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=s(()=>this.isConnectedObjectCategory()&&this.selectedOption()===T.Custom&&this.reason()===N.RequestedTierNotAvailableForPurchase),this.isCurrentTierAvailable=s(()=>{let e=this.activeTab();return this.availableTiers().includes(e)}),this.shouldShowOtyPassword=s(()=>!this.activeProfileIsAdmin()&&!this.activeProfileIsPrepay()&&!this.activeProfileIsExplorer()),this.canNotProceedWithPurchase=s(()=>!!(this.isAuthenticated()&&this.selectedOption()===null||this.isAuthenticated()&&this.selectedOption()===T.Custom&&this.isPhonePage()&&!ne(this.imei())||this.isAuthenticated()&&this.selectedOption()===T.Custom&&!this.isPhonePage()&&!qe(this.imei())||this.cartIsLoading())),this.purchaseBlockedReason=s(()=>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=H(()=>{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=H(()=>{this.isTierNotAvailable()&&this.showTierNotAvailableAlert()}),this.autoClearErrorEffect=H(()=>{let e=this.isSuccess(),i=this.hasError();e&&i&&setTimeout(()=>{this.clearError()},3e3)})}initializeLoadInsuranceItems(){return P(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 P(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)}setDeviceCategoryId(e){this.insuranceStore.setDeviceCategoryId(e)}selectBasicTier(){this.selectTier(d.Basic)}selectPremiumTier(){this.selectTier(d.Premium)}initiatePurchase(){return P(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(d.Basic),this.insuranceStore.setSelectedOption(null),this.insuranceStore.setImei(""),this.insuranceStore.setOrderId(void 0),this.clearPersistedSelection()}resetSelectionWithActiveTab(e){this.insuranceStore.setSelectedCategorySlug(null),this.insuranceStore.setActiveTab(e),this.insuranceStore.setSelectedOption(null),this.insuranceStore.setImei(""),this.insuranceStore.setOrderId(void 0),this.clearPersistedSelection()}initializeLoadProductDetails(){return P(this,null,function*(){try{this.restorePersistedSelection(),yield this.loadProductDetails()}catch(e){throw console.error("Failed to initialize Product Details Facade:",e),e}})}loadProductDetails(){return P(this,null,function*(){let e=this.selectedOption(),i=this.activeMsisdn(),n=this.selectedItemCategoryId(),r=this.activeTab(),a=this.imei(),m=this.deviceOaCode(),f=this.orderId();if(!r){console.warn("Cannot load product details: missing required parameters");return}let v={selectedOption:e,msisdn:i,deviceCategoryId:n,tier:r,imei:a,deviceOaCode:m,orderId:f};if(!this.canViewDetails()){let p=new Error("Insufficient permissions to view product details");throw console.warn("Permission denied for loading product details:",p),p}try{this.validateProductDetailsParams(v)}catch(p){throw console.error("Parameter validation failed:",p),p}try{let p=this.insuranceService.buildInsuranceProductDetailsRequest(e,i,n,r,a,m,f);this.insuranceStore.loadProductCustomDetails(p)}catch(p){throw console.error("Failed to load product details:",p),p}})}retryLoadProductDetails(){return P(this,null,function*(){try{yield this.loadProductDetails()}catch(e){throw e}})}setRedirectedAsConsole(e){this.insuranceStore.setRedirectedAsConsole(e)}resetRedirectedAsConsole(){this.insuranceStore.setRedirectedAsConsole(!1)}preparePurchaseData(){return{deviceCategoryId:void 0,tier:this.activeTab(),deviceImei:void 0,imei:this.imei(),orderId:this.orderId(),userId:void 0}}showTierNotAvailableAlert(){this.store.dispatch(ze.premiumPlanUnavailablePopupShown()),this.dialog.open(Xe,{autoFocus:!1,disableClose:!1,minHeight:"170px",maxWidth:"650px"}).afterClosed().pipe(Pe(this.destroyRef)).subscribe(i=>{i?.action==="confirm"&&(this.activeTab()===d.Basic?this.selectPremiumTier():this.activeTab()===d.Premium&&this.selectBasicTier(),this.selectOption(null),this.setDeviceImei(""),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()&&!ne(e.imei))throw new Error("Invalid IMEI format for phone device")}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275prov=O({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();export{Le as a,et as b,F as c,We as d,st as e,Ke as f};