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* Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaMeterProps, useMeter} from 'react-aria/useMeter';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface MeterProps\n  extends\n    Omit<AriaMeterProps, 'label'>,\n    RenderProps<MeterRenderProps>,\n    SlotProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-Meter'\n   */\n  className?: ClassNameOrFunction<MeterRenderProps>;\n}\n\nexport interface MeterRenderProps {\n  /**\n   * The value as a percentage between the minimum and maximum.\n   */\n  percentage: number;\n  /**\n   * A formatted version of the value.\n   *\n   * @selector [aria-valuetext]\n   */\n  valueText: string | undefined;\n}\n\nexport const MeterContext = createContext<ContextValue<MeterProps, HTMLDivElement>>(null);\n\n/**\n * A meter represents a quantity within a known range, or a fractional value.\n */\nexport const Meter = /*#__PURE__*/ (forwardRef as forwardRefType)(function Meter(\n  props: MeterProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  [props, ref] = useContextProps(props, ref, MeterContext);\n  let {value = 0, minValue = 0, maxValue = 100} = props;\n  value = clamp(value, minValue, maxValue);\n\n  let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n  let {meterProps, labelProps} = useMeter({...props, label});\n\n  // Calculate the width of the progress bar as a percentage\n  let percentage = ((value - minValue) / (maxValue - minValue)) * 100;\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-Meter',\n    values: {\n      percentage,\n      valueText: meterProps['aria-valuetext']\n    }\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <dom.div\n      {...mergeProps(DOMProps, renderProps, meterProps)}\n      ref={ref}\n      slot={props.slot || undefined}>\n      <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n        {renderProps.children}\n      </LabelContext.Provider>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"Meter.cjs.map"}