import{_ as R}from"./Ba76BwjT.js";import{e as j,J as E,K as J,j as O,c as n,a as s,b as f,y as D,z as q,f as l,D as N,N as M,F as g,r as S,h,i as u,E as A,o,t as r,m as P,d as T,w as G,G as K,_ as Q}from"./DpdQcRr7.js";import"./BcpEzrWT.js";const H={class:"org-page"},W={class:"org-container"},X={class:"filter-bar"},Y={class:"search-input-wrapper"},Z=["value"],tt={key:0,class:"state-box"},et={key:1,class:"empty-state"},st={class:"user-list"},at={class:"user-avatar"},nt={class:"user-main"},ot={class:"user-name-row"},it={class:"user-name"},lt={class:"tag"},rt={class:"tag tag-link"},ct={key:0,class:"tag tag-info"},dt={key:1,class:"user-meta"},ut={class:"user-email"},pt={key:0},mt={class:"user-meta"},_t={key:0},vt={key:0,class:"pagination"},gt=["disabled"],ht={key:0,class:"page-ellipsis"},yt=["onClick"],ft=["disabled"],bt=j({__name:"index",setup(kt){const $={regular:"通常",trial:"体験",short_term:"短期",special:"特別"},U={individual:"個人ユーザー",student:"生徒",instructor:"講師",manager:"教室管理者",owner:"企業管理者",system_admin:"システム管理者"},{$api:V}=E(),b=u([]),L=u([]),k=u(!1),p=u(""),m=u(""),_=u(""),c=u(1),v=u(1),I=async()=>{try{const a=await V("/api/company/organizations?limit=100");L.value=a.organizations}catch(a){console.error("教室一覧の取得に失敗しました:",a)}},y=async()=>{k.value=!0;try{const a=new URLSearchParams;a.append("page",String(c.value)),a.append("limit","20"),p.value&&a.append("search",p.value),m.value&&a.append("organization_id",m.value),_.value&&a.append("status",_.value);const e=a.toString(),i=await V(`/api/company/users?${e}`);b.value=i.users,v.value=i.pages||1}catch(a){console.error("ユーザー一覧の取得に失敗しました:",a)}finally{k.value=!1}},B=()=>{p.value="",m.value="",_.value="",c.value=1,y()},w=a=>{a<1||a>v.value||(c.value=a,y())},F=K(()=>{const a=v.value,e=c.value,i=[];if(a<=7){for(let d=1;d<=a;d++)i.push(d);return i}i.push(1),e>3&&i.push("...");const z=Math.max(2,e-1),t=Math.min(a-1,e+1);for(let d=z;d<=t;d++)i.push(d);return e<a-2&&i.push("..."),i.push(a),i}),x=a=>new Date(a).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"});let C=null;return J([p,m,_],()=>{C&&clearTimeout(C),C=setTimeout(()=>{c.value=1,y()},300)}),O(()=>{I(),y()}),(a,e)=>{const i=A("Icon"),z=R;return o(),n("div",H,[s("div",W,[e[11]||(e[11]=s("div",{class:"page-header"},[s("div",null,[s("h1",{class:"page-title"},"ユーザー管理"),s("p",{class:"page-sub"},"ユーザーの一覧を確認・管理します。アカウント作成は MCP で行います。")])],-1)),s("div",X,[s("div",Y,[f(i,{icon:"mdi:magnify",width:18,height:18,class:"search-icon"}),D(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>N(p)?p.value=t:null),type:"text",class:"search-input",placeholder:"ユーザー名・ユーザーID"},null,512),[[q,l(p)]])]),D(s("select",{"onUpdate:modelValue":e[1]||(e[1]=t=>N(m)?m.value=t:null),class:"filter-select"},[e[5]||(e[5]=s("option",{value:""},"全教室",-1)),(o(!0),n(g,null,S(l(L),t=>(o(),n("option",{key:t.id,value:t.id},r(t.name),9,Z))),128))],512),[[M,l(m)]]),D(s("select",{"onUpdate:modelValue":e[2]||(e[2]=t=>N(_)?_.value=t:null),class:"filter-select"},[...e[6]||(e[6]=[s("option",{value:""},"全てのステータス",-1),s("option",{value:"active"},"アクティブ",-1),s("option",{value:"inactive"},"非アクティブ",-1)])],512),[[M,l(_)]]),s("button",{class:"btn btn-secondary",onClick:B},"フィルタークリア")]),l(k)?(o(),n("div",tt,[...e[7]||(e[7]=[s("div",{class:"loader"},null,-1),s("p",null,"読み込み中...",-1)])])):l(b).length===0?(o(),n("div",et,[f(i,{icon:"mdi:account-multiple-outline",width:48,height:48,class:"empty-icon"}),e[8]||(e[8]=s("p",{class:"empty-title"},"ユーザーが見つかりません",-1)),e[9]||(e[9]=s("p",{class:"empty-sub"},"条件に一致するユーザーがありません。",-1))])):(o(),n(g,{key:2},[s("div",st,[(o(!0),n(g,null,S(l(b),t=>(o(),n("div",{key:t.id,class:"user-card"},[s("span",at,[f(i,{icon:"mdi:account-circle",width:44,height:44})]),s("div",nt,[s("div",ot,[s("span",it,r(t.name||"未設定"),1),s("span",lt,r(t.user_id),1),s("span",{class:P(["tag",t.is_active?"tag-success":"tag-danger"])},r(t.is_active?"アクティブ":"非アクティブ"),3),s("span",rt,r(U[t.role]||t.role),1),t.membership_type?(o(),n("span",ct,r($[t.membership_type]||t.membership_type),1)):h("",!0),t.membership_ended_at?(o(),n("span",dt," 〜"+r(x(t.membership_ended_at)),1)):h("",!0)]),s("p",ut,[T(r(t.organization_name||"未所属")+" ",1),t.email?(o(),n("span",pt," | "+r(t.email),1)):h("",!0)]),s("p",mt,[T(" 作成日: "+r(x(t.created_at))+" ",1),t.last_login_at?(o(),n("span",_t," | 最終ログイン: "+r(x(t.last_login_at)),1)):h("",!0)])]),f(z,{to:`/company/users/${t.id}/edit`,class:"btn btn-secondary btn-sm"},{default:G(()=>[...e[10]||(e[10]=[T(" 編集 ",-1)])]),_:1},8,["to"])]))),128))]),l(v)>1?(o(),n("nav",vt,[s("button",{class:"page-btn",disabled:l(c)<=1,onClick:e[3]||(e[3]=t=>w(l(c)-1))},"前へ",8,gt),(o(!0),n(g,null,S(l(F),(t,d)=>(o(),n(g,{key:d},[t==="..."?(o(),n("span",ht,"…")):(o(),n("button",{key:1,class:P(["page-btn",{"is-current":t===l(c)}]),onClick:wt=>w(t)},r(t),11,yt))],64))),128)),s("button",{class:"page-btn",disabled:l(c)>=l(v),onClick:e[4]||(e[4]=t=>w(l(c)+1))},"次へ",8,ft)])):h("",!0)],64))])])}}}),Dt=Q(bt,[["__scopeId","data-v-d38a6827"]]);export{Dt as default};
