import clsx from 'clsx'
import Link from 'next/link'
import _ from 'lodash'
import { Row } from '../layout/row'
import { formatPercent } from 'common/util/format'
import {
Contract,
contractPath,
getBinaryProbPercent,
} from 'web/lib/firebase/contracts'
import { Col } from '../layout/col'
import { Spacer } from '../layout/spacer'
import {
Binary,
CPMM,
DPM,
FreeResponse,
FreeResponseContract,
FullContract,
} from 'common/contract'
import {
AnswerLabel,
BinaryContractOutcomeLabel,
FreeResponseOutcomeLabel,
} from '../outcome-label'
import { getOutcomeProbability, getTopAnswer } from 'common/calculate'
import { AbbrContractDetails } from './contract-details'
export function ContractCard(props: {
contract: Contract
showHotVolume?: boolean
showCloseTime?: boolean
className?: string
}) {
const { contract, showHotVolume, showCloseTime, className } = props
const { question, outcomeType, resolution } = contract
return (
{question}
{outcomeType === 'BINARY' && (
)}
{outcomeType === 'FREE_RESPONSE' && (
}
truncate="long"
/>
)}
)
}
export function BinaryResolutionOrChance(props: {
contract: FullContract
large?: boolean
className?: string
}) {
const { contract, large, className } = props
const { resolution } = contract
const marketClosed = (contract.closeTime || Infinity) < Date.now()
const probColor = marketClosed ? 'text-gray-400' : 'text-primary'
return (
{resolution ? (
<>
Resolved
>
) : (
<>
{getBinaryProbPercent(contract)}
chance
>
)}
)
}
export function FreeResponseResolutionOrChance(props: {
contract: FreeResponseContract
truncate: 'short' | 'long' | 'none'
className?: string
}) {
const { contract, truncate, className } = props
const { resolution } = contract
const topAnswer = getTopAnswer(contract)
return (
{resolution ? (
<>
Resolved
>
) : (
topAnswer && (
{formatPercent(getOutcomeProbability(contract, topAnswer.id))}
chance
)
)}
)
}