import{id}from"@arcgis/core/kernel";function getAuthenticationToken(t){t=id.findCredential(t);return t&&t.token||""}function parsePortalItemUrl(t){t=t.match(/^(.*?)\/home\/item\.html\?id=(.*?)(\#.*)?$/);if(t)return{portalUrl:t[1],itemId:t[2]}}function getPortalDataUrl(t,e){return`${t.portalUrl}/sharing/rest/content/items/${t.itemId}?f=json&token=${e}`}async function getPortalItem(t,e,r){const o=e.create(void 0,"arcgis");if(r.finally(function(){o.cancel()}),o.request.url=t,!await o.send())throw console.error("Unable to get portal item.",o.response.message),Error("Unable to get portal item.");return o.getResponseData(o.response.payload)}function formatGlobalId(t){return"}"!=(t="{"!=t[0]?"{"+t:t)[t.length-1]&&(t+="}"),t}function combineGlobalIds(t){return`[${t.map(t=>`"${formatGlobalId(t)}"`).join(",")}]`}export{getAuthenticationToken,parsePortalItemUrl,getPortalDataUrl,getPortalItem,formatGlobalId,combineGlobalIds};