"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),x=require("../index-DnaHaH_0.js"),d=require("react"),k=require("../index-DO-atGp-.js"),$=require("../index-ChLwd62c.js"),C=require("@spark-ui/hooks/use-merge-refs");function D(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const R=D(d);var P="Progress",N=100,[T]=k.createContextScope(P),[V,A]=T(P),L=R.forwardRef((e,r)=>{const{__scopeProgress:t,value:a=null,max:s,getValueLabel:i=B,...l}=e;(s||s===0)&&!h(s)&&console.error(X(`${s}`,"Progress"));const o=h(s)?s:N;a!==null&&!j(a,o)&&console.error(z(`${a}`,"Progress"));const n=j(a,o)?a:null,c=m(n)?i(n,o):void 0;return u.jsx(V,{scope:t,value:n,max:o,children:u.jsx($.Primitive.div,{"aria-valuemax":o,"aria-valuemin":0,"aria-valuenow":m(n)?n:void 0,"aria-valuetext":c,role:"progressbar","data-state":_(n,o),"data-value":n??void 0,"data-max":o,...l,ref:r})})});L.displayName=P;var M="ProgressIndicator",S=R.forwardRef((e,r)=>{const{__scopeProgress:t,...a}=e,s=A(M,t);return u.jsx($.Primitive.div,{"data-state":_(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...a,ref:r})});S.displayName=M;function B(e,r){return`${Math.round(e/r*100)}%`}function _(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function m(e){return typeof e=="number"}function h(e){return m(e)&&!isNaN(e)&&e>0}function j(e,r){return m(e)&&!isNaN(e)&&e<=r&&e>=0}function X(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${N}\`.`}function z(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${N} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}const F=x.cva(["relative","h-sz-4 w-full","transform-gpu overflow-hidden","bg-on-background/dim-4"],{variants:{shape:{square:[],rounded:["rounded-sm"]}}}),w=d.createContext(null),G=":progress",I=()=>{const e=d.useContext(w);if(!e)throw new Error("useProgress must be used within a Progress provider");return e},U=x.cva(["h-full w-full","transition-transform duration-400"],{variants:{intent:{basic:["bg-basic"],main:["bg-main"],support:["bg-support"],accent:["bg-accent"],success:["bg-success"],alert:["bg-alert"],danger:["bg-error"],info:["bg-info"],neutral:["bg-neutral"]},shape:{square:[],rounded:["rounded-sm"]},isIndeterminate:{true:["absolute","-translate-x-1/2","animate-standalone-indeterminate-bar"],false:[]}}}),f=({className:e,style:r,ref:t,onTransitionEnd:a,...s})=>{const{value:i,max:l,intent:o,shape:n,isIndeterminate:c,onComplete:g}=I(),p=(l-i)/l*100,v=q=>{a?.(q),i>=l&&g&&!c&&g()};return u.jsx(S,{"data-spark-component":"progress-indicator",className:U({className:e,intent:o,shape:n,isIndeterminate:c}),style:{...r,...!c&&{transform:`translateX(-${p}%)`}},ref:t,onTransitionEnd:v,...s})};f.displayName="Progress.Indicator";const b=({className:e,children:r=u.jsx(f,{}),ref:t,...a})=>{const{shape:s}=I();return u.jsx("div",{"data-spark-component":"progress-bar",className:F({className:e,shape:s}),ref:t,...a,children:r})};b.displayName="Progress.Bar";const E=({className:e,value:r,max:t=100,shape:a="square",intent:s="basic",isIndeterminate:i=!1,onComplete:l,children:o=u.jsx(b,{}),ref:n,...c})=>{const[g,p]=d.useState(),v=d.useMemo(()=>({value:r??0,max:t,intent:s,shape:a,isIndeterminate:i,onLabelId:p,onComplete:l}),[t,r,s,a,i,p,l]);return u.jsx(w.Provider,{"data-spark-component":"progress",value:v,children:u.jsx(L,{"data-spark-component":"progress",ref:n,className:x.cx("gap-sm focus-visible:u-outline flex flex-col",e),value:r,"aria-labelledby":g,max:t,tabIndex:-1,...c,children:o})})};E.displayName="Progress";const y=({id:e,children:r,ref:t,...a})=>{const s=`${G}-label-${d.useId()}`,i=e||s,{onLabelId:l}=I(),o=d.useCallback(c=>{l(c?i:void 0)},[i,l]),n=C.useMergeRefs(t,o);return u.jsx("span",{"data-spark-component":"progress-label",id:i,className:"text-body-2 text-on-surface",ref:n,...a,children:r})};y.displayName="Progress.Label";const O=Object.assign(E,{Label:y,Bar:b,Indicator:f});O.displayName="Progress";b.displayName="Progress.Bar";f.displayName="Progress.Indicator";y.displayName="Progress.Label";exports.Progress=O;
//# sourceMappingURL=index.js.map
