{"version":3,"file":"chunk-Progress.mjs","names":["Progress","ProgressPrimitive"],"sources":["../../src/components/Progress/Progress.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Progress as ProgressPrimitive } from '@ark-ui/react/progress';\nimport React, { type CSSProperties, forwardRef, useEffect, useRef } from 'react';\n\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { recipes } from '../../recipes.ts';\n\nexport type ProgressProps = ThemedClassName<\n  Omit<ProgressPrimitive.RootProps, 'value' | 'defaultValue' | 'min' | 'max' | 'children'>\n> & {\n  /** How far through, from 0 to `max`; ignored when `indeterminate` or `countdown`. */\n  value?: number;\n  /** Defaults to 1, so `value` is a fraction. */\n  max?: number;\n  /** A sweep for a task with nothing to count. */\n  indeterminate?: boolean;\n  /** Draws the range in the error colour, for a run that stopped where it got to. */\n  error?: boolean;\n  /** Milliseconds to empty the bar over, for a deadline rather than a task; hidden from assistive tech. */\n  countdown?: number;\n  /** Holds a `countdown` where it is. */\n  paused?: boolean;\n  /** Names the progressbar (`aria-label` on Ark's track). */\n  label?: string;\n};\n\n/**\n * Ark's linear progress as a single thin bar: a track and its range, determinate, indeterminate or a countdown. A host\n * supplies any label or readout around it.\n */\nexport const Progress = forwardRef<HTMLDivElement, ProgressProps>(\n  (\n    { classNames, value = 0, max = 1, indeterminate, error, countdown, paused, label, style, ...props },\n    forwardedRef,\n  ) => {\n    // A run with nothing to count cannot say how far it got, so a failure fills the bar and stops sweeping: motion\n    // after the run is over reads as still working.\n    const counting = !!countdown && Number.isFinite(countdown) && countdown > 0 && !indeterminate && !error;\n    const mode = counting ? 'countdown' : indeterminate ? (error ? 'failed' : 'indeterminate') : 'determinate';\n\n    // An advance eases; a rewind snaps, since sliding backwards animates a run that never happened.\n    const previous = useRef(value);\n    const rewound = value < previous.current;\n    useEffect(() => {\n      previous.current = value;\n    }, [value]);\n\n    const rangeStyle: CSSProperties | undefined = counting\n      ? { animationDuration: `${countdown}ms`, animationPlayState: paused ? 'paused' : 'running' }\n      : rewound\n        ? { transition: 'none' }\n        : undefined;\n\n    return (\n      <ProgressPrimitive.Root\n        {...props}\n        {...(counting && { 'aria-hidden': true })}\n        value={mode === 'determinate' ? Math.min(max, Math.max(0, value)) : null}\n        min={0}\n        max={max}\n        data-mode={mode}\n        data-error={error ? '' : undefined}\n        style={style}\n        className={mx(recipes.progress(), classNames)}\n        ref={forwardedRef}\n      >\n        <ProgressPrimitive.Track\n          {...(counting ? { role: 'presentation' } : label ? { 'aria-label': label } : {})}\n          className={recipes.progressTrack()}\n        >\n          <ProgressPrimitive.Range className={recipes.progressRange()} style={rangeStyle} />\n        </ProgressPrimitive.Track>\n      </ProgressPrimitive.Root>\n    );\n  },\n);\n\nProgress.displayName = 'Progress';\n"],"mappings":";;;;;;;;;;AAmCA,IAAaA,aAAW,YAEpB,EAAE,YAAY,QAAQ,GAAG,MAAM,GAAG,eAAe,OAAO,WAAW,QAAQ,OAAO,OAAO,GAAG,SAC5F,iBACG;CAGH,MAAM,WAAW,CAAC,CAAC,aAAa,OAAO,SAAS,SAAS,KAAK,YAAY,KAAK,CAAC,iBAAiB,CAAC;CAClG,MAAM,OAAO,WAAW,cAAc,gBAAiB,QAAQ,WAAW,kBAAmB;CAG7F,MAAM,WAAW,OAAO,KAAK;CAC7B,MAAM,UAAU,QAAQ,SAAS;CACjC,gBAAgB;EACd,SAAS,UAAU;CACrB,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,aAAwC,WAC1C;EAAE,mBAAmB,GAAG,UAAU;EAAK,oBAAoB,SAAS,WAAW;CAAU,IACzF,UACE,EAAE,YAAY,OAAO,IACrB,KAAA;CAEN,OACE,oBAACC,SAAkB,MAAnB;EACE,GAAI;EACJ,GAAK,YAAY,EAAE,eAAe,KAAK;EACvC,OAAO,SAAS,gBAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;EACpE,KAAK;EACA;EACL,aAAW;EACX,cAAY,QAAQ,KAAK,KAAA;EAClB;EACP,WAAW,GAAG,QAAQ,SAAS,GAAG,UAAU;EAC5C,KAAK;EAEL,UAAA,oBAACA,SAAkB,OAAnB;GACE,GAAK,WAAW,EAAE,MAAM,eAAe,IAAI,QAAQ,EAAE,cAAc,MAAM,IAAI,CAAC;GAC9E,WAAW,QAAQ,cAAc;GAEjC,UAAA,oBAACA,SAAkB,OAAnB;IAAyB,WAAW,QAAQ,cAAc;IAAG,OAAO;GAAa,CAAA;EAC1D,CAAA;CACH,CAAA;AAE5B,CACF;AAEA,WAAS,cAAc"}