import{h,Host}from"@stencil/core";import{__}from"@wordpress/i18n";import{state as donationState}from"../../../../store/product-donation/index";export class ScProductDonationChoice{constructor(){this.productId=void 0,this.label=void 0,this.recurring=void 0}state(){return donationState[this.productId]}updateState(t){donationState[this.productId]={...donationState[this.productId],...t}}render(){var t,e,r,o;const i=((null===(r=null===(e=null===(t=this.state())||void 0===t?void 0:t.product)||void 0===e?void 0:e.prices)||void 0===r?void 0:r.data)||[]).filter((t=>this.recurring?(null==t?void 0:t.recurring_interval)&&(null==t?void 0:t.ad_hoc):!(null==t?void 0:t.recurring_interval)&&(null==t?void 0:t.ad_hoc))).filter((t=>!(null==t?void 0:t.archived)));return(null==i?void 0:i.length)?h("sc-recurring-price-choice-container",{prices:i.sort(((t,e)=>(null==t?void 0:t.position)-(null==e?void 0:e.position))),product:null===(o=this.state())||void 0===o?void 0:o.product,selectedPrice:this.state().selectedPrice,showDetails:!1,showAmount:!1,onScChange:t=>{var e,r;const o=((null===(r=null===(e=this.state().product)||void 0===e?void 0:e.prices)||void 0===r?void 0:r.data)||[]).find((({id:e})=>e==t.detail));this.updateState({selectedPrice:o})},"aria-label":this.recurring?__("If you want to make your donation recurring then Press Tab once & select the recurring interval from the dropdown. ","surecart"):__("If you want to make your donation once then Press Enter. ","surecart"),style:{"--sc-recurring-price-choice-white-space":"wrap","--sc-recurring-price-choice-text-align":"left"}},h("slot",null,this.label)):h(Host,{style:{display:"none"}})}static get is(){return"sc-product-donation-choices"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-product-donation-choices.scss"]}}static get styleUrls(){return{$:["sc-product-donation-choices.css"]}}static get properties(){return{productId:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The product id for the fields."},attribute:"product-id",reflect:!0},label:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The label for the field."},attribute:"label",reflect:!1},recurring:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:""},attribute:"recurring",reflect:!1}}}static get elementRef(){return"el"}}