PageSourceSearch

https://mark3t.ai/assets/admin.roles-C_kXQBHM.js

js mark3t.ai collected 2026-10-05 15:23:32 UTC 15,614 bytes, 1 lines download raw bytes

vendor: 4,453 bytes, line 1
1import{B as te,r as d,C as V,S as se,E as z,G as m,J as N,K as y,N as C,P,Q as $,T as ie,U as E,V as ae,W as ne,X as q,Y as w,Z as J,$ as oe,a0 as U,a1 as F,a2 as ce,a3 as D,a4 as L,j as i}from"./index-l-chEqZI.js";function I(e){const t=te();return d.useCallback(async(...r)=>{try{const s=await e(...r);if(V(s))throw s;return s}catch(s){if(V(s))return s.options._fromLocation=t.stores.location.get(),t.navigate(t.resolveRedirect(s).options);throw s}},[t,e])}var he=class extends se{constructor(e,t){super(),this.options=t,this.#s=e,this.#o=null,this.#n=z(),this.bindMethods(),this.setOptions(t)}#s;#e=void 0;#r=void 0;#t=void 0;#i;#a;#n;#o;#m;#d;#p;#h;#l;#c;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),X(this.#e,this.options)?this.#u():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Q(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Q(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#R(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,r=this.#e;if(this.options=this.#s.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof m(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#e.setOptions(this.options),t._defaulted&&!N(this.options,t)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const s=this.hasListeners();s&&Y(this.#e,r,this.options,t)&&this.#u(),this.updateResult(),s&&(this.#e!==r||m(this.options.enabled,this.#e)!==m(t.enabled,this.#e)||y(this.options.staleTime,this.#e)!==y(t.staleTime,this.#e))&&this.#b();const a=this.#x();s&&(this.#e!==r||m(this.options.enabled,this.#e)!==m(t.enabled,this.#e)||a!==this.#c)&&this.#v(a)}getOptimisticResult(e){const t=this.#s.getQueryCache().build(this.#s,e),r=this.createResult(t,e);return ue(this,r)&&(this.#t=r,this.#a=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(r,s)=>(this.trackProp(s),t?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#n.status==="pending"&&this.#n.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#s.defaultQueryOptions(e),r=this.#s.getQueryCache().build(this.#s,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#u(e){this.#S();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(C)),t}#b(){this.#y();const e=y(this.options.staleTime,this.#e);if(P.isServer()||this.#t.isStale||!$(e))return;const r=ie(this.#t.dataUpdatedAt,e)+1;this.#h=E.setTimeout(()=>{this.#t.isStale||this.updateResult()},r)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#R(),this.#c=e,!(P.isServer()||m(this.options.enabled,this.#e)===!1||!$(this.#c)||this.#c===0)&&(this.#l=E.setInterval(()=>{(this.options.refetchIntervalInBackground||ae.isFocused())&&this.#u()},this.#c))}#g(){this.#b(),this.#v(this.#x())}#y(){this.#h!==void 0&&(E.clearTimeout(this.#h),this.#h=void 0)}#R(){this.#l!==void 0&&(E.clearInterval(this.#l),this.#l=void 0)}createResult(e,t){const r=this.#e,s=this.options,a=this.#t,o=this.#i,n=this.#a,h=e!==r?e.state:this.#r,{state:l}=e;let c={...l},v=!1,u;if(t._optimisticResults){const f=this.hasListeners(),g=!f&&X(e,t),S=f&&Y(e,r,t,s);(g||S)&&(c={...c,...ne(l.data,e.options)}),t._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:R,errorUpdatedAt:K,status:x}=c;u=c.data;let B=!1;if(t.placeholderData!==void 0&&u===void 0&&x==="pending"){let f;a?.isPlaceholderData&&t.placeholderData===n?.placeholderData?(f=a.data,B=!0):f=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,f!==void 0&&(x="success",u=q(a?.data,f,t),v=!0)}if(t.select&&u!==void 0&&!B)if(a&&u===o?.data&&t.select===this.#m)u=this.#d;
1else try{this.#m=t.select,u=t.select(u),u=q(a?.data,u,t),this.#d=u,this.#o=null}catch(f){this.#o=f}this.#o&&(R=this.#o,u=this.#d,K=Date.now(),x="error");const T=c.fetchStatus==="fetching",M=x==="pending",_=x==="error",W=M&&T,G=u!==void 0,b={status:x,fetchStatus:c.fetchStatus,isPending:M,isSuccess:x==="success",isError:_,isInitialLoading:W,isLoading:W,data:u,dataUpdatedAt:c.dataUpdatedAt,error:R,errorUpdatedAt:K,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:c.dataUpdateCount>h.dataUpdateCount||c.errorUpdateCount>h.errorUpdateCount,isFetching:T,isRefetching:T&&!M,isLoadingError:_&&!G,isPaused:c.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:_&&G,isStale:k(e,t),refetch:this.refetch,promise:this.#n,isEnabled:m(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const f=b.data!==void 0,g=b.status==="error"&&!f,S=O=>{g?O.reject(b.error):f&&O.resolve(b.data)},H=()=>{const O=this.#n=b.promise=z();S(O)},j=this.#n;switch(j.status){case"pending":e.queryHash===r.queryHash&&S(j);break;case"fulfilled":(g||b.data!==j.value)&&H();break;case"rejected":(!g||b.error!==j.reason)&&H();break}}return b}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#a=this.options,this.#i.data!==void 0&&(this.#p=this.#e),N(t,e))return;this.#t=t;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!this.#f.size)return!0;const o=new Set(a??this.#f);return this.options.throwOnError&&o.add("error"),Object.keys(this.#t).some(n=>{const p=n;return this.#t[p]!==e[p]&&o.has(p)})};this.#j({listeners:r()})}#S(){const e=this.#s.getQueryCache().build(this.#s,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#r=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#j(e){w.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function le(e,t){return m(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&m(t.retryOnMount,e)===!1)}function X(e,t){return le(e,t)||e.state.data!==void 0&&Q(e,t,t.refetchOnMount)}function Q(e,t,r){if(m(t.enabled,e)!==!1&&y(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&k(e,t)}return!1}function Y(e,t,r,s){return(e!==t||m(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&k(e,r)}function k(e,t){return m(t.enabled,e)!==!1&&e.isStaleByTime(y(t.staleTime,e))}function ue(e,t){return!N(e.getCurrentResult(),t)}var de=class extends se{#s;#e=void 0;#r;#t;constructor(e,t){super(),this.#s=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#s.defaultMutationOptions(e),N(this.options,t)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),t?.mutationKey&&this.options.mutationKey&&J(t.mutationKey)!==J(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#i(),this.#a()}mutate(e,t){return this.#t=t,this.#r?.removeObserver(this),this.#r=this.#s.getMutationCache().build(this.#s,this.options),this.#r.addObserver(this),this.#r.execute(e)}#i(){const e=this.#r?.state??oe();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){w.batch(()=>{if(this.#t&&this.hasListeners()){const t=this.#e.variables,r=this.#e.context,s={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#t.onSuccess?.(e.data,t,r,s)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(e.data,null,t,r,s)}catch(a){Promise.reject(a)}}else if(e?.type==="error"){try{this.#t.onError?.(e.error,t,r,s)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(void 0,e.error,t,r,s)}catch(a){Promise.reject(a)}}}
1this.listeners.forEach(t=>{t(this.#e)})})}},re=d.createContext(!1),pe=()=>d.useContext(re);re.Provider;function fe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var me=d.createContext(fe()),be=()=>d.useContext(me),xe=(e,t,r)=>{const s=r?.state.error&&typeof e.throwOnError=="function"?U(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},ve=e=>{d.useEffect(()=>{e.clearReset()},[e])},ge=({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||U(r,[e.error,s])),ye=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>r(s(...a)):r(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Re=(e,t)=>e.isLoading&&e.isFetching&&!t,Se=(e,t)=>e?.suspense&&t.isPending,Z=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function je(e,t,r){const s=pe(),a=be(),o=F(),n=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(n);const p=o.getQueryCache().get(n.queryHash);n._optimisticResults=s?"isRestoring":"optimistic",ye(n),xe(n,a,p),ve(a);const h=!o.getQueryCache().get(n.queryHash),[l]=d.useState(()=>new t(o,n)),c=l.getOptimisticResult(n),v=!s&&e.subscribed!==!1;if(d.useSyncExternalStore(d.useCallback(u=>{const R=v?l.subscribe(w.batchCalls(u)):C;return l.updateResult(),R},[l,v]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),d.useEffect(()=>{l.setOptions(n)},[n,l]),Se(n,c))throw Z(n,l,a);if(ge({result:c,errorResetBoundary:a,throwOnError:n.throwOnError,query:p,suspense:n.suspense}))throw c.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(n,c),n.experimental_prefetchInRender&&!P.isServer()&&Re(c,s)&&(h?Z(n,l,a):p?.promise)?.catch(C).finally(()=>{l.updateResult()}),n.notifyOnChangeProps?c:l.trackResult(c)}function ee(e,t){return je(e,he)}function Oe(e,t){const r=F(),[s]=d.useState(()=>new de(r,e));d.useEffect(()=>{s.setOptions(e)},[s,e]);const a=d.useSyncExternalStore(d.useCallback(n=>s.subscribe(w.batchCalls(n)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),o=d.useCallback((n,p)=>{s.mutate(n,p).catch(C)},[s]);if(a.error&&U(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}const A=ce({type:"function"}),Ee=D({method:"GET"}).middleware([A]).handler(L("d8993bd40f9162497be09e35e3e219129afc683ceeb885dc57ad49e227c2d53b")),Ne=D({method:"GET"}).middleware([A]).handler(L("e5d2eed49d1d6c8270ecbe08c4303e6cd03129d1f12bb7d85432d1c64a590cc9")),Ce=D({method:"POST"}).middleware([A]).handler(L("167d775eb2ba5e128a7fed406310648216cbd5d1b677ae606a238599c2b98958")),we=["super_admin","admin","moderator","seller","vendor","buyer","support","read_only"];function Ie(){const e=te(),t=F(),r=I(Ee),s=I(Ne),a=I(Ce),o=ee({queryKey:["admin","users"],queryFn:()=>r()}),n=ee({queryKey:["admin","audit"],queryFn:()=>s()}),p=Oe({mutationFn:h=>a({data:h}),onSuccess:()=>{t.invalidateQueries({queryKey:["admin"]}),e.invalidate()}});return o.isLoading?i.jsx("div",{className:"p-6",children:"Loading…"}):o.error?i.jsxs("div",{className:"p-6 text-sm",children:[i.jsx("h1",{className:"text-lg font-semibold mb-2",children:"Admin · User roles"}),i.jsx("p",{className:"text-red-600",children:o.error.message})]}):i.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-8",children:[i.jsxs("header",{children:[i.jsx("h1",{className:"text-2xl font-semibold",children:"User roles"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Restricted to super_admin. Every change is written to the audit log."})]}),i.jsx("section",{className:"rounded-lg border",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"bg-muted/50 text-left",children:i.jsxs("tr",{children:[i.jsx("th",{className:"p-3",children:"Email"}),i.jsx("th",{className:"p-3",children:"Current roles"}),i.jsx("th",{className:"p-3",children:"Manage"})]})}),i.jsx("tbody",{children:o.data?.map(h=>i.jsx(Te,{user:h,busy:p.isPending,onChange:(l,c)=>p.mutate({target_user_id:h.id,role:l,operation:c})},h.id))})]})}),p.error&&i.jsx("p",{className:"text-red-600 text-sm",children:p.error.message}),i.jsxs("section",{children:[i.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Recent audit log"}),n.isLoading?i.jsx("p",{className:"text-sm",children:"Loading…"}):i.jsx("div",{className:"rounded-lg border overflow-x-auto",children:i.jsxs("table",{className:"w-full text-xs",children:[i.jsx("thead",{className:"bg-muted/50 text-left",children:i.jsxs("tr",{children:[i.jsx("th",{className:"p-2",children:"When"}),i.jsx("th",{className:"p-2",children:"Actor"}),i.jsx("th",{className:"p-2",children:"Tool"}),i.jsx("th",{className:"p-2",children:"Action"}),i.jsx("th",{className:"p-2",children:"Target"}),i.jsx("th",{className:"p-2",children:"OK"}),i.jsx("th",{className:"p-2",children:"Note"})]})}),i.jsx("tbody",{children:n.data?.map(h=>i.jsxs("tr",{className:"border-t",children:[i.jsx("td",{className:"p-2 whitespace-nowrap",children:new Date(h.created_at).toLocaleStr
1ing()}),i.jsx("td",{className:"p-2",children:h.user_email??"—"}),i.jsx("td",{className:"p-2",children:h.tool_name}),i.jsx("td",{className:"p-2",children:h.action}),i.jsx("td",{className:"p-2 font-mono",children:h.resource_id??"—"}),i.jsx("td",{className:"p-2",children:h.success?"✓":"✗"}),i.jsx("td",{className:"p-2 text-muted-foreground",children:h.error_message??""})]},h.id))})]})})]})]})}function Te({user:e,busy:t,onChange:r}){const[s,a]=d.useState("buyer"),o=we.filter(n=>!e.roles.includes(n));return i.jsxs("tr",{className:"border-t align-top",children:[i.jsx("td",{className:"p-3",children:e.email}),i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.roles.length===0&&i.jsx("span",{className:"text-muted-foreground text-xs",children:"none"}),e.roles.map(n=>i.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",children:[n,i.jsx("button",{type:"button",disabled:t,className:"text-red-600 disabled:opacity-40",onClick:()=>r(n,"revoke"),"aria-label":`Revoke ${n}`,children:"×"})]},n))]})}),i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("select",{className:"border rounded px-2 py-1 text-xs bg-background",value:o.includes(s)?s:o[0]??"buyer",onChange:n=>a(n.target.value),disabled:t||o.length===0,children:o.map(n=>i.jsx("option",{value:n,children:n},n))}),i.jsx("button",{type:"button",disabled:t||o.length===0,className:"rounded border px-2 py-1 text-xs disabled:opacity-40",onClick:()=>r(o.includes(s)?s:o[0],"grant"),children:"Grant"})]})})]})}export{Ie as component};

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.