{"version":3,"file":"0bfb1233.js","sources":["../../../node_modules/@shopify/hydrogen/dist/esnext/components/Money/Money.client.js"],"sourcesContent":["import React from 'react';\nimport { useMoney } from '../../hooks/index.js';\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in [the `LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\nexport function Money({ data, as, withoutCurrency, withoutTrailingZeros, measurement, measurementSeparator = '/', ...passthroughProps }) {\n if (!isMoney(data)) {\n throw new Error(` needs a valid 'data' prop that has 'amount' and 'currencyCode'`);\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n let output = moneyObject.localizedString;\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n }\n else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n }\n else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n return (React.createElement(Wrapper, { ...passthroughProps },\n output,\n measurement && measurement.referenceUnit && (React.createElement(React.Fragment, null,\n measurementSeparator,\n measurement.referenceUnit))));\n}\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(maybeMoney) {\n return (typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode);\n}\n"],"names":["Money","data","as","withoutCurrency","withoutTrailingZeros","measurement","measurementSeparator","passthroughProps","isMoney","moneyObject","useMoney","Wrapper","output","React","maybeMoney"],"mappings":"kKAOO,SAASA,EAAM,CAAE,KAAAC,EAAM,GAAAC,EAAI,gBAAAC,EAAiB,qBAAAC,EAAsB,YAAAC,EAAa,qBAAAC,EAAuB,OAAQC,GAAoB,CACrI,GAAI,CAACC,EAAQP,CAAI,EACb,MAAM,IAAI,MAAM,yEAAyE,EAE7F,MAAMQ,EAAcC,EAAST,CAAI,EAC3BU,EAAUT,GAAA,KAAAA,EAAM,MACtB,IAAIU,EAASH,EAAY,gBACzB,OAAIN,GAAmBC,KACfD,GAAmB,CAACC,EACpBQ,EAASH,EAAY,OAEhB,CAACN,GAAmBC,EACzBQ,EAASH,EAAY,qBAIrBG,EAASH,EAAY,iCAGrBI,EAAM,cAAcF,EAAS,CAAE,GAAGJ,CAAkB,EACxDK,EACAP,GAAeA,EAAY,eAAkBQ,EAAM,cAAcA,EAAM,SAAU,KAC7EP,EACAD,EAAY,aAAa,CAAE,CACvC,CAEA,SAASG,EAAQM,EAAY,CACzB,OAAQ,OAAOA,EAAW,QAAW,UACjC,CAAC,CAACA,EAAW,QACb,OAAOA,EAAW,cAAiB,UACnC,CAAC,CAACA,EAAW,YACrB"}