import{Fragment,h}from"@stencil/core";import{state}from"../../../../store/product/index";import{isOptionMissing,isOptionSoldOut}from"../../../../store/product/getters";import{__,sprintf}from"@wordpress/i18n";import{setProduct}from"../../../../store/product/setters";export class ScProductPillsVariantOption{constructor(){this.label=void 0,this.optionNumber=1,this.productId=void 0}render(){return h("sc-form-control",{key:"125baefe2b88d9c2eea35b13d59b3c6412f4af3e",label:this.label},h("span",{key:"0e08d93c8aae556bad0ae36a538b7b93a1439966",slot:"label"},this.label),h("div",{key:"891fc231b975e294870ce1296b788e55dfffdf21",class:"sc-product-pills-variant-option__wrapper"},(state[this.productId].variant_options[this.optionNumber-1].values||[]).map((t=>{const e=isOptionSoldOut(this.productId,this.optionNumber,t)||isOptionMissing(this.productId,this.optionNumber,t);return h("sc-pill-option",{isUnavailable:e,isSelected:state[this.productId].variantValues[`option_${this.optionNumber}`]===t,onClick:()=>setProduct(this.productId,{variantValues:{...state[this.productId].variantValues,[`option_${this.optionNumber}`]:t}})},h("span",{"aria-hidden":"true"},t),h("sc-visually-hidden",null,sprintf(__("Select %s: %s.","surecart"),this.label,t),e&&h(Fragment,null," ",__("(option unavailable)","surecart")),state[this.productId].variantValues[`option_${this.optionNumber}`]===t&&h(Fragment,null," ",__("This option is currently selected.","surecart"))))}))))}static get is(){return"sc-product-pills-variant-option"}static get originalStyleUrls(){return{$:["sc-product-pills-variant-option.scss"]}}static get styleUrls(){return{$:["sc-product-pills-variant-option.css"]}}static get properties(){return{label:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Label"},attribute:"label",reflect:!1},optionNumber:{type:"number",mutable:!1,complexType:{original:"1 | 2 | 3",resolved:"1 | 2 | 3",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Which option number?"},attribute:"option-number",reflect:!1,defaultValue:"1"},productId:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The product id"},attribute:"product-id",reflect:!1}}}}