1import{O as I,o as S}from"./index-BNPflmqD.js";import{_ as w,a1 as D,r as l,c as y}from"./vendor-misc-5pJBpqhN.js";const E=I.EXT_AUTH,R="data-orolith-ext",$="data-orolith-ext-user",O=600*1e3;function k(){try{localStorage.removeItem(E)}catch{}}function X(){k();try{const t=sessionStorage.getItem(E);if(!t)return null;const e=JSON.parse(t);return!(e!=null&&e.token)&&!(e!=null&&e.userData)?null:Date.now()-(e.timestamp||0)>O?(sessionStorage.removeItem(E),null):e}catch{return null}}function C(){const t=document.documentElement.getAttribute(R);if(!t)return null;let e=null;try{const n=document.documentElement.getAttribute($);n&&(e=JSON.parse(n))}catch{}return{installed:!0,authenticated:t==="authenticated",userData:e}}const _=l(!1),d=l(null);let s=null,o=null,m=0;function u(){const t=X(),e=C();_.value=!!(t||e),t!=null&&t.userData?d.value=t.userData:e!=null&&e.userData?d.value=e.userData:d.value=null}function M(){w(()=>{m++,u(),s||(s=()=>{u()},window.addEventListener("orolith-ext-auth",s)),o||(o=e=>{var n;(n=e.detail)!=null&&n.installed&&u()},window.addEventListener("orolith-ext-presence",o))}),D(()=>{m--,m===0&&(s&&(window.removeEventListener("orolith-ext-auth",s),s=null),o&&(window.removeEventListener("orolith-ext-presence",o),o=null))});function t(){u()}return{isInstalled:_,extUserData:d,refresh:t}}const G=["datasync","trace","affiliatekit","clippitch","taxmini","ugcstarterkit","digitalproductkit"],f=l([]),g=l(!1),p=l(null);function N(t){return`data-orolith-ext-${t}`}function P(t){const e=document.documentElement.getAttribute(N(t));if(!e){if(t==="datasync"){const n=document.documentElement.getAttribute("data-orolith-ext");if(n)return{installed:!0,authenticated:n==="authenticated"}}return null}return{installed:!0,authenticated:e==="authenticated"}}const x=l([]);function h(){x.value=G.filter(t=>{var e;return!!((e=P(t))!=null&&e.installed)})}let i=null,v=0;async function c(){g.value=!0,p.value=null;try{const{data:t}=await S.get("/extensions/registry");f.value=t.extensions??[]}catch(t){p.value=t instanceof Error?t.message:"Could not load extension registry",f.value=[]}finally{g.value=!1}}function q(t){const e="/app/".replace(/\/$/,""),n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`||n}function Y(t,e){const n=new URLSearchParams;return n.set("slug",t),n.set("state",crypto.randomUUID()),e&&n.set("ext_id",e),`${q("/extension-auth")}?${n.toString()}`}function z(){const{isInstalled:t,extUserData:e,refresh:n}=M();w(()=>{v++,h(),c(),i||(i=a=>{const r=a.detail;(r!=null&&r.slug||r!=null&&r.installed)&&h()},window.addEventListener("orolith-ext-presence",i))}),D(()=>{v--,v===0&&i&&(window.removeEventListener("orolith-ext-presence",i),i=null)});const A=y(()=>f.value),L=y(()=>f.value.filter(a=>a.paired||a.last_active_at).length);async function T(){h(),n(),await c()}async function U(a){await S.post("/extensions/sync-requested",{slug:a}),await c()}function b(a){return x.value.includes(a)||a==="datasync"&&t.value}return{extensions:A,registryLoading:g,registryError:p,installedSlugs:x,pairedCount:L,extUserData:e,refresh:T,requestSync:U,isDomInstalled:b,fetchRegistry:c}}export{Y as b,z as u};
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.