1import{br as e,yt as t}from"./Lso9-JEW.js";import{t as n}from"./DE1PFTae.js";import{d as r}from"./DoDkwLQP.js";import{t as i}from"./BbMY8Oz9.js";import{t as a}from"./B4dxwzry.js";import{n as o}from"./BfhgFZXI.js";function s(e){switch(e.org_type){case`distributor`:return`i-ph-network-light`;case`oem`:return`i-ph-cpu-light`;default:return`i-ph-buildings-light`}}function c(e){switch(e.org_type){case`customer`:return e.distributor?`Customer of ${e.distributor.name}`:`Customer organization`;case`distributor`:return`Distributor organization`;case`oem`:return`OEM organization`;case`oem_customer`:return e.distributor?`Affiliate of ${e.distributor.name}`:`Affiliate organization`;default:return`Organization`}}function l(){let l=a(),u=i(),d=o(),f=n(`actor-switching`,()=>!1),p=t(()=>{let e=l.user;if(!e)return[];let t=t=>String(e.actor)===String(t),n=l.isAdmin?[{id:`admin`,label:`NiagaraMods Admin`,description:`Admin-level access`,icon:`i-ph-shield-light`,active:t(`admin`)}]:[],r=[...e.organizations??[]].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({id:e.id,label:e.name,description:c(e),icon:s(e),active:t(e.id)})),i={id:`user`,label:e.display||e.name||e.email,description:`Your personal account`,icon:`i-ph-user-light`,active:t(`user`)};return[...n,...r,i]});async function m(e){if(f.value)return{status:`busy`};f.value=!0;let t=p.value.find(t=>String(t.id)===String(e));try{try{await l.setActor(e)}catch(e){return console.error(`[auth] actor switch failed`,e),{status:`failed`,message:r(e)?`You no longer have access to that account.`:`We could not switch accounts right now. Please try again in a moment.`}}return l.loggedIn?(await u.updateMargins().catch(e=>console.error(`[cart] repricing after an actor switch failed`,e)),d.add({title:t?`Now acting as ${t.label}`:`Account switched`,icon:t?.icon??`i-lucide-circle-check`}),{status:`switched`}):{status:`failed`,message:`Your session has ended. Please sign in again.`}}finally{f.value=!1}}return{choices:p,switching:e(f),switchActor:m}}export{l as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.