function o(){const e=document.querySelector('meta[name="api-token"]');return e?e.content:localStorage.getItem("api_token")}async function r(){if(typeof window.refreshApiToken=="function")try{return await window.refreshApiToken()}catch(e){return console.error("Token refresh error:",e),null}try{const e=document.querySelector('meta[name="api-token"]');if(!e)return null;const n=await fetch("/sanctum/token",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer "+e.getAttribute("content")}});if(!n.ok)throw new Error("Token refresh failed");const t=await n.json();return e&&(e.content=t.token),localStorage.setItem("api_token",t.token),t.token}catch(e){return console.error("Token refresh error:",e),null}}export{o as g,r};
