2 lines
1.8 KiB
JavaScript
2 lines
1.8 KiB
JavaScript
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Dr as t,Tr as n,dc as r,ei as i,fs as a,ms as o,ni as s,ti as c,uc as l}from"./control-ui-core-pH6nakZ-.js";import{Gs as u,Js as d}from"./control-ui-boot-Cdpgu1Gm.js";import{c as f,r as p,s as m}from"./usage-ClT4QiBm.js";function h(e){let t=new Date;return t.setDate(t.getDate()-e),`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function g(e){return s(e)?i(`model providers`):a(e,`request failed`)}function _(e){return e.then(e=>({ok:!0,result:e}),e=>({ok:!1,error:e}))}async function v(e,n){let i=r=>_(t(e,{agentId:n.agentId,...r,rejectOnFailure:!0,...n.signal?{signal:n.signal}:{}})),a=n.refresh?i({refresh:!0}):void 0,o=a?a.then(e=>e.ok?e:i({preparedOnly:!0})):i({preparedOnly:!0}),[s,c,l,u]=await Promise.all([_(d(e,n)),o,a??Promise.resolve(void 0),e.request(`config.get`,{},{signal:n.signal}).then(e=>r(e)).catch(()=>null)]);return{authStatus:s.ok&&Array.isArray(s.result?.providers)?s.result:null,models:c.ok?c.result.models:null,providerOutcomes:c.ok?c.result.providerOutcomes??[]:[],catalogError:l&&!l.ok?g(l.error):c.ok?null:g(c.error),config:u,providerUsage:null,costByProvider:null,updatedAt:Date.now(),error:s.ok?s.result.unavailable?.message??null:g(s.error)}}function y(e,t){return f(e,{signal:t})}function b(e,t){return p(e,{startDate:h(29),endDate:h(0),scope:`family`,timeZone:`local`},{signal:t}).then(e=>e?.aggregates?.byProvider??null).catch(e=>{if(t.aborted)throw e;return null})}var x;function S(){return(S=e((()=>{l(),o(),c(),u(),n(),m(),x={authStatus:null,models:null,providerOutcomes:[],catalogError:null,config:null,providerUsage:null,costByProvider:null,updatedAt:null,error:null}})))()}export{v as a,y as i,S as n,b as r,x as t};
|
|
//# sourceMappingURL=load-Bj0HzefF.js.map
|