import{A as o}from"./p-C2jRLMNW.js";import{S as r,C as s}from"./p-DaIKrQry.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{g as t,a as c}from"./p-Cb8cfh-k.js";const a=o();class n{async fetchSubAccounts(o,r,s){return a.get({authToken:r,endpoint:"sub_accounts",params:s,headers:{Account:o}})}}const e=({primaryAccountId:o,authToken:a,service:n})=>async({params:e,onSuccess:p,onError:i})=>{var u,m;try{const d=await n.fetchSubAccounts(o,a,e);if(d.error){return i({error:c(d.error),code:t(null===(m=d.error)||void 0===m?void 0:m.code),severity:s.ERROR})}{const o=Object.assign({},d.page_info);p({subAccounts:(null===(u=d.data)||void 0===u?void 0:u.map((o=>new r(o))))||[],pagingInfo:o})}}catch(o){const r=t(null==o?void 0:o.code);return i({error:o.message||o,code:r,severity:s.ERROR})}};export{n as S,e as m}