1import{c as d}from"./compiler-runtime-DLkwNwoZ.js";import{u as h}from"./useQuery-N1zTHCAY.js";import{q as v,b as P,u as R}from"./organization-szs4jqGw.js";import{u as q}from"./toolkit-B3pGKKyQ.js";import{r as m}from"./index-BBaSafD8.js";import{db as p}from"./db-BN6iLDKu.js";import{u as f}from"./context-D6OF2xnR.js";async function $(t,e,s){return(await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","server-action":e},body:JSON.stringify(s)})).json()}function k(t,e,s){return new Proxy(t,{get(r,o,i){return o==="url"?`/_serverid=${e}&name=${s}`:Reflect.get(r,o,i)},apply(r,o,i){return $("/_server",`${e}#${s}`,i)}})}const z=t=>t==="internal"||t==="public",O=t=>v({queryKey:["projects",t,"metadata",m?.auth?.me?.id],queryFn:async()=>{const[{data:e},{data:s},{data:r}]=await Promise.all([p.public.from("projects").select("title,user_id,visibility,organization_id").eq("id",Number(t)).single(),p.public.rpc("get_project_permissions",{p_project_id:Number(t),p_user_id:m?.auth?.me?.id}).select("*"),await p.public.from("project_roles").select("*").eq("project_id",Number(t)).eq("user_id",m?.auth?.me?.id)]);return{...e,permissions:s,role:r[0]??{project_role:e?.visibility==="public"?"viewer":"unknown"}}}});function _(t){const e=d.c(2),r=f()?.auth.me;let o;e[0]!==t?(o=O(t),e[0]=t,e[1]=o):o=e[1];const i=h(o);return r?i.data:null}function w(t){const e=d.c(2),s=_(t);let r;return e[0]!==s?.permissions?(r=s?.permissions||[],e[0]=s?.permissions,e[1]=r):r=e[1],r}function C(t){const e=d.c(5),s=f(),r=q().projectId,i=P(s?.auth?.me?.id)?.organization_role||"",c=R(),n=_(r),u=w(r),l=n?.organization_id,g=s?.auth?.me?.user_metadata?.is_super_admin===!0;let a;e[0]!==c||e[1]!==l||e[2]!==i||e[3]!==n?.visibility?(a=c===l&&z(n?.visibility)&&(i==="admin"||i==="analyst"),e[0]=c,e[1]=l,e[2]=i,e[3]=n?.visibility,e[4]=a):a=e[4];const y=a,b=!!u.find&&u.length>0&&!!u.find(j=>j.permission===t)?.is_granted;return g||y||b||!r}export{C as a,k as c,O as p,_ 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.