import{maybeConvertAmount}from"../../../functions/currency";const UNIT_TYPES={kg:"kilogram",lb:"pound",g:"gram",oz:"ounce"};export class ScFormatNumber{constructor(){this.value=0,this.locale=void 0,this.type="decimal",this.noGrouping=!1,this.currency="USD",this.currencyDisplay="symbol",this.minimumIntegerDigits=void 0,this.minimumFractionDigits=null,this.maximumFractionDigits=void 0,this.minimumSignificantDigits=void 0,this.maximumSignificantDigits=void 0,this.noConvert=void 0,this.unit="lb"}render(){if(isNaN(this.value))return"";const e=navigator.language||(null===navigator||void 0===navigator?void 0:navigator.browserLanguage)||(navigator.languages||["en"])[0],i=this.noConvert||"currency"!==this.type?this.value:maybeConvertAmount(this.value,this.currency.toUpperCase()),t=i%1==0?0:2;return new Intl.NumberFormat(this.locale||e,{style:this.type,currency:this.currency.toUpperCase(),currencyDisplay:this.currencyDisplay,useGrouping:!this.noGrouping,minimumIntegerDigits:this.minimumIntegerDigits,minimumFractionDigits:null!==this.minimumFractionDigits?this.minimumFractionDigits:t,maximumFractionDigits:this.maximumFractionDigits,minimumSignificantDigits:this.minimumSignificantDigits,maximumSignificantDigits:this.maximumSignificantDigits,unit:UNIT_TYPES[this.unit]}).format(i)}static get is(){return"sc-format-number"}static get properties(){return{value:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The number to format."},attribute:"value",reflect:!1,defaultValue:"0"},locale:{type:"string",mutable:!0,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The locale to use when formatting the number."},attribute:"locale",reflect:!1},type:{type:"string",mutable:!1,complexType:{original:"'currency' | 'decimal' | 'percent' | 'unit'",resolved:'"currency" | "decimal" | "percent" | "unit"',references:{}},required:!1,optional:!1,docs:{tags:[],text:"The formatting style to use."},attribute:"type",reflect:!1,defaultValue:"'decimal'"},noGrouping:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Turns off grouping separators."},attribute:"no-grouping",reflect:!1,defaultValue:"false"},currency:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The currency to use when formatting. Must be an ISO 4217 currency code such as `USD` or `EUR`."},attribute:"currency",reflect:!1,defaultValue:"'USD'"},currencyDisplay:{type:"string",mutable:!1,complexType:{original:"'symbol' | 'narrowSymbol' | 'code' | 'name'",resolved:'"code" | "name" | "narrowSymbol" | "symbol"',references:{}},required:!1,optional:!1,docs:{tags:[],text:"How to display the currency."},attribute:"currency-display",reflect:!1,defaultValue:"'symbol'"},minimumIntegerDigits:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The minimum number of integer digits to use. Possible values are 1 - 21."},attribute:"minimum-integer-digits",reflect:!1},minimumFractionDigits:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The minimum number of fraction digits to use. Possible values are 0 - 20."},attribute:"minimum-fraction-digits",reflect:!1,defaultValue:"null"},maximumFractionDigits:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The maximum number of fraction digits to use. Possible values are 0 - 20."},attribute:"maximum-fraction-digits",reflect:!1},minimumSignificantDigits:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The minimum number of significant digits to use. Possible values are 1 - 21."},attribute:"minimum-significant-digits",reflect:!1},maximumSignificantDigits:{type:"number",mutable:!1,complexType:{original:"number",resolved:"number",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The maximum number of significant digits to use,. Possible values are 1 - 21."},attribute:"maximum-significant-digits",reflect:!1},noConvert:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Should we convert"},attribute:"no-convert",reflect:!1},unit:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The unit to use when formatting."},attribute:"unit",reflect:!1,defaultValue:"'lb'"}}}}