import{i as e}from"./chunk-B3pr0VN8.js";import{n as t,t as n}from"./jsx-runtime-wTfS3W87.js";import{n as r}from"./promoTokenEvents-D_UTsplE.js";var i=e(t(),1),a=n(),o=e=>Math.max(0,Math.round(Number(e||0))).toLocaleString(`zh-CN`),s=e=>{let t=Math.max(0,Number(e||0));return t>=1?Number.isInteger(t)?o(t):t.toLocaleString(`zh-CN`,{maximumFractionDigits:2}):t>0?t.toLocaleString(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:2}):`0`},c=e=>{let t=Math.max(0,Number(e||0));if(!t)return``;let n=t/100;return n.toLocaleString(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:n<.01?4:2})};function l(e,t){if(!e)return``;let n=Math.max(0,Number(e.estimatedPoints||0)),r=Math.max(0,Number(e.actualPoints||0)),i=Math.max(0,Number(e.promoTokensCharged||0)),a=Math.max(0,Number(e.promoTokensRemaining||0)),l=Math.max(0,Number(e.recognitionPromoPointsCharged??(e.recognitionPromoPointCentsCharged==null?0:e.recognitionPromoPointCentsCharged/100))),u=Number(e.recognitionPromoPointsRemaining??(e.recognitionPromoPointCentsRemaining==null?NaN:e.recognitionPromoPointCentsRemaining/100)),d=String(t?.label||`本次平台计量`).trim();if(t?.showPoints===!1)return``;if(l>0){let t=String(e.recognitionPromoLabel||`618 识别体验积分`).trim()||`618 识别体验积分`,n=Number.isFinite(u)?`，剩余 ${s(u)} 积分`:``,i=(e.pointsStatus===`actual`||e.pointsStatus===`mixed`)&&r>0?`，另消耗 ${s(r)} 积分`:``,a=e.recognitionPromoNotice?`。${e.recognitionPromoNotice}`:``;return`${d}由 ${t}抵扣 ${s(l)} 积分${i}${n}${a}`}if(e.promoCovered&&i>0){let n=String(e.promoLabel||`618 体验包`).trim()||`618 体验包`,r=t?.showCost===!1?``:e.estimatedCostCents>0?`，约 ¥${c(e.estimatedCostCents)}`:``,s=a>0?`，剩余 ${o(a)} Token`:``;return`${d}由 ${n}抵扣 ${o(i)} Token${r}${s}`}return e.memberCovered?`${d}由会员权益覆盖，未额外扣减积分`:(e.pointsStatus===`actual`||e.pointsStatus===`mixed`)&&(r>0||n>0)?`${d}消耗 ${s(r)} 积分`:n>0?`${d}预计消耗 ${s(n)} 积分`:``}function u({billing:e,label:t,hideModel:n=!0,showCost:o,showPoints:s,showRequests:c,className:u,style:d}){let f=e?.promoCovered===!0,p=Math.max(0,Number(e?.promoTokensCharged||0)),m=Number(e?.promoTokensRemaining),h=String(e?.promoLabel||``).trim();(0,i.useEffect)(()=>{!f||p<=0||!Number.isFinite(m)||r({remainingTokens:Math.max(0,m),label:h||void 0})},[f,p,m,h]);let g=l(e,{label:t,hideModel:n,showCost:o,showPoints:s,showRequests:c});return g?(0,a.jsx)(`div`,{className:[`he-platform-usage-line`,f&&p>0?`he-platform-usage-line--promo`:``,u||``].filter(Boolean).join(` `),"data-promo":f&&p>0?`true`:void 0,style:{marginTop:8,...d,fontSize:13,lineHeight:1.55},children:g}):null}export{l as n,u as t};