import{i as e,n as t,r as n,t as r}from"./useQuery-BGE2QjQQ.js";import{B as i,H as a,k as o,l as s,q as c,u as l}from"./index-DjQIajtc.js";import{t as u}from"./compiler-runtime-JzGT6-yI.js";import{n as d}from"./clsx-D8eYare0.js";var f=c(a(),1),p=n?f.useLayoutEffect:f.useEffect;function m(t,n){let r=e(n?.client),[i,a]=f.useState(()=>h(r)),c=f.useRef({result:i,mutationId:0,isMounted:!0,client:r,mutation:t,options:n});p(()=>{Object.assign(c.current,{client:r,options:n,mutation:t})});let u=f.useCallback((e={})=>{let{options:t,mutation:n}=c.current,r={...t,mutation:n},i=e.client||c.current.client,u=typeof e.context==`function`?e.context(t?.context):e.context;!c.current.result.loading&&c.current.isMounted&&a(c.current.result={loading:!0,error:void 0,data:void 0,called:!0,client:i});let d=++c.current.mutationId,f=l(r,{...e,context:u});return s(i.mutate(f).then(t=>{let{data:n,error:r}=t,s=e.onError||c.current.options?.onError;if(r&&s&&s(r,f),d===c.current.mutationId){let e={called:!0,loading:!1,data:n,error:r,client:i};c.current.isMounted&&!o(c.current.result,e)&&a(c.current.result=e)}let l=e.onCompleted||c.current.options?.onCompleted;return r||l?.(t.data,f),t},t=>{if(d===c.current.mutationId&&c.current.isMounted){let e={loading:!1,error:t,data:void 0,called:!0,client:i};o(c.current.result,e)||a(c.current.result=e)}let n=e.onError||c.current.options?.onError;throw n&&n(t,f),t}))},[]),d=f.useCallback(()=>{if(c.current.isMounted){let e=h(c.current.client);Object.assign(c.current,{mutationId:0,result:e}),a(e)}},[]);return f.useEffect(()=>{let e=c.current;return e.isMounted=!0,()=>{e.isMounted=!1}},[]),[u,{reset:d,...i}]}function h(e){return{data:void 0,error:void 0,called:!1,loading:!1,client:e}}var g=d(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),_=u(),v=i();function y(){let e=(0,_.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,v.jsxs)(`a`,{href:`https://github.com/conao3/rust-sa`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-mute hover:text-ink font-mono text-xs flex-shrink-0`,children:[(0,v.jsx)(g,{size:14,"aria-hidden":`true`}),`GitHub`]}),e[0]=t):t=e[0],t}function b(e,t){let n=(0,_.c)(9),[r,i]=(0,f.useState)(t),a,o;n[0]===e?(a=n[1],o=n[2]):(a=()=>{if(typeof window>`u`)return;let t=window.localStorage.getItem(e);t&&i(t)},o=[e],n[0]=e,n[1]=a,n[2]=o),(0,f.useEffect)(a,o);let s,c;n[3]!==e||n[4]!==r?(s=()=>{typeof window>`u`||window.localStorage.setItem(e,r)},c=[e,r],n[3]=e,n[4]=r,n[5]=s,n[6]=c):(s=n[5],c=n[6]),(0,f.useEffect)(s,c);let l;return n[7]===r?l=n[8]:(l=[r,i],n[7]=r,n[8]=l),l}function x(e,t){let n=(0,_.c)(4),r,i;n[0]!==e||n[1]!==t?(r=()=>{let n=document.documentElement;return n.setAttribute(e,t),()=>n.removeAttribute(e)},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,f.useEffect)(r,i)}var S=t`
  query Preferences {
    preferences {
      theme
    }
  }
`,C=t`
  mutation SetPreferences($theme: String) {
    setPreferences(theme: $theme) {
      theme
    }
  }
`;function w(e){return e===`dark`?`dark`:`light`}function T(){let e=(0,_.c)(9),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={fetchPolicy:`cache-first`},e[0]=t):t=e[0];let{data:n}=r(S,t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={refetchQueries:[{query:S}],awaitRefetchQueries:!0},e[1]=i):i=e[1];let[a]=m(C,i),o=n?.preferences.theme,s;e[2]===o?s=e[3]:(s=w(o),e[2]=o,e[3]=s);let c=s,l;e[4]===a?l=e[5]:(l=e=>{a({variables:{theme:e}})},e[4]=a,e[5]=l);let u=l,d;return e[6]!==u||e[7]!==c?(d=[c,u],e[6]=u,e[7]=c,e[8]=d):d=e[8],d}export{y as i,b as n,x as r,T as t};