{"version":3,"file":"Score.jsx","names":["memo","FormattedNumber","style","wordBreak","formatter","Intl","NumberFormat","Score","props","$","_c","score","up","down","t0","undefined","format","t1","compact","t2","showUnit","t3"],"sources":["../src/Score.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport FormattedNumber, { type FormattedNumberProps } from \"./FormattedNumber\";\n\nexport type ScoreProps = PrecomputedScoreProps | ComputedScoreProps;\n\nexport interface PrecomputedScoreProps {\n\t/** The score to display. */\n\tscore: number;\n\t/** Forwarded to FormattedNumber. */\n\tcompact?: FormattedNumberProps[\"compact\"];\n\t/** Whether to show the unit \"Benis\" after the number. Defaults to `false`. */\n\tshowUnit?: boolean;\n}\n\nexport interface ComputedScoreProps {\n\t/** number of upvotes */\n\tup: number;\n\t/** number of downvotes */\n\tdown: number;\n\t/** Forwarded to FormattedNumber. */\n\tcompact?: FormattedNumberProps[\"compact\"];\n\t/** Whether to show the unit \"Benis\" after the number. Defaults to `false`. */\n\tshowUnit?: boolean;\n\n\t/** Used as a discriminator between `ComputedScoreProps` and `PrecomputedScoreProps` */\n\tscore?: undefined;\n}\n\nconst style = {\n\twordBreak: \"keep-all\",\n} as const;\n\nconst formatter = new Intl.NumberFormat(\"de\");\n\n/**\n * Base-component that just displays a score. If you need to handle logic with hidden scores, use `MaybeHiddenScore`.\n *\n * Using <Score />, the score is never hidden. This is useful for displaying scores in the Profile etc.\n */\nexport default memo(function Score(props: ScoreProps) {\n\tconst score =\n\t\ttypeof props.score !== \"undefined\"\n\t\t\t? props.score\n\t\t\t: props.up - props.down;\n\treturn (\n\t\t<span\n\t\t\ttitle={\n\t\t\t\tprops.score === undefined\n\t\t\t\t\t? `${formatter.format(props.up)} plus, ${formatter.format(props.down)} minus`\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t<FormattedNumber value={score} compact={props.compact} />\n\t\t\t{props.showUnit && \" Benis\"}\n\t\t</span>\n\t);\n});\n"],"mappings":";AAAA,SAASA,IA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