import{r as e,s as t}from"./rolldown-runtime-C5c2KzVm.js";import{$P as n,Db as r,Fs as i,Rl as a,lO as o}from"./lucide-C4oWPzu4.js";import{p as s}from"./utils-Bs-0X7qI.js";import{r as c}from"./bundle-mjs-C4g7ASB5.js";import{n as l}from"./dist-Cw-z5Xb0.js";import{t as u}from"./button-B-NlEi4h.js";import{t as d}from"./input-DcxjhZaU.js";import{t as f}from"./badge-CoY2mFvb.js";import{ct as p,lt as m}from"./console-BA0IzvI-.js";import{n as h,r as g,t as _}from"./collapsible--NKW0DRo.js";import{t as v}from"./dist-BU2y2QTQ.js";import{t as y}from"./permission-guard-C-WT75tf.js";import{t as b}from"./page-container-5wXiFE1n.js";var x=e({default:()=>D}),S=s(),C=t(n(),1),w=c(),T=e=>{let t=(0,S.c)(16),{group:n}=e,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,w.jsx)(o,{className:`transition-transform group-data-[state=open]:rotate-90`}),a=(0,w.jsx)(r,{}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let s;t[2]===n.name?s=t[3]:(s=(0,w.jsx)(`span`,{children:n.name}),t[2]=n.name,t[3]=s);let c;t[4]===n.permissions.length?c=t[5]:(c=(0,w.jsx)(f,{variant:`secondary`,className:`ml-auto`,children:n.permissions.length}),t[4]=n.permissions.length,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,w.jsx)(g,{asChild:!0,children:(0,w.jsxs)(u,{variant:`ghost`,size:`sm`,className:`group hover:bg-accent hover:text-accent-foreground h-9 w-full justify-start px-0 transition-[padding] hover:px-2 aria-expanded:px-2`,children:[i,a,s,c]})}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let d;t[9]===n.permissions?d=t[10]:(d=n.permissions.map(O),t[9]=n.permissions,t[10]=d);let p;t[11]===d?p=t[12]:(p=(0,w.jsx)(h,{className:`pl-8`,children:d}),t[11]=d,t[12]=p);let m;return t[13]!==l||t[14]!==p?(m=(0,w.jsxs)(_,{children:[l,p]}),t[13]=l,t[14]=p,t[15]=m):m=t[15],m},E=e=>{let t=(0,S.c)(11),{permission:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,w.jsx)(i,{className:`text-muted-foreground size-4`}),t[0]=r):r=t[0];let a;t[1]===n.name?a=t[2]:(a=(0,w.jsx)(`span`,{className:`flex-1`,children:n.name}),t[1]=n.name,t[2]=a);let o;t[3]===n.code?o=t[4]:(o=(0,w.jsx)(`code`,{className:`text-muted-foreground text-xs`,children:n.code}),t[3]=n.code,t[4]=o);let s;t[5]===n.isDeprecated?s=t[6]:(s=n.isDeprecated&&(0,w.jsx)(f,{variant:`destructive`,className:`text-xs`,children:`已废弃`}),t[5]=n.isDeprecated,t[6]=s);let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,w.jsxs)(`div`,{className:`hover:bg-muted/50 group/permission-item flex h-9 items-center gap-2 rounded-md px-2 py-1.5 text-sm`,children:[r,a,o,s]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c},D=()=>{let e=(0,S.c)(26),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={isGrouped:!0},e[0]=t):t=e[0];let[n,r]=(0,C.useState)(t),{data:i}=p(n),{mutateAsync:o,isPending:s}=m(),c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{r(t=>({...t,keyword:e||void 0}))},e[1]=c):c=e[1];let f=v(c,300),h;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>{r(t=>({...t,group:e||void 0}))},e[2]=h):h=e[2];let g=v(h,300),_;e[3]===f?_=e[4]:(_=(0,w.jsx)(d,{placeholder:`搜索权限名称`,className:`text-sm`,onChange:e=>f(e.target.value)}),e[3]=f,e[4]=_);let x;e[5]===g?x=e[6]:(x=(0,w.jsx)(d,{placeholder:`搜索权限分组`,className:`text-sm`,onChange:e=>g(e.target.value)}),e[5]=g,e[6]=x);let T;e[7]===o?T=e[8]:(T=async()=>{let e=await o();l.success(`权限同步成功`,{description:`新增: ${e.added}, 更新: ${e.updated}, 废弃: ${e.deprecated}, 总计: ${e.total}`})},e[7]=o,e[8]=T);let E;e[9]===s?E=e[10]:(E=!s&&(0,w.jsx)(a,{}),e[9]=s,e[10]=E);let D;e[11]!==s||e[12]!==T||e[13]!==E?(D=(0,w.jsx)(`div`,{className:`lg:end lg:col-span-1 xl:col-span-2 2xl:col-span-3`,children:(0,w.jsx)(y,{permissions:`permission:sync`,children:(0,w.jsxs)(u,{onClick:T,loading:s,children:[E,`更新权限`]})})}),e[11]=s,e[12]=T,e[13]=E,e[14]=D):D=e[14];let O;e[15]!==_||e[16]!==x||e[17]!==D?(O=(0,w.jsxs)(`div`,{className:`bg-background sticky top-0 z-2 grid grid-cols-1 gap-4 pt-1 pb-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:[_,x,D]}),e[15]=_,e[16]=x,e[17]=D,e[18]=O):O=e[18];let A;e[19]===i?A=e[20]:(A=i?.map(k),e[19]=i,e[20]=A);let j;e[21]===A?j=e[22]:(j=(0,w.jsx)(`div`,{className:`flex flex-col gap-1`,children:A}),e[21]=A,e[22]=j);let M;return e[23]!==j||e[24]!==O?(M=(0,w.jsx)(b,{children:(0,w.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4`,children:[O,j]})}),e[23]=j,e[24]=O,e[25]=M):M=e[25],M};function O(e){return(0,w.jsx)(E,{permission:e},e.id)}function k(e){return(0,w.jsx)(T,{group:e},e.code)}export{x as n,D as t};