define("@widget/LAYOUT/bs-ComponentGoPay-2d231fbf.js",["exports","~/c/bs-_rollupPluginBabelHelpers","~/c/bs-ComponentPropTypes","~/c/bs-dataAids","~/c/bs-index"],(function(t,e,a,r,o){"use strict";class s extends(global.React||guac.react).Component{constructor(t){super(t),e._(this,"setupOlaCart",(async()=>{const{websiteId:t,rootDomain:e,env:r,renderMode:o}=this.props;if(!this.gopayCart)try{const s=!!window.sessionStorage;if(!await a.g({shouldUseCache:s,websiteId:t,rootDomain:e}))return;if(this.setState({olaGopayCartOn:!0}),o!==(global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes.PUBLISH)return;this.gopayCart=await a.l.cartSetup({websiteId:t,env:r}),this.updateOlaStoreState(),this.gopayCartUnsubscribe=this.gopayCart.subscribe(this.updateOlaStoreState),a.h({cart:this.gopayCart,renderMode:o})}catch(t){this.gopayCart=null,this.setState({olaGopayCartOn:!1})}})),e._(this,"updateOlaStoreState",(()=>{if(!this.gopayCart)return;const{quantitiesByType:t}=this.gopayCart.getState(),e=t.service||0;this.setState({olaQuantity:e})})),e._(this,"renderItemCount",(()=>{const t=a.a(this.props.category);return 0===this.totalCartQuantity?null:(global.React||guac.react).createElement((global.Core||guac["@wsb/guac-widget-core"]).UX2.Element.Block,{style:{...t.wrapper,marginLeft:"!-6px"},"data-aid":r.D.CART_ICON_COUNT},(global.React||guac.react).createElement((global.Core||guac["@wsb/guac-widget-core"]).UX2.Element.Details.Minor,{style:{...t.count,color:"inherit"},featured:!0},this.totalCartQuantity))})),e._(this,"getLinkProps",(()=>this.props.renderMode!==(global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes.PUBLISH?{}:{onClick:()=>this.gopayCart.toggle()})),e._(this,"cartRouter",(()=>{const{staticContent:t={}}=this.props;return(global.React||guac.react).createElement((global.Core||guac["@wsb/guac-widget-core"]).UX2.Element.Link,e.a({style:{display:"flex",alignItems:"center"},"aria-label":t.cartIcon||"Shopping Cart Icon"},this.getLinkProps()),this.renderIcon(),this.renderItemCount())})),this.state={olaQuantity:0,olsQuantity:0,olaGopayCartOn:!1},this.dropdownToggleId="cart-dropdown-"+ +new Date}componentDidMount(){this.hasOlaWidget&&this.setupOlaCart()}componentWillUnmount(){this.enabledForOla&&this.gopayCart&&this.gopayCartUnsubscribe&&this.gopayCartUnsubscribe()}get hasOlaWidget(){return!!this.props.appointmentsPageId}get enabledForOla(){return this.hasOlaWidget&&this.state.olaGopayCartOn}get shouldRender(){return this.enabledForOla}get totalCartQuantity(){const{olsQuantity:t,olaQuantity:e}=this.state;return t+e}renderIcon(){const{cartStyles:t}=this.props;return(global.React||guac.react).createElement((global.Core||guac["@wsb/guac-widget-core"]).UX2.Element.Icon,{icon:"cart1",style:t,"data-aid":r.D.CART_ICON_RENDER,size:o.I,minTarget:!0})}render(){if(!this.shouldRender)return null;return(global.React||guac.react).createElement((global.Core||guac["@wsb/guac-widget-core"]).UX2.Element.Block,{style:{display:"flex",alignItems:"center",fontSize:"xsmall"},children:this.cartRouter()})}}s.propTypes=a.b,t.default=s,Object.defineProperty(t,"__esModule",{value:!0})})),"undefined"!=typeof window&&(window.global=window); //# sourceMappingURL=bs-ComponentGoPay-2d231fbf.js.map