1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1009],{12436:function(e,a,n){var t=n(54073),s=n(29259);e.exports=function(e,a,n){var i=!0,r=!0;if("function"!=typeof e)throw TypeError("Expected a function");return s(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),t(e,a,{leading:i,maxWait:a,trailing:r})}},31253:function(e,a,n){"use strict";n.d(a,{n3:function(){return eo}});var t=n(70865),s=n(96670),i=n(52322);n(5846);var r=n(97679),l=n(50862),o=n(89177),c=n(17115),d=n(54187),u=n(18427),m=n(5632),h=n(2784),g=n(29051),p=n(83883),b=n.n(p),x=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=(0,g.useDispatch)();return(0,h.useRef)(function(n,t){a((0,d.cancelAppointmentBooking)({accountNumber:t,bookingId:n,requireApiKey:e}))})},v=function(e){var a=e.accountNumber,n=(0,g.useDispatch)(),t=(0,h.useState)({showCancelModal:!1,id:"",status:""}),s=t[0],i=t[1],r=(0,h.useRef)(function(){i({showCancelModal:!1,id:"",status:""}),n((0,c.$e)({accountNumber:a}))}),l=(0,h.useRef)(function(e,a){i({showCancelModal:!0,id:e,status:a})});return{cancelState:s,onCancel:r,handleCancel:l}},_=function(e){var a,n=e.accountNumber,t=(0,g.useDispatch)();return{handleViewMore:(0,h.useRef)(function(){t((0,c.EP)({accountNumber:n}))}),onRepairButtonClick:function(e,a){t((0,d.setStoreAccountAction)({account:a})),t((0,d.setStoreAddressAction)({address:e}))}}},f=function(e){var a,n=e.accountNumber,t=e.mprnGprnIndex,s=(0,m.useRouter)(),i=_({accountNumber:n}),r=i.handleViewMore,l=i.onRepairButtonClick,c=x(),d=v({accountNumber:n}),h=d.cancelState;return{cancelState:h,onCancel:d.onCancel,handleCancel:d.handleCancel,onContinue:c,onReschedule:function(e,a){(0,u.rp)()&&b().sessionStorage.setItem(o.GEO,a||"");var i="/acc-mgmt/my-accounts/".concat(n,"/").concat(t,"/bookings/").concat(e,"/").concat(o.Ovz.UPDATE);s.push(i)},handleViewMore:r,onRepairButtonClick:function(e,a,n){l(a,n);var t="/services/book/".concat(e);s.push(t)}}},j=n(30156),N=n(17252),y=n(64226),w=n(68080),S=function(e){var a,n=e.accountNumber,i=e.startOptionCode,r=e.premises,l=(0,h.useState)({title:"",newBookingLabel:"",newBookingUrl:"",subTitle:"",paragraph:"",sideContent:{title:"",paragraph:""},bookNow:"",cancel:"",reschedule:"",status:"",bookingsUnavailable:"",repairTitle:"",repairParagraph:"",bookRepairButtonLabel:"",showMore:"",loaded:!1,cancelRescheduleReasonsBlock:{cancelTitle:"",cancelParagraph:"",rescheduleTitle:"",rescheduleParagraph:"",cancelTitleAgent:"",cancelParagraphAgent:"",rescheduleTitleAgent:"",rescheduleParagraphAgent:"",customerCancelReasons:[],customerRescheduleReasons:[],agentCancelReasons:[],agentRescheduleReasons:[],cancelReasonsDropdownPlaceholder:"",rescheduleReasonsDropdownPlaceholder:"",cancelModalContinueLabel:"",cancelModalCancelLabel:"",rescheduleModalContinueLabel:"",rescheduleModalCancelLabel:"",cancelDropdownLabel:"",rescheduleDropdownLabel:""},serviceAccountBookingTitle:"",bookingDetailsButtonLabel:"",bookingJobTypeLabel:"",bookingAppointmentLabel:"",bookingStatusLabel:""}),c=l[0],u=l[1],m=(0,h.useState)(!1),p=m[0],b=m[1],x=(0,g.useSelector)((0,j.FN)(n),g.shallowEqual),v=(0,g.useDispatch)(),_=(0,g.useSelector)(N.gp,g.shallowEqual),f=x?"".concat(n,"-").concat(r[0].premisesId):n,S=(0,g.useSelector)((0,y.selectBookings)(f),g.shallowEqual),C=(0,g.useSelector)((0,y.selectBookingsFiltered)(f),g.shallowEqual),D=(0,g.useSelector)((0,j.W4)(i)),k=(0,g.useSelector)((0,w.selectProductCatalogItemByOfferCode)(D&&D.breakdownProductOffer&&D.breakdownProductOffer.productCode),g.shallowEqual);return(0,h.useEffect)(function(){S.loaded||S.loading||v((0,d.serviceBookingAppointmentBookingForAccountAction)({accountNumber:n,isBusinessServicesUser:x,premiseId:r[0].premisesId}))},[x]),(0,h.useEffect)(function(){_&&u((0,s.Z)((0,t.Z)({},_),{loaded:!0}))},[_]),(0,h.useEffect)(function(){if(C.bookings){var e=Math.ceil((C.bookings.length||0)/o.vj9);b(S.pageNumber<e)}},[S.pageNumber,null===(a=C.bookings)||void 0===a?void 0:a.length]),{bookingsSectionContent:c,bookingsState:S,bookingsStateFiltered:C||{loaded:!1},planNameCode:D,productCatalogItem:k,loadMoreVisible:p,isBusinessServicesUser:x}},C=n(8020),D=n(50902),k=n(25340),M=n(79962),E=n(13922),A=n(46363),B=n(67107);n(5766);var L=n(92377),R=n(24398),T=n(12524),I=n.n(T),P=n(72670),F=n.n(P),O=function(e){var a=e.paragraph,n=e.placeholder,t=e.reasons,s=e.label,r=(0,g.useDispatch)();return(0,i.jsxs)("div",{children:[a&&F()(a),(0,i.jsx)("span",{className:"cancel-reschedule-reasons__label",children:s}),(0,i.jsx)(R.Ph,{options:t,placeholder:n,label:"Reason for cancellation",onChange:function(e){return r((0,d.storeCancelOrRescheduleReason)(e))},name:"cancel-reschedule-reasons",tabIndex:"0",className:"cancel-reschedule-reasons__dropdown",value:"",isNewBrand:!0})]})},Z=function(e){var a=e.continueButton,n=e.cancelButton,s=e.onClose,r=e.fullScreen,l=e.onCancel,o=e.shown,c=(0,g.useDispatch)();return(0,i.jsx)(L.DY,{children:(0,i.jsx)(L.u_,{isNewBrand:!0,fullScreen:void 0!==r&&r,head:(0,i.jsx)("p",{className:"bge-dialog__head__title",children:e.title}),body:(0,i.jsx)(O,(0,t.Z)({},e)),footer:(0,i.jsxs)("div",{className:"bookings_footer",children:[(0,i.jsx)("button",{type:"button",onClick:function(){l()},className:I()("button"),children:n}),(0,i.jsx)("button",{type:"button",onClick:function(){c((0,d.storeCancelOrRescheduleReason)(void 0)),s()},className:I()("button primary arrow",{disabled:!1,loading:!1}),children:a})]}),singleAction:!1,shown:o})})},G=function(e){var a=e.booking.id,n=e.content,t=n.reschedule,s=n.cancelRescheduleReasonsBlock,r=e.onReschedule,l=(0,h.useState)(!1),o=l[0],c=l[1],d=(0,g.useSelector)(y.selectCancelOrRescheduleReason),u=s.rescheduleTitle,m=s.rescheduleParagraph,p=s.rescheduleReasonsDropdownPlaceholder,b=s.customerRescheduleReasons,x=s.rescheduleModalContinueLabel,v=s.rescheduleModalCancelLabel,_=s.rescheduleDropdownLabel;return(0,i.jsxs)(i.Fragment,{children:[o&&(0,i.jsx)(Z,{title:u,paragraph:m,placeholder:p,reasons:b,continueButton:x,cancelButton:v,label:_,onClose:function(){r(a,d),c(!1)},onCancel:function(){c(!1)},shown:o}),(0,i.jsx)("button",{onClick:function(){return c(!0)},"aria-label":"Go to Rechedule Booking",className:"button primary arrow inline",children:t})]})},q=function(e){var a=e.booking,n=a.status,s=a.id,r=a.isBreakdown,l=a.offerCode,c=e.accountNumber,d=e.mprnGprnIndex,u=e.content,m=u.bookNow,h=u.cancel,p=u.reschedule,b=e.handleCancel,x=(0,g.useSelector)(B.rC);if(!n)return null;switch(n){case o.gn7.BOOKING_REQUIRED:return l?(0,i.jsx)(A.rU,{href:"/acc-mgmt/my-accounts/".concat(c,"/").concat(d,"/bookings/").concat(s,"/").concat(o.Ovz.CREATE),ariaLabel:"Go to book now",className:"button primary arrow inline",children:m}):null;case o.gn7.COMPLETED:return null;case o.gn7.UPCOMING:case o.gn7.DISPATCHED:return l?null:(0,i.jsx)("button",{onClick:function(){return b.current(s,n)},"aria-label":"Cancel booking",className:"button secondary inline mob__text__center",children:h});case o.gn7.NEW_MVP:return x?(0,i.jsx)("button",{onClick:function(){return b.current(s,n)},"aria-label":"Cancel booking",className:"button primary inline mob__text__center",children:h}):null;
1case o.gn7.PENDING:return(0,i.jsxs)(i.Fragment,{children:[l?(0,i.jsx)("button",{onClick:function(){return b.current(s,n)},"aria-label":"Cancel booking",className:"button secondary inline mob__text__center",children:h}):null,!r&&(0,i.jsx)(i.Fragment,{children:l?(0,i.jsx)(G,(0,t.Z)({},e)):(0,i.jsx)(A.rU,{href:"/acc-mgmt/my-accounts/".concat(c,"/").concat(d,"/bookings/").concat(s,"/").concat(o.Ovz.UPDATE),ariaLabel:"Go to Rechedule Booking",className:"button primary arrow inline",children:p})})]});default:return null}},U=function(e){var a=e.content,n=a.status,s=a.showMore,r=e.bookingsState.bookings,l=e.loadMoreVisible,c=e.handleViewMore,d=e.isNewBrand,u=function(e){switch(e){case o.gn7.BOOKING_REQUIRED:return d?(0,i.jsx)(E.u6,{fillColour:"#00306a",height:25,width:24}):(0,i.jsx)(E.v3,{fillColour:"#00306a"});case o.gn7.COMPLETED:return d?(0,i.jsx)(E.R$,{fillColour:"#00306a",height:25,width:24}):(0,i.jsx)(E.fB,{fillColour:"#00306a"});case o.gn7.UPCOMING:case o.gn7.PENDING:return(0,i.jsx)(E.SU,{fillColour:"#00306a"});default:return""}};return(0,i.jsxs)("section",{className:I()("bookings__list",{"new-brand":d}),children:[r&&r.map(function(a){return(0,i.jsxs)("div",{className:"booking__item",children:[(0,i.jsx)("h4",{className:"booking__item__title",children:a.type}),(0,i.jsx)("p",{className:"booking__item__date",children:a.status===o.gn7.BOOKING_REQUIRED?a.statusLabel:a.scheduledDateTime}),(0,i.jsxs)("p",{className:"booking__item__status",children:[u(a.status),n," - ",a.statusLabel]}),(0,i.jsx)("div",{className:"booking__item__footer",children:(0,i.jsx)(q,(0,t.Z)({booking:a},e))})]},a.id)}),l&&(0,i.jsx)("div",{className:"list-docs__button-container",children:(0,i.jsx)("button",{className:"button primary arrow arrow--down desktop-inline",onClick:c.current,children:s})})]})},Y=n(6228),H=function(e){var a=(0,h.useState)(!1),n=a[0],t=a[1],s=(0,g.useSelector)(B.rC),r=(0,g.useSelector)(y.selectCancelOrRescheduleReason),c=(0,g.useSelector)(N.gp,g.shallowEqual),d=(0,g.useSelector)((0,y.selectAccountBookings)(e.accountNumber),g.shallowEqual),u=d&&d.bookings&&d.bookings.find(function(a){return a.id===e.id}),m=(0,h.useState)({disableButtons:!1}),p=m[0],b=m[1],x=(0,h.useRef)(function(){return e.onCancel()}),v=(0,h.useRef)(function(){b({disableButtons:!0}),t(!0)}),_=(0,h.useRef)(function(){b({disableButtons:!0}),e.onContinue(e.id,e.accountNumber)});if(!c||!d)return(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:(0,i.jsx)(l.a,{className:"blue"})})});var f=c.closeButton,j=c.continueButton,w=c.rescheduleButton,S=c.cancelSuccessTitle,C=c.cancelSuccessBody,D=c.cancelDispatchedTitle,k=c.cancelDispatchedBody,M=c.cancelErrorTitle,A=c.cancelErrorBody,R=c.cancelMvpTitle,T=c.cancelMvpBody,P=c.cancelRescheduleReasonsBlock,G=P.cancelParagraph,q=P.cancelReasonsDropdownPlaceholder,U=P.customerCancelReasons,H=P.cancelModalContinueLabel,V=P.cancelModalCancelLabel,W=P.cancelDropdownLabel,X=P.agentCancelReasons,J=P.cancelParagraphAgent,Q=P.rescheduleTitleAgent,$=P.rescheduleParagraphAgent,K=P.rescheduleReasonsDropdownPlaceholder,z=P.agentRescheduleReasons,ee=P.rescheduleModalContinueLabel,ea=P.rescheduleModalCancelLabel,en=P.rescheduleDropdownLabel;if(s&&e.status===o.gn7.NEW_MVP&&!e.isAgent)return(0,i.jsx)(L.DY,{children:(0,i.jsx)(L.u_,{head:(0,i.jsx)("p",{className:"bge-dialog__head__title bold",children:R}),body:(0,i.jsx)("div",{className:"bookings_body",children:F()((0,Y.ZF)(T))}),footer:(0,i.jsx)("div",{className:"bookings_footer",children:(0,i.jsx)("button",{type:"button",onClick:function(){return x.current()},className:"button primary",children:f})}),singleAction:!1,shown:s&&e.status===o.gn7.NEW_MVP&&!e.isAgent})});var et=e.isAgent?J:G,es=e.isAgent?X:U;return n?(0,i.jsx)(Z,{title:Q,paragraph:$,placeholder:K,reasons:z,continueButton:ee,cancelButton:ea,label:en,onClose:function(){e.onReschedule(e.id,r),t(!1),x.current()},onCancel:function(){x.current(),t(!1)},shown:n}):d.cancelError?(0,i.jsx)(L.DY,{children:(0,i.jsx)(L.u_,{head:(0,i.jsx)("p",{className:"bge-dialog__head__title bold",children:M}),body:(0,i.jsx)("div",{className:"bookings_body",children:F()((0,Y.ZF)(A))}),footer:(0,i.jsx)("div",{className:"bookings_footer",children:(0,i.jsx)("button",{type:"button",onClick:function(){return x.current()},className:"button primary",children:f})}),singleAction:!1,shown:d.cancelError})}):d.cancelSuccess?(0,i.jsx)(L.DY,{children:(0,i.jsx)(L.u_,{head:(0,i.jsx)("p",{className:"bge-dialog__head__title bold",children:S}),body:(0,i.jsxs)("div",{className:"booking__success",children:[(0,i.jsx)("div",{className:"booking__circle",children:(0,i.jsx)("span",{children:(0,i.jsx)(E.dR,{fillColour:"white",width:90,height:90})})}),F()((0,Y.ZF)(C))]}),footer:(0,i.jsx)("button",{type:"button",onClick:function(){return x.current()},className:"button primary",children:f}),singleAction:!0,shown:d.cancelSuccess})}):(0,i.jsx)(L.DY,{children:(0,i.jsx)(L.u_,{head:(0,i.jsxs)(i.Fragment,{children:[e.status===o.gn7.DISPATCHED&&(0,i.jsx)("p",{className:"bge-dialog__head__title bold",children:D}),e.status!==o.gn7.DISPATCHED&&(0,i.jsx)("p",{className:"bge-dialog__head__title bold",children:e.isAgent?P.cancelTitleAgent:P.cancelTitle})]}),body:(0,i.jsx)("div",{className:"bookings_body",children:e.status===o.gn7.DISPATCHED?F()(k,(0,Y.Em)({replaceTagNames:"p"})):(0,i.jsx)(O,{paragraph:et,placeholder:q,reasons:es,continueButton:H,cancelButton:V,label:W,shown:e.status!==o.gn7.DISPATCHED})}),footer:(0,i.jsxs)("div",{className:"bookings_footer",children:[(0,i.jsx)("button",{type:"button",onClick:function(){return x.current()},disabled:p.disableButtons,className:I()("button",{disabled:p.disableButtons,primary:e.status===o.gn7.DISPATCHED}),children:f}),e.status!==o.gn7.DISPATCHED&&(0,i.jsxs)(i.Fragment,{children:[!(u&&u.isBreakdown)&&(0,i.jsx)("button",{type:"button",onClick:function(){return v.current()},disabled:p.disableButtons,className:I()("button secondary ",{disabled:p.disableButtons}),children:w}),(0,i.jsx)("button",{type:"button",onClick:function(){return _.current()},disabled:p.disableButtons,className:I()("button primary arrow",{disabled:p.disableButtons,loading:d.cancelSubmitting}),children:j})]})]}),singleAction:!1,shown:e.defaultShown})})},V=n(50797),W=n(92540),X=function(e){var a,n=e.accountNumber,t=e.premiseId,s=(0,h.useState)(!1),i=s[0],r=s[1],l=(0,g.useDispatch)(),c=(0,g.useSelector)((0,y.selectBookings)("".concat(n,"-").concat(t)),g.shallowEqual),u=(0,g.useSelector)((0,y.selectBookingsFiltered)("".concat(n,"-").concat(t)),g.shallowEqual);return(0,h.useEffect)(function(){c.loaded||c.loading||l((0,d.serviceBookingAppointmentBookingForAccountAction)({accountNumber:n,isBusinessServicesUser:!0,premiseId:t}))},[]),(0,h.useEffect)(function(){if(u.bookings){var e=Math.ceil((u.bookings.length||0)/o.vj9);r(c.pageNumber<e)}},[c.pageNumber,null===(a=u.bookings)||void 0===a?void 0:a.length]),{bookingsState:c,bookingsStateFiltered:u||{loaded:!1},loadMoreVisible:i}},J=function(e){var a=e.accountNumber,n=e.premiseId,t=e.content,s=X({accountNumber:a,premiseId:n}).bookingsState;if(!s.loaded)return(0,i.jsx)(l.a,{className:"blue large"});var r=s.error,o=s.bookings;return r||!Array.isArray(o)?(0,i.jsx)("span",{className:"bookings__unavailable",children:F()(t.bookingsUnavailable)}):0===o.length?(0,i.jsx)("p",{children:"No bookings found for this premise."}):(0,i.jsxs)("table",{className:"business-services-booking-item__table",children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{children:t.bookingJobTypeLabel}),(0,i.jsx)("th",{children:t.bookingAppointmentLabel}),(0,i.jsx)("th",{children:t.bookingStatusLabel})]})}),(0,i.jsx)("tbody",{children:o.map(function(e){return(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"business-services-booking-item__value",children:e.type}),(0,i.jsx)("td",{className:"business-services-booking-item__value",children:e.scheduledDateTime}),(0,i.jsx)("td",{className:"business-services-booking-item__value",children:e.statusLabel})]},"business-service-booking-".concat(e.id))})})]})},Q=function(e){var a=e.accountNumber,n=e.premise,t=e.content,s=e.isOpenByDefault,r=(0,h.useState)(s),l=r[0],o=r[1],c=function(){return o(function(e){return!e})},d=n.premisesId,u=n.premiseAddress;return(0,i.jsxs)("div",{className:"business-services-booking-item__container",children:[(0,i.jsxs)("div",{className:"business-services-booking-item__header",children:[(0,i.jsx)("p",{className:"business-services-booking-item__address",children:u}),(0,i.jsx)("button",{onClick:c,className:I()("button large new-brand inline secondary arrow mobile-icon-only",{"arrow--down":!l,"arrow--up":l}),id:"toggle-service-booking-premise-".concat(d),children:(0,i.jsx)("span",{className:"hide-for-small",children:t.bookingDetailsButtonLabel})})]}),l&&(0,i.jsx)(J,{accountNumber:a,premiseId:n.premisesId,content:t})]})};n(6964);var $=n(51603),K=n(10165),z=n(12436),ee=n.n(z),ea=[{name:"Default",value:"all"},{name:"A-Z",value:"az"},],en=function(e){var a=e.businessBookingFiltering,n=e.premises,t=e.onFilter,s=(0,h.useState)(n),i=s[0],r=s[1],l=(0,h.useState)(""),o=l[0],c=l[1],d=(0,h.useState)(ea[0]),u=d[0],m=d[1];(0,h.useEffect)(function(){var e=new Map;
1i.forEach(function(a){e.has(a.premisesId)||e.set(a.premisesId,a)}),"az"===u.value?t(Array.from(e.values()).sort(function(e,a){return e.premiseAddress.localeCompare(a.premiseAddress)})):t(Array.from(e.values()))},[i,u]);var g=(0,h.useRef)(ee()(function(e){e.length>=a.minimumCharacters?r(n.filter(function(a){var n,t,s,i;return(null===(n=a.eircode)||void 0===n?void 0:n.includes(e))||(null===(t=a.premiseAddress)||void 0===t?void 0:t.toLowerCase().includes(e.toLowerCase()))||(null===(s=a.gprn)||void 0===s?void 0:s.includes(e))||(null===(i=a.mprn)||void 0===i?void 0:i.includes(e))})):r(n)},300)),p=function(){o?(g.current(""),c("")):g.current(o)};return{filterValue:o,onTabChange:function(e){var a=e.target.value,n=null==ea?void 0:ea.find(function(e){return e.value===a});n&&m(n)},onFilterChange:function(e){var a=e.target?e.target.value:e.currentTarget.value;g.current(a),c(a)},onIconClick:p,Tabs:ea,currentTab:u}},et=n(63397),es=function(e){var a,n=e.businessBookingFiltering,t=en({businessBookingFiltering:n,premises:e.premises,onFilter:e.onFilter}),s=t.filterValue,r=t.onTabChange,l=t.onFilterChange,o=t.onIconClick,c=t.Tabs,d=t.currentTab,u=n.input;return(0,i.jsxs)("div",{className:"booking-list__filter",children:[(0,i.jsx)("div",{className:"booking-list__filter__tabbed-container",children:(0,i.jsx)(K.NF,{isNewBrand:!0,onChange:r,name:"payment-options",currentValue:d.value,values:c,title:"Sort",isVertical:!1})}),(0,i.jsx)("div",{className:"filter-search",children:(0,i.jsx)(et.J9,{initialValues:{},onSubmit:function(){},children:(0,i.jsx)($.af,{inputClassName:"input-section--no-m",placeholder:u.placeholder,value:s,name:"filter",id:"filter",isRequired:!1,groupClassName:"group--wider group--bigger-input",isNumeric:u.isNumericOnly,onChange:l,maxLength:u.maxLength,icon:(0,i.jsx)("button",{onClick:o,className:"filter__icon","data-testid":"filter-icon",children:s?(0,i.jsx)(E.XJ,{fillColour:"#4D4D4F",height:24,width:24}):(0,i.jsx)(E.lp,{height:24,width:24})}),ariaLabel:u.label})})})]})},ei=function(e){var a,n,t=e.content,s=e.premises,r=e.accountNumber,o=function(e){b(e)},c=(0,h.useState)([]),d=c[0],u=c[1],m=(0,W.Yh)(),g=(0,h.useState)(1),p=g[0],b=g[1],x=function(e){u(e),b(1)};if(!m.isContentLoaded||!(null===(a=m.content)||void 0===a?void 0:a.businessBookingFiltering))return(0,i.jsx)(l.a,{className:"blue loader-container--bigger"});var v=(p-1)*10,_=d.slice(v,v+10);return(0,i.jsxs)("section",{className:"business__bookings__premise__list new-brand",children:[(0,i.jsx)(es,{businessBookingFiltering:null===(n=m.content)||void 0===n?void 0:n.businessBookingFiltering,premises:s,onFilter:x}),_.map(function(e,a){return(0,i.jsx)(Q,{content:t,premise:e,isOpenByDefault:0===a,accountNumber:r},"booking-premise-".concat(e.premisesId))}),d.length>10&&(0,i.jsx)("div",{className:"accounts-list__pagination__wrapper",children:(0,i.jsx)(V.t,{itemsPerPage:10,items:d.length,currentPage:p,onPageClick:o})})]})},er=n(42598),el=function(e){var a,n=e.accountNumber,t=e.mprnGprnIndex,s=e.account,l=e.endDate,o=e.bookingsSectionContent,c=o.title,d=o.newBookingLabel,u=o.newBookingUrl,m=o.subTitle,h=o.paragraph,p=o.sideContent,b=o.bookNow,x=o.cancel,v=o.reschedule,_=o.status,f=o.bookingsUnavailable,j=o.repairTitle,N=o.repairParagraph,y=o.bookRepairButtonLabel,w=o.showMore,S=o.cancelRescheduleReasonsBlock,E=o.serviceAccountBookingTitle,A=o.bookingDetailsButtonLabel,B=o.bookingJobTypeLabel,L=o.bookingAppointmentLabel,R=o.bookingStatusLabel,T=e.cancelState,P=e.bookingsState,O=e.loadMoreVisible,Z=e.planNameCode,G=e.productCatalogItem,q=e.onCancel,Y=e.onContinue,V=e.handleCancel,W=e.onReschedule,X=e.handleViewMore,J=e.onRepairButtonClick,Q=e.isNewBrand,$=void 0!==Q&&Q,K=e.isBusinessServicesUser,z=null==Z?void 0:null===(a=Z.breakdownProductOffer)||void 0===a?void 0:a.productC
1ode,ee=(0,g.useSelector)((0,k.BW)(null==s?void 0:s.accountId),g.shallowEqual),ea=(0,g.useSelector)((0,k.RS)(s),g.shallowEqual);return K?(0,i.jsx)("div",{className:"main-container",children:(0,i.jsxs)(r.Zb,{children:[(0,i.jsx)("header",{className:"business-services-booking_header",children:(0,i.jsx)("h3",{className:"business-services-booking_header__title",children:E})}),(0,i.jsx)(ei,{premises:s.premises,accountNumber:n,content:{status:_,bookingsUnavailable:f,showMore:w,serviceAccountBookingTitle:E,bookingDetailsButtonLabel:A,bookingJobTypeLabel:B,bookingAppointmentLabel:L,bookingStatusLabel:R},bookingsState:P})]})}):(0,i.jsx)("div",{className:I()({"new-brand":$}),children:(0,i.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,i.jsxs)("div",{className:"col-2 col-2--min684-desktop",children:[(0,i.jsxs)("header",{children:[$?(0,i.jsx)("h3",{className:I()("bookings__title",{"section-header__title":$}),children:(0,i.jsx)("strong",{children:c})}):(0,i.jsx)("h3",{className:"section-header__title",children:c}),(0,i.jsx)(D.j,{label:d,url:u,className:"primary arrow button--fatter",isWide:!1,isWideMobile:!0})]}),(0,i.jsxs)("section",{className:"bookings__paragraph__container",children:[(0,i.jsx)("h3",{className:I()("bookings__title",{"section-header__title":$}),children:m}),!P.error&&(0,i.jsx)("span",{children:F()(h)}),P.error&&(0,i.jsx)("span",{className:"bookings__unavailable",children:F()(f)})]}),l&&(0,er.Z)(l,new Date)&&Z&&z&&(ee||ea)&&G&&(0,i.jsxs)("div",{className:"booking__item booking__item--repair",children:[(0,i.jsx)("div",{className:"booking__item__title",children:j}),F()(N.replace("$1",Z.label)),(0,i.jsx)("div",{className:"booking__item__footer",children:(0,i.jsx)("button",{onClick:function(){var e=s.premises[0];J(G.id,(0,M.Tg)(e.premiseAddress,e.eircode?e.eircode:""),s)},"aria-label":y,className:"button primary arrow inline",children:y})})]}),!P.error&&(0,i.jsx)(U,{accountNumber:n,mprnGprnIndex:t,content:{bookNow:b,cancel:x,reschedule:v,status:_,showMore:w,cancelRescheduleReasonsBlock:S},bookingsState:P,loadMoreVisible:O,handleCancel:V,onReschedule:W,handleViewMore:X,isNewBrand:$})]}),(0,i.jsx)(i.Fragment,{children:$?(0,i.jsx)(C.c,{title:p.title,children:(0,i.jsx)("div",{className:"side__richtext",children:F()(p.paragraph)})}):(0,i.jsx)("div",{className:"col-1",children:(0,i.jsx)("div",{className:"side side--mobile",children:(0,i.jsxs)("div",{className:"side__info",children:[(0,i.jsx)("h3",{className:"side__title",children:p.title}),(0,i.jsx)("div",{className:"side__richtext",children:F()(p.paragraph)})]})})})}),T.showCancelModal&&(0,i.jsx)(H,{onCancel:q.current,onContinue:Y.current,onReschedule:W,id:T.id,status:T.status,accountNumber:n,defaultShown:T.showCancelModal})]})})},eo=function(e){var a=e.accountNumber,n=e.mprnGprnIndex,o=e.account,c=o.startOptionCode,d=o.premises,u=e.isNewBrand,m=S({accountNumber:a,startOptionCode:c,premises:d}),h=f({accountNumber:a,mprnGprnIndex:n}),g=m.bookingsSectionContent,p=m.bookingsStateFiltered,b=m.bookingsState;return g.loaded&&p.loaded&&b.loaded?(0,i.jsx)(el,(0,s.Z)((0,t.Z)({},e,m,h),{isNewBrand:void 0!==u&&u})):m.isBusinessServicesUser?(0,i.jsx)(r.Zb,{children:(0,i.jsx)(l.a,{className:"blue loader-container--bigger"})}):(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:(0,i.jsx)(l.a,{className:"blue loader-container--bigger"})})})};n(80321),n(85145),n(23422),n(19526),n(84597),n(1195),n(56009),n(67345),n(53740),n(4054),n(17009),n(65413)},5192:function(e,a,n){"use strict";n.d(a,{I:function(){return F},X:function(){return O}});var t,s=n(70865),i=n(96670),r=n(52322),l=n(10420),o=n(27348),c=n(30156),d=n(26297);n(45387);var u=n(36787),m=n(50741),h=n(21980),g=n(96923),p=n(25340),b=n(17252),x=n(30717),v=n(3854),_=n(48939),f=n(47934),j=n(79962);n(22702);var N=n(50862),y=n(84597),w=n(6440),S=n(13922),C=n(29051),D=function(e){var a=e.details,n=e.tooltipLabel,t=e.accountId,s=(0,C.useSelector)(w.xE,C.shallowEqual),i=(0,l.oA)(t),o=i.lastBill,c=i.amountStr,d=i.dateStr,u=i.prevAmount,m=i.prevLastBill,h=i.showFromToBillDate,g=i.billCardNextDate,p=i.nextBillDate,b=s.content,x=s.loaded,v=(0,l.QV)().submissionType;if(void 0===a||!b||!x)return(0,r.jsx)("div",{className:"billcard",children:(0,r.jsx)(N.a,{className:"blue"})});var _=e.billTitle,f=e.billActionLabel,j=e.issuedLabel,D=e.noBillsAvailableLabel,k=e.previousBillLabel,M=e.nextBillLabel,E=e.nextBillDateLabel;return(0,r.jsxs)("div",{className:"billcard",onClick:e.onClick,onKeyDown:e.onClick,tabIndex:0,children:[(0,r.jsx)("div",{className:"billcard__highlight billcard__title",children:_}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"billcard__amount",children:c}),(0,r.jsx)("td",{children:v&&(0,r.jsx)("div",{className:"billcard__submissionType",children:(0,r.jsx)("div",{children:v})})})]})})}),o?(0,r.jsxs)("div",{className:"billcard__issued",children:[j,"\xa0",(0,r.jsx)("span",{className:"billcard__date",children:d})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(S.bG,{title:"alert icon null",fillColour:"#4D4D4F",svgClassName:"noBills__icon"}),D]}),(0,r.jsx)("table",{className:"billcard__previous-amount",children:(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{className:"billcard__previous-bill",children:k})}),(0,r.jsx)("td",{children:h?(0,r.jsx)("div",{className:"billcard__next-bill",children:M}):p&&(0,r.jsx)("div",{className:"billcard__next-bill",children:E})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{"data-testid":"billcard-amount",className:"billcard-prev-amount-value",children:[u,!m&&(0,r.jsx)(y.u,{infoIcon:!0,className:"bill__tooltip",title:n,trigger:"mouseenter"})]}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{className:"billcard__next-date",children:g})})]})]})}),(0,r.jsx)("table",{className:"billcard__action-row",children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:e.onClick,className:"billcard__action",children:f})}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:e.onClick,className:"billcard__arrow","aria-label":"".concat(f," button"),children:(0,r.jsx)(S.Eh,{closed:!0,fillColour:"#ffffff"})})})]})})})]})};n(16088);var k=function(e){var a=e.status,n=e.amount,t=e.period,s=e.costMissingLastYearDataLabel,i=(0,r.jsxs)("div",{className:"costcard__amount-period",children:[(0,r.jsx)("div",{className:"costcard__amount",children:n}
1),(0,r.jsxs)("div",{className:"costcard__period",children:["on ",(0,r.jsx)("span",{children:t})]})]});switch(a){case"up":return(0,r.jsxs)("div",{className:"costcard__item",children:[(0,r.jsx)(S.lg,{title:"up icon",fillColour:"#b70030",svgClassName:"costcard__icon"}),i]});case"down":return(0,r.jsxs)("div",{className:"costcard__item",children:[(0,r.jsx)(S.uC,{title:"down icon",fillColour:"#39b54a",svgClassName:"costcard__icon"}),i]});case"neutral":return(0,r.jsxs)("div",{className:"costcard__item",children:[(0,r.jsx)(S.tP,{title:"neutral icon",fillColour:"#4D4D4F",svgClassName:"costcard__icon"}),i]});case"nodata":return(0,r.jsxs)("div",{className:"costcard__item",children:[(0,r.jsx)(S.bG,{title:"alert icon",fillColour:"#4D4D4F",svgClassName:"costcard__icon nodata"}),(0,r.jsxs)("div",{className:"costcard__amount-period nodata",children:[(0,r.jsx)("div",{className:"costcard__amount",children:n}),(0,r.jsxs)("div",{className:"costcard__period",children:["on ",(0,r.jsx)("span",{children:t}),(0,r.jsx)(y.u,{infoIcon:!0,className:"costcard__tooltip",title:s,trigger:"mouseenter"})]})]})]});default:return(0,r.jsxs)("div",{className:"costcard__item",children:[(0,r.jsx)(S.bG,{title:"alert icon",fillColour:"#4D4D4F",svgClassName:"costcard__icon"}),i]})}},M=function(e){var a=(0,l.Io)(e.thresholdDays),n=a.lastBillAmountAndStatus,t=a.lastYearAmountAndStatus,s=a.content,i=a.loaded,o=e.costActionLabel,c=e.costTitle,d=e.costLastBillLabel,u=e.costLastYearLabel,m=e.costMissingLastYearDataLabel;return s&&i?(0,r.jsxs)("div",{className:"costcard",onClick:e.onClick,onKeyDown:e.onClick,tabIndex:0,children:[(0,r.jsx)("div",{className:"costcard__highlight costcard__title",children:c}),(0,r.jsx)(k,{status:null==n?void 0:n.status,amount:null==n?void 0:n.diff,costMissingLastYearDataLabel:m,period:d}),(0,r.jsx)("div",{className:"costcard__spacer"}),(0,r.jsx)(k,{status:null==t?void 0:t.status,amount:null==t?void 0:t.diff,costMissingLastYearDataLabel:m,period:u}),(0,r.jsx)("table",{className:"costcard__action-row",children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:e.onClick,className:"costcard__action",children:o})}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:e.onClick,className:"costcard__arrow","aria-label":"".concat(o," button"),children:(0,r.jsx)(S.Eh,{closed:!0,fillColour:"#ffffff"})})})]})})})]}):(0,r.jsx)("div",{className:"costcard",children:(0,r.jsx)(N.a,{className:"blue"})})};n(10968);var E=n(42046),A=function(e){var a=e.amount,n=e.balanceClass;return a<0?(0,r.jsx)("div",{className:"paymentcard__balance",children:(0,r.jsxs)("span",{className:n||"paymentcard__balance-ammount",children:["â¬",(0,E.as)(Math.abs(a))," ",(0,r.jsx)("span",{children:"CR"})]})}):(0,r.jsx)("div",{className:"paymentcard__balance",children:(0,r.jsxs)("span",{className:"paymentcard__balance-ammount",children:["â¬",(0,E.as)(Math.abs(a))]})})},B=function(e){var a=e.details,n=e.account,t=(0,l.a0)(n.accountId,{dueByLabel:e.dueByLabel,overdueByLabel:e.overdueByLabel,noOutstandingChargesLabel:e.noOutstandingChargesLabel,overdueLabel:e.overdueLabel,futureChargeLabel:e.futureChargeLabel}),s=t.accountDueLabel,i=t.accountDueValue,o=t.accountDueKey,c=(0,l.r4)(n.accountId),d=(0,l.kJ)(n.accountId),u=(0,l.h2)(n.accountId),m=u.latestLevelPay,h=u.noNegativeBalance,g=u.isCash;if(void 0===a)return(0,r.jsx)("div",{className:"paymentcard",children:(0,r.jsx)(N.a,{className:"white"})});var p=e.account,b=p.balance,x=p.payoffBalance,v=p.isLevelPay,_=e.paymentLabel,f=e.actionLabel,j=e.paymentMethodLabel,y=e.acBalanceLabel,w=e.makePaymentLabel,C=e.upToDateLabel;return(0,r.jsxs)("div",{tabIndex:0,className:"paymentcard",onClick:function(a){g&&b>0?e.onClick(a,!0):e.onClick(a,!1)},onKeyDown:function(a){g&&b>0?e.onClick(a,!0):e.onClick(a,!1)},children:[(0,r.jsx)("div",{className:"paymentcard__highlight paymentcard__title",children:_}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsx)("tr",{children:(0,r.jsx)("td",{className:"paymentcard__amount",children:c})})})}),s&&(0,r.jsxs)("div",{className:o,children:["success"===s?(0,r.jsx)(S.fB,{height:16,width:16,fillColour:"#FFFFFF",isOutLine:!0}):s,"\xa0",(0,r.jsx)("span",{className:"paymentcard__date",children:i})]}),(0,r.jsxs)("div",{className:"paymentcard__paymentContainer",children:[(0,r.jsxs)("div",{className:"paymentcard__paymentMethodWrapper",children:[(0,r.jsx)("div",{className:"paymentcard__title paymentcard__subtitle",children:j}),(0,r.jsx)("div",{className:"paymentcard__paymentmethod",children:d})]}),(0,r.jsxs)("div",{className:"paymentcard__paymentAmountWrapper",children:[(0,r.jsx)("div",{className:"paymentcard__subtitle",children:y}),(0,r.jsx)(A,{amount:x})]})]}),(0,r.jsx)("table",{className:"paymentcard__action-row",children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:0!==h||v?(0,r.jsx)("button",{onClick:function(a){g&&b>0?e.onClick(a,!0):e.onClick},className:"paymentcard__action",children:g&&b>0?w:f}):(0,r.jsxs)("div",{className:"paymentcard__actionLabel",children:[(0,r.jsx)("span",{children:C}),(0,r.jsx)(S.Vw,{width:16,height:16,fillColour:"white"})]})}),(0,r.jsx)("td",{children:0!==h||v&&m&&0!==m.amount?(0,r.jsx)("button",{onClick:function(a){g&&b>0?e.onClick(a,!0):e.onClick},className:"paymentcard__arrow","aria-label":"".concat(g&&b>0?w:f," button"),children:(0,r.jsx)(S.Eh,{closed:!0,fillColour:"#007acc"})}):null})]})})})]})},L=n(2784),R=n(83883),T=n.n(R),I=((null===T()||void 0===T()?void 0:null===(t=T().screen)||void 0===t?void 0:t.orientation)||{}).type;function P(e){var a,n=e.accountDetails,t=e.mprnGprnIndex,c=e.setCurrentTabIndex,N=e.content,y=e.isChangingPaperless,w=e.isBusinessUser,
1S=e.isBusinessServicesUser,k=e.toggleOnOffPaperless,E=e.onSchedulePaymentPromptClick,A=n.account,R=N.paperless,T=N.dueByLabel,P=N.actionLabel,F=N.paymentLabel,O=N.noOutstandingChargesLabel,Z=N.paymentMethodLabel,G=N.overdueByLabel,q=N.overdueLabel,U=N.costTitle,Y=N.costSubtitle,H=N.costActionLabel,V=N.costLastBillLabel,W=N.costLastYearLabel,X=N.costMissingLastYearDataLabel,J=N.accountCard,Q=N.futureChargeLabel,$=N.acBalanceLabel,K=N.previousBillTitle,z=N.previousBillActionTitle,ee=N.previousBillCardLabel,ea=N.nextBillLabel,en=N.previousBillTooltip,et=N.noBillAvailableLabel,es=N.previousBillCardIssuedLabel,ei=N.upToDateLabel,er=N.makePaymentLabel,el=N.thresholdDays,eo=N.meterReadBox,ec=N.nextBillDateLabel,ed=N.schedulePaymentPromptMessageNew,eu=N.schedulePaymentPromptMessageExists,em=N.schedulePaymentPromptLoaderText,eh=N.schedulePaymentPromptShowMeText,eg=(0,g.iP)(),ep=(0,C.useSelector)((0,p.Nl)(A.accountId)),eb=null==ep?void 0:null===(a=ep.meter)||void 0===a?void 0:a.maximumExportCapacity,ex=(0,C.useSelector)(b._o,C.shallowEqual),ev="number"==typeof eg.width&&eg.width<978,e_=(0,L.useState)(0),ef=e_[0],ej=e_[1],eN=(0,l.CP)(A.accountId,t),ey=eN.name,ew=eN.gprnMprnLabel,eS=eN.mprnOrGprn,eC=(0,l.T8)(A.accountId,u.Ru),eD=eC.icon,ek=eC.badgeMicrogen,eM=(0,L.useRef)(function(e){var a=e.eventName,n=(0,d.Z)(e,["eventName"]),t=(0,i.Z)((0,s.Z)({},n),{location:"accountDetail",accountType:A.isGasAccount?"GAS":A.isElectricAccount?"ELEC":""});(0,f.Nf)(a||"RENEWAL_OFFER_NOTIFICATION",t)}),eE=(0,l.wP)().getMprnOrGprn;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"account-detail__container",children:[(0,r.jsxs)("div",{className:"account-list__item",children:[(0,r.jsxs)("h1",{className:"main-title main-title--d-f normal--m-b",children:[eD,(0,r.jsx)("span",{className:"billsummary__main-title",children:ey}),ek]}),(0,r.jsxs)("div",{className:"billsummary__overview",children:[(0,r.jsx)("div",{className:"billsummary__address","data-cs-mask":!0,children:A.premises[t].premiseAddress}),(0,r.jsx)("table",{children:(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{className:"billsummary__account",children:[(0,r.jsx)("td",{children:"Account"}),(0,r.jsx)("td",{className:"billsummary__id","data-cs-mask":!0,children:A.accountId})]}),(0,r.jsxs)("tr",{className:"billsummary__account",children:[(0,r.jsx)("td",{children:ew}),(0,r.jsx)("td",{className:"billsummary__id","data-cs-mask":!0,children:eS})]})]})}),((null==ep?void 0:ep.eligibility)===v.K5.Eligible||A.hasExportCapability)&&(0,r.jsxs)("div",{className:"billsummary__account",children:[(0,r.jsx)("span",{children:null==ex?void 0:ex.maximumExportCapacityLabel}),(0,r.jsx)("span",{className:"billsummary__id",children:eb&&"".concat(Number(eb).toFixed(2)," ").concat((null==ex?void 0:ex.maximumExportCapacityUnit)?null==ex?void 0:ex.maximumExportCapacityUnit:"KW")})]}),A.isResidentialAccount&&(A.isElectricAccount||A.isGasAccount)&&(0,r.jsx)("div",{className:"latestBillSummary__change__plan",children:(0,r.jsx)(m.o,{accountId:A.accountId,premiseId:A.premises[0].premisesId,mprnGprnIndex:Number(t),address:A.premises[t].premiseAddress})}),A&&A.serviceStatus&&A.serviceStatus===x.$J.ACTIVE&&A.isResidentialAccount&&(A.isElectricAccount||A.isGasAccount)&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.Mj,{accountCard:J,accountId:A.accountId,onTrackEvent:eM.current})}),(0,r.jsx)(o.jh,{showInProgress:!0,account:A}),A.allowScheduledPayments&&(0,r.jsx)(o.wt,{accountId:A.accountId,schedulePaymentPromptMessageNew:ed,schedulePaymentPromptMessageExists:eu,schedulePaymentPromptLoaderText:em,schedulePaymentPromptShowMeText:eh,onSchedulePaymentPromptClick:E})]})]}),(0,r.jsx)(j.S7,{children:function(e){var a=e.isMobile,t=e.isTablet;return a&&eg&&eg.width&&eg.width<1733||t&&"portrait-primary"===I&&ev||ev?(0,r.jsx)("div",{className:"billsummary__row-container",children:(0,r.jsxs)(h.Z,{setSlideShown:ej,slideShown:ef,children:[(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(B,{account:A,details:n,onClick:function(e,a){if(e.stopPropagation(),0!==ef)ej(0);else if(e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){if(a){c(3);var n=document.getElementById("payment-options");n.click(),(0,_.k)(n,!0)}else{c(0);var t=document.getElementById("bills-activity");(0,_.k)(t,!0)}}},dueByLabel:T,paymentLabel:F,noOutstandingChargesLabel:O,actionLabel:P,paymentMethodLabel:Z,overdueByLabel:G,overdueLabel:q,futureChargeLabel:Q,acBalanceLabel:$,upToDateLabel:ei,makePaymentLabel:er})}),(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(D,{accountId:A.accountId,details:n,onClick:function(e){if(e.preventDefault(),1!==ef)ej(1);else if(e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){c(0);var a=document.getElementById("bills-activity");(0,_.k)(a,!0)}},billTitle:K,billActionLabel:z,issuedLabel:es,noBillsAvailableLabel:et,tooltipLabel:en,previousBillLabel:ee,nextBillLabel:ea,nextBillDateLabel:ec})}),(0,r.jsx)("div",{className:"billsummary__item-last",children:(0,r.jsx)(M,{costTitle:U,costSubtitle:Y,costActionLabel:H,costLastBillLabel:V,costLastYearLabel:W,costMissingLastYearDataLabel:X,onClick:function(e){if(2!==ef)ej(2);else if(e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){c(1);
1var a=document.getElementById("cost-usage");a.click(),(0,_.k)(a,!0)}},thresholdDays:el})})]})}):(0,r.jsxs)("div",{className:"billsummary__row-container",children:[(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(B,{account:A,details:n,onClick:function(e,a){if(e.stopPropagation(),e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){if(a){c(3);var n=document.getElementById("payment-options");n.click(),(0,_.k)(n,!0)}else{c(0);var t=document.getElementById("bills-activity");(0,_.k)(t,!0)}}},dueByLabel:T,paymentLabel:F,noOutstandingChargesLabel:O,actionLabel:P,paymentMethodLabel:Z,overdueByLabel:G,overdueLabel:q,futureChargeLabel:Q,acBalanceLabel:$,upToDateLabel:ei,makePaymentLabel:er})}),(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(D,{accountId:A.accountId,details:n,onClick:function(e){if(e.preventDefault(),e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){c(0);var a=document.getElementById("bills-activity");(0,_.k)(a,!0)}},billTitle:K,billActionLabel:z,issuedLabel:es,noBillsAvailableLabel:et,tooltipLabel:en,previousBillLabel:ee,nextBillLabel:ea,nextBillDateLabel:ec})}),(0,r.jsx)("div",{className:"billsummary__item-last",children:(0,r.jsx)(M,{costTitle:U,costSubtitle:Y,costActionLabel:H,costLastBillLabel:V,costLastYearLabel:W,costMissingLastYearDataLabel:X,onClick:function(e){if(e.preventDefault(),e.target.toString().includes("HTMLButtonElement")||e.target.toString().includes("SVGSVGElement")||e.target.toString().includes("SVGPolygonElement")){c(1);var a=document.getElementById("cost-usage");a.click(),(0,_.k)(a,!0)}},thresholdDays:el})})]})}})]}),(0,r.jsx)(j.S7,{children:function(e){var a=e.isDesktop;return(0,r.jsx)("div",{className:a&&A.isResidentialAccount||A.isPaperlessBusinessAccount?"account-detail__container":"",children:(0,r.jsx)(o.$I,(0,i.Z)((0,s.Z)({isBillSummaryEnabled:!0},R),{account:A,isBusiness:w,isBusinessServicesUser:S,bottomRightContent:(0,r.jsx)(o.uP,{accountDetails:n,accountCard:J}),isDetail:!0,toggleOnOffFunction:k,isChangingPaperless:y,mprnOrGprn:A.isGasAccount||A.isHomeServicesAccount?eE(A.premises[t].mprn,A.premises[t].gprn):A.premises[t].mprn,accountCard:J,startOptionCode:A.startOptionCode,isLevelPay:A.isLevelPay,isPaperLess:A.isPaperLess,meterReadBox:eo,schedulePaymentPromptMessageNew:ed,schedulePaymentPromptMessageExists:eu,schedulePaymentPromptLoaderText:em,schedulePaymentPromptShowMeText:eh,onSchedulePaymentPromptClick:E}))})}})]})}var F=function(e){var a=e.content,n=e.accountDetails,t=e.mprnGprnIndex,d=e.toggleOnOffPaperless,u=e.setCurrentTabIndex,m=e.onSchedulePaymentPromptClick,h=(0,l.bP)(n.account.accountId),g=(0,C.useSelector)(c.zN),p=(0,C.useSelector)(c.k8),b=(0,C.useSelector)(c.G6),x=a.paperless,v=a.accountCard,_=a.meterReadBox,f=a.schedulePaymentPromptMessageNew,j=a.schedulePaymentPromptMessageExists,N=a.schedulePaymentPromptLoaderText,y=a.schedulePaymentPromptShowMeText,w=n.account,S=(0,l.wP)().getMprnOrGprn;return(0,r.jsx)("span",{className:"new-brand",children:h?(0,r.jsx)(P,{accountDetails:n,mprnGprnIndex:t,setCurrentTabIndex:u,onSchedulePaymentPromptClick:m,content:a,isChangingPaperless:b.account.isChangingPaperless,isBusinessUser:g,isBusinessServicesUser:p,toggleOnOffPaperless:d}):(0,r.jsx)("div",{className:"account-detail__container",children:(0,r.jsx)(o.$I,(0,i.Z)((0,s.Z)({isBillSummaryEnabled:!1},x),{account:w,isBusiness:g,isBusinessServicesUser:p,bottomRightContent:(0,r.jsx)(o.uP,{accountDetails:n,accountCard:v}),isDetail:!0,toggleOnOffFunction:d,isChangingPaperless:b.account.isChangingPaperless,mprnOrGprn:w.isGasAccount||w.isHomeServicesAccount?S(w.premises[t].mprn,w.premises[t].gprn):w.premises[t].mprn,accountCard:v,startOptionCode:w.startOptionCode,isLevelPay:w.isLevelPay,isPaperLess:w.isPaperLess,meterReadBox:_,schedulePaymentPromptMessageNew:f,schedulePaymentPromptMessageExists:j,schedulePaymentPromptLoaderText:N,schedulePaymentPromptShowMeText:y,onSchedulePaymentPromptClick:m,isNewBrand:!0}))})})},O=function(e){var a=e.accountDetails,n=e.content,t=e.onPaymentCardClick,s=e.onBillCardClick,i=e.onCostCardClick,o=(0,C.useDispatch)(),c=(0,L.use
1State)(0),d=c[0],u=c[1],m=(0,l.Jk)().loaded;(0,L.useEffect)(function(){!m&&a&&a.account&&o(w.gu.getBills(a.account.accountId))},[a,m]);var g=a.account,p=n.dueByLabel,b=n.actionLabel,x=n.paymentLabel,v=n.noOutstandingChargesLabel,_=n.paymentMethodLabel,f=n.overdueByLabel,j=n.overdueLabel,N=n.costTitle,y=n.costSubtitle,S=n.costActionLabel,k=n.costLastBillLabel,E=n.costLastYearLabel,A=n.costMissingLastYearDataLabel,R=n.futureChargeLabel,T=n.acBalanceLabel,I=n.previousBillTitle,P=n.previousBillActionTitle,F=n.previousBillCardLabel,O=n.nextBillLabel,Z=n.previousBillTooltip,G=n.noBillAvailableLabel,q=n.previousBillCardIssuedLabel,U=n.upToDateLabel,Y=n.makePaymentLabel,H=n.thresholdDays,V=n.nextBillDateLabel;return(0,r.jsx)("div",{className:"billsummary__row-container new-brand",children:(0,r.jsxs)(h.Z,{setSlideShown:u,slideShown:d,children:[(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(B,{account:g,details:a,onClick:function(e,a){null==e||e.stopPropagation(),0!==d&&u(0),t(!!a)},dueByLabel:p,paymentLabel:x,noOutstandingChargesLabel:v,actionLabel:b,paymentMethodLabel:_,overdueByLabel:f,overdueLabel:j,futureChargeLabel:R,acBalanceLabel:T,upToDateLabel:U,makePaymentLabel:Y})}),(0,r.jsx)("div",{className:"billsummary__item",children:(0,r.jsx)(D,{accountId:g.accountId,details:a,onClick:function(e){null==e||e.stopPropagation(),1!==d&&u(1),s()},billTitle:I,billActionLabel:P,issuedLabel:q,noBillsAvailableLabel:G,tooltipLabel:Z,previousBillLabel:F,nextBillLabel:O,nextBillDateLabel:V})}),(0,r.jsx)("div",{className:"billsummary__item-last",children:(0,r.jsx)(M,{costTitle:N,costSubtitle:y,costActionLabel:S,costLastBillLabel:k,costLastYearLabel:E,costMissingLastYearDataLabel:A,onClick:function(e){null==e||e.stopPropagation(),2!==d&&u(2),i()},thresholdDays:H})})]})})}},15482:function(e,a,n){"use strict";n.d(a,{V:function(){return u}});var t=n(52322);n(82483);var s=n(13922),i=n(6228),r=n(12524),l=n.n(r),o=n(72670),c=n.n(o),d=n(2784),u=function(e){var a=e.title,n=e.infoPanelText,r=e.icon,o=e.defaultExpanded,u=e.isAccordion,m=void 0===u||u,h=e.isNewBrand,g=e.greyStyle,p=(0,d.useState)(!m||void 0!==o&&o),b=p[0],x=p[1],v=function(){m&&x(!b)};return(0,t.jsxs)("div",{className:l()("info-panel__main",{"new-brand":void 0!==h&&h,"is-accordion":m,"has-icon":r,"grey-style":void 0!==g&&g}),onClick:v,role:"presentation",children:[(0,t.jsxs)("div",{className:"info-panel__row",children:[r&&(0,t.jsx)("div",{className:"info-panel__icon",children:r}),(0,t.jsx)("div",{className:"info-panel__title",children:a}),m&&(0,t.jsx)("div",{className:"info-panel__chevron",children:(0,t.jsx)(s.x,{fillColour:"#007acc",className:b?"info-panel__chevron-circle-down":"info-panel__chevron-circle-up"})})]}),b&&(0,t.jsx)("div",{className:"info-panel__details",children:c()(n,(0,i.Em)({replaceTagNames:"p"}))})]})}},92652:function(e,a,n){"use strict";n.d(a,{m:function(){return m},z:function(){return h}});var t=n(70865),s=n(96670),i=n(52322);n(44252);var r=n(51603),l=n(89177),o=n(13922),c=n(12524),d=n.n(c),u=n(63397),m=function(e){var a=e.submitField,n=e.digits,c=e.isNewBrand,m=void 0!==c&&c,h=n?"e.g. ".concat(Array.from({length:n},function(e,a){return a+1}).join("")):"e.g. 10";switch(a){case l.ZDB.TwentyFourHourMeterReading:case l.ZDB.DayMeterReading:case l.ZDB.NightMeterReading:case l.ZDB.PeakMeterReading:case l.ZDB.NightStorageReading:return(0,i.jsx)(u.gN,{name:a,type:"input",children:function(e){var n=e.field,c=e.form,g=e.meta.touched;return(0,i.jsx)(r.af,(0,s.Z)((0,t.Z)({},n),{type:"tel",groupClassName:d()("group--wide group--no-margin-medium",{"reading-success-group":g&&!(0,u.u9)(c.errors,n.name)}),isRequired:!0,isNumeric:!0,placeholder:h,label:l.FLz[a],touched:g,error:(0,u.u9)(c.errors,n.name),icon:g&&!(0,u.u9)(c.errors,n.name)&&(0,i.jsx)("span",{className:"reading-success-tick",children:(0,i.jsx)(o.dR,{fillColour:"#5a8b2e"})}),isNewBrand:m}))}});default:return null}};n(25730);var h=function(e){var a=e.fieldName,n=e.digits,l=e.isNewBrand,c=n?"e.g. ".concat(Array.from({length:n},function(e,a){return a+1}).join("")):"e.g.123456";return(0,i.jsx)(u.gN,{name:void 0===a?"meterReading":a,type:"input",children:function(e){var a=e.field,n=e.form,m=e.meta,h=m.touched;return(0,i.jsx)(r.af,(0,s.Z)((0,t.Z)({},a),{type:"tel",groupClassName:d()("group--wide group--no-margin-medium",{"reading-success-group":h&&!(0,u.u9)(n.errors,a.name)}),isRequired:!0,isNumeric:!0,maxLength:6,placeholder:c,label:"Gas reading",touched:m.touched,error:(0,u.u9)(n.errors,a.name),tooltip:"Please enter your gas meter reading.",icon:h&&!(0,u.u9)(n.errors,a.name)&&(0,i.jsx)("span",{className:"reading-success-tick",children:(0,i.jsx)(o.dR,{fillColour:"#5a8b2e"})}),isNewBrand:l}))}})}},49527:function(e,a,n){"use strict";n.d(a,{CB:function(){return G}});var t=n(52322),s=n(15482),i=n(25340),r=n(17252),l=n(3854),o=n(13922),c=n(29051),d=function(e){var a=e.account,n=a.hasExportCapability,d=(0,c.useSelector)((0,i.Nl)(a.accountId)),u=null==d?void 0:d.meter,m=(null==d?void 0:d.eligibility)===l.K5.IneligibleOrderIsCompleted,h=(null==d?void 0:d.eligibility)===l.K5.IneligibleForDeemedPayment,g=(0,c.useSelector)(r._o,c.shallowEqual),p=void 0,b=null==g?void 0:g.eligibilityMessage,x=n&&(null==u?void 0:u.isSmartMeter),v=n&&m&&b&&!(null==u?void 0:u.isSmartMeter),_=n&&h&&b&&!(null==u?void 0:u.isSmartMeter);return(x&&b&&(p={title:b.meteredTitle,paragraph:b.meteredParagraph}),v&&(p={title:b.deemedTitle,paragraph:b.deemedParagraph}),_&&(p={title:b.deemedNotEligibleTitle,paragraph:b.deemedNotEligibleParagraph}),p)?(0,t.jsx)("div",{className:"bills__accordion-wrapper",children:(0,t.jsx)(s.V,{title:p.title,infoPanelText:p.paragraph,icon:(0,t.jsx)(o.Zd,{fillColour:"#007acc",width:24,height:24})})}):null};n(57356),n(22078);var u=n(10420),m=n(92377),h=n(8020),g=n(39933),p=n(46363),b=n(50862),x=n(89177),v=n(96923),_=n(92540),f=n(30156),j=n(6440),N=n(67107),y=n(60134),w=n(42046),S=n(6228),C=n(79962),D=n(8498),k=n(12524),M=n.n(k),E=n(8849),A=n(98075),B=n(2784),L=function(e){var a=e.billId,n=e.accountNumber,s=e.billSummary,i=e.lastBill,r=(e.windowOpenForTest,e.isBusinessServices),l=(0,c.useSelector)((0,j.zm)(a),c.shallowEqual),d=(0,c.useSelector)((0,D.rz)("myAccountsPage")),u=(0,B.useState)(!1)[0],m=function(){if(l){var e=i===l.billId&&!!p&&(0,E.Z)(g,p)<=f;(0,window.open)("/document-download/".concat(n,"/").concat(x.qen.BILL,"/").concat(l.billId,"?isProcessing=").concat(e.toString()),"_blank","noopener")}},h=d.content,g=(0,y.Ux)(),p=l&&l.date?(0,A.Z)(l.date,x.$Mt.YYYY_MM_D,new Date):void 0;if(!h)return null;var b=h.billsAndPayments,v=b.accessibilityParagraph,_=b.downloadLabel,f=b.processingBillThreshold;if(!l)return(0,t.jsx)("button",{"data-testid":"download-button",onClick:function(){return m()},type:"button",className:s?"button secondary arrow download inline":"button secondary round round--large",children:s?(0,t.jsx)("span",{children:_}):(0,t.jsx)("i",{className:"circle-wrapper",children:r?(0,t.jsx)(o.$L,{}):(0,t.jsx)(o.UW,{})})});var N=M()("button secondary round round--large",{loading:u});return(0,t.jsx)("button",{"data-testid":"download-button","aria-label":v,onClick:function(){return m()},type:"button",className:s?"button secondary arrow download inline":N,children:s?(0,t.jsx)("span",{children:_}):(0,t.jsx)("i",{className:"circle-wrapper",children:r?(0,t.jsx)(o.$L,{}):(0,t.jsx)(o.UW,{})})})};n(23641);var R=function(e){var a=e.amount,n=e.balanceClass;return a<0?(0,t.jsx)("div",{className:"paymentcard__balance",children:(0,t.jsxs)("span",{className:n||"paymentcard__balance-ammount",children:["â¬",(0,w.as)(Math.abs(a)
1)," ",(0,t.jsx)("span",{children:"CR"})]})}):(0,t.jsx)("div",{className:"paymentcard__balance",children:(0,t.jsxs)("span",{className:"paymentcard__balance-ammount",children:["â¬",(0,w.as)(Math.abs(a))]})})};function T(e){return(0,t.jsxs)("div",{className:"latestBillSummary__error new-brand",children:[e.displayAmountPlaceholder?(0,t.jsxs)("div",{className:"latestBillSummary__placeholder",children:[(0,t.jsx)("div",{className:"latestBillSummary__title",children:"Latest bill"}),(0,t.jsx)("div",{className:"latestBillSummary__amount-submission",children:(0,t.jsx)("div",{className:"latestBillSummary__amount",children:"â¬-.--"})})]}):null,e.isLoading?(0,t.jsx)("div",{className:"latestBillSummary__error--loading",children:(0,t.jsx)(b.a,{className:"blue"})}):(0,t.jsx)("div",{className:"latestBillSummary__error-message ".concat(e.displayAmountPlaceholder?"latestBillSummary__error-message--with-placeholder":""),children:(0,t.jsx)("table",{children:(0,t.jsx)("tbody",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"latestBillSummary__error-message--icon",children:"info"===e.icon?(0,t.jsx)(o.PK,{title:"info",fillColour:"#4D4D4F"}):(0,t.jsx)(o.v3,{fillColour:"#4D4D4F"})}),(0,t.jsx)("td",{className:"latestBillSummary__error-message--label",children:e.message})]})})})})]})}function I(e){var a=e.account,n=e.showLastBillMicrogenBill,s=a.accountId,i=(0,u.QV)(a.isLevelPay),l=i.latestBill,d=i.issuedOn,m=i.from,h=i.to,g=i.submissionType,p=i.adjustments,b=i.balanceCarriedOver,x=i.accountBalanceAtTimeOfBill,v=i.billAmount,_=(0,u.h2)(s).accountDetail,f=(0,c.useSelector)(r.b2,c.shallowEqual);return(0,t.jsxs)("div",{"data-testid":"LatestBillSummary",className:"latestBillSummary new-brand",children:[(0,t.jsx)("div",{className:"latestBillSummary__title",children:"Latest bill"}),(0,t.jsxs)("div",{className:"latestBillSummary__amount-container",children:[(0,t.jsxs)("div",{className:"latestBillSummary__amount-submission",children:[(0,t.jsx)("div",{className:"latestBillSummary__amount",children:(0,t.jsx)(R,{amount:v||0,balanceClass:"latestBillSummary__amount"})}),g?(0,t.jsx)("div",{className:"latestBillSummary__submissionType",children:(0,t.jsx)("div",{children:g})}):null]}),(0,t.jsx)("div",{className:"latestBillSummary__download",children:(null==l?void 0:l.billId)&&(0,t.jsx)(L,{accountNumber:s,billId:null==l?void 0:l.billId,billSummary:!0})})]}),(0,t.jsxs)("div",{className:"latestBillSummary__issued",children:["Issued on ",(0,t.jsx)("span",{children:d})]}),(0,t.jsxs)("div",{className:"latestBillSummary__billing-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__billing-period",children:"Billing period:"}),(0,t.jsxs)("div",{className:"latestBillSummary__billing-dates",children:[m," - ",h]})]}),(0,t.jsxs)("div",{className:"latestBillSummary__balance-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__balance-label",children:"Balance carried over"}),(0,t.jsx)("div",{className:"latestBillSummary__balance-amount",children:(0,t.jsx)(R,{amount:b||0,balanceClass:"latestBillSummary__balance-amount"})})]}),(0,t.jsxs)("div",{className:"latestBillSummary__totalCharges-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__totalCharges-label",children:"Total charges for this bill"}),(0,t.jsx)("div",{className:"latestBillSummary__totalCharges-amount",children:(0,t.jsx)(R,{amount:v||0,balanceClass:"latestBillSummary__totalCharges-amount"})})]}),(0,t.jsxs)("div",{className:"latestBillSummary__adjustments-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__adjustments-label",children:"Adjustments"}),(0,t.jsx)("div",{className:"latestBillSummary__adjustments-amount",children:p})]}),(0,t.jsxs)("div",{className:"latestBillSummary__accountBalance-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__accountBalance-label",children:"Account balance"}),(0,t.jsx)("div",{className:"latestBillSummary__accountBalance-amount",children:(0,t.jsx)(R,{amount:x||0,balanceClass:"latestBillSummary__accountBalance-amount"})})]}),n&&f.latestBill&&(0,t.jsxs)("div",{className:"latestBillSummary__microgen-message",children:[(0,t.jsx)(o.Ui,{title:"Microgen",fillColour:"#00306a",width:24,height:24}),(0,t.jsxs)("div",{className:"latestBillSummary__microgen-message--text",children:[(0,t.jsx)("div",{className:"latestBillSummary__microgen-message--title",children:f.latestBill.microgenMessageTitle}),(0,t.jsx)("div",{className:"latestBillSummary__microgen-message--description",children:f.latestBill.microgenMessageDescription})]})]}),(null==_?void 0:_.levelPayPayments)&&(null==_?void 0:_.levelPayPayments.length)>0?(0,t.jsxs)("div",{className:"latestBillSummary__levelPay-container",children:[(0,t.jsx)("div",{className:"latestBillSummary__levelPay-title",children:"Next payments"}),null==_?void 0:_.levelPayPayments.map(function(e,a){return(0,t.jsxs)("div",{className:"latestBillSummary__levelPay-payment",children:["Payment of"," ",(0,t.jsx)("span",{children:(0,w.L8)((0,w.as)(e.amount))})," ","will be due on"," ",(0,t.jsx)("span",{children:(0,y.js)(new Date(e.date))})]},a)})]}):null]})}var P=n(97361),F=n(31807),O=n(72670),Z=n.n(O),G=function(e){var a=(0,C.kh)().isTablet,n=e.account,s=e.accountDetails,i=e.isBusinessServices,l=n.accountId,D=n.isQhAccount,k=n.isBusinessAccount,A=n.isHomeServicesAccount,R=n.isResidentialAccount,O=n.isLevelPay,G=n.isMandated,U=(0,_._h)(l),Y=U.fetchStatementDownload,H=U.isStatementLoading,V=!1===O&&!1===G,W=(0,c.useSelector)(r.b2,c.shallowEqual),X=(0,c.useSelector)(r.m5,c.shallowEqual),J=(0,c.useSelector)(r.Vo,c.shallowEqual),Q=(0,c.useSelector)(r.JH,c.shallowEqual),$=(0,c.useSelector)(f.zN),K=(0,c.useSelector)(r.Wo,c.shallowEqual),z=(0,c.useSelector)(r.uE,c.shallowEqual),ee=(0,c.useSelector)(r.fo,c.shallowEqual),ea=(0,c.useDispatch)(),en=(0,c.useSelector)(j.y0,c.shallowEqual),et=(0,c.useSelector)(N.cN,
1c.shallowEqual),es=(0,u.bP)(l),ei=(0,u.Jk)(),er=ei.content,el=ei.loaded,eo=ei.error,ec=ei.quantityShown,ed=ei.billsToShow,eu=ei.lastBillDate,em=ei.lastBillId,eh=ei.lastBillUrl,eg=ei.isLastBillMicrogenBill,ep=s&&s.lastBill&&s.lastBill.billId?s.lastBill.billId:"";(0,B.useEffect)(function(){el||ea(j.gu.getBills(l))},[l,ea,el]),(0,B.useEffect)(function(){ep&&es&&er&&er.length>0&&ea(j.Rv.getBill(l,ep))},[l,ep,ea,es,er]);var eb=W&&W.customErrorMessage?"customErrorMessage-".concat(W.customErrorMessage.billType,"-").concat(W.customErrorMessage.amount):"customErrorMessage",ex=(0,v.By)(eb),ev=ex.cookie,e_=ex.setCookie;if(!el||!er||!W)return(0,t.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,t.jsx)("div",{className:"col-2",children:(0,t.jsx)(b.a,{className:"blue"})})});var ef=function(){ea(j.gu.loadMore(x.le0))},ej=W.genericErrorMessage,eN=W.residentialNoBillsMessage,ey=W.businessNoBillsMessage,ew=W.homeServicesHelpBlock,eS=W.processingBillThreshold,eC=W.customErrorMessage,eD=function(){if(eg&&(null==et?void 0:et.accountPageMicrogenBillEnabled))return J;if(D)return X;if(k)return Q;if(A)return ew;if(R){if(O)return ee;if(V)return K;if(G)return z}}();if(eo&&eo.length)return(0,t.jsx)("div",{className:"col-3-section align-top no-m-t new-brand",children:(0,t.jsx)("div",{className:"col-2",children:(0,t.jsx)("p",{className:"error",children:ej})})});var ek=er.length>ec,eM=(0,y.Ux)(),eE=!!eu&&(0,E.Z)(eM,eu)<=eS,eA=q(ed,eC,ev);return(0,t.jsxs)(m.DY,{children:[eC&&(0,t.jsx)(m.u_,{isNewBrand:!0,shown:eA,singleAction:!0,head:(0,t.jsx)("strong",{className:"bge-dialog__title--waiting","data-testid":"bill-custom-error",children:eC.modal.title}),body:Z()(eC.modal.paragraph),footer:(0,t.jsx)("div",{className:"align-center",children:(0,t.jsx)("button",{onClick:function(){e_("true",eC.cookieLength?eC.cookieLength:void 0)},className:"button primary",children:eC.modal.dismissButtonLabel})})}),(0,t.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,t.jsxs)("div",{className:a?"col-3 col-3--no-padding":"col-2 col-2--no-padding",children:[(0,t.jsx)("span",{className:"new-brand",children:(0,t.jsx)(d,{account:n})}),function(){if(!(er.length>0)||!es||!en)return null;if(!1===en.loaded)return(0,t.jsx)(T,{message:e.billSummaryNotFoundLabel,displayAmountPlaceholder:!0,isLoading:!0});if(404===en.error)return(0,t.jsx)(T,{message:eE&&""===eh?e.billSummaryBillProcessingLabel:e.billSummaryNotFoundLabel,displayAmountPlaceholder:!1,isLoading:!1,icon:"info"});if(500===en.error)return(0,t.jsx)(T,{message:e.billSummaryServerErrorLabel,displayAmountPlaceholder:!1,isLoading:!1});if(en.billId&&en.billId.length<0)return(0,t.jsx)(T,{message:e.billSummaryNoDataLabel,displayAmountPlaceholder:!1,isLoading:!1});if(en.billId&&en.billId.length>0)return(0,t.jsx)(I,{account:n,billUrl:en.billUrl,showLastBillMicrogenBill:eg&&(null==et?void 0:et.accountPageMicrogenBillEnabled)});else return null}(),!0===es&&0===er.length&&!$&&(0,t.jsx)(T,{message:eN,displayAmountPlaceholder:!0,isLoading:!1}),(0,t.jsx)("table",{className:M()("bills__table",{bills__table__business__services:i}),children:(0,t.jsxs)("tbody",{children:[!0===es&&0===er.length&&$&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:3,className:"list-docs__td list-docs__td--text-center",children:(0,t.jsx)("p",{children:ey})})}),!1===es&&0===er.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:3,className:"list-docs__td list-docs__td--text-center",children:(0,t.jsx)("p",{children:$?ey:eN})})}),ed.map(function(a,n){var s=a.date,r=a.billAmount,c=a.billId,d=a.transactionType,u=a.description,m=r<0?"-":"",h=(0,w.N7)(r),p=c&&(null==u?void 0:u.trim().toLowerCase())===x.Ay4.Bill.toLowerCase(),b=c&&(null==d?void 0:d.trim().toLowerCase())===x.Ay4.Statement.toLowerCase(),v=p||b;return(0,t.jsxs)("tr",{className:"bills__table__row",children:[(0,t.jsx)("td",{className:"bills__table__cell",children:(0,t.jsxs)("div",{className:"bills__table__transaction",children:[(0,t.jsx)("div",{children:v&&(0,t.jsx)(t.Fragment,{children:i?(0,t.jsx)(o.I9,{}):(0,t.jsx)(o.n2,{})})}),(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:M()("bills__table__transaction__info",{"bills__table__transaction__info--bill":v}),children:[(0,t.jsxs)("div",{className:"bills__table__transaction__info_name",children:[(0,t.jsx)("strong",{children:d===x.Ay4.Statement?e.billSummaryBillStatementLabel:u}),(null==et?void 0:et.accountPageMicrogenBillEnabled)&&d===x.Ay4.BillWithMicrogenCredit&&W.billMicrogenLabel&&(0,t.jsx)(g._,{text:W.billMicrogenLabel,labelClassName:"label--white-grey bill-microgen-label",isTitleCase:!1,children:(0,t.jsx)(o.Ui,{title:"Microgen",fillColour:"#00306a",width:16,height:16})})]}),(0,t.jsx)("small",{className:"normal",children:(0,P.Z)((0,F.Z)(s),x.$Mt.DD_MMM_YYYY)})]})})]})}),(0,t.jsx)("td",{className:"bills__table__cell",children:(0,t.jsxs)("div",{className:"bills__table__amount",children:[(0,t.jsx)("p",{className:M()({"bills__table__amount--bill":p}),children:p&&"".concat(m,"â¬").concat(h)}),p?(0,t.jsx)(L,{accountNumber:l,billId:c,lastBill:em,isBusinessServices:i}):b?(0,t.jsx)("button",{type:"button","data-testid":"download-".concat(c),className:"button secondary round round--large",onClick:function(){return Y(c)},disabled:H,children:(0,t.jsx)("i",{className:"circle-wrapper",children:(0,t.jsx)(o.UW,{ariaLabel:"Download Statement"})})}):(0,t.jsxs)("p",{children:[m,"â¬",h]})]})})]},"".concat(c,"-").concat(n))})]})}),ek&&(0,t.jsx)("div",{className:"list-docs__button-container new-brand",children:(0,t.jsx)("button",{className:"button primary arrow arrow--down desktop-inline",onClick:ef,children:"Show more"})})]}),eD&&(0,t.jsxs)(h.c,{title:eD.title,children:[eD.paragraph&&Z()(eD.paragraph,(0,S.Em)()),eD.link&&(0,t.jsx)("p",{children:(0,t.jsx)(p.rU,{href:eD.link.href,title:eD.link.title,isExternal:eD.link.isExternal,children:eD.link.title})})]})]})]})},q=function(e,a,n){if(n&&JSON.parse(n)||!a)return!1;var t=a.billType,s=a.amount;return!!a.enabled&&e.some(function(e){return(!t.length||e.description===t)&&(!s||e.billAmount===s)})}},2881:function(e,a,n){"use strict";n.d(a,{OO:function(){return u},OS:function(){return D},D5:function(){return eS},mv:function(){return eI},u9:function(){return e0},U4:function(){return e1},Aq:function(){return aa}});var t,s,i=n(52322),r=n(17252),l=n(6228),o=n(72670),c=n.n(o),d=n(29051),u=function(){var e=(0,d.useSelector)(r.fR,d.shallowEqual);return e?(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:c()(e,(0,l.Em)())})}):null},m=n(70865),h=n(96670);n(99537);var g=n(92377),p=n(51603),b=n(50862),x=n(89177),v=n(6440),_=n(51774),f=n(60134),j=n(12524),N=n.n(j),y=n(97208),w=n(13621),S=n(63397),C=n(2784),D=function(e){var a=e.mprn,n=e.accountId,t=(0,d.useDispatch)(),s=(0,d.useSelector)(_.t9,d.shallowEqual),o=(0,d.useSelector)(r.Ty,d.shallowEqual),u=(0,d.useSelector)(v.Ai,d.shallowEqual),j=(0,d.useSelector)(_.tO,d.shallowEqual),D=(0,d.useSelector)(_.AP,d.shallowEqual),k=function(e){t((0,_.$Q)({fromDate:e.fromDate,toDate:e.toDate,mprn:a,accountId:n}
1))},M=function(){t((0,_.xT)(!1))},E=N()("button primary inline arrow download",{loading:s.downloading});if((0,C.useEffect)(function(){t(v.c3.fetchAvailableIntervalsDates(n,a))},[n,t,a]),!s.loaded||!o)return(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:(0,i.jsx)(b.a,{className:"blue"})})});var A=o.paragraph,B=o.errorModal,L=o.intervalDatesError;return s.error?(0,i.jsx)("div",{className:"col-full-section",children:(0,i.jsx)("main",{className:"consumption",children:(0,i.jsx)("p",{className:"consumption__paragraph",children:(0,i.jsx)("strong",{children:L})})})}):D?(0,i.jsxs)(g.DY,{children:[(0,i.jsx)("div",{className:"col-full-section",children:(0,i.jsxs)("main",{className:"consumption consumption__mh",children:[(0,i.jsx)("p",{className:"consumption__paragraph",children:c()(A,(0,l.RG)("p"))}),(0,i.jsx)(S.J9,{onSubmit:k,initialValues:D,children:function(e){var a=e.values;return(0,i.jsxs)(S.l0,{className:"consumption__form",noValidate:!0,autoComplete:"off",children:[(0,i.jsx)(S.gN,{name:"fromDate",children:function(e){var n=e.field,t=e.form,s=e.meta;return(0,i.jsx)("div",{className:"consumption__form__item",children:(0,i.jsx)(p.bJ,{showFormat:x.$Mt.D_MMMM_YYYY,onDateChosen:function(e){t.setFieldValue(n.name,e)},datePickerProps:{currentView:x.OZA.DAY,minDate:j.limitFromDate,maxDate:(0,y.Z)([j.limitToDate,a.toDate,]),shouldDisableMonth:function(e){return!(0,f._2)(u,e)},shouldDisableYear:function(e){return!(0,f.gN)(u,e)},shouldDisableDay:function(e){return!(0,f.yp)(u,e)}},textFieldProps:(0,h.Z)((0,m.Z)({},n),{disableTyping:!0,isRequired:!1,label:"Start date",placeholder:"January, 2019",touched:s.touched,error:(0,S.u9)(t.errors,n.name)}),value:n.value})})}}),(0,i.jsx)("div",{className:"consumption__form__small-item",children:(0,i.jsx)("p",{children:"TO"})}),(0,i.jsx)(S.gN,{name:"toDate",children:function(e){var n=e.field,t=e.form,s=e.meta;return(0,i.jsx)("div",{className:"consumption__form__item",children:(0,i.jsx)(p.bJ,{showFormat:x.$Mt.D_MMMM_YYYY,onDateChosen:function(e){t.setFieldValue(n.name,e)},datePickerProps:{currentView:x.OZA.DAY,maxDate:j.limitToDate,minDate:(0,w.Z)([j.limitFromDate,a.fromDate,]),shouldDisableMonth:function(e){return!(0,f._2)(u,e)},shouldDisableYear:function(e){return!(0,f.gN)(u,e)},shouldDisableDay:function(e){return!(0,f.yp)(u,e)}},textFieldProps:(0,h.Z)((0,m.Z)({},n),{disableTyping:!0,isRequired:!1,label:"End date",placeholder:"January, 2019",touched:s.touched,error:(0,S.u9)(t.errors,n.name)}),value:n.value})})}}),(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:E,type:"submit",children:"CSV"})})]})}})]})}),s.error&&(0,i.jsx)(g.u_,{shown:s.error,singleAction:!0,head:(0,i.jsx)("strong",{className:"bge-dialog__title--waiting",children:B.title}),body:c()(B.paragraph),footer:(0,i.jsx)("div",{className:"align-center",children:(0,i.jsx)("button",{type:"button",className:"button primary",onClick:M,children:"Close"})})})]}):(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:(0,i.jsx)(b.a,{className:"blue"})})})},k=n(98788),M=n(42838),E=n(22970);n(25774);var A=n(10420);n(91156);var B=n(38842),L=n(8250),R=n(56085),T=n(67107),I=n(62637),P=function(e){var a=e.accountNumber,n=(0,d.useSelector)(T.Z8,d.shallowEqual),t=(0,d.useSelector)((0,R.ho)(a),d.shallowEqual),s=(0,d.useSelector)((0,R.Hj)(a),d.shallowEqual),i=(0,d.useSelector)(B.Pk,d.shallowEqual),l=i.completed,o=i.errorCode,c=i.loading,u=i.formValues,m=i.totalEstimatedCost,h=(0,d.useSelector)(r._A,d.shallowEqual),g=null==h?void 0:h.estimationToolErrors.find(function(e){return e.errorCode===o}),p=(0,C.useMemo)(function(){var e=h?(0,I.pg)(h.mccTypeAllowedForEstimationTool):[];return null!=t&&!!t.mcc&&e.includes(t.mcc)},[h,null==t?void 0:t.mcc]),b=(0,C.useMemo)(function(){return!!n&&((null==t?void 0:t.serviceType)===x.Cvl.GS||p)},[n,null==t?void 0:t.serviceType,p]);return{isElectricityAccount:(null==t?void 0:t.serviceType)===x.Cvl.EL,mccError:null==s?void 0:s.mccError,loading:c,formValues:u,totalEstimatedCost:m,errorCode:o,completed:l,mcc:null==t?void 0:t.mcc,preDecimalDigits:parseInt(null==t?void 0:t.preDecimalDigits),lastActualReads:null==t?void 0:t.lastActualReads,content:h,errorMessage:(null==g?void 0:g.errorMessage)||(null==h?void 0:h.estimationToolGenericErrorMessage),isEnabled:b}},F=n(92652),O=n(15541),Z=n(47842),G=n(30717),q=(t={},(0,Z.Z)(t,G.Qk.TwentyFourHourMeterReading,"24 hour meter reading"),
1(0,Z.Z)(t,G.Qk.DayMeterReading,"Day meter reading"),(0,Z.Z)(t,G.Qk.NightMeterReading,"Night meter reading"),(0,Z.Z)(t,G.Qk.PeakMeterReading,"Peak meter reading"),(0,Z.Z)(t,G.Qk.StorageMeterReading,"Night Storage meter reading"),(0,Z.Z)(t,G.Qk.GasMeterReading,"Gas reading"),t),U=(s={},(0,Z.Z)(s,x.ZDB.TwentyFourHourMeterReading,G.Qk.TwentyFourHourMeterReading),(0,Z.Z)(s,x.ZDB.DayMeterReading,G.Qk.DayMeterReading),(0,Z.Z)(s,x.ZDB.NightMeterReading,G.Qk.NightMeterReading),(0,Z.Z)(s,x.ZDB.PeakMeterReading,G.Qk.PeakMeterReading),(0,Z.Z)(s,x.ZDB.NightStorageReading,G.Qk.NightMeterReading),s);function Y(e){var a=e.accountNumber,n=e.preDecimalDigits,t=e.lastActualReads,s=e.submitText,r=e.mcc,l=e.isNewBrand,o=void 0!==l&&l,c=(0,d.useDispatch)(),u=(0,d.useSelector)(B.Pk,d.shallowEqual).loading,m=x.rAz[r],h=(0,O.TF)({preDecimalDigits:n,fields:m,lastActualReads:t}),g=h.schema,p=h.defaultValues,b=function(e){var n=m.map(function(a){return{readType:U[a],readValue:Number(e[a])}});c(B.nr.submit(a,n))};return(0,i.jsx)(S.J9,{initialValues:p,onSubmit:b,validateOnChange:!1,validateOnBlur:!0,validationSchema:g,children:(0,i.jsxs)(S.l0,{noValidate:!0,autoComplete:"off",children:[(0,i.jsxs)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum m-t-24",children:[(null==m?void 0:m[0])&&(0,i.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,i.jsx)(F.m,{submitField:null==m?void 0:m[0],digits:n,isNewBrand:o})}),(null==m?void 0:m[1])&&(0,i.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,i.jsx)(F.m,{submitField:null==m?void 0:m[1],digits:n,isNewBrand:o})}),(null==m?void 0:m[2])&&(0,i.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,i.jsx)(F.m,{submitField:null==m?void 0:m[2],digits:n,isNewBrand:o})}),(null==m?void 0:m[3])&&(0,i.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,i.jsx)(F.m,{submitField:null==m?void 0:m[3],digits:n,isNewBrand:o})})]}),(0,i.jsx)("button",{type:"submit","data-testid":"submit-meter-button",className:N()("button primary inline",{loading:u}),children:s})]})})}function H(e){var a=e.preDecimalDigits,n=e.lastActualReads,t=e.submitText,s=e.accountNumber,r=e.isNewBrand,l=(0,d.useDispatch)(),o=(0,d.useSelector)(B.Pk,d.shallowEqual).loading,c=function(e){l(B.nr.submit(s,[{readType:G.Qk.GasMeterReading,readValue:Number(e.meterReading)},]))},u=(0,O.qI)({preDecimalDigits:a,lastActualReads:n}),m=u.schema,h=u.defaultValues;return(0,i.jsx)(S.J9,{initialValues:h,onSubmit:c,validateOnChange:!1,validateOnBlur:!0,validationSchema:m,children:(0,i.jsxs)(S.l0,{className:"form",noValidate:!0,autoComplete:"off","data-testid":"gas-meter",children:[(0,i.jsx)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum m-t-24",children:(0,i.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,i.jsx)(F.z,{digits:a,isNewBrand:void 0!==r&&r})})}),(0,i.jsx)("button",{"data-testid":"submit-form",type:"submit",className:N()("button primary inline",{loading:o}),children:t})]})})}function V(e){var a=e.accountId,n=e.isNewBrand,t=void 0!==n&&n,s=P({accountNumber:a}),r=s.isElectricityAccount,o=s.preDecimalDigits,d=s.lastActualReads,u=s.mcc,m=s.content,h=s.loading,g=m.estimationToolTitle,p=m.estimationToolParagraph,x=m.estimationToolCurrentRead,v=m.estimationToolButton;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"estimation-tool__title",children:g}),(0,i.jsx)("p",{className:"no-margin-top",children:c()(p,(0,l.RG)("p"))}),r?(0,i.jsx)(L.xM,{preDecimalDigits:o,isNewBrand:t}):(0,i.jsx)(L.QP,{preDecimalDigits:o,isNewBrand:t}),(0,i.jsx)("p",{className:"bold m-t-24 no-margin-bottom",children:x}),h?(0,i.jsx)(b.a,{className:"blue loader-container--bigger"}):r&&u?(0,i.jsx)(Y,{accountNumber:a,submitText:v,preDecimalDigits:o,lastActualReads:d,mcc:u,isNewBrand:t}):(0,i.jsx)(H,{accountNumber:a,submitText:v,preDecimalDigits:o,lastActualReads:d,isNewBrand:t})]})}var W=n(47466),X=n(47934),J=n(42046),Q=n(54908);function $(e){var a=e.accountId,n=e.onOpenSubmitAReadingTab,t=(0,d.useDispatch)(),s=P({accountNumber:a}),r=s.isElectricityAccount,o=s.loading,u=s.formValues,m=s.totalEstimatedCost,h=s.errorCode,g=s.content,p=s.errorMessage,b=g.estimationToolResponseTitle,x=g.estimationToolResponseParagraph,v=g.estimationToolResponseCurrentRead,_=g.estimationToolResponseButton,f=g.estimationToolResponseCostTitle,j=g.estimationToolResponseExplainerGas,y=g.estimationToolResponseExplainerEnergy;return((0,C.useEffect)(function(){(0,X.Nf)("BET_TOOL_RESULT",{message:h?p.replace(/<[^>]*>/g,""):f,meters:u.map(function(e){return q[e.readType]}).join(" - "),success:!h})},[]),u)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"estimation-tool__title",children:b}),(0,i.jsx)("p",{className:"no-margin-top",children:c()(x,(0,l.RG)("p"))}),(0,i.jsx)("p",{className:"bold m-t-24 no-margin-bottom",children:v}),(0,i.jsx)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum m-t-4",children:null==u?void 0:u.map(function(e,a){return(0,i.jsxs)("div",{className:"group__flex-item group-item__pad-right",children:[(0,i.jsx)("b",{className:"meter-label",children:q[e.readType]}),(0,i.jsx)("p",{className:"meter-value no-margin-top",children:e.readValue})]},a)})}),m&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{className:"bold no-margin-top no-margin-bottom",children:f}),(0,i.jsxs)("p",{className:"estimation-tool__response-value",children:[(0,J.L8)(m),(0,i.jsx)("span",{className:"estimation-tool__explainer-mark",children:"*"})]}),(0,i.jsx)("div",{className:"estimation-tool__explainer",children:c()(r?y:j,(0,Q.A5)("/submit-a-reading-link",n))})]}),h&&(0,i.jsx)(W.aZ,{isRichText:!0,isNewBrand:!0,icon:"Alert",children:c()(p,(0,l.RG)("p"))}),(0,i.jsx)("button",{"data-testid":"reset-form",className:N()("button secondary inline arrow back",{loading:o}),onClick:function(){t(B.nr.reset())},children:_})]}):null}function K(e){var a=e.accountId,n=e.onOpenSubmitAReadingTab,t=e.isNewBrand,s=(0,d.useDispatch)(),r=P({accountNumber:a}),l=r.isEnabled,o=r.completed;return((0,C.useEffect)(function(){return function(){s(B.nr.reset())}},[]),l)?(0,i.jsx)("div",{className:"estimation-tool",children:o?(0,i.jsx)($,{accountId:a,onOpenSubmitAReadingTab:n}):(0,i.jsx)(V,{accountId:a,isNewBrand:void 0!==t&&t})}):null}var z=n(8020),ee=n(50902);n(53344);var ea=function(e){var a=e.isNewBrand,n=void 0!==a&&a,t=e.header,s=e.items,r=(0,C.useState)(0),l=r[0],o=r[1];return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:N()({"smart-box__header":!0,"smart-box__header_new-brand":n}),children:[(0,i.jsx)("div",{className:"view-toggle-menu","data-testid":"view-toggle-menu",children:s.map(function(e,a){return(0,i.jsx)("button",{"data-testid":"view-toggle-selectedIndex-".concat(a),className:N()("view-toggle-item",{"view-toggle-item-active":!n&&a===l,button:n,primary:n&&a===l,tertiary:n&&a!==l}),onClick:function(){return o(a)},children:e.icon},a)})}),t&&(0,i.jsx)("div",{className:"view-toggle-header",children:t})]}),(0,i.jsx)("div",{className:"view-toggle-content",children:s[l].view})]})},en=n(30156),et=n(17009),es=n(39933),ei=n(13922),er=n(97361),el=function(e){return null===e.diff?null:e.diff<0?(0,i.jsx)(ei.lg,{title:"Up",fillColour:"#b70030",svgClassName:"costcard__icon"}):e.diff>0?(0,i.jsx)(ei.uC,{title:"Down",fillColour:"#39b54a",svgClassName:"costcard__icon"}):(0,i.jsx)(ei.tP,{title:"Neutral",fillColour:"#4D4D4F",svgClassName:"costcard__icon"})},eo=function(e){var a="cost"===e.view?"â¬-.--":"-.--",n=a,t=a,s=a,r=null,l=null,o=e.billingPeriodStart?(0,er.Z)(e.billingPeriodStart,x.$Mt.DD_MMM_YYYY_NO_COMMA):null,c=e.billingPeriodEnd?(0,er.Z)(e.billingPeriodEnd,x.$Mt.DD_MMM_YYYY_NO_COMMA):null;return"cost"===e.view?(n=e.billingPeriodAmount?"â¬".concat((0,J.as)(e.billingPeriodAmount)):a,t=e.previousBillingPeriodAmount?"â¬".concat((0,J.as)(e.previousBillingPeriodAmount)):a,s=e.oneYearAgoAmount?"â¬".concat((0,J.as)(e.oneYearAgoAmount)):a,r=null!==e.billingPeriodAmount&&null!==e.previousBillingPeriodAmount?e.previousBillingPeriodAmount-e.billingPeriodAmount:null,l=null!==e.billingPeriodAmount&&null!==e.oneYearAgoAmount?e.oneYearAgoAmount-e.billingPeriodAmount:null):(n=e.billingPeriodUsage?e.billingPeriodUsage.toFixed(0):a,t=e.previousBillingPeriodUsage?e.previousBillingPeriodUsage.toFixed(0):a,s=e.oneYearAgoUsage?e.oneYearAgoUsage.toFixed(0):a,r=null!==e.billingPeriodUsage&&null!==e.previousBillingPeriodUsage?e.previousBillingPeriodUsage-e.billingPeriodUsage:null,l=null!==e.billingPeriodUsage&&null!==e.oneYearAgoUsage?e.oneYearAgoUsage-e.billingPeriodUsage:null),(0,i.jsxs)("div",{className:"cost-and-usage-details-card",children:[(0,i.jsx)("div",{className:"cost-and-usage-details-card-title",children:"cost"===e.view?"Cost in â¬":"Usage (kWh)"}),(0,i.jsxs)("div",{className:"cost-and-usage-details-card-label",children:[(0,i.jsx)("span",{children:"Billing period: "}),(0,i.jsx)("span",{className:"cost-and-usage-details-card-label-dates",children:null!==o&&null!==c?"".concat(o," - ").concat(c):"-"})]}),(0,i.jsx)("div",{className:"cost-and-usage-details-card-main-value",children:n}),(null==e?void 0:e.hasMicrogenLabel)&&(null==e?void 0:e.costAndUsageMicrogenLabel)&&(0,i.jsx)(es._,{text:e.costAndUsageMicrogenLabel,labelClassName:"label--white cost-and-usage-microgen-label",isTitleCase:!1,children:(0,i.jsx)(ei.Ui,{title:"Microgen",fillColour:"#00306a",width:16,height:16})}),(0,i.jsx)("div",{className:"cost-and-usage-details-card-label",children:"Previous billing period"}),(0,i.jsx)("table",{className:"cost-and-usage-details-card-value-row",children:(0,i.jsx)("tbody",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"cost-and-usage-details-card-value",children:t}),(0,i.jsxs)("td",{className:"cost-and-usage-details-card-diff-container",children:[(0,i.jsxs)("div",{className:N()({"cost-and-usage-details-card-diff":!0,"cost-and-usage-details-card-diff-up":null!==r&&r<0,"cost-and-usage-details-card-diff-down":null!==r&&r>0}),children:[(0,i.jsx)(el,{diff:r}),(0,i.jsx)("span",{children:null===r?a:"cost"===e.view?"â¬".concat((0,J.as)(r)):Math.abs(r).toFixed(0)})]}),(0,i.jsx)("div",{children:"on previous period"})]})]})})}),(0,i.jsx)("div",{className:"cost-and-usage-details-card-label",children:"1 year ago"}),(0,i.jsx)("table",{className:"cost-and-usage-details-card-value-row",children:(0,i.jsx)("tbody",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"cost-and-usage-details-card-value",children:s}),(0,i.jsxs)("td",{className:"cost-and-usage-details-card-diff-container",children:[(0,i.jsxs)("div",{className:N()({"cost-and-usage-details-card-diff":!0,"cost-and-usage-details-card-diff-up":null!==l&&l<0,"cost-and-usage-details-card-diff-down":null!==l&&l>0}),children:[(0,i.jsx)(el,{diff:l}),(0,i.jsx)("span",{children:null===l?a:"cost"===e.view?"â¬".concat((0,J.as)(l)):Math.abs(l).toFixed(0)})]}),(0,i.jsx)("div",{children:"on 1 year ago"})]})]})})})]})},ec=n(50930),ed=n(79962);function eu(e){return(0,i.jsxs)("div",{className:"cost-and-usage-no-data-placeholder",children:[(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-line"}),(0,i.jsx)("div",{className:"cost-and-usage-no-data-placeholder-msg",children:(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:(0,i.jsx)(ei.v3,{fillColour:"#4D4D4F"})}),(0,i.jsx)("td",{children:e.error})]})})})})]})}var em=n(24468),eh=n(31807);em.kL.register(em.ZL,em.vn,em.uw,em.od,em.u);var eg={white:"#FFF",grey:"#4d4d4f",blue:"#002659",lightBlue:"#007acc",lightGrey:"#b3b3b3",transparent:"transparent"};function ep(e){var a=(0,C.useRef)(null),n=(0,C.useRef)(),t=(0,ed.kh)().isMobile;return(0,C.useEffect)(function(){if(a&&a.current){a.current.height=350;var s,i,r,l,o,c,d,u,m,h,g,p=a.current.getContext("2d"),b=(m=e.datasets,g=(h=Math).max.apply(h,(0,ec.Z)(m))/7,[50,100,500,1e3,2500,5e3].reduce(function(e,a){return Math.abs(a-g)<Math.abs(e-g)?a:e}));
1p&&(n.current&&n.current.destroy(),n.current=new em.kL(p,{type:"bar",data:{labels:e.groups,datasets:(s=e.datasets,i=e.selectedDataPointIndex,r=e.oneYearBackIndex,[{backgroundColor:s.map(function(e,a){return a===i?eg.lightBlue:a===r?eg.blue:eg.lightGrey}),data:s,borderRadius:{topLeft:4,topRight:4}},])},options:{responsive:!0,maintainAspectRatio:!1,animation:!1,onClick:function(a,n){setTimeout(function(){if(void 0!==n&&void 0!==n[0]){var a=n[0].index;e.onSelecPeriod(a)}})},plugins:{legend:{display:!1},tooltip:{callbacks:{title:function(a){var n=a[0].dataIndex,t=e.rawEntries[n],s=(0,er.Z)(t.startDate,x.$Mt.D_MMM_YYYY_NO_COMMA),i=(0,er.Z)(t.endDate,x.$Mt.D_MMM_YYYY_NO_COMMA),r=(0,J.as)(t.cost);return"".concat(s," - ").concat(i," \xb7 â¬").concat(r)},label:function(){return""}},displayColors:!1}},layout:{padding:{left:11,right:11,top:0,bottom:20}},scales:{y:{type:"linear",beginAtZero:!0,min:0,max:(l=e.datasets,o=b,u=(d=((c=Math).max.apply(c,(0,ec.Z)(l))+o)/o)-Math.floor(d)>0?parseInt(d.toString()):d,+Math.round((Number(o*u)+Number.EPSILON)*100)/100),ticks:{display:!t,stepSize:b,padding:10,color:eg.grey,font:{size:14,style:"normal"},callback:function(e){return"â¬".concat(e)}},grid:{display:!0,color:eg.lightGrey},border:{display:!1}},x:{ticks:{display:!t,color:eg.grey,font:{size:12,style:"normal"},maxRotation:65,minRotation:65,autoSkip:!0,callback:function(e){var a=this.getLabelForValue(e);return(0,er.Z)((0,eh.Z)(a),x.$Mt.DD_MM_YY)}},grid:{lineWidth:0},border:{display:!1}}}}}),t&&function(e,a){var n=e.getDatasetMeta(0),t=e.canvas.getBoundingClientRect(),s=n.data[a].getCenterPoint(),i=new MouseEvent("mousemove",{clientX:t.left+s.x,clientY:t.top+s.y});e.canvas.dispatchEvent(i)}(n.current,e.selectedDataPointIndex))}},[t,e]),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"cost-and-usage-legend",children:[t?null:(0,i.jsx)("div",{className:"cost-and-usage-legend-title",children:"Cost (â¬)"}),(0,i.jsxs)("div",{className:"cost-and-usage-legend-item",children:[(0,i.jsx)("div",{className:"cost-and-usage-legend-icon cost-and-usage-legend-icon--light"}),"Selected period"]}),(0,i.jsxs)("div",{className:"cost-and-usage-legend-item",children:[(0,i.jsx)("div",{className:"cost-and-usage-legend-icon cost-and-usage-legend-icon--dark"}),"1 year ago"]})]}),(0,i.jsx)("div",{style:{height:"350px"},children:null===e.error&&e.datasets.length>0?(0,i.jsx)("canvas",{ref:a}):404===e.error?(0,i.jsx)(eu,{error:e.costAndUsageNotFoundLabel}):500===e.error?(0,i.jsx)(eu,{error:e.costAndUsageServerErrorLabel}):(0,i.jsx)(eu,{error:e.costAndUsageNoDataLabel})})]})}em.kL.register(em.f$,em.ST,em.jn,em.od,em.u);var eb={white:"#ffffff",grey:"#4d4d4f",blue:"#002659",lightBlue:"#007acc",lightGrey:"#b3b3b3",transparent:"transparent"};function ex(e){var a=C.useRef(null),n=C.useRef(),t=(0,ed.kh)().isMobile;return C.useEffect(function(){if(a&&a.current){var s,i,r,l,o,c,d,u,m,h,g,p,b,v,_=a.current.getContext("2d");a.current.height=350;var f=(p=e.datasets,v=(b=Math).max.apply(b,(0,ec.Z)(p))/7,[250,500,1e3,5e3,25e3].reduce(function(e,a){return Math.abs(a-v)<Math.abs(e-v)?a:e}));_&&(n.current&&n.current.destroy(),n.current=new em.kL(_,{type:"line",data:{labels:e.groups,datasets:(s=e.datasets,i=e.selectedDataPointIndex,r=e.oneYearBackIndex,l=s.map(function(e,a){return a===i?eb.lightBlue:a===r?eb.blue:eb.white}),o=s.map(function(e,a){return a===i?eb.lightBlue:a===r?eb.blue:eb.lightGrey}
1),[{pointBackgroundColor:l,pointBorderColor:o,pointRadius:c=s.map(function(e,a){return a===i?10:a===r?10:5}),pointHoverRadius:c,data:s,stepped:"middle",borderColor:eb.lightGrey,fill:!1},])},options:{responsive:!0,maintainAspectRatio:!1,animation:!1,onClick:function(a,n){setTimeout(function(){if(void 0!==n&&void 0!==n[0]){var a=n[0].index;e.onSelecPeriod(a)}})},plugins:{legend:{display:!1},tooltip:{callbacks:{title:function(a){var n=a[0].dataIndex,t=e.rawEntries[n],s=(0,er.Z)(t.startDate,x.$Mt.D_MMM_YYYY_NO_COMMA),i=(0,er.Z)(t.endDate,x.$Mt.D_MMM_YYYY_NO_COMMA),r=t.usage.toFixed(0);return"".concat(s," - ").concat(i," \xb7 ").concat(r,"kWh")},label:function(){return""}},displayColors:!1}},layout:{padding:{left:11,right:11,top:0,bottom:20}},scales:{y:{type:"linear",beginAtZero:!0,min:0,max:(d=e.datasets,u=f,g=(h=((m=Math).max.apply(m,(0,ec.Z)(d))+u)/u)-Math.floor(h)>0?parseInt(h.toString()):h,+Math.round((Number(u*g)+Number.EPSILON)*100)/100),ticks:{display:!t,stepSize:f,padding:10,color:eb.grey,font:{size:14,style:"normal"},callback:function(e){return e}},grid:{display:!0,color:eb.lightGrey},border:{display:!1}},x:{ticks:{display:!t,color:eb.grey,font:{size:12,style:"normal"},maxRotation:65,minRotation:65,autoSkip:!0,callback:function(e){var a=this.getLabelForValue(e);return(0,er.Z)((0,eh.Z)(a),x.$Mt.DD_MM_YY)}},grid:{lineWidth:0},border:{display:!1}}}}}),t&&function(e,a){var n=e.getDatasetMeta(0),t=e.canvas.getBoundingClientRect(),s=n.data[a].getCenterPoint(),i=new MouseEvent("mousemove",{clientX:t.left+s.x,clientY:t.top+s.y});e.canvas.dispatchEvent(i)}(n.current,e.selectedDataPointIndex))}},[e,e.groups,e.datasets,t]),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"cost-and-usage-legend",children:[t?null:(0,i.jsx)("div",{className:"cost-and-usage-legend-title",children:"kWh"}),(0,i.jsxs)("div",{className:"cost-and-usage-legend-item",children:[(0,i.jsx)("div",{className:"cost-and-usage-legend-icon cost-and-usage-legend-icon--light"}),"Selected period"]}),(0,i.jsxs)("div",{className:"cost-and-usage-legend-item",children:[(0,i.jsx)("div",{className:"cost-and-usage-legend-icon cost-and-usage-legend-icon--dark"}),"1 year ago"]})]}),(0,i.jsx)("div",{style:{height:"350px"},children:null===e.error&&e.datasets.length>0?(0,i.jsx)("canvas",{ref:a}):404===e.error?(0,i.jsx)(eu,{error:e.costAndUsageNotFoundLabel}):500===e.error?(0,i.jsx)(eu,{error:e.costAndUsageServerErrorLabel}):(0,i.jsx)(eu,{error:e.costAndUsageNoDataLabel})})]})}var ev=n(66700),e_=n(52946),ef=n(45901),ej=n(88984),eN=n(28187),ey=function(e,a,n){if(a[e]){var t=a[e].date,s=(0,ev.Z)((0,e_.Z)(t,-1)),i=[];a.map(function(e){i.push(e.date)});var r=(0,ef.Z)(s,i);if(r){var l=(0,ej.Z)(r,s),o=a.findIndex(function(e){return e.date.getTime()===r.getTime()});if(0===l||l<=n)return o}}return -1},ew=function(e){var a=e.isResidentialAccount,n=e.isQhAccount,t=e.isBusinessAccount;return a?"Residential":n?"QH":t?"Business":"Residential"},eS=function(e){var a=function(e,a,n){var t=ey(e,a,n);N(e),S(t)},n=e.account,t=e.thresholdDays,s=e.costAndUsageNoDataLabel,r=e.costAndUsageNotFoundLabel,l=e.costAndUsageServerErrorLabel,o=e.helpBoxContent,u=e.helpBoxContentMicrogen,m=e.isGroupAccount,h=e.onOpenSubmitAReadingTab,g=(0,C.useState)(null),p=g[0],_=g[1],f=(0,C.useState)(0),j=f[0],N=f[1],y=(0,C.useState)(0),w=y[0],S=y[1],D=(0,d.useSelector)(v.vN,d.shallowEqual),B=(0,d.useSelector)(en.zN,d.shallowEqual),L=(0,C.useMemo)(function(){return(null==n?void 0:n.hasExportCapability)&&!B},[null==n?void 0:n.hasExportCapability,B])&&u?u:o,R=(0,d.useSelector)(T.cN,d.shallowEqual),I=(0,A.Jk)().billsToShow;(0,C.useEffect)(function(){(0,k.Z)(function(){var e,s,i,r,l,o;return(0,E.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),e=new Date,[4,(0,et.K3)({accountId:n.accountId,from:(0,ev.Z)((0,eN.Z)(e,-24)),to:e,accountType:ew(n)})];case 1:if(200!==(s=r.sent()).status)return[3,3];return[4,s.json()];case 2:return _(o=(l=((i=r.sent()).items?i.items.map(function(e){return{cost:e.cost,usage:e.kwh.total,date:(0,eh.Z)(e.billDate),startDate:(0,eh.Z)(e.startDate),endDate:(0,eh.Z)(e.endDate),billId:e.billId}}).filter(function(e){return!(D&&D.includes(e.billId))}):[]).sort(function(e,a){return e.date.getTime()-a.date.getTime()})).slice(Math.max(l.length-13,0))),a(o.length-1,o,t),[3,4];case 3:404===s.status?_(Error("404")):_(Error("500")),r.label=4;case 4:return[3,6];case 5:return r.sent(),_(Error("500")),[3,6];case 6:return[2]}})})()},[n,t,D]);var P=(0,C.useMemo)(function(){if(!p)return!1;var e=p[j];return I.filter(function(a){return a.transactionType===x.Ay4.BillWithMicrogenCredit&&a.billId===(null==e?void 0:e.b
1illId)}).length>0},[I,p,j]),F=null,O=null,Z=null,G=null,q=null;if((0,M.Z)(p,Error))q="404"===p.message?404:500;else{if(null===p)return(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2 cost-and-usage",children:(0,i.jsx)(b.a,{className:"blue"})})});F=p,O=p[j],Z=p[j-1],G=p[w]}return(0,i.jsxs)("div",{className:"col-3-section align-top no-m-t new-brand",children:[(0,i.jsxs)("div",{className:"col-2 cost-and-usage",children:[!m&&(0,i.jsx)(K,{accountId:n.accountId,onOpenSubmitAReadingTab:h,isNewBrand:!0}),(0,i.jsx)(ea,{isNewBrand:!0,header:(0,i.jsx)(i.Fragment,{}),items:[{icon:(0,i.jsx)("div",{className:"nb_icon-header",children:"Usage"}),view:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"cost-and-usage-chart-container",children:(0,i.jsx)(ex,{error:q,costAndUsageNoDataLabel:s,costAndUsageNotFoundLabel:r,costAndUsageServerErrorLabel:l,selectedDataPointIndex:j,oneYearBackIndex:w,onSelecPeriod:function(e){return a(e,F||[],t)},groups:F?F.map(function(e){return e.endDate.toISOString()}):[],datasets:F?F.map(function(e){return e.usage}):[],rawEntries:F||[]})}),(0,i.jsx)(eo,{view:"usage",billingPeriodStart:O?O.startDate:null,billingPeriodEnd:O?O.endDate:null,billingPeriodAmount:O?O.cost:null,previousBillingPeriodAmount:Z?Z.cost:null,oneYearAgoAmount:G?G.cost:null,billingPeriodUsage:O?O.usage:null,previousBillingPeriodUsage:Z?Z.usage:null,oneYearAgoUsage:G?G.usage:null})]})},{icon:(0,i.jsx)("div",{className:"nb_icon-header",children:"Cost"}),view:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"cost-and-usage-chart-container",children:(0,i.jsx)(ep,{error:q,costAndUsageNoDataLabel:s,costAndUsageNotFoundLabel:r,costAndUsageServerErrorLabel:l,selectedDataPointIndex:j,oneYearBackIndex:w,onSelecPeriod:function(e){return a(e,F||[],t)},groups:F?F.map(function(e){return e.endDate.toISOString()}):[],datasets:F?F.map(function(e){return e.cost}):[],rawEntries:F||[]})}),(0,i.jsx)(eo,{view:"cost",billingPeriodStart:O?O.startDate:null,billingPeriodEnd:O?O.endDate:null,billingPeriodAmount:O?O.cost:null,previousBillingPeriodAmount:Z?Z.cost:null,oneYearAgoAmount:G?G.cost:null,billingPeriodUsage:O?O.usage:null,previousBillingPeriodUsage:Z?Z.usage:null,oneYearAgoUsage:G?G.usage:null,costAndUsageMicrogenLabel:e.costAndUsageMicrogenLabel,hasMicrogenLabel:(null==R?void 0:R.accountPageMicrogenBillEnabled)&&P})]})},]})]}),L&&(0,i.jsxs)(z.c,{title:L.title,children:[(0,i.jsx)("div",{className:"cost-and-usage-help-box-content",children:(0,i.jsx)("div",{className:"side__richtext",children:c()(L.content)})}),L.button&&(0,i.jsx)("div",{className:"side__button",children:(0,i.jsx)(ee.j,{className:L.button.className,url:L.button.url,label:L.button.label,isWide:L.button.isWide,isWideMobile:L.button.isWideMobile})})]})]})};n(40681);var eC=n(5192),eD=n(64731),ek=n(52273),eM=n(18323),eE=n(92540),eA=n(3854);n(55042);var eB=n(36787);n(96153);var eL=n(51075),eR=function(){var e=(0,eE.Xb)(),a=e.mprn,n=e.accountId,t=e.account,s=(0,eL.iJ)({mprn:a,accountId:n}),r=s.downloadState,l=r.downloading,o=r.error,d=s.closeModal,u=s.isBDFReport,m=s.downloadBdfReport,h=(0,eE.f_)(n).eligibleForBDF,p=(0,eL.cX)({isSmart:!1}).smartBoxContent;if(!p||!t||t.isSmart||!h)return null;var b=p.downloadBill,x=b.historicDownloadTitle,v=b.costUsageNonSmartMessageOne,_=b.costUsageNonSmartMessageTwo,f=b.historicDownloadErrorModalButtonLabel,j=b.costUsageButtonLabel,N=p.errorMod
1al;return(0,i.jsxs)(g.DY,{children:[(0,i.jsxs)("div",{className:"bdf-download-container",children:[(0,i.jsx)("h4",{className:"bdf-download-tile",children:x}),(0,i.jsx)("p",{className:"bdf-download-message-one",children:v}),(0,i.jsx)("span",{className:"bdf-download-button-container",children:(0,i.jsx)("button",{"data-testid":"dynamic-cost-usage-download-button",className:"button small dynamic-cost-usage-download-button download",type:"button",disabled:u&&l,onClick:m,children:(0,i.jsx)("span",{children:j})})}),(0,i.jsx)("p",{className:"bdf-download-message-two",children:_})]}),(0,i.jsx)(g.u_,{isNewBrand:!0,shown:o,singleAction:!0,head:(0,i.jsx)("strong",{className:"bge-dialog__title--waiting",children:N.title}),body:c()(N.paragraph),footer:(0,i.jsx)("div",{className:"align-center",children:(0,i.jsx)("button",{type:"button",onClick:d,className:"button primary",children:f})})})]})},eT=function(e){var a=e.account,n=e.accountCard,t=e.footerTitle,s=(0,A.T8)(a.accountId,eB.tC).badgeMicrogen,r=(0,eE.ys)({account:a,isDetailsPanel:!0,startOptionCode:a.startOptionCode}),l=r.maximumExportCapacity,o=r.microgenContent,c=r.productName,d=r.showPlanName,u=r.microgenEligibility,m=r.shouldHideOverviewSummaryFooter,h=n.levelPay,g=n.planName;return m?null:(0,i.jsx)("div",{className:"overview-footer-summary-container",children:(0,i.jsxs)("div",{className:"container-column container__full-width",children:[(0,i.jsx)("h4",{className:"footer-title",children:void 0===t?"Other Information":t}),(0,i.jsxs)("div",{className:"container-row container__full-width",children:[(0,i.jsxs)("div",{className:"container-column container-half-width",children:[d&&(0,i.jsxs)("div",{className:"content-item",children:[(0,i.jsx)("p",{children:g}),(0,i.jsx)("p",{children:(0,i.jsx)("strong",{children:c})})]}),!a.isBusinessAccount&&!a.isQhAccount&&!a.isHomeServicesAccount&&(0,i.jsxs)("div",{className:"content-item",children:[(0,i.jsx)("p",{children:h}),(0,i.jsx)("p",{children:(0,i.jsx)("strong",{children:a.isLevelPay?"Yes":"No"})})]})]}),(0,i.jsx)("div",{className:"container-column container-half-width",children:((null==u?void 0:u.eligibility)===eA.K5.Eligible||a.hasExportCapability)&&(0,i.jsx)(i.Fragment,{children:void 0!==l&&(0,i.jsxs)("div",{className:"content-item",children:[(0,i.jsx)("p",{children:null==o?void 0:o.maximumExportCapacityLabel}),(0,i.jsxs)("span",{className:"microgen-capacity-value",children:[(0,i.jsx)("p",{children:"".concat(Number(l).toFixed(2)," ").concat((null==o?void 0:o.maximumExportCapacityUnit)?null==o?void 0:o.maximumExportCapacityUnit:"KW")}),s]})]})})})]}),(0,i.jsx)(eR,{})]})})},eI=function(){var e=(0,eE.Xb)(),a=e.account,n=e.mprn,t=e.isLoaded,s=e.accountId,r=e.accountDetails,l=(0,eE.Yh)().content,o=(0,A.bP)(s),c=(0,eM.Yk)(),d=c.showPaymentOptions,u=c.showBillsAndActivity,m=c.showCostAndUsage,h=(0,eM.hm)(a),g=h.showOverviewInsights,p=h.insightsEligibilityDetails;return t&&r&&l&&a?(0,i.jsxs)("div",{className:"my-account-overview-container",children:[g&&p&&(p.eligibility===eA.Hv.IneligibleLegacyNonSmart||p.eligibility===eA.Hv.IneligibleSmartNonHH||p.eligibility===eA.Hv.IneligibleLegacySmart||p.eligibility===eA.Hv.Ineligible)&&(0,i.jsx)(ek.X,{}),o&&(0,i.jsx)(eC.X,{accountDetails:r,content:l,onPaymentCardClick:function(e){return e?d():u()},onBillCardClick:u,onCostCardClick:m}),a&&(a.isSmart||a.hasExportCapability)&&(0,i.jsx)("div",{className:"my-account-overview__",children:(0,i.jsx)(C.Suspense,{fallback:(0,i.jsx)(b.a,{className:"blue loader-container--bigger"}),children:(0,i.jsx)(eD.NewBrandSmartBox,{isNewBrand:!0,mprn:n,accountId:a.accountId,accountType:a.accountType,isSmart:a.isSmart,isMicrogen:a.hasExportCapability,isDynamic:a.isDynamic})})}),(0,i.jsx)(eT,{account:a,accountCard:l.accountCard,footerTitle:l.newBrandOverviewFooterTitle})]}):(0,i.jsx)(b.a,{className:"blue loader-container--bigger"})};n(46630);var eP=n(77793),eF=n(58576),eO=n(66829),eZ=n(10165),eG=n(95937),eq=n(63238),eU=n(4054),eY=n(33596),eH=n(40130),eV=n(37434),eW=n(63738),eX=n(5830),eJ=n(82453),eQ=function(e){var a=e.isShown,n=e.updateDirectDebitErrorModal,t=e.updateDirectDebitForAccountsErrorModal,s=e.myAccounts,r=e.failedUpdateAccountIds,l=e.onClose,o=(null==r?void 0:r.length)?t.title:n.title,d=r.map(function(e){var a,n=s.find(function(a){return a.accountId===e}),t=null===(a=null==n?void 0:n.premises[0])||void 0===a?void 0:a.premiseAddress,i=(null==n?void 0:n.isGasAccount)?x.OV_:(null==n?void 0:n.isHomeServicesAccount)?x.Q6_:x.$5h;return"<br/>\n <strong>".concat(i,": ").concat(t,"</strong><br/>\n <strong>\n ").concat((null==n?void 0:n.mandateAccountNumberEndsWith)?"IBAN: XXXX XXXX XXXX XXXX XXX".concat(null==n?void 0:n.mandateAccountNumberEndsWith,"<br/>"):"","\n </strong>")}),u=(null==r?void 0:r.length)?c()(t.paragraph.replace(/\$1/g,d.join(""))):c()(n.paragraph);return(0,i.jsx)(g.DY,{children:(0,i.jsx)(g.u_,{shown:a,head:(0,i.jsx)("h4",{children:o}),body:u,footer:(0,i.jsx)("div",{className:"align-right",children:(0,i.jsx)("button",{onClick:l,className:"button primary-sub",children:"Close"})}),singleAction:!1})})},e$=n(65413),eK=function(e){var a,n,t,s=(0,eG.cr)(),r=(0,d.useSelector)(eq.aH,d.shallowEqual),o=(0,d.useSelector)(T.to,d.shallowEqual),u=e.accordionParagraph,h=e.accordionTitle,g=e.bankAuthorisationLabel,b=e.directDebitLink,x=e.directDebitMandateParagraph,v=e.ibanErrorModal,_=e.account,f=e.existingDirectDebitDetailsHeadline,j=e.updateExistingDirectDebitInfoLabel,y=e.directDebitMainInfo,w=e.applyToAccountsTitle,D=e.applyToAllAccountsLabel,k=e.updateDirectDebitErrorModal,M=e.updateDirectDebitForAccountsErrorModal,E=e.accountNumber,A=e.isAgent,B=e.agentTitle,L=e.agentParagraph,R=r.failedUpdateAccountIds,I=(0,d.useSelector)(en.RL),P=null==I?void 0:null===(t=I.account)||void 0===t?void 0:t.accountsImpls,F=(0,eq.xO)(E),O=F.submit,Z=F.submitted,G=F.applyToAllAccounts,q=F.loading,U=F.showError,Y=(0,d.useDispatch)(),H=(0,C.useState)(!1),V=H[0],W=H[1],J=(null==_?void 0:_.mandateAccountNumberEndsWith)||(null==r?void 0:r.isSuccess);return((0,C.useEffect)(function(){J||W(!0)}
1,[J]),(0,C.useEffect)(function(){Z&&!U&&(W(!1),(0,X.Nf)("DIRECT_DEBIT_SUBMIT_SUCCESS"))},[U,Z]),(0,C.useEffect)(function(){U&&(0,X.Nf)("DIRECT_DEBIT_SUBMIT_FAILED")},[U]),o&&A)?(0,i.jsxs)(i.Fragment,{children:[J&&(0,i.jsxs)("div",{className:N()({"new-brand":e.isNewBrand}),children:[(0,i.jsx)("header",{className:"section-header section-header--no-m-b",children:(0,i.jsx)("h4",{className:"section-header__title section-header__title--no-m-b ",children:f})}),(0,i.jsx)("section",{className:"payment",children:(0,i.jsxs)("div",{className:"payment__existing-details-row",children:[(0,i.jsx)("p",{className:"payment__existing-details-label",children:"IBAN:"}),(0,i.jsxs)("p",{className:"payment__existing-details",children:["XXXX XXXX XXXX XXXX XXX",J]})]})})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"direct-debit-info",children:[(0,i.jsx)(ei.bG,{})," ",B]}),(0,i.jsx)(i.Fragment,{children:c()(L||"",(0,l.Em)())})]})]}):(0,i.jsx)(S.J9,{validateOnChange:!1,validationSchema:((0,eX.lA)({accountName:{fieldName:"paymentDetails.directDebitAccountName",schemaName:"directDebitAccountName"},bic:{fieldName:"paymentDetails.bic",schemaName:"bic"},iban:{fieldName:"paymentDetails.iban",schemaName:"iban",ibanErrorModal:v}}),e$.Ry().shape({paymentDetails:e$.Ry((0,m.Z)({},(0,eJ.aA)(s)))})),onSubmit:O,initialValues:eq.Pg,children:(0,i.jsxs)("div",{className:N()({"new-brand":e.isNewBrand}),children:[J&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("header",{className:"section-header section-header--no-m-b",children:(0,i.jsx)("h4",{className:"section-header__title section-header__title--no-m-b ",children:f})}),(0,i.jsx)("section",{className:"payment",children:(0,i.jsxs)("div",{className:"payment__existing-details-row",children:[(0,i.jsx)("p",{className:"payment__existing-details-label",children:"IBAN:"}),(0,i.jsxs)("p",{className:"payment__existing-details",children:["XXXX XXXX XXXX XXXX XXX",J,!V&&(0,i.jsx)("button",{className:"button tertiary arrow small inline",onClick:function(){return W(!0)},children:"Edit"})]})]})})]}),V&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{children:[J&&(0,i.jsxs)("div",{className:"direct-debit-containter-title",children:[(0,i.jsx)("h4",{className:"section-header__title section-header__title--no-m-b direct-debit-title",children:j}),(0,i.jsxs)("span",{className:"section-header__legend",children:[(0,i.jsx)(p.RT,{})," Required information"]})]}),!J&&(0,i.jsxs)("div",{className:"direct-debit-containter-title",children:[(0,i.jsx)("h4",{className:"section-header__title section-header__title--no-m-b direct-debit-title",children:"Sign up for Direct Debit on your account"}),(0,i.jsxs)("span",{className:"section-header__legend",children:[(0,i.jsx)(p.RT,{})," Required information"]})]}),(0,i.jsxs)("section",{className:"payment",children:[(0,i.jsx)("p",{className:"payment__intro",children:c()(y,(0,l.Em)())}),(0,i.jsxs)(S.l0,{noValidate:!0,children:[(0,i.jsx)(eJ.cX,{isNewBrand:e.isNewBrand,bankAuthorisationLabel:g,levelPayLink:"",directDebitLink:b,hasLevelPay:!1,accordionTitle:h,accordionContent:c()(u,(0,l.Em)()),showMainAccountQuestion:!0,applyToAccountsTitle:w,applyToAllAccountsLabel:D,otherAccounts:G,product:"",content:""}),c()(x,(0,l.Em)()),(0,i.jsx)("div",{className:"align-right payment__button-container",children:(0,i.jsx)("button",{type:"submit",className:N()("button",{loading:q,"primary-sub arrow":!e.isNewBrand,"primary arrow":e.isNewBrand}),disabled:q,children:"Sign up for Direct Debit"})})]}),(0,i.jsx)(eQ,{isShown:!!U,updateDirectDebitErrorModal:k,updateDirectDebitForAccountsErrorModal:M,myAccounts:P,failedUpdateAccountIds:R,onClose:function(){Y(eq.zx.reset())}})]})]})})]})})},ez=[{name:"Quick payment",value:x.pY_.QUICK_PAYMENT},{name:"Scheduled card payment",value:x.pY_.RECURRING_CARD_PAYMENT},{name:"Direct debit",value:x.pY_.DIRECT_DEBIT},],e0=function(e){var a=e.accountNumber,n=e.account,t=e.optionIndex,s=e.setOptionIndex,l=e.bypassValidation,o=(0,C.useState)({currentTab:ez[t]}),u=o[0],h=o[1],g=(0,d.useDispatch)(),p=(0,d.useSelector)(eH.ph),b=(0,d.useSelector)(eU.Pe,d.shallowEqual),v=(0,d.useSelector)(eq.aH,d.shallowEqual),_=(0,d.useSelector)(r.Lk,d.shallowEqual),f=(0,d.useSelector)(r.Jn,d.shallowEqual),j=(0,d.useSelector)(eY._e,d.shallowEqual),N=(0,d.useSelector)(eW.yH,d.shallowEqual),y=(0,C.useRef)(function(){var e=ez;return(null==n?void 0:n.allowScheduledPayments)||(e=[{name:"Quick payment",value:x.pY_.QUICK_PAYMENT},{name:"Direct debit",value:x.pY_.DIRECT_DEBIT},]),e}),w=function(e){s(ez.findIndex(function(a){return a.value===e.target.value})),g(eV.r.reset()),g(eq.zx.reset())},S=function(e){var t=n.premises[0],s=t.mprn,i=t.gprn,r=n.isElectricAccount||!i&&s?{mprn:s}:{gprn:i},l={accountId:a,cardPaymentsDetails:(0,m.Z)({amount:(0,J.a0)(e.amountToPay)},r),context:G.Mc.Oam};g(eV.r.submitRequest(l))},D=function(e){var a="MDA="===e.RESULT;g(eV.r.paymentCompleted(a,e))},k=(0,C.useCallback)(function(){g(eq.zx.reset())},[g]),M=(0,C.useCallback)(function(){g(eV.r.reset())},[g]);if((0,C.useEffect)(function(){h({currentTab:ez[t]})},[t]),(0,C.useEffect)(function(){return function(){s(0),k(),M()}},[k,M,s]),!_||!f)return null;var E=u.currentTab,A=_.ibanValidationService,B=_.accordionParagraph,L=_.bankAuthorisationLabel,R=_.accordionTitle,T=_.directDebitUrl,I=_.directDebitMandateParagraph,P=_.ibanErrorModal,F=_.updateExistingDirectDebitInfoLabel,O=_.existingDirectDebitDetailsHeadline,Z=_.directDebitMainInfo,q=_.applyToAccountsTitle,U=_.applyToAllAccountsLabel,Y=_.updateDirectDebitErrorModal,H=_.updateDirectDebitForAccountsErrorModal,V=_.updateDirectDebitSuccessTitle,W=_.updateDirectDebitSuccessParagraph,X=_.agentTitle,Q=_.agentParagraph,$=f.sidebarContent;return(0,i.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,i.jsxs)("div",{className:"col-2",children:[v.content&&v.isSuccess&&(0,i.jsx)(eO.h,{success:!0,className:"direct-debit-response",title:V,responseBody:W,isOutLine:!0,fillColor:"#39B54A",size:96}),!p.isCompleted&&(0,i.jsx)(eZ.NF,{onChange:w,name:"payment-options",currentValue:E.value,className:"paymentoptions__tabs",values:y.current(),isNewBrand:!0}),(0,i.jsx)(eZ.g3,{currentValue:E,panels:[{value:x.pY_.QUICK_PAYMENT,element:(0,i.jsx)(eP.gr,{title:"Pay now",subtitle:"How much do you wish to pay now?",accountType:n.isElectricAccount?"ResElectricity":n.isHomeServicesAccount?"HCWEB":"ResGas",payNowState:p,accountNumber:a,submitPaymentRequest:S,handlePaymentResponse:D,resetPaymentRequest:M,realexEnvVars:b,isLoggedOut:j,isNewBrand:!0,bypassValidation:void 0!==l&&l})},{value:x.pY_.RECURRING_CARD_PAYMENT,element:(0,i.jsx)(eF.Q,{accountNumber:a,account:n,isNewBrand:!0})},{value:x.pY_.DIRECT_DEBIT,element:(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eG.KZ,{initialState:{serviceDown:A.serviceDown,modalDismissed:!0===A.serviceDown},children:(0,i.jsx)(eK,{accordionParagraph:B,bankAuthorisationLabel:L,accordionTitle:R,directDebitLink:T,directDebitMandateParagraph:I,ibanErrorModal:P,account:n,updateExistingDirectDebitInfoLabel:F,existingDirectDebitDetailsHeadline:O,directDebitMainInfo:Z,applyToAccountsTitle:q,applyToAllAccountsLabel:U,updateDirectDebitErrorModal:Y,updateDirectDebitForAccountsErrorModal:H,accountNumber:a,isAgent:N||!1,agentTitle:X,agentParagraph:Q,isNewBrand:!0})})})},]})]}),E.value===x.pY_.RECURRING_CARD_PAYMENT&&(0,i.jsx)(z.c,{title:"",children:c()($,{})})]})},e1=function(){var e=(0,d.useSelector)(r.Bn,d.shallowEqual);return e?(0,i.jsx)("div",{className:"col-3-section align-top no-m-t",children:(0,i.jsx)("div",{className:"col-2",children:c()(e,(0,l.Em)())})}):null};n(54291);var e2=n(31256),e4=n(84134),e3=(0,e$.Ry)().shape({graphType:(0,e$.Z_)().oneOf([x.gsu.DATE_RANGE,x.gsu.COMPARISON]).required((0,e4.q8)("Graph type")),fromDate:(0,e$.hT)().required((0,e4.q8)("From date")),toDate:(0,e$.hT)().required((0,e4.q8)("To date"))});function e5(e){var a=function(a){e.onSubmit(a)},n=(0,d.useSelector)(e2.Gj,d.shallowEqual),t=(0,d.useSelector)(e2.xd),s=(0,d.useSelector)(e2.rQ,d.shallowEqual),r=(0,d.useSelector)(v.H2,d.shallowEqual),l=(0,d.useSelector)(e2.QX,d.shallowEqual),o=(0,d.useSelector)(e2.E8,d.shallowEqual),c=(0,y.Z)(r);if(!n)return null;var u=N()("button primary inline",{loading:s});return(0,i.jsx)(S.J9,{onSubmit:a,initialValues:l,validationSchema:e3,children:function(e){var a=e.values;return(0,i.jsxs)(S.l0,{className:"reports__form",noValidate:!0,autoComplete:"off",children:[(0,i.jsx)(S.gN,{name:"graphType",children:function(e){var a=e.field,n=e.form,s=e.meta;return(0,i.jsx)("div",{className:"reports__form__type",children:(0,i.jsx)(p.SY,(0,h.Z)((0,m.Z)({},a),{disabled:t&&t.length<1,touched:s.touched,error:(0,S.u9)(n.errors,a.name),options:[{value:x.gsu.DATE_RANGE,label:"Date range"},{value:x.gsu.COMPARISON,label:"Compare"},],onChange:function(e){n.setFieldValue(a.name,e)}}))})}}),(0,i.jsx)(S.gN,{name:"fromDate",children:function(e){var n=e.field,t=e.form,s=e.meta;return(0,i.jsx)("div",{className:"reports__form__item",children:(0,i.jsx)(p.bJ,{showFormat:
1x.$Mt.MMMM__YYYY,onDateChosen:function(e){t.setFieldValue(n.name,e)},datePickerProps:{minDate:o&&o.limitFromDate,maxDate:o&&(0,y.Z)([o.limitToDate,a.toDate,]),currentView:x.OZA.MONTH,views:[x.OZA.MONTH,x.OZA.YEAR,],shouldDisableMonth:function(e){return!(0,f._2)(r,e)},shouldDisableYear:function(e){return e.getFullYear()<c.getFullYear()}},textFieldProps:(0,h.Z)((0,m.Z)({},n),{disableTyping:!0,isRequired:!1,label:"From",placeholder:"January, 2019",touched:s.touched,error:(0,S.u9)(t.errors,n.name)}),value:n.value})})}}),(0,i.jsx)(S.gN,{name:"toDate",children:function(e){var n=e.field,t=e.form,s=e.meta;return(0,i.jsx)("div",{className:"reports__form__item",children:(0,i.jsx)(p.bJ,{showFormat:x.$Mt.MMMM__YYYY,onDateChosen:function(e){t.setFieldValue(n.name,e)},datePickerProps:{minDate:o&&(0,w.Z)([o.limitFromDate,a.fromDate,]),maxDate:o&&o.limitToDate,currentView:x.OZA.MONTH,views:[x.OZA.MONTH,x.OZA.YEAR,],shouldDisableMonth:function(e){return!(0,f._2)(r,e)},shouldDisableYear:function(e){return e.getFullYear()<c.getFullYear()}},textFieldProps:(0,h.Z)((0,m.Z)({},n),{disableTyping:!0,isRequired:!1,label:"To",placeholder:"January, 2019",touched:s.touched,error:(0,S.u9)(t.errors,n.name)}),value:n.value})})}}),(0,i.jsx)("div",{className:"reports__controls",children:(0,i.jsx)("button",{className:u,type:"submit",disabled:s,children:"Apply"})})]})}})}function e6(e){var a=e.consumptionLabel,n=e.costLabel;return(0,i.jsxs)("div",{className:"reports__legend",children:[(0,i.jsxs)("div",{className:"reports__legend__item",children:[(0,i.jsx)("div",{className:"reports__legend__color reports__legend__costs"}),(0,i.jsx)("span",{className:"reports__legend__label",children:n})]}),(0,i.jsxs)("div",{className:"reports__legend__item",children:[(0,i.jsx)("span",{className:"reports__legend__label",children:a}),(0,i.jsx)("div",{className:"reports__legend__color reports__legend__consumptions"})]})]})}em.kL.register(em.ZL,em.vn,em.uw,em.Gu,em.f$,em.ST,em.jn,em.od,em.u);var e7="#007acc",e9="#42bb93";function e8(e){var a=e.legend,n=(0,C.useState)({graphReady:!1}),t=n[0],s=n[1],r=(0,C.useRef)(null),l=(0,C.useRef)(),o=(0,d.useSelector)(e2.Gj,d.shallowEqual),c=(0,d.useSelector)(e2.R$,d.shallowEqual),u=c.fromDate,h=c.toDate,g=(0,d.useSelector)(e2.mc),p=(0,d.useSelector)(e2.yA),v=(0,d.useSelector)(e2.Wc,d.shallowEqual),_=(0,d.useSelector)(e2.jP),f=(0,d.useSelector)(e2.a8),j=(0,d.useSelector)(e2.GM),N=(0,d.useSelector)(e2.i4);return((0,C.useEffect)(function(){if(!0===o&&g&&_&&f&&!l.current&&r.current&&"COMPARISON"!==v){var e=r.current.getContext("2d"),n=e.createLinearGradient(0,0,0,200),t=e.createLinearGradient(0,0,0,200);n.addColorStop(0,"rgba(0, 122, 204, 0.64)"),n.addColorStop(1,"rgba(0, 122, 204, 0.16)"),t.addColorStop(0,"rgb(66, 187, 147)"),t.addColorStop(1,"rgba(66, 187, 147, 0.22)"),l.current=new em.kL(e,{type:"DATE_RANGE"===v?"line":"bar",data:{labels:"DATE_RANGE"===v?g:p,datasets:[{label:a.consumptionLabel,data:_,backgroundColor:n,borderColor:e7,yAxisID:"y-axis-2",pointBackgroun
1dColor:e7,pointHoverRadius:7,borderRadius:{topLeft:10,topRight:10},fill:!0,tension:.3},{label:a.costLabel,data:f,backgroundColor:t,borderColor:e9,yAxisID:"y-axis-1",pointBackgroundColor:e9,pointHoverRadius:7,borderRadius:{topLeft:10,topRight:10},fill:!0,tension:.3},]},options:{animation:{duration:800,easing:"linear"},plugins:{tooltip:{mode:"index",intersect:!0,padding:9,titleFont:{size:14,weight:"bold"},bodyFont:{size:14,weight:"bold"},itemSort:function(e,a){return a.datasetIndex-e.datasetIndex},callbacks:{title:function(e){return(0,er.Z)((0,eh.Z)(e[0].label),x.$Mt.DD_MMM_YYYY)},label:function(e){var a=e.dataset.label||"";if(0===e.datasetIndex){var n=e.formattedValue.toLocaleString(x.MVU);return"".concat(a,": ").concat(n)}return"".concat(a,": ").concat(e.formattedValue)}}},legend:{display:!1}},maintainAspectRatio:!1,scales:{x:{ticks:{callback:function(e){var a=this.getLabelForValue(e);return(0,er.Z)((0,eh.Z)(a),x.$Mt.DD_MMM_YYYY)},font:{weight:"bold"}}},"y-axis-1":{type:"linear",position:"left",beginAtZero:!0,ticks:{display:!0,font:{weight:"bold"}},grid:{drawOnChartArea:!0}},"y-axis-2":{type:"linear",position:"right",beginAtZero:!0,ticks:{display:!0,font:{weight:"bold"}},grid:{drawOnChartArea:!1}}}}}),s({graphReady:!0})}},[g,_,f,v,a.consumptionLabel,a.costLabel,o]),(0,C.useEffect)(function(){!0===o&&g&&_&&f&&l.current&&r.current&&l.current.data.datasets&&(l.current.data.labels="DATE_RANGE"===v?g:p,l.current.data.datasets[0].data="DATE_RANGE"===v?_:N,l.current.data.datasets[1].data="DATE_RANGE"===v?f:j,l.current.update())},[g,_,f,o,u,h,p,N,j]),(0,C.useEffect)(function(){if(!0===o&&g&&_&&f&&l.current&&r.current){l.current.destroy();var e=r.current.getContext("2d"),n=e.createLinearGradient(0,0,0,200),t=e.createLinearGradient(0,0,0,200);n.addColorStop(0,"rgba(0, 122, 204, 0.64)"),n.addColorStop(1,"rgba(0, 122, 204, 0.16)"),t.addColorStop(0,"rgb(66, 187, 147)"),t.addColorStop(1,"rgba(66, 187, 147, 0.22)"),l.current=new em.kL(e,{type:"DATE_RANGE"===v?"line":"bar",data:{labels:"DATE_RANGE"===v?g:p,datasets:[{label:"DATE_RANGE"===v?a.consumptionLabel:a.costLabel,data:"DATE_RANGE"===v?_:N,backgroundColor:"DATE_RANGE"===v?n:e9,borderColor:"DATE_RANGE"===v?e7:e9,yAxisID:"y-axis-2",pointBackgroun
1dColor:"DATE_RANGE"===v?e7:e9,pointHoverRadius:7,maxBarThickness:150,borderRadius:{topLeft:10,topRight:10},fill:!0,tension:.3},{label:"DATE_RANGE"===v?a.costLabel:a.consumptionLabel,data:"DATE_RANGE"===v?f:j,backgroundColor:"DATE_RANGE"===v?t:e7,borderColor:"DATE_RANGE"===v?e9:e7,yAxisID:"y-axis-1",pointBackgroundColor:"DATE_RANGE"===v?e9:e7,pointHoverRadius:7,maxBarThickness:150,borderRadius:{topLeft:10,topRight:10},fill:!0,tension:.3},]},options:{animation:{duration:800,easing:"linear"},plugins:{tooltip:{mode:"index",position:"DATE_RANGE"===v?"average":"nearest",intersect:!0,padding:9,titleFont:{size:14,weight:"bold"},bodyFont:{size:14,weight:"bold"},itemSort:function(e,a){return"DATE_RANGE"===v?a.datasetIndex-e.datasetIndex:e.datasetIndex-a.datasetIndex},callbacks:{title:function(e){return(0,er.Z)((0,eh.Z)(e[0].label),x.$Mt.DD_MMM_YYYY)},label:function(e){var a=e.dataset.label||"";if(0===e.datasetIndex){var n=e.formattedValue.toLocaleString(x.MVU);return"".concat(a,": ").concat(n)}return"".concat(a,": ").concat(e.formattedValue)}}},legend:{display:!1}},maintainAspectRatio:!1,scales:{x:{ticks:{callback:function(e){var a=this.getLabelForValue(e);return(0,er.Z)((0,eh.Z)(a),x.$Mt.DD_MMM_YYYY)},font:{weight:"bold"}}},"y-axis-1":{type:"linear",position:"DATE_RANGE"===v?"left":"right",beginAtZero:!0,ticks:{display:!0,font:{weight:"bold"}},grid:{drawOnChartArea:"DATE_RANGE"===v}},"y-axis-2":{type:"linear",position:"DATE_RANGE"===v?"right":"left",beginAtZero:!0,ticks:{display:!0,font:{weight:"bold"}},grid:{drawOnChartArea:"DATE_RANGE"!==v}}}}}),s({graphReady:!0})}},[v,o]),(0,C.useEffect)(function(){t.graphReady&&l.current&&l.current.update()},[t.graphReady]),!1===o&&!1===t.graphReady)?(0,i.jsx)(b.a,{className:"blue"}):g&&0===g.length?(0,i.jsx)("div",{className:"reports__no-reports",children:(0,i.jsx)("p",{children:(0,i.jsx)("strong",{children:"There is nothing to see here right now."})})}):(0,i.jsxs)("div",{className:"reports__graph__wrapper",children:[l.current&&(0,i.jsx)(e6,(0,m.Z)({},a)),(0,i.jsx)("canvas",{ref:r,id:"reports-chart"})]})}function ae(e){var a=(0,d.useSelector)(e2.aC,d.shallowEqual),n=e.billDate,t=e.costs,s=e.downloadButton,r=e.day,l=e.night,o=e.costWithVat,c=e.total,u=e.peak,m=e.vat,h=e.start,g=e.end;if(!a)return null;var p=function(){e.handleDownloadCsv()};return(0,i.jsxs)(C.Fragment,{children:[(0,i.jsx)("div",{className:"reports__csv",children:(0,i.jsx)("button",{className:"button secondary arrow download",type:"button",onClick:p,children:s})}),(0,i.jsxs)("div",{className:"list-docs__table-wrapper",children:[(0,i.jsxs)("table",{className:"list-docs__table",children:[(0,i.jsx)("thead",{className:"list-docs__head",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header list-docs__td--b-r-t-l",children:n}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:h}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:g}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:r}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:l}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:u}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:c}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:t}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header",children:m}),(0,i.jsx)("td",{className:"list-docs__td list-docs__td--smaller list-docs__td--header list-docs__td--narrow list-docs__td--b-r-t-r",children:o})]})}),a.length>0&&(0,i.jsx)("tbody",{children:a.map(function(e,a){var n=N()("list-docs__td",{"list-docs__td--grey":a%2==0});return(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{className:n,children:(0,er.Z)((0,eh.Z)(e.billDate),x.$Mt.DD_MM_YY)}),(0,i.jsx)("td",{className:n,children:(0,er.Z)((0,eh.Z)(e.startDate),x.$Mt.DD_MM_YY)}),(0,i.jsx)("td",{className:n,children:(0,er.Z)((0,eh.Z)(e.endDate),x.$Mt.DD_MM_YY)}
1),(0,i.jsx)("td",{className:n,children:e.kwh.day.toLocaleString(x.MVU)}),(0,i.jsx)("td",{className:n,children:e.kwh.night.toLocaleString(x.MVU)}),(0,i.jsx)("td",{className:n,children:e.kwh.peak.toLocaleString(x.MVU)}),(0,i.jsx)("td",{className:n,children:e.kwh.total.toLocaleString(x.MVU)}),(0,i.jsxs)("td",{className:n,children:["â¬",e.costExVat.toLocaleString(x.MVU)]}),(0,i.jsxs)("td",{className:n,children:["â¬",e.vat.toLocaleString(x.MVU)]}),(0,i.jsxs)("td",{className:n,children:["â¬",e.cost.toLocaleString(x.MVU)]})]},"".concat(e.billDate,"-").concat(a))})})]}),0===a.length&&(0,i.jsx)("p",{className:"reports__nothing-to-see",children:(0,i.jsx)("strong",{children:"There is nothing to see here right now."})})]})]})}var aa=function(e){var a=e.accountId,n=(0,d.useDispatch)(),t=(0,d.useSelector)(e2.R$,d.shallowEqual),s=t.fromDate,l=t.toDate,o=(0,d.useSelector)(e2.Wc,d.shallowEqual),u=(0,d.useSelector)(e2.at,d.shallowEqual),p=(0,d.useSelector)(r.KN,d.shallowEqual);(0,C.useEffect)(function(){n((0,e2.oj)({accountId:a}))},[]),(0,C.useEffect)(function(){return function(){n((0,e2.uf)())}},[n]);var b=function(e){(0,f.AN)(e.fromDate,s)&&(0,f.AN)(e.toDate,l)||n((0,e2.RC)({fromDate:e.fromDate,toDate:e.toDate,accountId:a})),e.graphType!==o&&n((0,e2._S)(e.graphType))},x=function(){n((0,e2.so)({fromDate:s,toDate:l,accountId:a}))},v=function(){n((0,e2.xT)(!1))};if(!p)return null;
1var _=p.title,j=p.legend,N=p.table,y=p.errorModal;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"col-full-section",children:[(0,i.jsx)("header",{className:"section-header",children:(0,i.jsx)("h3",{className:"section-header__title section-header__title--no-m-b ",children:_})}),(0,i.jsxs)("main",{className:"reports",children:[(0,i.jsx)(e5,{onSubmit:b}),(0,i.jsx)(e8,{legend:j}),(0,i.jsx)(ae,(0,h.Z)((0,m.Z)({},N),{handleDownloadCsv:x}))]})]}),(0,i.jsx)(g.DY,{children:u.error&&(0,i.jsx)(g.u_,{shown:u.error,singleAction:!0,head:(0,i.jsx)("strong",{className:"bge-dialog__title--waiting",children:y.title}),body:c()(y.paragraph),footer:(0,i.jsx)("div",{className:"align-center",children:(0,i.jsx)("button",{type:"button",onClick:v,className:"button primary",children:"Close"})})})})]})}},95544:function(e,a,n){"use strict";n.d(a,{r:function(){return y}});var t=n(52322),s=n(89177),i=n(52273),r=n(67107),l=n(47934),o=n(2784),c=n(29051),d=n(2881).OS,u=n(2881).Aq,m=n(49527).CB,h=n(2881).U4,g=n(2881).u9,p=n(2881).OO,b=n(70549).S,x=n(36299).X,v=n(36299).S,_=n(46731).U,f=n(31253).n3,j=n(2881).D5,N=n(2881).mv,y=function(e){var a=e.currentTabName,n=e.accountId,y=e.mprn,w=e.account,S=e.mprnGprnIndex,C=e.accountDetails,D=e.endDate,k=e.thresholdDays,M=e.gasReadingHelpBoxContent,E=e.electricityReadingHelpBoxContent,A=e.paymentOptionIndex,B=e.setPaymentOptionIndex,L=e.onOpenSubmitAReadingTab,R=e.billSummaryNoDataLabel,T=e.billSummaryNotFoundLabel,I=e.billSummaryServerErrorLabel,P=e.billSummaryBillProcessingLabel,F=e.billSummaryBillStatementLabel,O=e.costAndUsageNoDataLabel,Z=e.costAndUsageMicrogenLabel,G=e.costAndUsageNotFoundLabel,q=e.costAndUsageServerErrorLabel,U=e.helpBoxContent,Y=e.helpBoxContentMicrogen,H=(0,c.useSelector)(r.qQ,c.shallowEqual);switch((0,o.useEffect)(function(){(0,l.Nf)("OAM_TAB_SELECTION",{selectedTab:a})},[]),a){case s.iwB.OVERVIEW:return(0,t.jsx)(N,{});case s.iwB.REPORTS:return(0,t.jsx)(u,{accountId:n,mprn:y});case s.iwB.QH_USAGE:return(0,t.jsx)(d,{mprn:y,accountId:n});case s.iwB.BILLS_AND_ACTIVITY:return(0,t.jsx)(m,{account:w,accountDetails:C,billSummaryNoDataLabel:R,billSummaryNotFoundLabel:T,billSummaryServerErrorLabel:I,billSummaryBillProcessingLabel:P,billSummaryBillStatementLabel:F});case s.iwB.COST_AND_USAGE:return(0,t.jsx)(j,{account:w,costAndUsageNoDataLabel:O,costAndUsageMicrogenLabel:Z,costAndUsageNotFoundLabel:G,costAndUsageServerErrorLabel:q,helpBoxContent:U,helpBoxContentMicrogen:Y,thresholdDays:k,isGroupAccount:C.isGroupAccount,onOpenSubmitAReadingTab:L});case s.iwB.LETTERS:return H?(0,t.jsx)(v,{}):(0,t.jsx)(x,{accountNumber:n,isNewBrandOam:!0});case s.iwB.PRICE_INFORMATION:return(0,t.jsx)(h,{});case s.iwB.PAYMENT_OPTIONS:return(0,t.jsx)(g,{account:w,accountNumber:n,optionIndex:A,setOptionIndex:B});case s.iwB.BOOKING_WINDOW_INFO:return(0,t.jsx)(p,{});case s.iwB.SUBMIT_A_READING:return(0,t.jsx)(b,{account:w,accountNumber:n,mprn:y,submitElectricityMeterReadingHelpBoxContent:M,submitGasMeterReadingHelpBoxContent:E,isNewBrand:!0});case s.iwB.HAVE_A_QUESTION:return(0,t.jsx)(_,{accountNumber:n,isNewBrand:!0,isOam:!0});case s.iwB.BOOKINGS:return(0,t.jsx)(f,{endDate:D,accountNumber:n,mprnGprnIndex:S,account:w,isNewBrand:!0});case s.iwB.INSIGHTS:return(0,t.jsx)(i.q,{account:w,accountNumber:n,mprnGprnIndex:S});default:return null}}},8250:function(e,a,n){"use strict";n.d(a,{xM:function(){return p},QP:function(){return g},PZ:function(){return h}});var t=n(52322);n(41755);var s=n(15541),i=n(47466),r=n(17252),l=n(6228),o=n(12524),c=n.n(o),d=n(72670),u=n.n(d),m=n(29051),h=function(e){var a=e.accountNumber,n=(0,m.useSelector)(r.BR),o=(0,s.RC)({accountNumber:a,content:n}),d=o.image,h=o.preDecimalDigits,g=o.message,p=o.title,b=o.isPredecimalEnabled;return h&&b?(0,t.jsx)(i.Xx,{children:(0,t.jsxs)("div",{className:"pre-decimal-digits-container",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("h3",{className:"pre-decimal-digits-title",children:p}),(0,t.jsx)("p",{className:"pre-decimal-digits-paragraph",children:u()(g,(0,l.Em)({replaceTagNames:"p"}))})]}),(0,t.jsx)("img",{className:c()("pre-decimal-digits-image",{"pre-decimal-digits-image--five":5===h,"pre-decimal-digits-image--six":6===h}),src:null==d?void 0:d.url,alt:null==d?void 0:d.description,height:33,width:168})]})}):(0,t.jsx)(i.H3,{children:u()(g,(0,l.Em)({replaceTagNames:"p"}))})},g=function(e){var a=e.preDecimalDigits,n=e.isNewBrand,o=(0,m.useSelector)(r.BR),c=(0,s.ao)({content:o,preDecimalDigits:a}),d=c.image,h=c.message,g=c.title,p=c.isPredecimalEnabled;return a&&p?(0,t.jsx)(t.Fragment,{children:void 0!==n&&n?(0,t.jsx)(i.wx,{children:(0,t.jsxs)("div",{className:"pre-decimal-digits-container",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("h3",{className:"pre-decimal-digits-title",children:g}),(0,t.jsx)("p",{className:"pre-decimal-digits-paragraph",children:u()(h,(0,l.Em)({replaceTagNames:"p"}))})]}),(0,t.jsx)("img",{className:"pre-decimal-digits-image",src:null==d?void 0:d.url,alt:null==d?void 0:d.description,height:33,width:168})]})}):(0,t.jsx)(i.Xx,{children:(0,t.jsxs)("div",{className:"pre-decimal-digits-container",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("h3",{className:"pre-decimal-digits-title",children:g}),(0,t.jsx)("p",{className:"pre-decimal-digits-paragraph",children:u()(h,(0,l.Em)({replaceTagNames:"p"}))})]}),(0,t.jsx)("img",{className:"pre-decimal-digits-image",src:null==d?void 0:d.url,alt:null==d?void 0:d.description,height:33,width:168})]})})}):(0,t.jsx)(i.H3,{children:u()(h,(0,l.Em)({replaceTagNames:"p"}))})},p=function(e){var a=e.preDecimalDigits,n=e.isNewBrand,o=(0,m.useSelector)(r.BR),d=(0,s.gb)({content:o,preDecimalDigits:a}),h=d.image,g=d.message,p=d.title,b=d.isPredecimalEnabled;return a&&b?(0,t.jsx)(t.Fragment,{children:void 0!==n&&n?(0,t.jsx)(i.wx,{children:(0,t.jsxs)("div",{className:"pre-decimal-digits-container",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("h3",{className:"pre-decimal-digits-title",children:p}),(0,t.jsx)("p",{className:"pre-decimal-digits-paragraph",children:u()(g,(0,l.Em)({replaceTagNames:"p"}))})]}),(0,t.jsx)("img",{className:c()("pre-decimal-digits-image",{"pre-decimal-digits-image--five":5===a,"pre-decimal-digits-image--six":6===a}),src:null==h?void 0:h.url,alt:null==h?void 0:h.description,height:33,width:168})]})}):(0,t.jsx)(i.Xx,{children:(0,t.jsxs)("div",{className:"pre-decimal-digits-container",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("h3",{className:"pre-decimal-digits-title",children:p}),(0,t.jsx)("p",{className:"pre-decimal-digits-paragraph",children:u()(g,(0,l.Em)({replaceTagNames:"p"}))})]}),(0,t.jsx)("img",{className:c()("pre-decimal-digits-image",{"pre-decimal-digits-image--five":5===a,"pre-decimal-digits-image--six":6===a}),src:null==h?void 0:h.url,alt:null==h?void 0:h.description,height:33,width:168})]})})}):(0,t.jsx)(i.H3,{children:u()(g,(0,l.Em)({replaceTagNames:"p"}))})}},15541:function(e,a,n){"use strict";n.d(a,{kQ:function(){return y},gb:function(){return j},TF:function(){return b},ao:function(){return E},qI:function(){return S},RC:function(){return N},oi:function(){return x}});var t=n(25340),s=n(24973),i=n(67107),r=n(89177),l=n(30717),o=n(65413),c=function(e){var a=e.lastRead,n=e.fieldLength,t=void 0===n?7:n;return(0,o.Z_)().typeError("This field must be a number").required("This field is mandatory").test({name:"Length",message:function(e){var n=e.value;if(n){if(n.toString().length>t||n.toString().length<t)return"Enter ".concat(t," digit meter reading");if(a&&parseInt(n)<=a)return"Cannot submit value less than last actual read"}return""},test:function(e){return!!e&&(a&&e.toString().length===t?parseInt(e)>a:e.toString().length===t)}})},d=function(e,a){return!!e&&!!e.registerType&&!!a&&e.registerType.toLowerCase().trim().startsWith(a.toLowerCase().trim())},u=function(e,a){switch(a){case r.ZDB.TwentyFourHourMeterReading:var n=e.find(function(e){return e.registerType===l.ut.TwentyFourHour});return(null==n?void 0:n.readValue)||0;case r.ZDB.DayMeterReading:var t=e.find(function(e){return d(e,l.ut.Day)});return(null==t?void 0:t.readValue)||0;case r.ZDB.NightMeterReading:var s=e.find(function(e){return d(e,l.ut.Night)});return(null==s?void 0:s.readValue)||0;case r.ZDB.PeakMeterReading:var i=e.find(function(e){return d(e,l.ut.Peak)});return(null==i?void 0:i.readValue)||0;case r.ZDB.NightStorageReading:var o=e.find(function(e){return e.registerType===l.ut.NightSaver});return(null==o?void 0:o.readValue)||0}},m=function(e){var a=e.find(function(e){return e.registerType===l.ut.Gas});return(null==a?void 0:a.readValue)||0},h=function(e){var a=e.fields,n=e.lastActualReads,t=e.fieldLength,s=void 0===t?7:t;return(0,o.Ry)().shape(null==a?void 0:a.reduce(function(e,a){if(!n||!(n.length>0))return e[a]=c({fieldLength:s}),e;var t=u(n,a);return e[a]=c({lastRead:t,fieldLength:s}),e},{}))},g=n(2784),p=n(29051),b=function(e){var a,n=e.fields,t=e.preDecimalDigits,r=e.lastActualReads,l=(0,g.useState)(),o=l[0],c=l[1],d=(0,g.useState)(!0),u=d[0],m=d[1],b=null==n?void 0:n.reduce(function(e,a){return e[a]="",e},{}),x=(0,p.useSelector)(i.R5);return(0,g.useEffect)(function(){n&&(x?t&&5===t?(c(h({fields:n,lastActualReads:r,fieldLength:5})),m(!1)):t&&6===t?(c(h({fields:n,lastActualReads:r,fieldLength:6})),m(!1)):t&&7===t?(c(h({fields:n,lastActualReads:r})),m(!1)):(c((0,s.Pj)(n)),m(!1)):(c((0,s.Pj)(n)),m(!1)))},[t,n]),{schema:o,defaultValues:b,loading:u}},x=function(e){var a=e.fields,n=e.accountNumber;return b({fields:a,preDecimalDigits:(0,p.useSelector)((0,t.A_)(n))})},v={width:168,height:33},_={width:150,height:33},f={width:132,height:33},j=function(e){var a=e.preDecimalDigits,n=e.content,t=(0,g.useState)(),s=t[0],r=t[1],l=(0,g.useState)(""),o=l[0],c=l[1],d=(0,g.useState)(v),u=d[0],m=d[1],h=(0,p.useSelector)(i.R5),b=n.fiveFieldMeter,x=n.sixFieldMeter,j=n.sevenFieldMeter,N=n.submitReadingParagraph,y=n.preDecimalMeterReadMessageTitle,w=n.preDecimalMeterReadMessage;return(0,g.useEffect)(function(){h&&(a&&5===a?(r(b),m(f)):a&&6===a?(r(x),m(_)):a&&7===a&&r(j))},[a]),(0,g.useEffect)(function(){if(h){if(a&&w){var e=w.replace(/\$1/g,a.toString());a&&5===a?c(e.replace(/\$2/g,"01234")):a&&6===a?c(e.replace(/\$2/g,"001234")):a&&7===a&&c(e.replace(/\$2/g,"0001234"))}else N&&c(N)}else c(N)},[a,N,w]),{image:s,message:o,title:y||"",preDecimalDigits:a,mobileImageSize:u,isPredecimalEnabled:h}},N=function(e){var a=e.accountNumber,n=e.content;return j({preDecimalDigits:(0,p.useSelector)((0,t.A_)(a)),content:n})},y=o.Ry().shape({meterReading:o.Rx().typeError("Meter reading must be a number").required("Meter reading is required")}),w=function(e){var a=e.lastActualReads,n=e.fieldLength,t=a&&a.length>0?m(a):void 0;return o.Ry().shape({meterReading:c({lastRead:t,fieldLength:void 0===n?6:n})})},S=function(e){var a=e.preDecimalDigits,n=e.lastActualReads,t=(0,g.useState)(),s=t[0],i=t[1],r=(0,g.useState)(!0),l=r[0],o=r[1];return(0,g.useEffect)(function(){a&&5===a?(i(w({lastActualReads:n,fieldLength:5}
1)),o(!1)):a&&6===a?(i(w({lastActualReads:n,fieldLength:6})),o(!1)):a&&4===a?(i(w({lastActualReads:n,fieldLength:4})),o(!1)):(i(y),o(!1))},[a]),{schema:s,defaultValues:{meterReading:""},loading:l}},C={width:168,height:33},D={width:150,height:33},k={width:150,height:33},M={width:132,height:33},E=function(e){var a=e.preDecimalDigits,n=e.content,t=(0,g.useState)(),s=t[0],i=t[1],r=(0,g.useState)(""),l=r[0],o=r[1],c=(0,g.useState)(C),d=c[0],u=c[1],m=n.gasFiveFieldMeter,h=n.gasSixFieldMeter,p=n.gasFourFieldMeter,b=n.submitReadingParagraph,x=n.preDecimalMeterReadMessageTitle,v=n.preDecimalMeterReadMessage;return(0,g.useEffect)(function(){5===a?(i(m),u(M)):a&&6===a?(i(h),u(D)):a&&4===a&&(i(p),u(k))},[a]),(0,g.useEffect)(function(){if(a&&v){var e=v.replace(/\$1/g,a.toString());a&&4===a?o(e.replace(/\$2/g,"0705")):a&&5===a?o(e.replace(/\$2/g,"07059")):a&&6===a&&o(e.replace(/\$2/g,"007059"))}else b&&o(b)},[a,b,v]),{image:s,message:l,title:x||"",mobileImageSize:d,isPredecimalEnabled:!0}}},70549:function(e,a,n){"use strict";n.d(a,{S:function(){return H}});var t=n(70865),s=n(52322),i=n(67107),r=n(96670);n(22227);var l=n(10420),o=n(8250),c=n(66829),d=n(15541),u=n(47466),m=n(51603),h=n(50862),g=n(89177),p=n(25340),b=n(24973),x=n(17252),v=n(13922),_=n(6228),f=n(12524),j=n.n(f),N=n(63397),y=n(72670),w=n.n(y),S=n(48090),C=n(29051);function D(e){switch(e){case g.ZDB.TwentyFourHourMeterReading:case g.ZDB.DayMeterReading:case g.ZDB.NightMeterReading:case g.ZDB.PeakMeterReading:case g.ZDB.NightStorageReading:return(0,s.jsx)(N.gN,{name:e,type:"input",children:function(a){var n=a.field,i=a.form,l=a.meta.touched;return(0,s.jsx)(m.af,(0,r.Z)((0,t.Z)({},n),{type:"tel",groupClassName:j()("group--wide group--no-margin-medium",{"reading-success-group":l&&!(0,N.u9)(i.errors,n.name)}),isRequired:!0,isNumeric:!0,placeholder:"e.g. 10",label:e,touched:l,error:(0,N.u9)(i.errors,n.name),icon:l&&!(0,N.u9)(i.errors,n.name)&&(0,s.jsx)("span",{className:"reading-success-tick",children:(0,s.jsx)(v.dR,{fillColour:"#5a8b2e"})})}))}});default:return null}}var k=function(e){var a=(0,C.useDispatch)(),n=(0,l.CP)(e.accountNumber),t=n.gprnMprnLabel,i=n.mprnOrGprn,r=n.multiplePremises,v=(0,l.PD)(e.accountNumber),f=v.fields,y=v.isUnknownMcc,k=v.lisElectricityMeterReadingState,M=(0,C.useSelector)(x.BR),E=k.mccError,A=k.isEligible,B=k.isGoodTime,L=k.message,R=k.isLoading,T=k.submitError,I=k.canRetry,P=k.submitSuccess,F=M.submitMeterReadingSuccessTitle,O=M.submitMeterReadingSuccessSubtitle,Z=M.submitMeterReadingSuccessParagraph,G=M.submitMeterReadingErrorTitle,q=M.submitMeterReadingErrorSubtitle,U=M.submitMeterReadingErrorParagraph,Y=M.submitMeterReadingErrorBackLabel,H=M.unknownMccMessage,V=M.multipleMprnMessage,W=M.mccErrorMessage,X=M.goodTimeMessage,J=M.badTimeMessage,Q=M.smartMeterWithCommsAlertMessage,$=(0,d.oi)({accountNumber:e.accountNumber,fields:f}),K=$.schema,z=$.defaultValues,ee=(0,C.useSelector)((0,p.md)(e.accountNumber)),ea=e.accountNumber,en=e.submitElectricityMeterReadingHelpBoxContent;return(0,s.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,s.jsx)("div",{className:"col-2",children:r?(0,s.jsx)("div",{children:w()(V,(0,_.Em)())}):(0,s.jsxs)("div",{children:[!1===P&&!1===T?(0,s.jsxs)("header",{className:"section-header",children:[(0,s.jsxs)("h3",{className:"section-header__title",children:["Submit reading",(0,s.jsxs)("span",{className:"light no-wrap",children:["(".concat(t,": "),(0,s.jsx)("span",{className:"bold",children:i}),")"]})]}),!0===A&&!1===y&&!1===E?(0,s.jsxs)("span",{className:"section-header__legend",children:[(0,s.jsx)(m.RT,{})," Required information"]}):null]}):null,(0,s.jsx)("main",{children:ee?(0,s.jsx)(u.H3,{isRichText:!0,children:(0,s.jsx)("span",{className:"is-smart-meter-with-comms",children:w()(Q,(0,_.Em)())})}):E?(0,s.jsx)(u.aZ,{isRichText:!0,children:w()(W,(0,_.Em)())}):void 0===A?(0,s.jsx)(h.a,{className:"blue"}):y?(0,s.jsx)(u.aZ,{isRichText:!0,children:w()(H,(0,_.Em)())}):A?!0===T?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.h,{success:!1,className:"response-message-container--margin-top",title:G,responseBody:(0,S.uS)((0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-center",children:[(0,s.jsx)("strong",{children:q}),(0,s.jsx)("br",{}),I?L:U]})}))}),I?(0,s.jsx)("div",{className:"align-center",children:(0,s.jsx)("button",{"data-testid":"retry-meter-button",type:"button",className:j()("button secondary back arrow inline"),onClick:e.onRetry,children:Y})}):null]}):!0===P?(0,s.jsx)(c.h,{success:!0,className:"response-message-container--margin-top",title:F,responseBody:(0,S.uS)((0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-center",children:[(0,s.jsx)("strong",{children:O}),(0,s.jsx)("br",{}),Z]})}))}):(0,s.jsx)(N.J9,{validateOnChange:!1,validateOnBlur:!0,validationSchema:K,onSubmit:function(e){a(b.AJ.submitMeterReading(U,ea,e[g.ZDB.TwentyFourHourMeterReading],e[g.ZDB.DayMeterReading],e[g.ZDB.NightMeterReading],e[g.ZDB.PeakMeterReading],e[g.ZDB.NightStorageReading]))},initialValues:z,children:function(){return(0,s.jsxs)(N.l0,{noValidate:!0,autoComplete:"off",children:[(0,s.jsxs)(s.Fragment,{children:[B?(0,s.jsx)(u.qG,{children:X}):(0,s.jsx)(u.aZ,{children:J}),(0,s.jsx)("br",{})]}),(0,s.jsx)(o.PZ,{accountNumber:e.accountNumber}),(0,s.jsxs)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum",children:[(0,s.jsx)("div",{className:"group__flex-item group-item__pad-right",children:D(null==f?void 0:f[0])}),(0,s.jsx)("div",{className:"group__flex-item",children:D(null==f?void 0:f[1])})]}),(0,s.jsxs)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum",children:[(0,s.jsx)("div",{className:"group__flex-item group-item__pad-right",children:D(null==f?void 0:f[2])}),(0,s.jsx)("div",{className:"group__flex-item",children:D(null==f?void 0:f[3])})]}),(0,s.jsx)("div",{className:"align-right",children:(0,s.jsx)("button",{type:"submit","data-testid":"submit-meter-button",className:j()("button primary arrow inline",{loading:R}),children:"Submit"})})]})}}):(0,s.jsx)(u.aZ,{children:w()(L,(0,_.Em)())})})]})}),en&&en.title.length>0&&en.content.length>0?(0,s.jsx)("div",{className:"col-1 col-1--420",children:(0,s.jsx)("div",{className:"side side--mobile",children:(0,s.jsxs)("div",{className:"side__info",children:[(0,s.jsx)("h3",{className:"side__title",children:en.title}),(0,s.jsx)("div",{className:"side__richtext",children:w()(en.content)})]})})}):null]})};n(72299);var M=n(2784),E=function(e){return(0,s.jsx)(N.l0,{className:"form",noValidate:!0,autoComplete:"nope",children:(0,s.jsxs)("div",{className:"inputs-fieldset--flex",children:[(0,s.jsx)(N.gN,{name:"meterReading",type:"input",children:function(e){var a=e.field,n=e.form,i=e.meta;return(0,s.jsx)(m.af,(0,r.Z)((0,t.Z)({groupClassName:"group--wide group--no-margin-medium"},a),{isRequired:!0,isNumeric:!0,maxLength:6,placeholder:"e.g.123456",label:"Meter reading",touched:i.touched,error:(0,N.u9)(n.errors,a.name),tooltip:"Please enter your gas meter reading."}))}}),(0,s.jsx)("button",{className:"button arrow primary inline button-m-l-medium "+(e.loading?"loading":""),type:"submit","data-testid":"submit-form",children:"Submit"})]})})},A=function(e){var a=e.accountNumber,n=e.formCompleted,i=e.formSuccess,r=e.loading,o=e.submitForm,h=e.paragraph,g=e.multipleGprnMessage,p=e.submitGasMeterReadingHelpBoxContent,b=(0,l.CP)(a),x=b.gprnMprnLabel,f=b.mprnOrGprn,j=b.multiplePremises,y=(0,M.useRef)(w()(g,(0,_.Em)())),S=n?i?(0,s.jsx)(c.h,(0,t.Z)({success:!0,className:"response-message-container--margin-top"},e.successResponse)):(0,s.jsx)(c.h,(0,t.Z)({success:!1,className:"response-message-container--margin-top"},e.errorResponse)):!0===j?(0,s.jsx)("div",{children:y.current}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("header",{className:"section-header",children:[(0,s.jsxs)("h3",{className:"section-header__title",children:["Submit reading"," ",(0,s.jsxs)("span",{className:"light no-wrap",children:["(",x,": ",(0,s.jsx)("span",{className:"bold",children:f}),")"]})]}),(0,s.jsxs)("span",{className:"section-header__legend",children:[(0,s.jsx)(m.RT,{})," Required information"]})]}),(0,s.jsxs)("main",{children:[(0,s.jsx)("div",{children:(0,s.jsx)(u.e3,{children:(0,s.jsxs)("p",{children:[(0,s.jsx)(v.kI,{title:"info"})," ",h]})})}),(0,s.jsx)(N.J9,{initialValues:{meterReading:""},onSubmit:o,validateOnChange:!1,validationSchema:d.kQ,children:function(e){return(0,s.jsx)(E,(0,t.Z)({loading:r},e))}})]})]});return(0,s.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,s.jsx)("div",{className:"col-2",children:S}),p&&p.title.length>0&&p.content.length>0?(0,s.jsx)("div",{className:"col-1 col-1--420",children:(0,s.jsx)("div",{className:"side side--mobile",children:(0,s.jsxs)("div",{className:"side__info",children:[(0,s.jsx)("h3",{className:"side__title",children:p.title}),(0,s.jsx)("div",{className:"side__richtext",children:w()(p.content)})]})})}):null]})},B=function(e){var a=e.accountNumber,n=e.account,t=e.submitElectricityMeterReadingHelpBoxContent,i=e.submitGasMeterReadingHelpBoxContent,r=(0,C.useSelector)(x.BR,C.shallowEqual),l=(0,C.useSelector)(b.kh,C.shallowEqual),o=(0,C.useDispatch)(),c=function(e){o(b.UN.submitMeterReading(a,Number(e.meterReading)))};if((0,M.useEffect)(function(){return function(){o(b.UN.reset())}},[]),!r)return null;var d=r.submitReadingParagraph,u=r.multipleGprnMessage;return n.isGasAccount?(0,s.jsx)(A,{accountNumber:a,multipleGprnMessage:u,successResponse:{success:!0,title:"Reading submitted",responseBody:"<p>Thank you, your reading has been submitted.</p>"},errorResponse:{success:!1,title:"Reading submission error",responseBody:'<p>\n Unfortunately, your reading was not submitted. Please call us on \n <a href="tel:01 611 0101">01 611 0101</a>.\n </p>'},formCompleted:l.completed,loading:l.loading,formSuccess:l.success,submitForm:c,paragraph:d&&w()(d,(0,_.Em)({replaceTagNames:"p"})),submitGasMeterReadingHelpBoxContent:i}):(0,s.jsx)(k,{accountNumber:a,submitElectricityMeterReadingHelpBoxContent:t,onRetry:function(){o(b.AJ.resetMeterReadingConfig()),o(b.AJ.getMeterConfig(a))}})};n(31445);var L=n(8020),R=n(9790),T=n(56085),I=n(47934);n(27956);var P=n(92652),F=function(e){var a=e.goodTimeMessage,n=e.badTimeMessage,t=e.isGoodTime,i=e.fields,r=e.preDecimalDigits,l=e.isNewBrand,c=void 0!==l&&l,d=(0,C.useSelector)(b.Gp,C.shallowEqual).isLoading;return(0,s.jsxs)(N.l0,{noValidate:!0,autoComplete:"off",children:[(0,s.jsxs)(s.Fragment,{children:[t?(0,s.jsx)(u.qG,{isNewBrand:!0,children:(0,s.jsx)("p",{className:"m-b-0 m-t-3",children:a})}):(0,s.jsx)(u.aZ,{isNewBrand:!0,children:(0,s.jsx)("p",{className:"m-b-0 m-t-3",children:n})}),(0,s.jsx)("br",{})]}),(0,s.jsx)(o.xM,{preDecimalDigits:r}),(0,s.jsxs)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum",children:[(0,s.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,s.jsx)(P.m,{submitField:null==i?void 0:i[0],isNewBrand:c})}),(0,s.jsx)("div",{className:"group__flex-item",children:(0,s.jsx)(P.m,{submitField:null==i?void 0:i[1],isNewBrand:c})})]}),(0,s.jsxs)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum",children:[(0,s.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,s.jsx)(P.m,{submitField:null==i?void 0:i[2],isNewBrand:c})}),(0,s.jsx)("div",{className:"group__flex-item",children:(0,s.jsx)(P.m,{submitField:null==i?void 0:i[3],isNewBrand:c})})]}),(0,s.jsx)("div",{className:"align-right m-b-20",children:(0,s.jsx)("button",{type:"submit","data-testid":"submit-meter-button",className:j()("button primary arrow inline",{loading:d}),children:"Submit"})})]})},O=function(e){var a=e.accountNumber,n=e.isGoodTime,t=e.goodTimeMessage,i=e.badTimeMessage,r=e.mcc,l=e.preDecimalDigits,o=e.onSubmit,c=e.lastActualReads,u=e.isNewBrand,m=void 0!==u&&u,h=g.mGv[r],p=(0,d.TF)({preDecimalDigits:l,fields:h,lastActualReads:c}),b=p.schema,x=p.defaultValues;return(0,s.jsx)("div",{className:j()({"new-brand new-brand__new-font":m}),children:(0,s.jsx)(N.J9,{validateOnChange:!1,validateOnBlur:!0,validationSchema:b,onSubmit:o,initialValues:x,children:(0,s.jsx)(F,{accountNumber:a,isGoodTime:n,goodTimeMessage:t,badTimeMessage:i,fields:h,preDecimalDigits:l,isNewBrand:m})})})};n(88387);var Z=function(e){var a=e.preDecimalDigits,n=e.goodTimeMessage,t=e.badTimeMessage,i=e.isGoodTime,r=e.onSubmit,l=e.lastActualReads,c=e.isNewBrand,m=void 0!==c&&c,h=(0,C.useSelector)(b.kh,C.shallowEqual).loading,g=(0,d.qI)({preDecimalDigits:a,lastActualReads:l}),p=g.schema,x=g.defaultValues;return(0,s.jsx)("div",{className:j()({"new-brand new-brand__new-font":m}),children:(0,s.jsx)(N.J9,{initialValues:x,onSubmit:r,validateOnChange:!1,validateOnBlur:!0,validationSchema:p,children:(0,s.jsxs)(N.l0,{className:"form",noValidate:!0,autoComplete:"off",children:[(0,s.jsxs)(s.Fragment,{children:[i?(0,s.jsx)(u.qG,{isNewBrand:!0,children:(0,s.jsx)("p",{className:"m-b-0 m-t-3",children:n})}):(0,s.jsx)(u.aZ,{isNewBrand:!0,children:(0,s.jsx)("p",{className:"m-b-0 m-t-3",children:t})}),(0,s.jsx)("br",{})]}),(0,s.jsx)(o.QP,{preDecimalDigits:a,isNewBrand:m}),(0,s.jsx)("div",{className:"group group--fullwidth group--is-flex group--is-multicolum m-t-40",children:(0,s.jsx)("div",{className:"group__flex-item group-item__pad-right",children:(0,s.jsx)(P.z,{fieldName:"meterReading",isNewBrand:m})})}),(0,s.jsx)("div",{className:"align-right m-b-20",children:(0,s.jsx)("button",{"data-testid":"submit-form",type:"submit",className:j()("button primary arrow inline",{loading:h}),children:"Submit"})})]})})})},G=function(e){var a,n,t,i=e.isElectricityAccount,r=e.accountNumber,l=e.isSmartWithComms,o=e.mccError,d=e.isEligible,m=e.isGoodTime,p=e.message,x=e.submitError,v=e.canRetry,f=e.submitSuccess,N=e.isUnknownMcc,y=e.content,D=e.mcc,k=e.preDecimalDigits,E=e.lastActualReads,A=e.isNewBrand,B=void 0!==A&&A,L=(0,C.useDispatch)();(0,M.useEffect)(function(){!0===f&&(i?(0,I.Nf)("SUBMIT_READING_ELECTRICITY_FORM_SUCCESS"):(0,I.Nf)("SUBMIT_READING_GAS_FORM_SUCCESS"))},[f]),(0,M.useEffect)(function(){!0===x&&(i?(0,I.Nf)("SUBMIT_READING_ELECTRICITY_FORM_ERROR"):(0,I.Nf)("SUBMIT_READING_GAS_FORM_ERROR"))},[x]),(0,M.useEffect)(function(){return function(){L(R.U.reset()),L(b.AJ.resetMeterReadingConfig())}},[]);var P=y.submitMeterReadingSuccessTitle,F=y.submitMeterReadingSuccessSubtitle,G=y.submitMeterReadingSuccessParagraph,q=y.submitMeterReadingErrorTitle,U=y.submitMeterReadingErrorSubtitle,Y=y.submitMeterReadingErrorParagraph,H=y.submitMeterReadingErrorBackLabel,V=y.unknownMccMessage,W=y.mccErrorMessage,X=y.gasMccErrorMessage,J=y.goodTimeMessage,Q=y.badTimeMessage,$=y.smartMeterWithCommsAlertMessage;return l?(0,s.jsx)(u.H3,{isRichText:!0,children:(0,s.jsx)("span",{className:"is-smart-meter-with-comms",children:w()($,(0,_.Em)())})}):o?(0,s.jsx)(u.aZ,{isRichText:!0,isNewBrand:!0,children:w()(i?W:X,(0,_.Em)())}):void 0===d?(0,s.jsx)(h.a,{className:"blue"}):N?(0,s.jsx)(u.aZ,{isRichText:!0,isNewBrand:!0,children:w()(V,(0,_.Em)())}):d?!0===x?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.h,{success:!1,className:"response-message-container--margin-top",title:q,responseBody:(0,S.uS)((0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-center",children:[(0,s.jsx)("strong",{children:U}),(0,s.jsx)("br",{}),v?p:Y]})}
1))}),v?(0,s.jsx)("div",{className:"align-center",children:(0,s.jsx)("button",{type:"button",className:j()("button secondary back arrow inline"),onClick:function(){L((0,T.N9)(r)),L((0,T.Q$)(r))},children:H})}):null]}):!0===f?(0,s.jsx)(c.h,{success:!0,className:"response-message-container--margin-top",title:P,responseBody:(0,S.uS)((0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-center",children:[(0,s.jsx)("strong",{children:F}),(0,s.jsx)("br",{}),G]})}))}):i?(0,s.jsx)(O,{accountNumber:r,isGoodTime:m,goodTimeMessage:J,badTimeMessage:Q,mcc:D,onSubmit:(a=Y,n=r,t=L,function(e){t(b.AJ.submitMeterReading(a,n,e[g.ZDB.TwentyFourHourMeterReading],e[g.ZDB.DayMeterReading],e[g.ZDB.NightMeterReading],e[g.ZDB.PeakMeterReading],e[g.ZDB.NightStorageReading]))}),preDecimalDigits:k,lastActualReads:E,isNewBrand:B}):(0,s.jsx)(Z,{accountNumber:r,isGoodTime:m,goodTimeMessage:J,badTimeMessage:Q,onSubmit:function(e){L(R.U.submitMeterReading(r,Number(e.meterReading)))},preDecimalDigits:k,lastActualReads:E,isNewBrand:B}):(0,s.jsx)(u.aZ,{isNewBrand:!0,children:w()(p,(0,_.Em)())})},q=function(e){var a=e.accountNumber,n=e.submitMeterReadingHelpBoxContent,t=e.isSmartWithComms,i=e.mccError,r=e.isEligible,l=e.isGoodTime,o=e.message,c=e.submitError,d=e.canRetry,u=e.submitSuccess,h=e.isUnknownMcc,g=e.mcc,p=e.preDecimalDigits,b=e.lastActualReads,v=e.gprnMprnLabel,f=e.mprnOrGprn,N=e.multiplePremises,y=e.isElectricityAccount,S=e.isNewBrand,D=void 0!==S&&S,k=(0,C.useSelector)(x.BR),M=k.submitMeterReadingSuccessTitle,E=k.submitMeterReadingSuccessSubtitle,A=k.submitMeterReadingSuccessParagraph,B=k.submitMeterReadingErrorTitle,R=k.submitMeterReadingErrorSubtitle,T=k.submitMeterReadingErrorParagraph,I=k.submitMeterReadingErrorBackLabel,P=k.unknownMccMessage,F=k.multipleGprnMessage,O=k.multipleMprnMessage,Z=k.mccErrorMessage,q=k.gasMccErrorMessage,U=k.goodTimeMessage,Y=k.badTimeMessage,H=k.smartMeterWithCommsAlertMessage;return(0,s.jsx)("div",{className:j()({"new-brand":!0}),children:(0,s.jsxs)("div",{className:"col-3-section align-top no-m-t",children:[(0,s.jsx)("div",{className:"col-2",children:N?(0,s.jsx)("div",{children:w()(y?O:F,(0,_.Em)())}):(0,s.jsxs)("div",{children:[!1===u&&!1===c?(0,s.jsxs)("header",{className:"section-header section-header__new-brand",children:[(0,s.jsxs)("h3",{className:"section-header__title",children:["Submit reading ",(0,s.jsxs)("span",{className:"light no-wrap",children:["(".concat(v,": "),(0,s.jsx)("span",{className:"bold","data-cs-mask":!0,children:f}),")"]})]}),!0===r&&!1===h&&!1===i?(0,s.jsxs)("span",{className:"section-header__legend",children:[(0,s.jsx)(m.RT,{})," Required information"]}):null]}):null,(0,s.jsx)("section",{children:(0,s.jsx)(G,{isElectricityAccount:y,accountNumber:a,isSmartWithComms:t,mccError:i,isEligible:r,isGoodTime:l,message:o,submitError:c,canRetry:d,submitSuccess:u,isUnknownMcc:h,content:{submitMeterReadingSuccessTitle:M,submitMeterReadingSuccessSubtitle:E,submitMeterReadingSuccessParagraph:A,submitMeterReadingErrorTitle:B,submitMeterReadingErrorSubtitle:R,submitMeterReadingErrorParagraph:T,submitMeterReadingErrorBackLabel:I,unknownMccMessage:P,mccErrorMessage:Z,gasMccErrorMessage:q,goodTimeMessage:U,badTimeMessage:Y,smartMeterWithCommsAlertMessage:H},mcc:g,preDecimalDigits:p,lastActualReads:b,gprnMprnLabel:v,mprnOrGprn:f,multiplePremises:N,isNewBrand:D})})]})}),n&&n.title.length>0&&n.content.length>0&&(0,s.jsx)(s.Fragment,{children:D?(0,s.jsx)(L.c,{title:n.title,children:(0,s.jsx)("div",{className:"side__richtext",children:w()(n.content)})}):(0,s.jsx)("div",{className:"col-1 col-1--420",children:(0,s.jsx)("div",{className:"side side--mobile",children:(0,s.jsxs)("div",{className:"side__info",children:[(0,s.jsx)("h3",{className:"side__title",children:n.title}),(0,s.jsx)("div",{className:"side__richtext",children:w()(n.content)})]})})})})]})})},U=function(e){var a=e.accountNumber,n=e.submitElectricityMeterReadingHelpBoxContent,t=e.submitGasMeterReadingHelpBoxContent,s=(0,C.useSelector)(x.BR),i=s.maxReadElectricMessage,r=s.maxReadGasMessage,o=(0,C.useSelector)((0,T.ho)(a),C.shallowEqual),c=(0,C.useSelector)((0,T.Hj)(a),C.shallowEqual),d=(0,C.useSelector)((0,T.iu)(a),C.shallowEqual),u=(0,C.useSelector)((0,T.ae)(a),C.shallowEqual),m=(0,C.useSelector)((0,T.rC)(a,i,r),C.shallowEqual),h=(0,l.CP)(a),p=h.gprnMprnLabel,b=h.mprnOrGprn,v=h.multiplePremises,_=h.isElectricityAccount,f=(0,M.useMemo)(function(){return void 0===g.mGv[(null==o?void 0:o.mcc)||""]},[null==o?void 0:o.mcc]);return{isElectricityAccount:_,accountNumber:a,submitMeterReadingHelpBoxContent:_?n:t,isSmartWithComms:!!(null==o?void 0:o.isSmartMeter),mccError:!!(null==c?void 0:c.mccError),isEligible:!!(null==o?void 0:o.eligible),isGoodTime:!!(null==o?void 0:o.goodTime),message:m,submitError:u.submitError,canRetry:d,submitSuccess:u.submitSuccess,isUnknownMcc:!!_&&f,mcc:null==o?void 0:o.mcc,preDecimalDigits:parseInt(null==o?void 0:o.preDecimalDigits),lastActualReads:null==o?void 0:o.lastActualReads,gprnMprnLabel:p,mprnOrGprn:b,multiplePremises:v}},Y=function(e){var a=e.accountNumber,n=e.submitElectricityMeterReadingHelpBoxContent,i=e.submitGasMeterReadingHelpBoxContent,l=e.isNewBrand,o=U({accountNumber:a,submitElectricityMeterReadingHelpBoxContent:n,submitGasMeterReadingHelpBoxContent:i});return(0,s.jsx)(q,(0,r.Z)((0,t.Z)({},o),{isNewBrand:void 0!==l&&l}))},H=function(e){return(0,C.useSelector)(i.Ev)?(0,s.jsx)(Y,(0,t.Z)({},e)):(0,s.jsx)(B,(0,t.Z)({},e))}},50797:function(e,a,n){"use strict";n.d(a,{t:function(){return h}});var t=n(70865),s=n(26297),i=n(52322);n(90261);var r=n(13922),l=n(12524),o=n.n(l),c=n(2784),d=function(e){var a=e.items,n=e.itemsPerPage,t=e.currentPage,s=e.onPageClick,i=Math.ceil(a/n),r=void 0===t?1:t;r>i&&(console.warn("The current page can be higher than ".concat(i,". Please provide a correct number. Defaulting to one")),r=1);var l=(0,c.useMemo)(function(){return!Number.isFinite(i)||i<=0?[]:Array.from({length:i},function(e,a){return a})},[i]),d=1===r,u=r===i,m=o()("pagination__previous pagination__page__button",{"pagination__previous--disabled":d}),h=o()("pagination__next pagination__page__button",{"pagination__next--disabled":u}),g=(0,c.useCallback)(function(e){s&&s(e)},[s]),p=(0,c.useCallback)(function(){s&&s(r-1)},[s,r]),b=(0,c.useCallback)(function(){s&&s(r+1)},[s,r]),x=(0,c.useCallback)(function(e){return i>7&&r>=4&&e<r-1&&e<i-4},[i,r]),v=(0,c.useCallback)(function(e){return i>7&&i-r>=4&&e>r+1&&r+1!==e&&e>5},[i,r]);return{safeCurrentPage:r,numberOfPages:i,pages:l,previousDisabled:d,nextDisabled:u,previousClass:m,nextClass:h,onNumberClick:g,onPreviousClick:p,onNextClick:b,shouldApplyLeftDots:x,shouldApplyRightDots:v}},u=function(e){var a=e.items,n=e.itemsPerPage,t=e.onPageClick,s=e.description,l=e.currentPage,c=void 0===l?1:l,d=Math.ceil(a/n);c>d&&(console.warn("The current page can be higher than ".concat(d,". Please provide a correct number. Defaulting to one")),c=1);var u=Array.from(Array(d).keys()),m=1===c,h=c===d,g=o()("pagination__previous pagination__page__button",{"pagination__previous--disabled":m}),p=o()("pagination__next pagination__page__button",{"pagination__next--disabled":h}),b=function(e){t&&t(e)},x=function(){t&&t(c-1)},v=function(){t&&t(c+1)},_=!1,f=!1;return(0,i.jsx)("nav",{role:"navigation","aria-label":s,children:(0,i.jsxs)("ul",{className:"pagination",children:[(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{className:g,onClick:x,children:(0,i.jsx)(r.ii,{title:"Previous page",fillColour:m?"#001c45":void 0,direction:"right","data-testid":"pagination-previous"})})}),u.map(function(e){var a,n,t=e+1,s=1===t||t===d;if(t===c)return(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Current page, page ".concat(t),"aria-current":!0,className:"pagination__page__button pagination__current-page","data-testid":"left-dots",children:t})},e);if(d>7&&c>=4&&t<c-1&&t<d-4&&!s&&c-1!==t){if(_)return;return _=!0,(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Nothing",className:"pagination__page__button pagination__page__button--nothing","data-testid":"right-dots",children:"..."})},e)}if(d>7&&d-c>=4&&t>c+1&&c+1!==t&&t>5&&!s){if(f)return;return f=!0,(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Nothing",className:"pagination__page__button pagination__page__button--nothing",children:"..."})},e)}return(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Go to page number ".concat(t),className:"pagination__page__button",onClick:function(){return b(t)},children:t})},e)}
1).filter(Boolean),(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{className:p,onClick:v,"data-testid":"pagination-next",children:(0,i.jsx)(r.ii,{title:"Next page",direction:"left",fillColour:m?"#001c45":void 0,"data-testid":"pagination-next"})})})]})})},m=function(e){var a=e.items,n=e.itemsPerPage,t=e.onPageClick,s=e.description,l=e.currentPage,o=d({items:a,itemsPerPage:n,onPageClick:t,currentPage:void 0===l?1:l}),c=o.safeCurrentPage,u=o.numberOfPages,m=o.pages,h=o.previousDisabled,g=o.nextDisabled,p=o.previousClass,b=o.nextClass,x=o.onNumberClick,v=o.onPreviousClick,_=o.onNextClick,f=o.shouldApplyLeftDots,j=o.shouldApplyRightDots,N=!1,y=!1,w=[];return m.forEach(function(e){var a=e+1,n=1===a||a===u;if(a===c){w.push((0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Current page, page ".concat(a),"aria-current":!0,className:"pagination__page__button pagination__current-page","data-testid":"left-dots",children:a})},e));return}if(f(a)&&!n&&c-1!==a){N||(N=!0,w.push((0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Nothing",className:"pagination__page__button pagination__page__button--nothing","data-testid":"right-dots",children:"..."})},e)));return}if(j(a)&&!n){y||(y=!0,w.push((0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Nothing",className:"pagination__page__button pagination__page__button--nothing",children:"..."})},e)));return}w.push((0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{"aria-label":"Go to page number ".concat(a),className:"pagination__page__button",onClick:function(){return x(a)},children:a})},e))}),(0,i.jsx)("span",{className:"pagination--new-brand",children:(0,i.jsx)("nav",{role:"navigation","aria-label":s,children:(0,i.jsxs)("ul",{className:"pagination",children:[(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{className:p,onClick:v,children:(0,i.jsx)(r.Eh,{title:"Previous page",fillColour:h?"#001c45":void 0,"data-testid":"pagination-previous"})})}),w,(0,i.jsx)("li",{className:"pagination__page",children:(0,i.jsx)("button",{className:b,onClick:_,"data-testid":"pagination-next",children:(0,i.jsx)(r.Eh,{title:"Next page",fillColour:g?"#001c45":void 0,"data-testid":"pagination-next"})})})]})})})},h=(0,c.memo)(function(e){var a=e.isNewBrand,n=(0,s.Z)(e,["isNewBrand"]);return a?(0,i.jsx)(m,(0,t.Z)({},n)):(0,i.jsx)(u,(0,t.Z)({},n))},function(e,a){return e.items===a.items&&e.itemsPerPage===a.itemsPerPage&&e.currentPage===a.currentPage})},52273:function(e,a,n){"use strict";n.d(a,{q:function(){return ai},X:function(){return am}});var t,s,i,r=n(52322);n(92285);var l=n(50862),o=n(18323),c=n(30156),d=n(25340),u=n(20030),m=n(92377),h=n(89369),g=n(48939),p=n(47934),b=n(89177),x=n(20895),v=n(17615),_=n(67107),f=n(51075);n(89506);var j=n(29051);
1function N(){var e,a=(0,j.useSelector)(u.gj,j.shallowEqual),n=a.pageState,t=n.achievements,s=n.isLoadingAchievements,i=new Set(null==t?void 0:t.map(function(e){return e.achievementId})),r=i.has("onboarded"),l=Array.isArray(t)&&t.length>0;return{hasOnboardingAchievement:r,awardedAchievementIds:i,achievements:t,hasAchievements:l,isLoading:null!=s&&s,isOnboardingCompleteLoading:null!==(e=a.pageState.isOnboardingCompleteLoading)&&void 0!==e&&e}}var y=n(72670),w=n.n(y),S=n(2784),C=function(e){var a=e.accountId,n=(0,j.useDispatch)(),t=(0,j.useSelector)(u.Pp,j.shallowEqual),s=N().awardedAchievementIds;return((0,S.useEffect)(function(){n(u.bH.fetchAchievements(a))},[a]),void 0===t||void 0===t.achievements||0===t.achievements.length)?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)("section",{className:"achievements insights__card",children:[(0,r.jsx)("h2",{className:"achievements__title",children:t.title}),(0,r.jsx)("div",{className:"achievements__list",children:t.achievements.map(function(e,a){return(0,r.jsxs)("div",{className:"achievements__card",children:[(0,r.jsxs)("div",{className:"achievements__content",children:[e.icon&&s.has(e.id)&&(0,r.jsx)("div",{className:"achievements__icon",children:(0,r.jsx)("img",{src:e.icon.url,alt:e.icon.description})}),e.iconInactive&&!s.has(e.id)&&(0,r.jsx)("div",{className:"achievements__icon",children:(0,r.jsx)("img",{src:e.iconInactive.url,alt:e.iconInactive.description})}),(0,r.jsx)("div",{className:"achievements__card-title",children:e.title})]}),(0,r.jsx)("div",{className:"achievements__card-message",children:w()(e.paragraph)})]},"achievement"+a)})})]})};n(87688);var D=function(e){if("string"==typeof e&&""===e.trim())return["None"];if(!Array.isArray(e))return e;var a=e.filter(function(e){return!("string"==typeof e&&""===e.trim())});return a.length>0?a:["None"]},k=n(47842),M=n(70789),E=n(13922),A=n(6228),B=[M.SG.AO,M.SG.A,M.SG.B,M.SG.C,M.SG.D,M.SG.E,M.SG.F,M.SG.G,],L=(t={},(0,k.Z)(t,M.SG.AO,"#0497D6"),(0,k.Z)(t,M.SG.A,"#00A945"),(0,k.Z)(t,M.SG.B,"#00BB32"),(0,k.Z)(t,M.SG.C,"#B8D800"),(0,k.Z)(t,M.SG.D,"#FFF100"),(0,k.Z)(t,M.SG.E,"#FFB500"),(0,k.Z)(t,M.SG.F,"#FF6400"),(0,k.Z)(t,M.SG.G,"#FF0009"),t),R=function(e){var a=B.indexOf(e);return -1===a?0:Math.round(100-a*(99/(B.length-1)))},T=function(e){if(!e)return null;var a=e.trim().toUpperCase();return"A0"===a?M.SG.AO:B.includes(a)?a:null},I=function(e){var a=e.goToHomeSettingsTab,n=e.energyRating,t=(0,j.useSelector)(function(e){return e.myInsightsPage},j.shallowEqual).pageContent.content,s=T(n);if(!t||!t.myInsightsComparisonsHomeEnergy)return(0,r.jsx)(r.Fragment,{});var i,l=t.myInsightsComparisonsHomeEnergy;return(0,r.jsxs)("div",{className:"comparisons__card comparisons__card--energy-rating",children:[(0,r.jsx)("div",{className:"comparisons__icon",children:(0,r.jsx)(E.Gu,{height:24,width:24})}),(0,r.jsxs)("div",{className:"comparisons__card--section",children:[(0,r.jsx)("div",{className:"comparisons__card-title",children:l.title}),n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"comparisons__energy-bar-group",children:[(0,r.jsx)("div",{className:"comparisons__energy-bar",children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"comparisons__energy-bar-fill",style:{width:"".concat(R(s),"%"),backgroundColor:L[s]||L[M.SG.C]}}),(0,r.jsx)("div",{className:"comparisons__energy-bar-label",style:{left:"".concat(R(s)-3,"%")},children:n})]}):null}),(0,r.jsxs)("div",{className:"comparisons__energy-bar-minmax",children:[(0,r.jsx)("span",{className:"comparisons__energy-bar-min",children:M.SG.G}),(0,r.jsx)("span",{className:"comparisons__energy-bar-max",children:M.SG.AO})]}),(0,r.jsxs)("div",{className:"comparisons__energy-bar-desc",children:[(0,r.jsx)("span",{children:l.minDesc}),(0,r.jsx)("span",{children:l.maxDesc})]})]}),(0,r.jsx)("a",{className:"comparisons__energy-bar-button button secondary arrow small",href:l.buttonLink,id:"home-energy-rating-button",children:l.buttonText})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"comparisons__no-rating-text",children:w()(l.noRatingText,(0,A.Em)({replaceTagNames:"p"}))}),(0,r.jsx)("button",{className:"comparisons__energy-bar-button button secondary arrow small",id:"set-energy-rating-button",type:"button",onClick:a,children:l.noRatingButtonText})]})]})]})},P=n(18427),F="qaDebugSession",O=function(e){var a=(e||"").trim().toUpperCase();return a?"USE AVERAGE"===a?"C":a.charAt(0):""},Z=function(e,a){return new Date(e,a+1,0).getDate()},G=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())},q=function(e,a){var n=new Date(e);return n.setDate(n.getDate()+a),n},U=function(){if(!(0,P.rp)())return!1;try{return!!localStorage.getItem(F)}catch(e){return!1}},Y=function(e,a,n,t){if(0===n.length)return[];for(var s="URBAN"===t?"Urban":"Rural",i=G(e),r=G(a),l=[],o=i;o<=r;o=q(o,1))!function(e){var a=e.getFullYear(),t=e.getMonth(),i=t+1,r=n.find(function(e){return e.month===i&&e.urb_rur===s});if(!r)return"continue";var o=r.proportion_yearly_cons/Z(a,t);l.push({date:e.toISOString().slice(0,10),month:i,region:s,monthlyProportionYearlyCons:r.proportion_yearly_cons,dailyAppliedFactor:o})}(o);return l},H=function(e,a,n,t){if(0===n.length)return 0;for(var s="URBAN"===t?"Urban":"Rural",i=q(G(a),1),r=G(e),l=0;r<i;)!function(){var e=r.getFullYear(),a=r.getMonth(),t=a+1,o=new Date(e,a,1),c=new Date(e,a+1,1),d=r>o?r:o,u=Math.max(0,Math.round(((i<c?i:c).getTime()-d.getTime())/864e5));if(u>0){var m=n.find(function(e){return e.month===t&&e.urb_rur===s});m&&(l+=m.proportion_yearly_cons*(u/Z(e,a)))}r=c}();return l},V=function(e){var a,n,t,s,i,l,o,c,d,h,g=e.accountId,p=e.mprn,x=e.energyRating,v=e.houseType,_=e.usageByBerAndDwelling,N=e.loadFactors,y=void 0===N?[]:N,C=e.urbanRuralProfile,D=void 0===C?"URBAN":C,k=S.useMemo(function(){var e=G
1(new Date);return{accountId:g,mprn:p,from:q(e,-29),to:e,granularity:b.Hef.Daily}},[g,p]),M=S.useMemo(function(){return(0,f.Fs)(k)},[k]),B=(0,j.useSelector)(u.vn),L=(0,j.useSelector)(u.l0),R=(0,S.useState)(!1),T=R[0],I=R[1],P=(0,j.useSelector)(M);if(!B||!L||!P)return(0,r.jsx)("div",{className:"comparisons__card comparisons__card--compare comparisons__card--loading",children:(0,r.jsxs)("div",{className:"comparisons__card--section",children:[(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--text"}),(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--text comparisons__skeleton--text-short"}),(0,r.jsxs)("div",{className:"comparisons__bar-group",children:[(0,r.jsxs)("div",{className:"comparisons__bar-row",children:[(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--label"}),(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--bar"})]}),(0,r.jsxs)("div",{className:"comparisons__bar-row",children:[(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--label"}),(0,r.jsx)("div",{className:"comparisons__skeleton comparisons__skeleton--bar"})]})]})]})});var Z=null!==(o=null===(n=P.readings)||void 0===n?void 0:n.reduce(function(e,a){return e+(null!==(l=a.consumption)&&void 0!==l?l:0)},0))&&void 0!==o?o:0,V=O(x),W=null==_?void 0:null===(t=_[V])||void 0===t?void 0:t[v],X=k.from,J=k.to,Q=X&&J?Y(X,J,y,D):[],$=(null!==(c=null===(s=L[v])||void 0===s?void 0:s[x])&&void 0!==c?c:0)/12,K=0,z="legacyLookup";if("number"==typeof W&&X&&J&&y.length>0){var ee=H(X,J,y,D);K=ee,z="berDwellingWithLoadFactor",$=W*ee}if(U()){var ea=Q.reduce(function(e,a){return e+a.dailyAppliedFactor},0);console.groupCollapsed("[QA Debug][MyInsights][HowYouCompare]"),console.log("sessionKey",F),console.log("inputs",{accountId:g,mprn:p,berInput:x,normalizedBer:V,dwellingType:v,urbanRuralProfile:D,periodFrom:X,periodTo:J,loadFactorsCount:y.length,hasUsageByBerAndDwelling:!!_,annualBerDwellingUsage:W}),console.log("calculation",{youKwh:Z,similarKwh:$,similarKwhSource:z,weightedFactorApplied:K,dailyFactorSum:ea,dayCount:Q.length}),console.table(Q),console.groupEnd()}if((null!==(d=null===(i=P.readings)||void 0===i?void 0:i.filter(function(e){return null!=e.consumption}).length)&&void 0!==d?d:0)<(null!==(h=B.minimumDaysRequired)&&void 0!==h?h:25)&&B.missingDataMessage)return(0,r.jsx)("div",{className:"comparisons__card comparisons__card--compare comparisons__card--missing-data",children:(0,r.jsx)("div",{className:"comparisons__card--section",children:(0,r.jsx)("div",{className:"comparisons__card-message comparisons__card-message--missing-data",children:w()(B.missingDataMessage)})})});var en=Number(Z.toFixed(2)),et=Number($.toFixed(2)),es=Math.max(en,et,1),ei=Math.abs(en-et),er=Z<$,el=0===ei?B.similarMessage:er?B.lessMessage:B.moreMessage,eo=function(e){return"".concat(Number(e.toFixed(2))," kWh")},ec="string"==typeof el?el.replace(/\$1/g,Z.toFixed(2)).replace(/\$2/g,ei.toFixed(2)):"",ed=(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("span",{children:w()(ec,(0,A.RG)("p"))})});return(0,r.jsx)("div",{className:"comparisons__card comparisons__card--compare",children:(0,r.jsxs)("div",{className:"comparisons__card--section",children:[(0,r.jsx)("div",{className:"comparisons__card-message",children:ed}),er&&(0,r.jsx)("div",{className:"comparisons__card-highlight",children:B.highlight}),(0,r.jsxs)("div",{className:"comparisons__bar-group",children:[(0,r.jsxs)("div",{className:"comparisons__bar-row",children:[(0,r.jsx)("div",{className:"comparisons__bar-label",children:B.youLabel}),(0,r.jsx)("div",{className:"comparisons__bar comparisons__bar--you",children:(0,r.jsx)("div",{className:"comparisons__bar-fill",style:{width:"".concat(en/es*100,"%")},children:(0,r.jsx)("span",{className:"comparisons__bar-pill",children:eo(Z)})})})]}),(0,r.jsxs)("div",{className:"comparisons__bar-row",children:[(0,r.jsx)("div",{className:"comparisons__bar-label",children:B.similarLabel}),(0,r.jsx)("div",{className:"comparisons__bar comparisons__bar--similar",children:(0,r.jsx)("div",{className:"comparisons__bar-fill comparisons__bar-fill--similar",style:{width:"".concat(et/es*100,"%")},children:(0,r.jsx)("span",{className:"comparisons__bar-pill comparisons__bar-pill--similar",children:eo($)})})})]})]}),B.learnMoreLink&&B.learnMoreModal&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"comparisons-learn-more-link",className:"comparisons__learn-more",role:"button",onClick:function(){return I(!0)},onKeyDown:function(e){("Enter"===e.key||" "===e.key)&&I(!0)},tabIndex:0,children:B.learnMoreLink}),(0,r.jsx)(m.u_,{shown:!0===T,head:(0,r.jsxs)("div",{className:"learn__more__modal__title",children:[B.learnMoreModal.title,(0,r.jsx)("div",{className:"modal__header__close",onClick:function(){return I(!1)},onKeyDown:function(){return I(!1)},children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsx)("div",{className:"learn__more__modal__body",children:w()(B.learnMoreModal.paragraph)}),footer:(0,r.jsx)("div",{className:"learn__more__modal__footer",children:(0,r.jsx)("button",{className:"button primary",onClick:function(){return I(!1)},children:"Close"})}),singleAction:!1})]})]})})};n(39089);var W=function(e){var a=e.title,n=e.description,t=e.energyRatingLabel,s=e.energyRating,i=e.ratingOptions,l=e.selectedRating,o=e.buttonText,c=e.onRatingChange,d=e.onSaveChanges,u=null!=s?s:void 0===l?"A":l,m=(0,S.useState)(u),h=m[0],g=m[1];(0,S.useEffect)(function(){g(u)},[u]);var p=function(e){g(e),c&&c(e)},b=function(){d&&d(h)};return(0,r.jsxs)("section",{className:"comparisons insights__card",children:[(0,r.jsx)("h2",{className:"comparisons__title",children:(void 0===a?"Comparisons":a)||"Comparisons"}),(0,r.jsxs)("div",{className:"comparsions-settings-card__content",children:[(0,r.jsx)("p",{className:"comparsions-settings-card__description",children:void 0===n?"In order to see how your home compares to other similar homes, we require the BER rating of your home.":n}),(!s||""===s||"null"===s)&&(0,r.jsxs)("div",{className:"comparsions-settings-card__section",children:[(0,r.jsx)("div",{className:"comparsions-settings-card__section-header",children:(0,r.jsx)("p",{className:"comparsions-settings-card__section-label",children:void 0===t?"Home energy rating":t})}),(0,r.jsx)("div",{className:"comparsions-settings-card__rating-options",children:(void 0===i?["AO","A","B","C","D","E","F","G","Use average"]:i).map(function(e){return(0,r.jsx)("button",{id:"energy-rating-option-".concat(e),className:"comparsions-settings-card__rating-option ".concat(h===e?"comparsions-settings-card__rating-option--selected":""),onClick:function(){return p(e)},children:(0,r.jsx)("div",{className:"comparsions-settings-card__rating-option-inner",children:(0,r.jsx)("p",{className:"comparsions-settings-card__rating-option-label",children:e})})},e)})})]}),(0,r.jsx)("button",{className:"button secondary",onClick:b,id:"save-energy-rating-button",type:"button",children:void 0===o?"Save changes":o})]})]})},X=["A0","A","B","C","D","E","F","G"],J=/^A0$|^[A-G]$/,Q=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;var a=Object.keys(e);return 0!==a.length&&a.some(function(a){return J.test(a)&&"object"==typeof e[a]&&null!==e[a]})},$=function(e){if(Q(e))return e;if(!(!e||"object"!=typeof e||Array.isArray(e))){var a=!0,n=!1,t=void 0;
1try{for(var s,i=["usageByBerAndDwelling","usage_by_ber_and_dwelling","data","result"][Symbol.iterator]();!(a=(s=i.next()).done);a=!0){var r=e[s.value];if(Q(r))return r}}catch(l){n=!0,t=l}finally{try{a||null==i.return||i.return()}finally{if(n)throw t}}var o=!0,c=!1,d=void 0;try{for(var u,m=Object.values(e)[Symbol.iterator]();!(o=(u=m.next()).done);o=!0){var h=u.value;if(Q(h))return h}}catch(g){c=!0,d=g}finally{try{o||null==m.return||m.return()}finally{if(c)throw d}}}},K=function(e){var a=$(e);if(!a)return[];var n=Object.keys(a).filter(function(e){return"object"==typeof a[e]});return 0===n.length?[]:n.sort(function(e,a){var n=X.indexOf(e),t=X.indexOf(a);return -1===n&&-1===t?e.localeCompare(a):-1===n?1:-1===t?-1:n-t})},z=function(e){var a,n,t,s=e.accountId,i=e.mprn,l=e.goToHomeSettingsTab,o=N().hasOnboardingAchievement,c=(0,j.useDispatch)(),m=(0,j.useSelector)(u.Gf,j.shallowEqual),h=(0,j.useSelector)(function(e){return(0,d.vU)(s)(e)},j.shallowEqual),g=(0,j.useSelector)(u.sj,j.shallowEqual),b=null==m?void 0:m.myInsightsHowYouCompareCard,x=null==b?void 0:b.energyRatingFile,v=null==b?void 0:b.loadFactorFile,_=x?null==g?void 0:null===(a=g[x])||void 0===a?void 0:a.data:void 0,f=v?null==g?void 0:null===(n=g[v])||void 0===n?void 0:n.data:void 0,y=(0,S.useMemo)(function(){return K(_)},[_]),w=(0,S.useMemo)(function(){return $(_)},[_]),C=(0,S.useMemo)(function(){var e;return Array.isArray(f)?f.filter(function(e){return!!e&&"object"==typeof e&&"string"==typeof e.urb_rur&&"number"==typeof e.month&&"number"==typeof e.proportion_yearly_cons}):[]},[f]),k=(0,j.useSelector)(function(e){return e.myInsightsPage.pageState.answers},j.shallowEqual),M=function(e){var a="energyRating";(0,p.Nf)("MY_INSIGHTS_ANSWER",{question:a,answer:D(e)}),c(u.bH.insightsSubmitAnswer({questionId:a,answer:[{answerId:e,value:e}]},s))};(0,S.useEffect)(function(){s&&c(u.bH.insightsFetchAnswers(s))},[s,c]),(0,S.useEffect)(function(){x&&c(u.bH.fetchComparisonJsonFile(x)),v&&v!==x&&c(u.bH.fetchComparisonJsonFile(v))},[c,x,v]);var E=(0,S.useMemo)(function(){var e="",a="";if(k){var n,t,s=Object.values(k).find(function(e){return"energyRating"===e.questionId});s&&Array.isArray(s.answer)&&s.answer.length>0&&(e=(null===(n=s.answer[0])||void 0===n?void 0:n.value)!==void 0?String(s.answer[0].value):"");var i=Object.values(k).find(function(e){return"houseType"===e.questionId});i&&Array.isArray(i.answer)&&i.answer.length>0&&(a=(null===(t=i.answer[0])||void 0===t?void 0:t.value)!==void 0?String(i.answer[0].value):"")}return{energyRating:e,houseType:a}},[k]),A=E.energyRating,B=E.houseType,L=(null==h?void 0:null===(t=h.duosGroup)||void 0===t?void 0:t.toLowerCase())==="dg2"?"RURAL":"URBAN";return(0,r.jsx)(r.Fragment,{children:o&&(0,r.jsx)(r.Fragment,{children:A&&""!==A&&"null"!==A?(0,r.jsxs)("section",{className:"comparisons insights__card",children:[(0,r.jsx)("h2",{className:"comparisons__title",children:(null==m?void 0:m.comparisonsTitle)||"Comparisons"}),(0,r.jsxs)("div",{className:"comparisons__grid",children:[(0,r.jsx)(V,{accountId:s,mprn:i,energyRating:A,houseType:B,usageByBerAndDwelling:w,loadFactors:C,urbanRuralProfile:L}),(0,r.jsx)(I,{goToHomeSettingsTab:l,energyRating:A})]})]}):(0,r.jsx)(W,{energyRating:A,ratingOptions:y,onSaveChanges:M})})})},ee=n(70865),ea=n(96670);n(17328);var en=n(10405),et=n(63761),es=n(75549),ei="peak_usage_dismissed",er="peak_usage_feedback_dismissed",el="qaDebugSessionPeakUsage",eo=function(e){return 864e5*e};function ec(){return new Date().toISOString().slice(0,10)}function ed(){try{var e,a=localStorage.getItem(ei);if(!a)return{};var n=JSON.parse(a);return{manualDismissedAt:null!==(e=n.manualDismissedAt)&&void 0!==e?e:n.dismissedAt,seenDate:n.seenDate}}catch(t){return{}}}function eu(e){localStorage.setItem(ei,JSON.stringify(e))}function em(){return(0,r.jsx)("span",{className:"peak-usage__alert-icon","aria-hidden":"true",children:(0,r.jsx)("svg",{viewBox:"0 0 22 22",fill:"none",children:(0,r.jsx)("path",{d:"M11.001 0C17.0764 0.000251454 22 4.92422 22 11.001C22 17.0757 17.0764 21.9997 11.001 22C4.92637 22 0 17.0759 0 11.001C2.4738e-05 4.92407 4.92639 0 11.001 0ZM11.001 2.04395C6.06282 2.04395 2.04397 6.06158 2.04395 11.001C2.04395 15.9394 6.06281 19.9561 11.001 19.9561C15.9389 19.9558 19.9561 15.9392 19.9561 11.001C19.956 6.06173 15.9389 2.0442 11.001 2.04395ZM11 16C11.5522 16 11.9998 16.4481 12 17C12 17.5521 11.5523 18 11 18C10.4477 18 10 17.5521 10 17C10.0002 16.4481 10.4478 16 11 16ZM12 14H10V5H12V14Z",fill:"#e00087"})})})}function eh(e){var a=e.onClick;return(0,r.jsx)("button",{id:"peak-usage__alert_close_button",onClick:a,"aria-label":"Close",className:"peak-usage__close-btn",children:(0,r.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M12 4L4 12M4 4L12 12",stroke:"black",strokeWidth:"1.75",strokeLinecap:"round"})})})}
1function eg(e){var a=e.accountId,n=e.mprn,t=(0,j.useSelector)(function(e){return(0,u.oK)(e)},j.shallowEqual)||{},s=t.dismissDurationDays,i=t.description,l=t.title,o=t.feedbackQuestion,c=t.yesLabel,d=t.noLabel,m=t.daysSelectedForComparison,h=t.weekdayPeakThreshold,g=t.weekendPeakThreshold,p=t.feedbackMessage,x=t.minimumDaysRequired,v=t.minimumPeakConsumption,_=(0,S.useMemo)(function(){var e=(0,en.Z)(new Date);return{accountId:a,mprn:n,from:(0,et.Z)(e,-29),to:e,granularity:b.Hef.Daily}},[a,n]),N=(0,S.useMemo)(function(){return(0,f.Fs)(_)},[_]),y=(0,j.useSelector)(N),C=(0,S.useMemo)(function(){if(!(null==y?void 0:y.readings)||!m)return[];var e=(0,en.Z)(new Date),a=(0,et.Z)(e,-m);return y.readings.filter(function(n){var t=new Date(n.interval);return"Peak"===n.tariff&&t>=a&&t<=e&&n.consumption>=(v||0)})},[null==y?void 0:y.readings,m,v]),D=(0,S.useMemo)(function(){return 0===C.length?0:C.reduce(function(e,a){return e+(a.consumption||0)},0)/C.length},[C]),k=(0,S.useMemo)(function(){return 0!==C.length&&D&&h&&g?C.filter(function(e){var a=new Date(e.interval),n=(0,es.Z)(a);return(e.consumption||0)>D*(1+(n?g:h)/100)}).map(function(e){return new Date(e.interval)}):[]},[C,D,h,g]);(function(){if(!(0,P.rp)())return!1;try{return!!localStorage.getItem(el)}catch(e){return!1}})()&&(console.groupCollapsed("[QA Debug][MyInsights][PeakUsage]"),console.log("sessionKey",el),console.log("inputs",{accountId:a,mprn:n,daysSelectedForComparison:m,weekdayPeakThreshold:h,weekendPeakThreshold:g,peakReadingsCount:C.length}),console.log("calculation",{averagePeakConsumption:D,exceedingThresholdDaysCount:k.length}),console.table(k.map(function(e,a){var n;return{"Day #":a+1,Date:e.toISOString().slice(0,10),Consumption:null===(n=C.find(function(a){return new Date(a.interval).toISOString().slice(0,10)===e.toISOString().slice(0,10)}))||void 0===n?void 0:n.consumption}})),console.groupEnd());var M=(0,S.useState)(!1),E=M[0],B=M[1],L=(0,S.useState)(!function(){if(!(0,P.rp)())return!1;try{var e=localStorage.getItem(er);if(!e)return!1;var a=JSON.parse(e).dismissedDate,n=new Date().toISOString().slice(0,10);return a===n}catch(t){return!1}}()),R=L[0],T=L[1],I=function(){B(!1);var e=ed();eu((0,ea.Z)((0,ee.Z)({},e),{manualDismissedAt:Date.now()}))},F=function(){T(!1);var e=new Date().toISOString().slice(0,10);localStorage.setItem(er,JSON.stringify({dismissedDate:e}))};return((0,S.useEffect)(function(){if(!function(e){if(e<=0)return!1;var a=ed(),n=a.manualDismissedAt,t=a.seenDate;if(n)return Date.now()-n<eo(e);if(!t)return!1;var s=ec();if(t===s)return!1;var i=Date.parse("".concat(t,"T00:00:00.000Z"))+864e5;return Date.now()-i<eo(e)}(s||0)&&k.length>0&&C.length>=(x||0)){var e=ed(),a=ec();e.seenDate!==a&&eu((0,ea.Z)((0,ee.Z)({},e),{seenDate:a})),B(!0)}},[s,k,C.length,x]),E)?(0,r.jsxs)("div",{className:"peak-usage",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"peak-usage__border"}),(0,r.jsxs)("div",{className:"peak-usage__head",children:[(0,r.jsx)(em,{}),(0,r.jsx)("h2",{className:"peak-usage__title",children:l}),(0,r.jsx)(eh,{onClick:I})]}),(0,r.jsxs)("div",{className:"peak-usage__content",children:[(0,r.jsx)("p",{className:"peak-usage__body",children:i&&w()(i,(0,A.Em)({replaceTagNames:"p"}))}),(0,r.jsxs)("div",{className:"peak-usage__feedback",children:[!R&&p&&(0,r.jsx)("p",{className:"peak-usage__feedback-message",children:w()(p,(0,A.Em)({replaceTagNames:"p"}))}),R&&o&&(0,r.jsxs)("div",{className:"peak-usage__feedback-label",children:[o,(0,r.jsx)("button",{id:"peak-usage__feedback_yes_button",className:"button secondary peak-usage__feedback-btn","aria-label":"Yes",onClick:F,children:c||"Yes"}),(0,r.jsx)("button",{id:"peak-usage__feedback_no_button",className:"button secondary peak-usage__feedback-btn","aria-label":"No",onClick:F,children:d||"No"})]})]})]})]}):(0,r.jsx)(r.Fragment,{})}n(3947);var ep=n(50902),eb=function(e){var a=e.card,n=a.icon,t=a.title,s=a.description,i=a.offerText,l=a.button;return(0,r.jsxs)("div",{className:"recommendations__card",children:[n&&(0,r.jsx)("div",{className:"recommendations__icon",children:(0,r.jsx)("img",{src:n.url,alt:n.description||t})}),(0,r.jsxs)("div",{className:"recommendations__card-content",children:[(0,r.jsx)("div",{className:"recommendations__card-title",children:t}),(0,r.jsx)("div",{className:"recommendations__card-description",children:s&&w()(s,(0,A.Em)({replaceTagNames:"p"}))}),i&&(0,r.jsx)("p",{className:"recommendations__offer",children:i}),(null==l?void 0:l.url)&&(0,r.jsx)(ep.j,{className:"recommendations__button button secondary arrow small",url:l.url,label:l.label,isWide:!1,isWideMobile:!1})]})]})}
1,ex=function(){var e=(0,j.useSelector)(u.Gf,j.shallowEqual);if(!(null==e?void 0:e.myInsightsRecommendationCards)||0===e.myInsightsRecommendationCards.length)return(0,r.jsx)(r.Fragment,{});var a=e.recommendationsTitle,n=e.myInsightsRecommendationCards;return(0,r.jsxs)("section",{className:"recommendations insights__card",children:[(0,r.jsx)("h2",{className:"recommendations__title",children:a||"Recommendations"}),(0,r.jsx)("div",{className:"recommendations__grid",children:n.map(function(e,a){return(0,r.jsx)(eb,{card:e},a)})})]})};n(26111);var ev=n(97361),e_=n(31807),ef=function(e){var a=e.accountId,n=e.mprn,t=(0,j.useDispatch)(),s=(0,j.useSelector)(u.gj,j.shallowEqual).pageContent,i=s.loaded,l=s.content,o=(0,j.useSelector)(function(e){return(0,u.Ii)()(e,a)}),c=(0,S.useState)(!1),d=c[0],h=c[1];if((0,S.useEffect)(function(){a&&n&&t(u.bH.fetchBillForecastChart(a,n))},[a,n,t]),!i||!l)return(0,r.jsx)(r.Fragment,{});var g=null==l?void 0:l.myInsightsBillForecastCard;if(!g||!o||!o.data)return(0,r.jsx)(r.Fragment,{});if(!o.data.current)return(0,r.jsxs)("div",{className:"bill-forecast",children:[(0,r.jsxs)("div",{className:"bill-forecast__header",children:[(0,r.jsx)("p",{className:"bill-forecast__title",children:g.title}),g.learnMoreLink&&(null==g?void 0:g.learnMoreModal)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"bill-forecast-learn-more-link",className:"bill-forecast__link",role:"button",onClick:function(){return h(!0)},onKeyDown:function(e){("Enter"===e.key||" "===e.key)&&h(!0)},tabIndex:0,children:g.learnMoreLink}),(0,r.jsx)(m.u_,{shown:!0===d,head:(0,r.jsxs)("div",{className:"learn__more__modal__title",children:[null==g?void 0:g.learnMoreModal.title,(0,r.jsx)("div",{className:"modal__header__close",onClick:function(){return h(!1)},onKeyDown:function(){return h(!1)},children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsx)("div",{className:"learn__more__modal__body",children:w()(null==g?void 0:g.learnMoreModal.paragraph)}),footer:(0,r.jsx)("div",{className:"learn__more__modal__footer",children:(0,r.jsx)("button",{className:"button primary",onClick:function(){return h(!1)},children:"Close"})}),singleAction:!1})]})]}),(0,r.jsxs)("p",{className:"bill-forecast__period",children:[(0,r.jsxs)("span",{className:"bill-forecast__period-label",children:[g.billingPeriodLabel," "]}),(0,r.jsx)("span",{className:"bill-forecast__period-value",children:"-"})]}),(0,r.jsx)("div",{className:"bill-forecast__amount-wrapper",children:(0,r.jsx)("div",{className:"bill-forecast__no-data",children:(0,r.jsx)("span",{children:g.noDataMessage})})}),o.data.previous&&(0,r.jsxs)("div",{className:"bill-forecast__last-bill",children:[(0,r.jsx)("p",{className:"bill-forecast__last-bill-label",children:g.lastBillLabel}),(0,r.jsx)("p",{className:"bill-forecast__last-bill-amount",children:(0,r.jsxs)(r.Fragment,{children:[g.currency,o.data.previous.value.toFixed(2)]})})]})]});var p=!o.data.previous,b=p?0:o.data.current.value-o.data.previous.value,x=b>0,v="".concat((0,ev.Z)((0,e_.Z)(o.data.current.period.from),"d MMM")," - ").concat((0,ev.Z)((0,e_.Z)(o.data.current.period.to),"d MMM"));return(0,r.jsxs)("div",{className:"bill-forecast",children:[(0,r.jsxs)("div",{className:"bill-forecast__header",children:[(0,r.jsx)("p",{className:"bill-forecast__title",children:g.title}),g.learnMoreLink&&(null==g?void 0:g.learnMoreModal)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"bill-forecast__link",role:"button",onClick:function(){return h(!0)},onKeyDown:function(e){("Enter"===e.key||" "===e.key)&&h(!0)},tabIndex:0,children:g.learnMoreLink}),(0,r.jsx)(m.u_,{shown:!0===d,head:(0,r.jsxs)("div",{className:"learn__more__modal__title",children:[null==g?void 0:g.learnMoreModal.title,(0,r.jsx)("div",{className:"modal__header__close",onClick:function(){return h(!1)},onKeyDown:function(){return h(!1)},children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsx)("div",{className:"learn__more__modal__body",children:w()(null==g?void 0:g.learnMoreModal.paragraph)}),footer:(0,r.jsx)("div",{className:"learn__more__modal__footer",children:(0,r.jsx)("button",{className:"button primary",onClick:function(){return h(!1)},children:"Close"})}),singleAction:!1})]})]}),(0,r.jsxs)("p",{className:"bill-forecast__period",children:[(0,r.jsxs)("span",{className:"bill-forecast__period-label",children:[g.billingPeriodLabel," "]}),(0,r.jsx)("span",{className:"bill-forecast__period-value",children:v})]}),(0,r.jsxs)("div",{className:"bill-forecast__amount-wrapper",children:[(0,r.jsxs)("p",{className:"bill-forecast__amount ".concat(x?"bill-forecast__amount--increase":"bill-forecast__amount--decrease"),children:[g.currency,o.data.current.value.toFixed(2)]}),!p&&(0,r.jsxs)("div",{className:"bill-forecast__indicator ".concat(x?"bill-forecast__indicator--increase":"bill-forecast__indicator--decrease"),children:[(0,r.jsx)("div",{className:"bill-forecast__arrow ".concat(x?"bill-forecast__arrow--up":"bill-forecast__arrow--down"),children:(0,r.jsx)("svg",{className:"bill-forecast__arrow-svg",fill:"none",preserveAspectRatio:"none",viewBox:"0 0 9.8425 6.89922",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M1.00188 0C0.163371 0 -0.302802 0.969932 0.221009 1.6247L4.14038 6.52391C4.54071 7.02432 5.3018 7.02432 5.70212 6.52391L9.6215 1.6247C10.1453 0.969932 9.67913 0 8.84063 0H1.00188Z",fill:"white",fillRule:"evenodd"})})}),(0,r.jsxs)("p",{className:"bill-forecast__indicator-text",children:[g.currency,Math.abs(b).toFixed(2)," ",g.comparisonPeriod]})]})]}),!p&&(0,r.jsxs)("div",{className:"bill-forecast__last-bill",children:[(0,r.jsx)("p",{className:"bill-forecast__last-bill-label",children:g.lastBillLabel}),(0,r.jsxs)("p",{className:"bill-forecast__last-bill-amount",children:[g.currency,o.data.previous.value.toFixed(2)]})]})]})},ej=n(53137),eN=n(87394);n(53344);var ey=(0,S.createContext)(void 0),ew=function(e){var a=e.chartType,n=e.setDateRange,t=e.children;return(0,r.jsx)(ey.Provider,{value:{chartType:a,setDateRange:n},children:t})},eS=n(50930),eC=function(e,a){var n,t=Object.values(e),s=function(e){var a;return null!==(n=null===(a=t.find(function(a){return a.questionId===e}))||void 0===a?void 0:a.answer)&&void 0!==n?n:[]},i=function(e){return s(e).filter(function(e){return!0===e.value}).map(function(e){return e.answerId})};return a?i(a):(0,eS.Z)(i("appliances")).concat((0,eS.Z)(i("extras")))},eD=function(e,a){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=arguments.length>3?arguments[3]:void 0,s="ev_estimated_kwh"===e||"electric_showers"===e?"extras":"appliances",i=eC(n,s),r="ev_estimated_kwh"===e?"ev_charger":e,l=i.findIndex(function(e){return e===r});l>-1?i=i.filter(function(e,a){return a!==l}):i.push(r);var o={questionId:s,answer:i.map(function(e){return{answerId:e,value:!0}})};(0,p.Nf)("MY_INSIGHTS_ANSWER",{question:s,answer:D(i)}),t(u.bH.insightsSubmitAnswer(o,a));var c=eC(n,"extras"===s?"appliances":"extras");return(0,eS.Z)(i).concat((0,eS.Z)(c))};n(49147);var ek=n(7873),eM=function(e){var a=e.children,n=e.setDateRange,t=e.chartType,s=e.viewTabs,i=e.isPeriodFilterEnabled,l=e.sliderDate,o=e.setSliderDate,c=function(e){var a=new Date(e),n=a.getDay(),t=new Date(a);t.setDate(a.getDate()-(n+6)%7),t.setHours(0,0,0,0);var s=new Date(t);return s.setDate(t.getDate()+6),s.setHours(23,59,59,999),{monday:t,sunday:s}},d=function(e){var a=new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0),n=new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999);return{first:a,last:n}},u=function(e){if("Weekly"===t){var a=c(e),s=a.monday,i=a.sunday;o(s),n({start:s,end:i,type:t})}else if("Monthly"===t){var r=d(e),l=r.first,u=r.last;o(l),n({start:l,end:u,type:t})}else o(e),n({start:e,end:e,type:t})};return(0,S.useEffect)(function(){u(l)},[t]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"detailed__energy__chart__header",children:[i&&(0,r.jsx)("div",{"data-testid":"detailed-energy-chart-tabs-wrapper",className:"detailed__energy__chart__tabs",children:(0,r.jsx)(h.br,{tabs:s,testId:"detailed-energy-chart-tabs",tabButtonSize:h.xO.MEDIUM_SQUARE,isEnclosedTabs:!0})}),(0,r.jsx)("div",{"data-testid":"detailed-energy-chart-time-period",className:"detailed__energy__chart__time-period",children:(0,r.jsx)(ek.nV,{isNewBrandSmartBox:!0,t
1ype:t,onChange:n,showCalendar:!0})})]}),(0,r.jsx)("section",{children:"function"==typeof a?a(l):a})]})};n(63485),n(54237);var eE="ev_charger_prompt_dismissed";function eA(){return(0,r.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 13 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M9 9H13L2 22L3 13H0L10 0L9 9ZM4.06152 11H5.23438L4.71191 15.6982L8.68848 11H6.76562L7.22168 6.89062L4.06152 11Z",fill:"white"})})}function eB(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M12 4L4 12M4 4L12 12",stroke:"white",strokeWidth:"1.75",strokeLinecap:"round"})})}function eL(e){var a=e.onEvAccepted,n=e.content,t=n.title,s=n.body,i=n.dismissedDuration,l=void 0===i?7:i,o=n.okLabel,c=n.cancelLabel,d=e.hasEvLikelyUndeclared,u=(0,S.useState)(!1),m=u[0],h=u[1];if((0,S.useEffect)(function(){d&&!function(e){try{var a=localStorage.getItem(eE);if(!a)return!1;var n,t=JSON.parse(a).dismissedAt;return Date.now()-t<864e5*e}catch(s){return!1}}(l)&&h(!0)},[d]),!m)return null;var g=function(){localStorage.setItem(eE,JSON.stringify({dismissedAt:Date.now()})),h(!1)},p=function(){h(!1),null==a||a()},b=function(){h(!1)};return(0,r.jsxs)("div",{className:"ev_prompt__container",children:[(0,r.jsxs)("h5",{className:"ev_prompt__title",children:[(0,r.jsx)(eA,{}),(0,r.jsx)("span",{children:t})]}),(0,r.jsx)("div",{className:"ev_prompt__body",children:w()(s)}),(0,r.jsxs)("div",{className:"ev_prompt__button-container",children:[(0,r.jsx)("button",{onClick:p,className:"button secondary small",children:o}),"\xa0",(0,r.jsx)("button",{onClick:g,className:"button secondary small",children:c})]}),(0,r.jsx)("button",{onClick:b,"aria-label":"Close",style:{position:"absolute",top:14,right:14,background:"transparent",border:"none",cursor:"pointer",padding:4,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)(eB,{})})]})}function eR(){return(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M14 14.76V4a2 2 0 0 0-4 0v10.76a4 4 0 1 0 4 0Z",stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("text",{x:"15",y:"6",fontSize:"5",fill:"#1a2e5a",fontWeight:"700",children:"c"})]})}function eT(){return(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4",stroke:"#1a2e5a",strokeWidth:"1.75"}),[0,45,90,135,180,225,270,315].map(function(e,a){var n=e*Math.PI/180;return(0,r.jsx)("line",{x1:12+6.5*Math.cos(n),y1:12+6.5*Math.sin(n),x2:12+8.5*Math.cos(n),y2:12+8.5*Math.sin(n),stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round"},a)})]})}function eI(){return(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M20 16.58A5 5 0 0 0 18 7h-1.26A8 8 0 1 0 4 15.25",stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("line",{x1:"8",y1:"19",x2:"8",y2:"21",stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21",stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"21",stroke:"#1a2e5a",strokeWidth:"1.75",strokeLinecap:"round"})]})}function eP(e){var a=e.icon,n=e.label,t=e.value;return t?(0,r.jsxs)("p",{className:"weather_conditions__row",children:[(0,r.jsx)("span",{className:"weather_conditions__row__icon",children:a}),(0,r.jsx)("span",{className:"weather_conditions__label",children:n}),(0,r.jsx)("span",{className:"weather_conditions__value",children:t})]}):null}n(57697);var eF=function(e){if("number"!=typeof e.daylight_hours)return null;var a=Math.floor(e.daylight_hours),n=Math.round((e.daylight_hours-a)*60);return"".concat(a,"h ").concat(n,"m approx.")};function eO(e){var a,n,t=e.content,s=t.title,i=t.averageTempLabel,l=t.daylightHoursLabel,o=t.rainInMmLabel,c=e.weather;return c?(0,r.jsxs)("div",{className:"weather_conditions__container",children:[(0,r.jsx)("h5",{className:"weather_conditions__title",children:s}),(0,r.jsx)("hr",{className:"weather_conditions__divider"}),(0,r.jsx)(eP,{icon:(0,r.jsx)(eR,{}),label:i,value:"number"!=typeof c.mean_temp?null:"".concat(c.mean_temp.toFixed(1),"\xb0C")}),(0,r.jsx)(eP,{icon:(0,r.jsx)(eT,{}),label:l,value:eF(c)}),(0,r.jsx)(eP,{icon:(0,r.jsx)(eI,{}),label:o,value:"number"!=typeof c.rain_mm?null:"".concat(c.rain_mm.toFixed(1),"mm")})]}):null}var eZ,eG=n(24468);(eZ=s||(s={})).DAY="Daily",eZ.WEEK="Weekly",eZ.MONTH="Monthly",eZ.YEAR="Yearly",eG.kL.register(eG.jI,eG.qi,eG.u,eG.De);
1var eq=function(e){var a,n,t,s,i,l,o,c,d,m=(0,j.useSelector)(u.gj,j.shallowEqual).pageContent.content,h=e.dataForChart,g=h.chartData,p=h.evLikelyUndeclared,b=h.weather,x=e.loading,v=void 0!==x&&x,_=e.totalCost,f=e.error,N=e.onEvAccepted,y=e.isEvPromptEnabled,C=e.isWeatherEnabled,D=!g||0===g.length,k=v||D,M=(0,S.useRef)(null);return((0,S.useEffect)(function(){if(M.current){var e="#e0e0e0",a=new eG.kL(M.current,{type:"doughnut",data:{labels:D?[""]:g.map(function(e){return e.label}),datasets:[{data:D?[1]:g.map(function(e){return e.value}),backgroundColor:k?D?[e]:g.map(function(){return e}):g.map(function(e){return e.color}),borderWidth:2,borderColor:"#fff"},]},options:{cutout:"36%",plugins:{legend:{display:!1},tooltip:{enabled:!k,callbacks:{label:function(e){if(k)return"";var a=e.parsed||0;return[" ".concat(g[e.dataIndex].cost.toFixed(1)," kWh")," ".concat(a,"% of total"),]}}}}}});return function(){a.destroy()}}},[g,v,D,k,f]),m)?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"energy-use-chart__section",children:[(0,r.jsxs)("div",{className:"energy-use-chart__main",children:[(0,r.jsxs)("div",{className:"energy-use-chart__canvas",children:[(0,r.jsx)("canvas",{ref:M,width:360,height:360}),f?(0,r.jsx)("div",{className:"energy-use-chart__error-overlay",children:(0,r.jsxs)("p",{children:[w()((null==m?void 0:m.noDataMessage)||"",(0,A.RG)("p")),(0,r.jsx)("a",{href:"/home/help/why-is-my-smart-daily-usage-graph-in-my-online-account-displaying-the-message-no-data-yet-to-display","data-new-window":"true",title:"help link",target:"_blank",rel:"noopener noreferrer",children:(0,r.jsx)("strong",{children:(null==m?void 0:m.noDataMessageButton)||""})})]})}):(0,r.jsx)(r.Fragment,{children:k?(0,r.jsx)("div",{className:"energy-use-chart__loading-overlay",children:(0,r.jsx)("div",{className:"energy-use-chart__spinner"})}):(0,r.jsxs)("div",{className:"energy-use-chart__center-text",children:[(0,r.jsx)("span",{children:m.totalUsage}),(0,r.jsxs)("span",{style:{fontWeight:"bold",fontSize:"2rem"},children:[(void 0===_?0:_).toFixed(2)," kWh"]})]})})]}),(0,r.jsx)("ul",{className:"energy-use-chart__legend",children:D||f?(0,r.jsx)("li",{className:"energy-use-chart__legend-item"}):g.map(function(e){return e.value>0&&(0,r.jsxs)("li",{className:"energy-use-chart__legend-item",children:[(0,r.jsx)("span",{className:"energy-use-chart__legend-dot",style:{backgroundColor:k?"#e0e0e0":e.color}}),(0,r.jsx)("span",{className:"energy-use-chart__legend-label",style:k?{color:"#bdbdbd"}:{},children:e.label})]},e.label)})})]}),(y||C)&&(0,r.jsxs)("div",{className:"energy-use-second__column",children:[y&&(0,r.jsx)(eL,{content:{title:(null===(a=m.myInsightsCharts)||void 0===a?void 0:a.evPromptTitle)||"Do you have an EV charger?",body:(null===(n=m.myInsightsCharts)||void 0===n?void 0:n.evPromptBody)||"<p>You're using a lot of electricity at night.</p>",okLabel:(null===(t=m.myInsightsCharts)||void 0===t?void 0:t.evPromptOkLabel)||"Yes",cancelLabel:(null===(s=m.myInsightsCharts)||void 0===s?void 0:s.evPromptCancelLabel)||"No",dismissedDuration:(null===(i=m.myInsightsCharts)||void 0===i?void 0:i.evPromptDismissedDuration)||7},onEvAccepted:N,hasEvLikelyUndeclared:p}),C&&(0,r.jsx)(eO,{content:{title:(null===(l=m.myInsightsCharts)||void 0===l?void 0:l.weatherCardTitle)||"Weather conditions",averageTempLabel:(null===(o=m.myInsightsCharts)||void 0===o?void 0:o.weatherCardAverageTempLabel)||"Average temp:",daylightHoursLabel:(null===(c=m.myInsightsCharts)||void 0===c?void 0:c.weatherCardDaylightHoursLabel)||"Daylight hours:",rainInMmLabel:(null===(d=m.myInsightsCharts)||void 0===d?void 0:d.rainInMmLabel)||"Rain in mm:"},weather:b})]})]})}):(0,r.jsx)(r.Fragment,{})},eU=function(e){var a=e.accountId,n=e.mprn,t=e.isSmart,i=e.isPeriodFilterEnabled,o=e.sliderDate,c=e.setSliderDate,d=e.eircode,m=e.isEvPromptEnabled,h=e.isWeatherEnabled,g=(0,ej.t)(),p=g.graphTableTypeTabs,b=g.chartType,x=g.granularity,_=p.filter(function(e){return"year"!==e.label.toLowerCase()}),y=(0,f.cX)({isSmart:t}).smartBoxContent,w=(0,f.Sy)({mprn:n,accountId:a,granularity:x,dateRangeType:b,disableDefaultOnTypeChange:!0}),C=w.dateRange,D=w.setDateRange,k=(0,j.useDispatch)();(0,S.useEffect)(function(){a&&k(u.bH.insightsFetchAnswers(a))},[a,k]);
1var M=(0,j.useSelector)(u.gf,j.shallowEqual),E=(0,j.useSelector)(u.H2,j.shallowEqual),A=Object.values(E),B=A&&A.find(function(e){return"extras"===e.questionId}),L=B&&B.answer&&Object.values(B.answer).some(function(e){return"electric vehicle"===e.answerId.toLowerCase()||"ev_charger"===e.answerId.toLowerCase()}),R=S.useMemo(function(){if(!M)return{};var e={};return M.forEach(function(a){(L||"ev"!==a.sectionName.toLowerCase())&&(e[a.sectionName.toLowerCase()]={label:a.sectionName,color:a.color,appliances:a.defaultAppliances.map(function(e){return e.answerId})})}),e},[M]),T=s.DAY,I=N().hasOnboardingAchievement,P=(0,eN.Z)(S.useState(!1),2),F=P[0],O=P[1],Z=function(){O(!0),eD("ev_estimated_kwh",a,E,k)},G=(0,S.useMemo)(function(){return(0,u.Di)()},[]),q=(0,j.useSelector)(function(e){return G(e,a,(0,ev.Z)(C.start,"yyyy-MM-dd"),(0,ev.Z)(C.end,"yyyy-MM-dd"))});(0,S.useEffect)(function(){I&&a&&n&&Object.keys(E).length>0&&(q?O(!1):(O(!0),k(u.bH.fetchEnergyUsageBreakdown(a,n,(0,ev.Z)(C.start,"yyyy-MM-dd"),(0,ev.Z)(C.end,"yyyy-MM-dd"),d?d.substring(0,3):""))))},[I,C,E]),(0,S.useEffect)(function(){q&&(O(!1),k((0,v.c9)(!0)))},[q]);var U=S.useMemo(function(){if(!q||q.error)return{chartData:[]};var e=q.totalKwh||1,a=q.result,n=q.evLikelyUndeclared,t=q.weather;return{chartData:Object.entries(R).map(function(n){var t=(0,eN.Z)(n,2),s=(t[0],t[1]),i=s.appliances.reduce(function(e,n){return Object.hasOwn(a,n)?e+Number(a[n]):e},0),r=Number((i/e*100).toFixed(1));return{label:s.label,value:r,color:s.color||"#888",cost:Number(i)}}),weather:t,evLikelyUndeclared:n}},[q,R]),Y=function(e){var a=new Date(e);D({start:a,end:a,type:"Daily"})};return(0,r.jsx)(eM,{viewTabs:_,chartType:b,setDateRange:D,accountId:a,mprn:n,isPeriodFilterEnabled:i,sliderDate:o,setSliderDate:c,children:function(){return y?(0,r.jsx)(ew,{chartType:T,setDateRange:Y,children:(0,r.jsx)(eq,{dataForChart:U,loading:F,sliderDate:o,setSliderDate:c,totalCost:null==q?void 0:q.totalKwh,error:null==q?void 0:q.error,isEvPromptEnabled:m,isWeatherEnabled:h,onEvAccepted:Z})}):(0,r.jsx)(l.a,{className:"blue loader-container--bigger m-t-80 m-b-80"})}})},eY=function(e){var a=e.openOnboardingModal,n=e.account,t=e.accountId,s=e.mprn,i=e.sliderDate,o=e.setSliderDate,c=e.eircode,d=e.isEvPromptEnabled,h=e.isWeatherEnabled,g=e.goToHomeSettingsTab,p=(0,j.useSelector)(u.VC,j.shallowEqual),b=N(),x=b.hasOnboardingAchievement,v=b.isLoading,_=b.isOnboardingCompleteLoading,f=(0,S.useState)(!1),y=f[0],C=f[1];return(0,r.jsxs)("div",{className:"",children:[(v||_)&&(0,r.jsx)(l.a,{className:"blue"}),!v&&!x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{children:(null==p?void 0:p.simpleViewOnboarding)&&w()(p.simpleViewOnboarding)}),(0,r.jsx)("button",{className:"button arrow inline primary",onClick:a,children:null==p?void 0:p.simpleViewOnboardingButton})]}),!v&&x&&!_&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.a,{isSmart:n.isSmart,isMicrogen:n.hasExportCapability,children:(0,r.jsx)(eU,{isSmart:n.isSmart,isMicrogen:n.hasExportCapability,isSpayGo:n.isSpaygo,accountType:n.accountType,accountId:t,mprn:s,isPeriodFilterEnabled:!0,sliderDate:i,setSliderDate:o,eircode:c,isEvPromptEnabled:d,isWeatherEnabled:h})}),(0,r.jsxs)("div",{className:"insights__chart__buttons",children:[(0,r.jsx)("button",{className:"button secondary small edit__appliances__button",id:"edit-appliances-button",type:"button",onClick:g,children:null==p?void 0:p.editAppliancesLabel}),(null==p?void 0:p.learnMoreModal)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"energy-chart-learn-more-link",className:"learn__more__button",role:"button",onClick:function(){return C(!0)},onKeyDown:function(e){("Enter"===e.key||" "===e.key)&&C(!0)},tabIndex:0,children:null==p?void 0:p.learnMoreLabel}),(0,r.jsx)(m.u_,{shown:!0===y,head:(0,r.jsxs)("div",{className:"learn__more__modal__title",children:[null==p?void 0:p.learnMoreModal.title,(0,r.jsx)("div",{className:"modal__header__close",onClick:function(){return C(!1)},onKeyDown:function(){return C(!1)},children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsx)("div",{className:"learn__more__modal__body",children:w()(null==p?void 0:p.learnMoreModal.paragraph)}),footer:(0,r.jsx)("div",{className:"learn__more__modal__footer",children:(0,r.jsx)("button",{className:"button primary",onClick:function(){return C(!1)},children:"Close"})}),singleAction:!1})]})]})]})]})},eH=S.memo(eY),eV=function(e){var a,n,t,s,i,l,o,c,d,h,g,p,N=e.selectedAccount,y=e.openOnboardingModal,w=e.goToHomeSettingsTab,D=(0,j.use
1Selector)(u.gj,j.shallowEqual).pageContent,k=D.loaded,M=D.content,E=(0,j.useDispatch)();(0,S.useEffect)(function(){E(u.bH.fetchAchievements(N.accountId))},[N.accountId]);var A=(0,S.useState)(function(){var e=new Date;return e.setDate(e.getDate()-1),e.setHours(0,0,0,0),e}),B=A[0],L=A[1],R=S.useMemo(function(){var e=new Date;return e.setDate(e.getDate()-1),e.setFullYear(e.getFullYear()-2),e.setHours(0,0,0,0),e},[]),T=(0,j.useSelector)(_.SK)||{},I=T.isBillForecastEnabled,P=T.isComparisonsEnabled,F=void 0!==P&&P,O=T.isRecommendationsEnabled,Z=T.isAchievementsEnabled,G=T.isEvPromptEnabled,q=T.isWeatherEnabled,U=T.isPeakUsageEnabled,Y=void 0!==U&&U,H=null==N?void 0:N.accountId,V=(null==N?void 0:null===(a=N.premises)||void 0===a?void 0:null===(n=a[0])||void 0===n?void 0:n.mprn)||"",W=(0,S.useMemo)(function(){var e=new Date;e.setHours(0,0,0,0);var a=new Date(e);return a.setDate(a.getDate()-29),{accountId:H,mprn:V,from:a,to:e,granularity:b.Hef.Daily}},[H,V]),X=(0,S.useMemo)(function(){return(0,f.Fs)(W)},[W]),J=(0,j.useSelector)(X);return((0,S.useEffect)(function(){(Y||F)&&!J&&E((0,v.Nx)(W))},[H,V,E,J,Y,F]),k&&M)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"energy-use-chart__container",children:[void 0!==I&&I&&(0,r.jsx)(m.DY,{children:(0,r.jsx)(ef,{accountId:null==N?void 0:N.accountId,mprn:(null==N?void 0:null===(t=N.premises)||void 0===t?void 0:null===(s=t[0])||void 0===s?void 0:s.mprn)||""})}),Y&&(0,r.jsx)(eg,{accountId:null==N?void 0:N.accountId,mprn:(null==N?void 0:null===(i=N.premises)||void 0===i?void 0:null===(l=i[0])||void 0===l?void 0:l.mprn)||""}),(0,r.jsx)(eH,{openOnboardingModal:y,account:new x.d(N),accountId:null==N?void 0:N.accountId,mprn:(null==N?void 0:null===(o=N.premises)||void 0===o?void 0:null===(c=o[0])||void 0===c?void 0:c.mprn)||"",sliderDate:B,setSliderDate:L,startDate:R,eircode:(null==N?void 0:null===(d=N.premises)||void 0===d?void 0:null===(h=d[0])||void 0===h?void 0:h.eircode)||"",isEvPromptEnabled:void 0!==G&&G,isWeatherEnabled:void 0!==q&&q,goToHomeSettingsTab:w})]}),void 0!==O&&O&&(0,r.jsx)(ex,{}),F&&(0,r.jsx)(z,{accountId:null==N?void 0:N.accountId,mprn:(null==N?void 0:null===(g=N.premises)||void 0===g?void 0:null===(p=g[0])||void 0===p?void 0:p.mprn)||"",goToHomeSettingsTab:w}),void 0!==Z&&Z&&(0,r.jsx)(C,{accountId:null==N?void 0:N.accountId})]}):(0,r.jsx)(r.Fragment,{})},eW=n(51603),eX=n(63397),eJ=function(e){var a,n,t,s,i,l=e.show,o=e.onClose,c=e.accountId,d=(0,j.useDispatch)(),h=(0,j.use
1Selector)(u.V5,j.shallowEqual),g=(0,j.useSelector)(function(e){var a,n;return!!(null===(a=(0,u.gj)(e))||void 0===a?void 0:null===(n=a.pageState)||void 0===n?void 0:n.isOnboardingCompleteLoading)}),b=(0,S.useState)("intro"),x=b[0],v=b[1],_=(0,S.useState)(0),f=_[0],N=_[1],y=(null==h?void 0:h.questions)||[],C=(0,S.useState)({}),M=C[0],B=C[1],L=(0,S.useState)(!1),R=L[0],T=L[1],I=(n=(a={questions:y,dispatch:d,accountId:c}).questions,t=a.accountId,s=a.dispatch,i=(0,j.useSelector)(u.H2),(0,S.useCallback)(function(e,a){var r,l,o=n[e];if(o){var c=o.id,d=function(e,a,n,t){var s,i=e.answers||[];if((null===(s=e.answerType)||void 0===s?void 0:s.toLowerCase())==="checkbox"){var r=t||a[n]||{};return Object.keys(r).filter(function(e){return r[e]}).map(function(e){var a=e.split("-").pop(),n=i.find(function(e){return String(e.id)===String(a)});return n?{answerId:n.id,value:!0}:null}).filter(Boolean)}var l=null!=t?t:a[n],o=i.find(function(e){return String(e.value)===String(l)});return o?[{answerId:o.id,value:l}]:[]}(o,i,e,a);if("AppliancesList"===c&&(null===(r=o.answerType)||void 0===r?void 0:r.toLowerCase())==="checkbox"){var m=["Refrigeration","Heating","Washing","Entertainment","Lighting","Cooking",],h={};m.forEach(function(e){h[e]=[]});var g=new Set(d.map(function(e){return e.answerId}));o.answers.forEach(function(e){if(g.has(e.id)){var a=e.section&&m.includes(e.section)?e.section:"Other";h[a]||(h[a]=[]),h[a].push(e.text)}});var b=(0,eS.Z)(m.map(function(e){return{name:e,appliances:h[e]||[]}}));h.Other&&h.Other.length>0&&b.push({name:"Other",appliances:h.Other});var x=d.map(function(e){return e.answerId});(0,p.Nf)("MY_INSIGHTS_ANSWER",{question:c,answer:D(x)}),s(u.bH.insightsSubmitAnswer({questionId:c,answer:b},t));return}var v=(null===(l=o.answerType)||void 0===l?void 0:l.toLowerCase())==="checkbox"?d.map(function(e){return e.answerId}):1===d.length?d[0].value:d.map(function(e){return e.value});(0,p.Nf)("MY_INSIGHTS_ANSWER",{question:c,answer:D(v)}),s(u.bH.insightsSubmitAnswer({questionId:c,answer:d},t))}},[n,i,s,t]));(0,S.useEffect)(function(){if("questions"===x&&y.length>0){var e,a=y[f];a&&(null===(e=a.answerType)||void 0===e?void 0:e.toLowerCase())==="checkbox"&&T(!0)}},[x,f,y]);var P=function(e,a,n){e.setFieldValue(a.name,n.target.checked);var t=(0,ea.Z)((0,ee.Z)({},e.values),(0,k.Z)({},a.name,n.target.checked));T(!0),B(function(e){return(0,ea.Z)((0,ee.Z)({},e),(0,k.Z)({},f,t))})},F=function(){v("questions"),N(0)},O=function(){return v("confirm-later")},Z=function(){0===f?v("intro"):N(function(e){var a,n=e-1,t=y[n],s=!1;return t&&(s=(null===(a=t.answerType)||void 0===a?void 0:a.toLowerCase())==="checkbox"?Object.values(M[n]||{}).some(function(e){return!0===e}):!!M[n]),T(s),n})},G=function(){I(f,M[f]),N(function(e){var a,n=e+1,t=y[n],s=!1;return t&&(s=(null===(a=t.answerType)||void 0===a?void 0:a.toLowerCase())==="checkbox"?Object.values(M[n]||{}).some(function(e){return!0===e}):!!M[n]),T(s),n})},q=function(){I(f,M[f]),v("complete"),d(u.bH.completeOnboarding(c))},U=f===y.length-1,Y="complete"===x&&g,H=function(){if(!Y){if("complete"===x){o();return}O()}};if(!h)return null;var V=h.introText,W=h.introParagraph,X=h.introImage,J=h.buttonLater,Q=h.buttonStart,$=h.buttonFinish,K=h.buttonNext,z=h.completeTitle,en=h.completeParagraph,et=h.confirmLaterTitle,es=h.confirmLaterParagraph,ei=h.buttonConfirmLater,er=h.buttonKeepGoing;return(0,r.jsx)(m.u_,{isNewBrand:!0,wrapperClass:"onboarding__modal",shown:l,head:(0,r.jsxs)("div",{className:"onboarding__head__title",children:["intro"===x?V:"complete"===x?z:"confirm-later"===x?et:y.length>0?y[f].questionText:"",(0,r.jsx)("div",{id:"onboarding-close-button",role:"button",className:"addnewcard__header__close",onClick:H,onKeyDown:function(e){Y||"Enter"!==e.key&&" "!==e.key||H()},tabIndex:Y?-1:0,"aria-disabled":Y,children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:"intro"===x?(0,r.jsxs)("div",{children:[w()(W),X&&(0,r.jsx)("div",{className:"onboarding__image-wrapper",children:(0,r.jsx)("img",{className:"onboarding__image",src:X.url,alt:X.description})})]}):"complete"===x?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:w()(en)}),(0,r.jsx)("div",{className:"onboarding__image-wrapper",children:(0,r.jsx)(E.oc,{width:73,height:73,className:"onboarding__image",f
1illColour:"#2B8731","aria-hidden":"true"})})]}):"confirm-later"===x?(0,r.jsx)("div",{children:(0,r.jsx)("p",{children:w()(es,(0,A.Em)({replaceTagNames:"p"}))})}):(0,r.jsx)("div",{children:y.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{children:w()(y[f].questionIntro)}),function(){for(var e,a=y[f].answers,n=[],t=0;t<a.length;t+=2)n.push(a.slice(t,t+2));return(null===(e=y[f].answerType)||void 0===e?void 0:e.toLowerCase())==="checkbox"?(0,r.jsx)(eQ,{questionIndex:f,rows:n,handleCheckboxChange:P,questions:y,answersState:M}):(0,r.jsx)(e$,{questionIndex:f,answers:a,answersState:M,setAnswersState:B,setIsAnswered:T})}()]})}),footer:"intro"===x?(0,r.jsxs)("div",{children:[(0,r.jsx)("button",{id:"onboarding-skip-button",className:"button onboarding__button_space",onClick:O,type:"button","data-testid":"onboarding-skip","aria-label":(null==h?void 0:h.ariaSkipOnboarding)||"Skip onboarding and do this later",children:J}),(0,r.jsx)("button",{id:"onboarding-start-button",className:"button primary",onClick:F,type:"button","data-testid":"onboarding-start","aria-label":(null==h?void 0:h.ariaStartOnboarding)||"Start onboarding questions",children:Q})]}):"complete"===x?(0,r.jsxs)("div",{className:"onboarding__footer__questions",children:[(0,r.jsx)("button",{id:"onboarding-back-complete",className:"onboarding__back__icon",onClick:function(){v("questions"),N(y.length-1);var e,a=y[y.length-1],n=!1;a&&(n=(null===(e=a.answerType)||void 0===e?void 0:e.toLowerCase())==="checkbox"?Object.values(M[y.length-1]||{}).some(function(e){return!0===e}):!!M[y.length-1]),T(n)},type:"button","data-testid":"onboarding-back-complete","aria-label":(null==h?void 0:h.ariaGoBackLastQuestion)||"Go back to last onboarding question",children:(0,r.jsx)(E.Y0,{fillColour:"#001C45",bgColour:"#DFDFE0",width:48,height:48,"aria-hidden":"true"})}),(0,r.jsx)("button",{className:"button primary onboarding__button--grow",onClick:o,type:"button","data-testid":"onboarding-close",disabled:Y,"aria-label":(null==h?void 0:h.ariaCloseModal)||"Close onboarding modal",children:"Close"})]}):"confirm-later"===x?(0,r.jsxs)("div",{children:[(0,r.jsx)("button",{id:"onboarding-confirm-later-button",className:"button onboarding__button_space",onClick:o,type:"button","data-testid":"onboarding-skip-confirm","aria-label":(null==h?void 0:h.ariaSkipFinishLater)||"Skip and finish onboarding later",children:ei}),(0,r.jsx)("button",{id:"onboarding-keep-going-button",className:"button primary onboarding__button--grow",onClick:function(){return v("questions")},type:"button","data-testid":"onboarding-keep-going","aria-label":(null==h?void 0:h.ariaContinueQuestions)||"Continue onboarding questions",children:er})]}):(0,r.jsxs)("div",{className:"onboarding__footer__questions",children:[(0,r.jsx)("button",{id:"onboarding-back-button",className:"onboarding__back__icon",onClick:Z,type:"button","data-testid":"onboarding-back","aria-label":(null==h?void 0:h.ariaGoBackPrevious)||"Go back to previous onboarding question",children:(0,r.jsx)(E.Y0,{fillColour:"#001C45",bgColour:"#DFDFE0",width:48,height:48,"aria-hidden":"true"})}),U?(0,r.jsx)("button",{id:"onboarding-finish-button",className:"button primary onboarding__button--grow",onClick:q,type:"button","data-testid":"onboarding-finish",disabled:!R,"aria-label":(null==h?void 0:h.ariaFinishOnboarding)||"Finish onboarding",children:$}):(0,r.jsx)("button",{id:"onboarding-next-button",className:"button primary onboarding__button--grow",onClick:G,type:"button","data-testid":"onboarding-next",disabled:!R,"aria-label":(null==h?void 0:h.ariaNextQuestion)||"Go to next onboarding question",children:K})]}),singleAction:!1})},eQ=function(e){var a=e.questionIndex,n=e.rows,t=e.handleCheckboxChange,s=e.questions,i=e.answersState,l=s[a],o=i[a],c={};return l.answers.forEach(function(e){c["question-".concat(a,"-").concat(e.id)]=!!o&&!!o["question-".concat(a,"-").concat(e.id)]}),(0,r.jsx)(eX.J9,{initialValues:c,enableReinitialize:!0,onSubmit:function(){},children:function(e){return(0,r.jsx)(eX.l0,{children:n.map(function(n,s){return(0,r.jsxs)("div",{className:"onboarding__answers-row",children:[n.map(function(n){return(0,r.jsx)("div",{className:"onboarding__answers-col",children:(0,r.jsx)(eX.gN,{name:"question-".concat(a,"-").concat(n.id),children:function(a){var s=a.field;return(0,r.jsx)(eW.Jg,{field:s,formik:e,label:n.text,showError:!1,onChange:function(a){return t(e,s,a)}})}})},n.id)}),1===n.length&&(0,r.jsx)("div",{className:"onboarding__answers-col"})]},s)})})}})},e$=function(e){var a=e.questionIndex,n=e.answers,t=e.answersState,s=e.setAnswersState,i=e.setIsAnswered;return(0,r.jsx)("div",{className:"onboarding__answers-row",children:(0,r.jsx)(eW.SY,{name:"question-".concat(a),value:t[a]||"",label:"",vertical:!1,isRequired:!0,disabled:!1,displayButtons:!0,options:n.map(function(e){return{value:e.value,label:e.text,icon:(0,r.jsx)(r.Fragment,{children:e.icon&&(0,r.jsx)("img",{src:e.icon.url,alt:e.icon.description||e.text,width:40,height:40})})}}),onChange:function(e){s(function(n){return(0,ea.Z)((0,ee.Z)({},n),(0,k.Z)({},a,e))}),i(void 0!==e&&""!==e)},wrapperClass:"",groupClassName:""})})};n(16633);var eK=n(24398),ez=function(e,a){return e?e.reduce(function(e,n){var t,s;return n.hideInSettings||e.push({name:n.sectionName,appliances:null!==(s=null===(t=n.defaultAppliances)||void 0===t?void 0:t.map(function(e){var n="ev_estimated_kwh"===e.answerId?"ev_charger":e.answerId;return{name:e.name,checked:a.includes(n),answerId:e.answerId}}))&&void 0!==s?s:[]}),e},[]):[]},e0=function(e,a,n,t){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=arguments.length>5?arguments[5]:void 0,r=eD(e,n,s,i);a(ez(t||[],r))}
1,e1=function(e){var a,n=e.accountId,t=(0,j.useSelector)(u.gj,j.shallowEqual),s=(0,j.useSelector)(u.u8,j.shallowEqual),i=(0,j.useDispatch)(),l=t.pageContent,o=l.loaded,c=l.content,d=(0,S.useState)(function(){var e,a=null!==(e=t.pageState.answers)&&void 0!==e?e:{},n=eC(a);return ez((null==c?void 0:c.defaultSections)||[],n)}),h=d[0],g=d[1],p=(0,S.useState)(null),b=p[0],x=p[1],v=(0,S.useState)(null),_=v[0],f=v[1],N=(0,S.useState)(null),y=N[0],w=N[1],C=(0,S.useState)(""),D=C[0],k=C[1],M=(0,S.useState)(""),A=M[0],B=M[1],L=(0,S.useState)(""),R=L[0],T=L[1];if(!o||!c||t.pageState.isLoadingAnswers)return null;var I=c.myAppliancesTitle,P=c.applianceModalAddTitle,F=c.applianceModalEditTitle,O=c.applianceTypeLabel,Z=c.applianceTypePlaceholder,G=c.applianceSectionLabel,q=c.applianceSectionPlaceholder,U=c.applianceModalCancel,Y=c.applianceModalDelete,H=c.applianceModalSave,V=c.applianceTypeRequiredError,W=c.applianceSectionRequiredError,X=c.applianceDuplicateError,J=function(){_&&y&&g(h.map(function(e){return e.name===_.name?(0,ea.Z)((0,ee.Z)({},e),{appliances:e.appliances.filter(function(e){return e!==y})}):e})),x(null),f(null),w(null)};return(0,r.jsxs)("div",{className:"my-appliances__container insights__card",children:[(0,r.jsx)("h3",{className:"my-appliances__title",id:"my-appliances",children:I}),(0,r.jsx)("div",{className:"my-appliances__sections",children:h.map(function(e){return(0,r.jsxs)("div",{className:"my-appliances__section",children:[(0,r.jsx)("div",{className:"my-appliances__section-header",children:(0,r.jsx)("span",{className:"my-appliances__section-title",children:e.name})}),(0,r.jsx)("div",{className:"my-appliances__appliances-list",children:e.appliances&&e.appliances.map(function(e){return(0,r.jsx)("div",{className:"my-appliances__appliance-item",children:(0,r.jsx)(eW.Jg,{field:{name:e.answerId,value:e.checked},label:e.name,showError:!1,isNewBrand:!0,disabled:s,onChange:function(e){var a,s=e.nativeEvent.srcElement.id;s&&e0(s,g,n,(null==c?void 0:c.defaultSections)||[],null!==(a=t.pageState.answers)&&void 0!==a?a:{},i)}})},"checkbox-".concat(e.name))})})]},e.name)})}),(0,r.jsx)(eX.J9,{initialValues:{applianceType:D,applianceSection:A},enableReinitialize:!0,onSubmit:function(e,a){var n=e.applianceType,t=e.applianceSection,s=a.setSubmitting,i=(n||"").trim(),r=(t||"").trim();if(!i){T(V),s(!1);return}if(!r){T(W),s(!1);return}if(h.find(function(e){return e.name===r})&&(!_||y!==i)){T(X),s(!1);return}b&&"add-appliance"===b.type?h.map(function(e){return e.name===r?(0,ea.Z)((0,ee.Z)({},e),{appliances:(0,eS.Z)(e.appliances).concat([i])}):e}):b&&"edit-appliance"===b.type&&_&&y&&h.map(function(e){return e.name===_.name?(0,ea.Z)((0,ee.Z)({},e),{appliances:e.appliances.filter(function(e){return e!==y})}):e.name===r?(0,ea.Z)((0,ee.Z)({},e),{appliances:(0,eS.Z)(e.appliances).concat([i])}):e}),x(null),f(null),w(null),s(!1)},children:function(e){var n=e.handleSubmit;return(0,r.jsx)(m.u_,{shown:!!b&&("add-appliance"===b.type||"edit-appliance"===b.type),hideCallback:function(){x(null),f(null),w(null)},head:(0,r.jsxs)("div",{className:"my-appliances__modal-title",children:[(null==b?void 0:b.type)==="edit-appliance"?F:P,(0,r.jsx)("div",{role:"button",className:"add-appliance__close",onClick:function(){x(null),f(null)},onKeyDown:function(e){"Enter"===e.key&&(x(null),f(null))},tabIndex:0,children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsxs)("form",{onSubmit:n,id:"appliance-form",children:[(0,r.jsxs)("div",{className:"my-appliances__delete__row new-brand",children:[(0,r.jsx)(eX.gN,{name:"applianceType",children:function(e){var n,t=e.field,s=e.form,i=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},t),{id:"appliance-type",options:null!==(a=null==c?void 0:null===(n=c.appliances)||void 0===n?void 0:n.map(function(e){return{label:e.name,value:e.name}}))&&void 0!==a?a:[],label:O,placeholder:Z,onChange:function(e){k(e),s.setFieldValue(t.name,e),T("")},touched:i.touched,error:i.error,groupClassName:"my-appliances__input"}))}}),(null==b?void 0:b.type)==="edit-appliance"&&(0,r.jsx)("button",{className:"button danger",type:"button",onClick:J,children:Y})]}),R&&(0,r.jsx)("div",{className:"my-appliances__error",children:R}),(0,r.jsx)(eX.gN,{name:"applianceSection",children:function(e){var a=e.field,n=e.form,t=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},a),{id:"appliance-section",options:h.map(function(e){return{label:e.name,value:e.name}}),label:G,placeholder:q,onChange:function(e){B(e),n.setFieldValue(a.name,e),T("")},touched:t.touched,error:t.error,groupClassName:"my-appliances__input"}))}})]}),footer:(0,r.jsx)("div",{className:"modal__footer",children:(0,r.jsxs)("div",{className:"my-appliances__modal-footer new-brand",children:[(0,r.jsx)("button",{className:"button",type:"button",onClick:function(){x(null),f(null),w(null)},children:U}),(0,r.jsx)("button",{className:"button primary",type:"submit",form:"appliance-form",children:H})]})}),singleAction:!1})}})]})};n(88096),n(80247);var e2=function(e){var a=e.field,n=e.form,t=e.label,s=e.min,i=void 0===s?1:s,l=e.max,o=void 0===l?1/0:l,c=e.step,d=void 0===c?1:c,u=e.onChange,m=e.showPlusIndicator,h=n.values[a.name],g=function(e){e>=i&&e<=o&&(n.setFieldValue(a.name,e),u&&u(e))},p=function(e){var t=e.target.value;if(""===t){n.setFieldValue(a.name,"");return}/^\d+$/.test(t)&&g(Number(t))},b=function(e){"ArrowUp"===e.key?g(Math.min(o,h+d)):"ArrowDown"===e.key&&g(Math.max(i,h-d))};return(0,r.jsx)("div",{className:"bge-counter-field",children:(0,r.jsxs)("div",{className:"input-section",children:[(0,r.jsx)("label",{className:"bge-counter-field__label",htmlFor:"bge-counter-input-".concat(a.name),children:t}),(0,r.jsxs)("div",{className:"bge-counter-field__controls",children:[(0,r.jsx)("button",{type:"button",className:"bge-counter-field__button bge-counter-field__button--minus",onClick:function(){return g(Math.max(i,h-d))},"aria-label":"Decrease ".concat(t),disabled:h<=i,children:"â"}),(0,r.jsx)("input",{id:"bge-counter-input-".concat(a.name),className:"bge-counter-field__value",type:"number",inputMode:"numeric",pattern:"[0-9]*",step:d,min:i,max:o,value:null==h?"":h,onChange:p,onKeyDown:b,"aria-label":t,tabIndex:0}),void 0!==m&&m&&h===o&&(0,r.jsx)("span",{className:"bge-counter-field__plus-indicator",children:"+"}),(0,r.jsx)("button",{type:"button",className:"bge-counter-field__button bge-counter-field__button--plus",onClick:function(){return g(Math.min(o,h+d))},"aria-label":"Increase ".concat(t),disabled:h>=o,children:"+"})]})]})})},e4=function(e){var a,n=e.accountId,t=(0,j.useDispatch)(),s=(0,j.use
1Selector)(u.gj,j.shallowEqual),i=s.pageContent,l=i.loaded,o=i.content;if(!l||!o)return null;var c,d,m=null!==(a=s.pageState.answers)&&void 0!==a?a:{},h=o.myHomeLabel,g=o.energyRatingLabel,b=o.energyRatingText,x=o.homeTypeLabel,v=o.homeHeatingLabel,_=o.occupantsLabel,f=o.bedroomsLabel,N=o.waterHeatingLabel,y=o.energyRatingFieldLabel,S=function(e,a){var s=1===a.length?a[0].value:a.map(function(e){return e.value});(0,p.Nf)("MY_INSIGHTS_ANSWER",{question:e,answer:D(s)}),t(u.bH.insightsSubmitAnswer({questionId:e,answer:a},n))},C=function(e,a){if(!Array.isArray(e))return[];var n=e.find(function(e){return e.id===a});return n&&Array.isArray(n.answers)?n.answers.map(function(e){return{label:e.text,value:e.value}}):[]},k={houseType:(d=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Object.values(m).find(function(a){return"object"==typeof a&&null!==a&&"questionId"in a&&a.questionId===e});return n&&n.answer&&0!==n.answer.length?"string"==typeof n.answer[0].value||"number"==typeof n.answer[0].value?n.answer[0].value:n.answer.map(function(e){return e.value}):a})("houseType",""),bedrooms:Number(d("bedrooms",0)?d("bedrooms",0).replace(/\D/g,""):0),occupants:Number(d("occupants",0)?d("occupants",0).replace(/\D/g,""):0),homeHeating:d("homeHeating",""),waterHeating:d("waterHeating",""),energyRating:d("energyRating","")};return(0,r.jsx)(eX.J9,{enableReinitialize:!0,initialValues:k,onSubmit:function(){},children:function(){return(0,r.jsx)(eX.l0,{children:(0,r.jsxs)("section",{className:"my-home-settings energy-use-chart__container",children:[(0,r.jsx)("h3",{className:"my-home-settings__section-title",children:h}),(0,r.jsxs)("div",{className:"my-home-settings__row",children:[(0,r.jsx)(eX.gN,{name:"houseType",children:function(e){var a=e.field,n=e.form,t=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},a),{options:C(o.homeConfigQuestions,"houseType"),label:x,placeholder:"Select home type",onChange:function(e){n.setFieldValue(a.name,e),S("houseType",[{value:e},])},touched:t.touched,error:(0,eX.u9)(n.errors,a.name),groupClassName:"group--wide group--z-50"}))}}),(0,r.jsx)("div",{className:"my-home-settings__counter",children:(0,r.jsx)(eX.gN,{name:"bedrooms",children:function(e){var a=e.field,n=e.form,t=e.meta,s=function(e){n.setFieldValue(a.name,e),S(a.name,[{value:5===e?"5+":e.toString()},])};return(0,r.jsx)(e2,{field:a,form:n,meta:t,label:f,min:1,max:5,onChange:s,showPlusIndicator:!0})}})}),(0,r.jsx)("div",{className:"my-home-settings__counter",children:(0,r.jsx)(eX.gN,{name:"occupants",children:function(e){var a=e.field,n=e.form,t=e.meta,s=function(e){n.setFieldValue(a.name,e),S(a.name,[{value:5===e?"5+":e.toString()},])};return(0,r.jsx)(e2,{field:a,form:n,meta:t,label:_,min:1,max:5,onChange:s,showPlusIndicator:!0})}})})]}),(0,r.jsxs)("div",{className:"my-home-settings__row my-home-settings__row--mb0",children:[(0,r.jsx)(eX.gN,{name:"homeHeating",children:function(e){var a=e.field,n=e.form,t=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},a),{options:C(o.homeConfigQuestions,"homeHeating"),label:v,placeholder:"Select home heating",onChange:function(e){n.setFieldValue(a.name,e),S(a.name,[{value:e},])},touched:t.touched,error:(0,eX.u9)(n.errors,a.name),groupClassName:"group--wide group--z-50"}))}}),(0,r.jsx)(eX.gN,{name:"waterHeating",children:function(e){var a=e.field,n=e.form,t=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},a),{options:C(o.homeConfigQuestions,"waterHeating"),label:N,placeholder:"Select water heating",onChange:function(e){n.setFieldValue(a.name,e),S("waterHeating",[{value:e},])},touched:t.touched,error:(0,eX.u9)(n.errors,a.name),groupClassName:"group--wide group--z-50"}))}})]}),(0,r.jsx)("h3",{className:"my-home-settings__section-title my-home-settings__section-title--top",children:g}),(0,r.jsx)("div",{className:"my-home-settings__helper-text",children:w()(b)}),(0,r.jsx)("div",{className:"my-home-settings__row",children:(0,r.jsx)(eX.gN,{name:"energyRating",children:function(e){var a=e.field,n=e.form,t=e.meta;return(0,r.jsx)(eK.lU,(0,ea.Z)((0,ee.Z)({},a),{options:C(o.homeConfigQuestions,"energyRating"),label:y,placeholder:"Select energy rating",onCh
1ange:function(e){n.setFieldValue(a.name,e),S("energyRating",[{value:e},])},touched:t.touched,error:(0,eX.u9)(n.errors,a.name),groupClassName:"group--wide group--z-50"}))}})})]})})}})};n(39961);var e3,e5=function(e){var a=e.accountId,n=(0,S.useState)(!1),t=n[0],s=n[1],i=(0,j.useDispatch)(),l=(0,j.useSelector)(u.gj,j.shallowEqual).pageContent,o=l.loaded,c=l.content;if(!o||!c||!c.myInsightsEnrolment)return null;var d=c.myInsightsEnrolment,h=d.enrolmentTitle,p=d.enrolmentText,b=d.enrolmentButtonText,x=d.enrolmentModalTitle,v=d.enrolmentModalText,_=d.enrolmentModalButtonCancel,f=d.enrolmentModalButtonRemove,N=function(){s(!1),i(u.bH.removeInsights(a)),(0,g.k)()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("section",{className:"my-enrolment__container insights__card",children:[(0,r.jsx)("h3",{className:"my-enrolment__title",children:h}),(0,r.jsx)("div",{className:"my-enrolment__content",children:w()(p)}),(0,r.jsxs)("button",{id:"my-insights-enrolment-button",className:"button my-enrolment__button__remove",onClick:function(){return s(!0)},children:[b," ",(0,r.jsx)(E.Dl,{fillColour:"white"})]})]}),(0,r.jsx)(m.u_,{shown:!0===t,head:(0,r.jsxs)("div",{className:"my-enrolment__modal-title",children:[x,(0,r.jsx)("div",{id:"my-insights-enrolment-modal-close-button",className:"modal__header__close",onClick:function(){return s(!1)},onKeyDown:function(){return s(!1)},children:(0,r.jsx)(E.XJ,{fillColour:"#00306a",className:"modal__header__close__svg",height:17,width:17})})]}),body:(0,r.jsx)("div",{className:"my-enrolment__modal__body",children:w()(v)}),footer:(0,r.jsxs)("div",{className:"my-enrolment__modal__footer",children:[(0,r.jsx)("button",{id:"my-insights-enrolment-cancel-button",className:"button secondary",onClick:function(){return s(!1)},children:_}),(0,r.jsxs)("button",{id:"my-insights-enrolment-confirm-remove-button",className:"button my-enrolment__button__remove",onClick:N,children:[f," ",(0,r.jsx)(E.Dl,{fillColour:"white"})]})]}),singleAction:!1})]})},e6=function(e){var a=e.accountId,n=(0,j.useDispatch)();return((0,S.useEffect)(function(){a&&n(u.bH.insightsFetchAnswers(a))},[a]),a)?(0,r.jsxs)("div",{children:[(0,r.jsx)(e4,{accountId:a}),(0,r.jsx)(e1,{accountId:a}),(0,r.jsx)(e5,{accountId:a})]}):(0,r.jsx)(r.Fragment,{})};(e3=i||(i={})).Insights="insights",e3.HomeSettings="home-settings";var e7=function(e){var a=e.showOnboardingModal,n=e.selectedAccount,t=(0,j.useSelector)(u.Gf,j.shallowEqual),s=(0,S.useMemo)(function(){return[{label:(null==t?void 0:t.overviewTabLabel)||"Insights",value:i.Insights,id:"myinsights-insights"},{label:(null==t?void 0:t.homeProfileTabLabel)||"Home Settings",value:i.HomeSettings,id:"myinsights-home-settings"},]},[t]),l=i.Insights,o=(0,S.useState)(void 0!==a&&a),c=o[0],d=o[1],b=(0,S.useState)(l),x=b[0],v=b[1],_=S.useRef(!1);(0,S.useEffect)(function(){(0,p.Nf)("MY_INSIGHTS_TAB_CHANGE",{selectedTab:l})},[l]);var f=function(e){v(e),(0,p.Nf)("MY_INSIGHTS_TAB_CHANGE",{selectedTab:e})},N=function(){_.current=!0,f(i.HomeSettings)};S.useEffect(function(){x===i.HomeSettings&&_.current&&(_.current=!1,setTimeout(function(){var e=document.getElementById("my-appliances");e&&(0,g.k)(e,!0)},0))},[x]);var y=s.map(function(e){return{label:e.label,isSelected:x===e.value,onClick:function(){return f(e.value)}}});return(0,r.jsx)("div",{className:"my-insights-panel",children:(0,r.jsxs)(m.DY,{children:[(0,r.jsx)(eJ,{show:c,onClose:function(){return d(!1)},accountId:null==n?void 0:n.accountId}),!c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.fO,{tabs:y,testId:"main-view-tabs",children:(0,r.jsx)(r.Fragment,{})}),function(){switch(x){case i.Insights:return(0,r.jsx)(eV,{selectedAccount:n,openOnboardingModal:function(){return d(!0)},goToHomeSettingsTab:N});case i.HomeSettings:return(0,r.jsx)(e6,{accountId:null==n?void 0:n.accountId});default:return null}}()]})]})})},e9=n(3854),e8=n(12144),ae=n(27671),aa=function(e){var a=e.hero,n=e.blocks;return(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)(ae.U,(0,ee.Z)({},a)),n&&n.length>0&&(0,r.jsx)("div",{className:"main-section-container",children:(0,r.jsx)("div",{className:"main-container",children:n.map(function(e,a){return(0,r.jsx)(ae.Yu,{block:e},"INSIGHTS_BLOCK_".concat(a))})})})]})},an=n(50741),at=function(e){var a=e.title,n=e.paragraph,t=e.buttonLabel,s=e.image,i=e.account,l=e.mprnGprnIndex;return(0,r.jsxs)("div",{className:"col-3-section no-m-t content-block before-mobile new-brand",children:[(0,r.jsx)("div",{className:"col-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("header",{className:"section-header",children:(0,r.jsx)("h3",{children:a})}),(0,r.jsx)("div",{className:"content-template-article",children:(0,r.jsx)("p",{children:w()(n)})}),(0,r.jsx)("footer",{className:"col-2__footer to-bottom",children:(0,r.jsx)(an.S,{account:i,mprnGprnIndex:Number(l),buttonLabel:t,showAsPrimaryButton:!0})})]})}),(0,r.jsx)("div",{className:"col-1",children:(0,r.jsx)("div",{className:"side side--mobile",children:(0,r.jsx)("div",{className:"side__image__container",children:s&&(0,r.jsx)("img",{className:"side__image",src:null==s?void 0:s.url,alt:(null==s?void 0:s.description)||a})})})})]})},as=function(e){var a=e.insightsObject,n=e.onHandleSmartPlanRegistration,t=e.account,s=e.mprnGprnIndex,i=(0,j.use
1Selector)(u.gj,j.shallowEqual).pageContent,l=i.loaded,o=i.content;if(l&&o){var c=o.myInsightsRegistrationInstall,d=o.myInsightsRegistrationSwitchOn,m=o.myInsightsRegistrationSwitchSmartPlan,h=o.myInsightsRegistrationUnavailable,g=function(){n()},p=null==d?void 0:d.heroBlock,b=null==d?void 0:d.insightsIcon;if(p&&"string"==typeof p.mainTitle&&b&&(p=(0,ea.Z)((0,ee.Z)({},p),{mainTitle:p.mainTitle.replace(/\$/,'<img src="'.concat(b.url,'" alt="').concat(b.description,'" class="insights_icon_text" />'))})),(0,e8.T)(e8.j.INSIGHTS_REGISTRATION_STATUS,{insightsEligibility:a}),!a)return null;var x=a.eligibility;return x===e9.Hv.EligibleActive||x===e9.Hv.Eligible||x===e9.Hv.EligibleOptOut?d&&p&&(0,r.jsx)(aa,{hero:(0,ea.Z)((0,ee.Z)({},p),{onClick:g}),blocks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(function(e){return e.FEATURE_BLOCK?(0,ea.Z)((0,ee.Z)({},e),{FEATURE_BLOCK:(0,ea.Z)((0,ee.Z)({},e.FEATURE_BLOCK),{onToggleChange:g})}):e})}(d.blocks)}):x===e9.Hv.IneligibleLegacySmart?m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(at,{title:m.switchSmartTitle,paragraph:m.switchSmartParagraph,buttonLabel:m.switchSmartButtonLabel,image:m.switchSmartImage,account:t,mprnGprnIndex:s}),(0,r.jsx)(aa,{blocks:m.blocks})]}):x===e9.Hv.IneligibleLegacyNonSmart?c&&(0,r.jsx)(aa,{blocks:c.blocks}):x===e9.Hv.IneligibleSmartNonHH?m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(at,{title:m.switchSmartTitle,paragraph:m.switchSmartParagraph,buttonLabel:m.switchSmartButtonLabel,image:m.switchSmartImage,account:t,mprnGprnIndex:s}),(0,r.jsx)(aa,{blocks:m.blocks})]}):h&&(0,r.jsx)(aa,{blocks:h.blocks})}},ai=function(e){var a=e.accountNumber,n=e.account,t=e.mprnGprnIndex,s=(0,o.hm)(n).showInsights,i=(0,j.useDispatch)(),m=(0,j.useSelector)(u.gj,j.shallowEqual),h=(0,j.useSelector)(c.G6,j.shallowEqual),g=m.pageContent,p=g.loaded,b=g.error,x=g.content,v=m.pageState,_=v.isShowInsights,f=v.isUnrollingAccount,N=v.isRegisteringSmartPlan,y=v.isOnboardingComplete,w=(0,S.useState)(!1),C=w[0],D=w[1],k=(0,j.useSelector)((0,d.kU)(null!=a?a:""),j.shallowEqual);(0,S.useEffect)(function(){s&&D(!0)},[s]);var M=function(){""!==a&&(i(u.bH.registerSmartPlan(a)),i(u.bH.showInsights(!0)))};return C?p&&x&&h.account.loaded&&!f&&k?b&&b.length?(0,r.jsx)("div",{className:"main-container",children:(0,r.jsx)("p",{className:"error",children:b})}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"main-container",children:(0,r.jsx)("div",{className:"my-insights-content new-brand",children:k&&(_||(null==k?void 0:k.eligibility)!=="EligibleActive"?_?(0,r.jsx)(e7,{showOnboardingModal:!y,selectedAccount:n}):(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsx)("div",{className:"my-insights-registration__loader",children:(0,r.jsx)(l.w,{})}),!N&&(0,r.jsx)(as,{insightsObject:k,onHandleSmartPlanRegistration:M,account:n,mprnGprnIndex:t||"0"})]}):(0,r.jsx)(e7,{showOnboardingModal:!1,selectedAccount:n}))})})}):(0,r.jsx)(l.w,{}):(0,r.jsx)(r.Fragment,{})};n(33966);var ar=n(46363),al="insight_card_dismissed";function ao(){return(0,r.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M12 4L4 12M4 4L12 12",stroke:"white",strokeWidth:"1.75",strokeLinecap:"round"})})}function ac(){return(0,r.jsx)("div",{className:"insight-card__icon-container",children:(0,r.jsx)("div",{className:"insight-card__icon",children:(0,r.jsx)("div",{className:"insight-card__icon-svg",children:(0,r.jsx)("svg",{className:"insight-card__svg",fill:"none",preserveAspectRatio:"none",viewBox:"0 0 13 22",children:(0,r.jsx)("path",{d:"M9 9H13L2 22L3 13H0L10 0L9 9ZM4.06152 11H5.23438L4.71191 15.6982L8.68848 11H6.76562L7.22168 6.89062L4.06152 11Z",fill:"var(--fill-0, white)"})})})})})}function ad(){return(0,r.jsx)("div",{className:"insight-card__arrow-icon",children:(0,r.jsx)("div",{className:"insight-card__arrow-wrapper",children:(0,r.jsx)("div",{className:"insight-card__arrow-rotate",children:(0,r.jsx)("div",{className:"insight-card__arrow-svg-container",children:(0,r.jsx)("svg",{className:"insight-card__svg",fill:"none",preserveAspectRatio:"none",viewBox:"0 0 22 22",children:(0,r.jsx)("path",{d:"M11.001 0C17.0762 0.000249954 22 4.92499 22 11C22 17.075 17.0762 21.9998 11.001 22C4.9245 22 0 17.0752 0 11C0 4.92484 4.9245 0 11.001 0ZM11.001 2.05371C6.06769 2.05371 2.05469 6.06695 2.05469 11C2.05469 15.932 6.06769 19.9463 11.001 19.9463C15.933 19.946 19.9453 15.9319 19.9453 11C19.9453 6.0671 15.933 2.05396 11.001 2.05371ZM11 10H17V12H11V16L5 11.001L11 6V10Z",fill:"var(--fill-0, white)"})})})})})})}function au(e){var a=e.title,n=e.description,t=e.ctaLink,s=e.className,i=e.dismissDuration,l=void 0===i?7:i,o=(0,S.useState)(!1),c=o[0],d=o[1],u=function(){d(!1),localStorage.setItem(al,JSON.stringify({dismissedAt:Date.now()}))};return((0,S.useEffect)(function(){!function(e){try{var a=localStorage.getItem(al);
1if(!a)return!1;var n,t=JSON.parse(a).dismissedAt;return Date.now()-t<864e5*e}catch(s){return!1}}(l)&&d(!0)},[l]),c)?(0,r.jsxs)("div",{className:"insight-card ".concat(s||""),children:[(0,r.jsx)(ac,{}),(0,r.jsxs)("div",{className:"insight-card__content",children:[(0,r.jsx)("div",{className:"insight-card__header",children:(0,r.jsx)("div",{className:"insight-card__title-wrapper",children:(0,r.jsx)("div",{className:"insight-card__title",children:(0,r.jsx)("p",{className:"insight-card__title-text",children:a})})})}),(0,r.jsxs)("div",{className:"insight-card__cta-section",children:[(0,r.jsx)("p",{className:"insight-card__description",children:w()(n,(0,A.Em)({replaceTagNames:"p"}))}),t&&(0,r.jsxs)(ar.rU,{id:"insight-card-cta-link",href:t.href,className:"insight-card__cta-text",children:[t.title," ",(0,r.jsx)(ad,{})]})]})]}),(0,r.jsx)("button",{id:"insight-card-close-button",onClick:u,"aria-label":"Close",className:"insight-card__close-button",children:(0,r.jsx)(ao,{})})]}):(0,r.jsx)(r.Fragment,{})}function am(){var e=(0,j.useSelector)(function(e){return(0,u.en)(e)},j.shallowEqual);return e?(0,r.jsx)(au,{title:e.title,description:e.description,ctaLink:e.ctaLink,dismissDuration:e.dismissDuration?parseInt(e.dismissDuration):0,className:"insight-card__notification"}):(0,r.jsx)(r.Fragment,{})}},5846:function(){},5766:function(){},85145:function(){},19526:function(){},80321:function(){},67345:function(){},6964:function(){},22702:function(){},16088:function(){},45387:function(){},10968:function(){},91156:function(){},80247:function(){},82483:function(){},44252:function(){},25730:function(){},57356:function(){},23641:function(){},99537:function(){},25774:function(){},96153:function(){},55042:function(){},40681:function(){},54291:function(){},41755:function(){},22227:function(){},72299:function(){},27956:function(){},88387:function(){},31445:function(){},90261:function(){},89506:function(){},87688:function(){},39089:function(){},54237:function(){},33966:function(){},17328:function(){},3947:function(){},16633:function(){},88096:function(){},39961:function(){},26111:function(){},63485:function(){},57697:function(){},49147:function(){},92285:function(){}}]);
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.