1import{c as oe,j as e,C as le,m as ce,B as M,r as c,b as V,t as v,u as de,K as ue,T as me,a2 as xe}from"./index-CnD64O-O.js";import{g as he,a as pe,u as ge,d as be}from"./admin-NtP17WyB.js";import{P as fe}from"./Pagination-BZdcQiyp.js";import{S as W}from"./switch-B87kDLN-.js";import{I as E}from"./input-C48x21mA.js";import{L as F}from"./label-BrNY7LbK.js";import{S as O,a as X,b as q,c as G,d as m}from"./select-DM4MWNIY.js";import{S as Q}from"./search-Dc68Zg49.js";import{R as ee}from"./rotate-ccw-DmaXJd3Q.js";import{u as je,A as ve,f as Se,g as Ne}from"./AdminUserTanStackTableHeader-DrYFIm8f.js";import{B as L}from"./badge-CYge-pgM.js";import{T as Ce,a as ye,b as J,d as ke,e as D}from"./table-BmB_chFW.js";import{S as we}from"./SubscriptionStatusBadge-CApL5MIM.js";import{S as Te}from"./shield-check-jI1FfI4B.js";import{C as Ae}from"./copy-CPr4GYhI.js";import{A as Fe}from"./AdminPageHeader-07uqLHgw.js";import{U as Y}from"./users-CkG7qrFU.js";import{C as Je}from"./credit-card-BSPaBLtw.js";import{D as Pe}from"./download-CLDSaj8z.js";import"./chevron-left-DyzQWZgR.js";import"./chevron-right-92kdo-2C.js";import"./index-QtH-xY58.js";import"./chevron-down-CjwehzcN.js";import"./check-CSNy1TZ9.js";import"./chevron-up-Cgk6_S1X.js";import"./index-BdQq_4o_.js";import"./index-DxCoXAjk.js";import"./index-CW7ZL7oC.js";import"./index-D6trnHb-.js";const Ue=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],Re=oe("user-x",Ue),I="all",_="all";function Ee({searchInput:o,onSearchInputChange:g,onSearchSubmit:x,statusFilter:l,onStatusFilterChange:h,subFilter:d,onSubFilterChange:S,dateJoinedFrom:N,onDateJoinedFromChange:C,dateJoinedTo:b,onDateJoinedToChange:f,onReset:u}){return e.jsx(le,{className:"bg-muted/30",children:e.jsxs(ce,{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(F,{className:"text-label",children:"ê²ì"}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Q,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(E,{placeholder:"ì´ë¦, ì´ë©ì¼, ì íë²í¸ë¥¼ ì
ë ¥íì¸ì",value:o,onChange:n=>g(n.target.value),onKeyDown:n=>n.key==="Enter"&&x(),className:"pl-9 bg-background"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(F,{className:"text-label",children:"ê³ì ìí"}),e.jsxs(O,{value:l||I,onValueChange:n=>h(n===I?"":n),children:[e.jsx(X,{className:"w-full bg-background",children:e.jsx(q,{})}),e.jsxs(G,{children:[e.jsx(m,{value:I,children:"ì ì²´"}),e.jsx(m,{value:"active",children:"íì±"}),e.jsx(m,{value:"inactive",children:"ë¹íì±"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(F,{className:"text-label",children:"구ë
"}),e.jsxs(O,{value:d||_,onValueChange:n=>S(n===_?"":n),children:[e.jsx(X,{className:"w-full bg-background",children:e.jsx(q,{})}),e.jsxs(G,{children:[e.jsx(m,{value:_,children:"ì ì²´"}),e.jsx(m,{value:"active",children:"구ë
ì¤"}),e.jsx(m,{value:"payment_issue",children:"ê²°ì 문ì "}),e.jsx(m,{value:"cancelled",children:"구ë
ì·¨ì"}),e.jsx(m,{value:"refunded",children:"íë¶ í´ì§"}),e.jsx(m,{value:"expired",children:"구ë
ë§ë£"}),e.jsx(m,{value:"none",children:"미구ë
"})]})]})]}),e.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[e.jsx(F,{className:"text-label",children:"ê°ì
ì¼"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{type:"date",value:N,onChange:n=>C(n.target.value),className:"w-full bg-background"}),e.jsx("span",{className:"text-body-sm text-muted-foreground",children:"~"}),e.jsx(E,{type:"date",value:b,onChange:n=>f(n.target.value),className:"w-full bg-background"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(M,{variant:"outline",onClick:u,children:[e.jsx(ee,{className:"mr-1 h-4 w-4"}),"ì´ê¸°í"]}),e.jsxs(M,{onClick:x,children:[e.jsx(Q,{className:"mr-1 h-4 w-4"}),"ê²ì"]})]})]})})}const Z=new Set(["index","role","subscriptionPlan","subscriptionStatus","identityVerified","isActive"]);function Le({users:o,loading:g,page:x,pageSize:l,sortType:h,sortOrder:d,onSortChange:S,phoneMasked:N,onToggleActive:C,onRowClick:b}){const f=c.useMemo(()=>[{id:"index",header:"ì°ë²",enableSorting:!1,cell:({row:s})=>(x-1)*l+s.index+1},{id:"email",header:"ì´ë©ì¼",accessorFn:s=>s.email,enableSorting:!0,cell:({row:s})=>e.jsx("span",{className:"text-body-sm",children:s.original.email})},{id:"name",header:"ì´ë¦",accessorFn:s=>s.name,enableSorting:!0,cell:({row:s})=>
1{const t=s.original.name||"â",i=s.original.identity?.name,j=i&&i!==s.original.name;return e.jsx("span",{className:"text-body-sm",children:j?`${t}(${i})`:t})}},{id:"role",header:"ê¶í",accessorFn:s=>s.isStaff?1:0,enableSorting:!0,cell:({row:s})=>s.original.isStaff?e.jsxs(L,{className:"border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-50",children:[e.jsx(Te,{className:"mr-1 h-3 w-3"}),"ê´ë¦¬ì"]}):e.jsx("span",{className:"text-caption text-muted-foreground",children:"ì¼ë°"})},{id:"subscriptionPlan",header:"구ë
íë",accessorFn:s=>s.subscription?.plan.name??"",enableSorting:!0,cell:({row:s})=>{const t=s.original.subscription;return t?e.jsx(L,{variant:"outline",className:"border-blue-300 text-blue-600",children:t.plan.name}):e.jsx("span",{className:"text-caption text-muted-foreground",children:"â"})}},{id:"subscriptionStatus",header:"구ë
ìí",accessorFn:s=>s.subscription?.status??"none",enableSorting:!0,cell:({row:s})=>{const t=s.original.subscription?.status??"none";return e.jsx(we,{status:t})}},{id:"subscriptionExpiresAt",header:"구ë
ë§ë£ì¼",accessorFn:s=>s.subscription?.expiresAt??"",enableSorting:!0,cell:({row:s})=>e.jsx("span",{className:"text-caption text-muted-foreground",children:s.original.subscription?new Date(s.original.subscription.expiresAt).toLocaleDateString("ko-KR"):"â"})},{id:"dateJoined",header:"ê°ì
ì¼",accessorFn:s=>s.dateJoined,enableSorting:!0,cell:({row:s})=>e.jsx("span",{className:"text-caption text-muted-foreground",children:new Date(s.original.dateJoined).toLocaleDateString("ko-KR")})},{id:"identityVerified",header:"본ì¸ì¸ì¦",accessorFn:s=>s.identity?.verifiedAt??"",enableSorting:!0,cell:({row:s})=>s.original.identity?e.jsx(L,{className:"border-green-300 bg-green-50 text-green-700 hover:bg-green-50",children:"ìë£"}):e.jsx("span",{className:"text-caption text-muted-foreground",children:"미ì¸ì¦"})},{id:"phone",header:"í´ëí°",accessorFn:s=>s.identity?.phone??"",enableSorting:!0,cell:({row:s})=>{const t=s.original.identity;if(!t)return e.jsx("span",{className:"text-caption text-muted-foreground",children:"â"});const i=j=>{j.stopPropagation(),navigator.clipboard.writeText(t.phone),v.success("ë³µì¬ëììµëë¤.")};return e.jsxs("div",{className:"flex items-center gap-1",onClick:j=>j.stopPropagation(),children:[e.jsx("span",{className:"text-caption text-muted-foreground",children:N?t.phone.replace(/(\d{3})(\d{4})(\d{4})/,"$1-****-$3"):t.phone.replace(/(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",onClick:i,children:e.jsx(Ae,{className:"h-3 w-3"})})]})}},{id:"isActive",header:"ê³ì íì±í",enableSorting:!1,cell:({row:s})=>e.jsx("div",{className:"flex justify-center",onClick:t=>t.stopPropagation(),children:e.jsx(W,{checked:s.original.isActive,onCheckedChange:()=>C(s.original.id,s.original.isActive),"aria-label":"ê³ì íì±í"})})}],[x,l,N,C]),u=h?[{id:h,desc:d==="desc"}]:[],p=je({data:o,columns:f,state:{sorting:u},onSortingChange:s=>{const t=typeof s=="function"?s(u):s;if(t.length===0){S(null,"asc");return}const i=t[0];S(i.id,i.desc?"desc":"asc")},getCoreRowModel:Ne(),manualSorting:!0});return e.jsx("div",{className:"rounded-lg border",children:e.jsxs(Ce,{children:[e.jsx(ye,{className:"bg-muted/50",children:p.getHeaderGroups().map(s=>e.jsx(J,{children:s.headers.map(t=>{const i=Z.has(t.column.id);return e.jsx(ve,{header:t,align:i?"center":"left",className:V(t.column.id==="index"&&"w-[50px]",i&&"text-center")},t.id)})},s.id))}),e.jsx(ke,{children:g?e.jsx(J,{children:e.jsx(D,{colSpan:f.length,className:"h-32 text-center text-muted-foreground",children:"ë¶ë¬ì¤ë ì¤..."})}):o.length===0?e.jsx(J,{children:e.jsx(D,{colSpan:f.length,className:"h-32 text-center text-muted-foreground",children:"ì¬ì©ìê° ììµëë¤."})}):p.getRowModel().rows.map(s=>e.jsx(J,{className:"cursor-pointer hover:bg-accent/50",onClick:()=>b(s.original.id),children:s.getVisibleCells().map(t=>{const i=Z.has(t.column.id);return e.jsx(D,{className:V(t.column.id==="index"&&"text-center font-mono text-caption",i&&t.column.id!=="index"&&"text-center"),children:Se(t.column.columnDef.cell,t.getContext())},t.id)})},s.id))})]})})}function k({icon:o,label:g,value:x,onClick:l}){return e.jsxs("button",{type:"button",onClick:l,className:V("rounded-lg border bg-card p-4 text-left transition-colors",l&&"cursor-pointer hover:bg-accent/50"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[o,e.jsx("span",{className:"text-body-sm",children:g})]}),e.jsx("p",{className:"mt-2 text-h3 tabular-nums",children:x.toLocaleStr
1ing()})]})}const T=20,De=["email","name","role","subscriptionPlan","subscriptionStatus","subscriptionExpiresAt","dateJoined","identityVerified","phone"],Ie=o=>o&&De.includes(o)?o:null,_e=o=>o==="desc"?"desc":"asc",A=()=>({search:"",status:"",subscription:"",dateJoinedFrom:"",dateJoinedTo:""});function hs(){const o=de(),[g,x]=ue(),l=Ie(g.get("type")),h=_e(g.get("sort")),[d,S]=c.useState(null),[N,C]=c.useState([]),[b,f]=c.useState(0),[u,n]=c.useState(1),[p,s]=c.useState(A),[t,i]=c.useState(A),[j,B]=c.useState(!1),[$,se]=c.useState(!0),[H,z]=c.useState(!1),P=c.useCallback(()=>{he().then(S).catch(()=>v.error("íµê³ë¥¼ ë¶ë¬ì¤ì§ 못íìµëë¤."))},[]),U=c.useCallback(()=>{B(!0),pe({page:u,pageSize:T,search:t.search||void 0,dateJoinedFrom:t.dateJoinedFrom||void 0,dateJoinedTo:t.dateJoinedTo||void 0,status:t.status||void 0,subscription:t.subscription||void 0,type:l??void 0,sort:l?h:void 0}).then(a=>{C(a.results),f(a.count)}).catch(()=>v.error("ì¬ì©ì 목ë¡ì ë¶ë¬ì¤ì§ 못íìµëë¤.")).finally(()=>B(!1))},[u,t,l,h]),te=(a,r)=>{n(1),x(R=>{const w=new URLSearchParams(R);return a===null?(w.delete("type"),w.delete("sort")):(w.set("type",a),w.set("sort",r)),w},{replace:!0})};c.useEffect(()=>{P()},[P]),c.useEffect(()=>{U()},[U]);const ae=()=>{n(1),i(p)},ne=()=>{s(A()),i(A()),n(1)},y=a=>{const r={...A(),...a};s(r),i(r),n(1)},ie=async(a,r)=>{try{const R=await ge(a,{isActive:!r});U(),P(),v.success(R.isActive?"ê³ì ì íì±ííìµëë¤.":"ê³ì ì ë¹íì±ííìµëë¤.")}catch{v.error("ê³ì ìí ë³ê²½ì ì¤í¨íìµëë¤.")}},re=async()=>{z(!0);try{await be({search:t.search||void 0,dateJoinedFrom:t.dateJoinedFrom||void 0,dateJoinedTo:t.dateJoinedTo||void 0,status:t.status||void 0,subscription:t.subscription||void 0,type:l??void 0,sort:l?h:void 0}),v.success("ì¬ì©ì 목ë¡ì ë¤ì´ë¡ëíìµëë¤.")}catch{v.error("ì¬ì©ì ëª©ë¡ ë¤ì´ë¡ëì ì¤í¨íìµëë¤.")}finally{z(!1)}},K=Math.ceil(b/T);return e.jsxs("div",{children:[e.jsx(Fe,{title:"ì¬ì©ì ê´ë¦¬",description:"ì ì²´ ì¬ì©ìì 구ë
ìí를 ê²ì·ê´ë¦¬í©ëë¤."}),d&&e.jsxs("div",{className:"mt-6 flex flex-col gap-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-6",children:[e.jsx(k,{icon:e.jsx(Y,{className:"h-5 w-5"}),label:"ì ì²´ ì¬ì©ì",value:d.totalUsers,onClick:()=>y({})}),e.jsx(k,{icon:e.jsx(Y,{className:"h-5 w-5 text-green-600"}),label:"íì± ì¬ì©ì",value:d.activeUsers,onClick:()=>y({status:"active"})}),e.jsx(k,{icon:e.jsx(Je,{className:"h-5 w-5 text-blue-600"}),label:"구ë
ì¤",value:d.activeSubscriptions,onClick:()=>y({subscription:"active"})}),e.jsx(k,{icon:e.jsx(me,{className:"h-5 w-5 text-amber-500"}),label:"ê²°ì 문ì ",value:d.paymentIssueSubscriptions,onClick:()=>y({subscription:"payment_issue"})}),e.jsx(k,{icon:e.jsx(Re,{className:"h-5 w-5 text-red-500"}),label:"구ë
ì·¨ì",value:d.cancelledSubscriptions,onClick:()=>y({subscription:"cancelled"})}),e.jsx(k,{icon:e.jsx(ee,{className:"h-5 w-5 text-orange-500"}),label:"íë¶ í´ì§",value:d.refundedSubscriptions,onClick:()=>y({subscription:"refunded"})})]}),e.jsx("p",{className:"text-caption text-muted-foreground",children:"ì¬ì©ì ì를 ì¸ë ìì ë ì¥ì 빼면 ë머ì§ë 구ë
ê±´ì 기ì¤ì
ëë¤ â í ì¬ì©ìê° êµ¬ë
ì ì¬ë¬ ê±´ ê°ì§ ì ìì´ ì¹´ë를 ëë ì ë ëì¤ë ì¬ì©ì ìì ë¤ë¥¼ ì ììµëë¤. 'ê²°ì 문ì 'ë ê²°ì ì¬ìë ì¤Â·ê²°ì ì¤í¨Â·ê²°ì ì¹´ë ë±ë¡ íì를 í©ì¹ ê°ì
ëë¤."})]}),e.jsx("div",{className:"mt-8",children:e.jsx(Ee,{searchInput:p.search,onSearchInputChange:a=>s(r=>({...r,search:a})),onSearchSubmit:ae,statusFilter:p.status,onStatusFilterChange:a=>s(r=>({...r,status:a})),subFilter:p.subscription,onSubFilterChange:a=>s(r=>({...r,subscription:a})),dateJoinedFrom:p.dateJoinedFrom,onDateJoinedFromChange:a=>s(r=>({...r,dateJoinedFrom:a})),dateJoinedTo:p.dateJoinedTo,onDateJoinedToChange:a=>s(r=>({...r,dateJoinedTo:a})),onReset:ne})}),e.jsxs("div",{className:"mt-8 flex items-center justify-end gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-caption text-muted-foreground",children:["í´ëí° ë²í¸ ë§ì¤í¹",e.jsx(W,{checked:$,onCheckedChange:se,"aria-label":"í´ëí° ë²í¸ ë§ì¤í¹"})]}),e.jsxs(M,{variant:"outline",size:"sm",onClick:re,disabled:H,children:[e.jsx(Pe,{className:"mr-1 h-4 w-4"}
1),H?"ë¤ì´ë¡ë ì¤...":"ê²ì ê²°ê³¼ ë¤ì´ë¡ë"]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Le,{users:N,loading:j,page:u,pageSize:T,sortType:l,sortOrder:h,onSortChange:te,phoneMasked:$,onToggleActive:ie,onRowClick:a=>o(xe(a))})}),K>1&&e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("p",{className:"text-body-sm text-muted-foreground",children:["ì´ ",b,"ëª
ì¤ ",(u-1)*T+1,"â",Math.min(u*T,b)]}),e.jsx(fe,{page:u,totalPages:K,onPageChange:n})]})]})}export{hs as default};
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.