import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{a as r,r as i}from"./billingCopy-19NcY4pu.js";import{r as a}from"./toolRuntime-wpPmOqkC.js";var o=e(t(),1),s=n(),c=(e,t,n=`done`)=>{let r=Math.max(1,Math.round(Number(t||0))||1),i=Math.max(1,Math.min(r,Math.round(Number(e||0))||1)),a=r*2,o=n===`start`?i*2-1:i*2;return Math.max(1,Math.min(95,Math.round(12+o/a*76)))};function l(){let[e,t]=(0,o.useState)(`idle`),[n,c]=(0,o.useState)(0),l=e=>{c(t=>{let n=typeof e==`function`?e(t):e;return Number.isFinite(Number(n))?Math.max(0,Math.min(100,Math.round(Number(n||0)))):0})};return{runState:e,progress:n,setProgress:l,setRunState:t,start:()=>{t(`running`),c(0)},partial:e=>{t(`partial`),Number.isFinite(Number(e))&&l(Number(e))},done:()=>{t(`done`),c(100)},failByMessage:(e,n)=>{let o=a(e);if(o===`cancelled`){t(`cancelled`),n(e);return}if(t(`failed`),o===`credit`){n((0,s.jsxs)(`span`,{children:[i,`，请`,(0,s.jsx)(`a`,{href:r,style:{color:`var(--accent)`},children:`前往统一收银台`}),`继续操作`]}));return}if(o===`proxy`){n((0,s.jsxs)(`span`,{children:[`AI 配置异常，请`,(0,s.jsx)(`a`,{href:`/me`,style:{color:`var(--accent)`},children:`前往个人中心检查配置`}),`后重试`]}));return}n(e)}}}export{l as n,c as t};