/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{map as o,result as n}from"./asyncUtils.js";import r from"./Collection.js";import{isLoadable as t}from"./Loadable.js";async function l(o,n){return await o.load(),a(o,n)}async function a(l,a){const c=[],s=(...o)=>{for(const n of o)null!=n&&(Array.isArray(n)?s(...n):r.isCollection(n)?n.forEach(o=>s(o)):t(n)&&c.push(n))};a(s);let f=null;if(await o(c,async o=>{const r=await n(i(o)?o.loadAll():o.load());!1!==r.ok||f||(f=r)}),f)throw f.error;return l}function i(o){return"loadAll"in o&&"function"==typeof o.loadAll}export{l as loadAll,a as loadAllChildren};
