Files
Ydisks-Xianyu-Helper/internal/webui/static/assets/AccountList-bZfynCVm.js
T

4 lines
61 KiB
JavaScript

import{b as ie,j as e,a as l,d as Me}from"./react-vendor-Bf9ELcll.js";import{r as q,c as L}from"./chat-metadata-CxFNzZmJ.js";import{c as Ae,o as Pe}from"./contract-COFcZjyb.js";import{r as de,X as ce,h as Be,L as H,s as Te,t as Ge,u as Oe,v as qe,w as Le,U as Ie,x as te,y as ze,m as _e,Q as we,z as Ee,R as We,H as Ve,I as Je,T as Ne,K as Ke,J as He,N as Xe,g as Ye,O as Ze}from"./icons-vendor-eB2mgMyz.js";import"./vendor-BE-_xUHH.js";const Fe=(a,s)=>{const t=a.avatar_url||"";if(!t)return"";try{const r=new URL(t,window.location.origin);return r.hostname.endsWith("alicdn.com")&&r.searchParams.set("_v",s),r.toString()}catch{return t}},es=async a=>{const s=await q(n=>L.GET("/api/v1/accounts/details",{signal:n}),a),t=Ae(s,["data","accounts","details"]),r=Date.now().toString();return t.map(n=>({id:n.id,cookie_configured:n.has_cookie===!0,enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,pause_duration:n.pause_duration,paused_until:Number(n.paused_until||0),paused:n.paused===!0,username:n.username||"",login_password_configured:void 0,show_browser:n.show_browser===!0||n.show_browser===1||n.show_browser==="1"||n.show_browser==="true",nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:Fe(n,r),profile_error:n.profile_error||"",ai_enabled:!1,auto_rate_enabled:n.auto_rate_enabled,rate_content:n.rate_content||"不错的买家,交易愉快",auto_polish_enabled:n.auto_polish_enabled,polish_time:n.polish_time||"03:00",last_rate_scan_at:Number(n.last_rate_scan_at||0),last_polish_date:n.last_polish_date||"",last_polish_at:Number(n.last_polish_at||0)}))},ve=async(a,s)=>q(t=>L.GET("/api/v1/account-tasks/{cid}",{params:{path:{cid:a}},signal:t}),s),ke=async(a,s,t)=>q(r=>L.PUT("/api/v1/account-tasks/{cid}",{params:{path:{cid:a}},body:s,signal:r}),t),ss=async(a,s,t)=>q(r=>L.POST("/api/v1/account-tasks/{cid}/run",{params:{path:{cid:a}},body:{task_type:s},signal:r}),{timeoutMs:12e4,...t}),as=async a=>await q(t=>L.GET("/api/v1/accounts/runtime-status",{signal:t}),a),ts=async a=>q(s=>L.POST("/api/v1/qr-login/generate",{signal:s}),{...a,timeoutMs:(a==null?void 0:a.timeoutMs)??13e4}),rs=async(a,s)=>q(t=>L.GET("/api/v1/qr-login/check/{session_id}",{params:{path:{session_id:a}},signal:t}),{signal:s,timeoutMs:1e4}),ns=async(a,s)=>q(t=>L.POST("/api/v1/qr-login/complete-verification/{session_id}",{params:{path:{session_id:a}},body:{target_account_id:s||""},signal:t})),ls=async(a,s)=>q(t=>L.PUT("/api/v1/accounts/{cid}/status",{params:{path:{cid:a}},body:{enabled:s},signal:t})),os=async a=>q(s=>L.DELETE("/api/v1/accounts/{cid}",{params:{path:{cid:a}},signal:s})),is=async(a,s,t)=>q(r=>L.PUT("/api/v1/accounts/{cid}/pause-duration",{params:{path:{cid:a}},body:{pause_duration:s},signal:r}),t),cs=async(a,s,t)=>q(r=>L.PUT("/api/v1/accounts/{cid}/settings",{params:{path:{cid:a}},body:s,signal:r}),t),ds=async(a,s)=>q(t=>L.GET("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:a}},signal:t}),s),us=async(a,s,t)=>q(r=>L.PUT("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:a}},body:{enabled:s},signal:r}),t),xs=async(a,s)=>q(t=>L.POST("/api/v1/password-login",{body:a,signal:t}),s),ms=async(a,s)=>q(r=>L.GET("/api/v1/password-login/check/{session_id}",{params:{path:{session_id:a}},signal:r}),{signal:s,timeoutMs:1e4}),bs=async(a,s)=>q(t=>L.DELETE("/api/v1/password-login/cancel/{session_id}",{params:{path:{session_id:a}},signal:t}),s),hs=async a=>q(s=>L.POST("/api/v1/accounts/{cid}/refresh-profile",{params:{path:{cid:a}},signal:s})),gs=async a=>{const s=await q(t=>L.GET("/api/v1/settings/ai-reply",{signal:t}),a);return Pe(s,["settings","data","result"])||{}},ps=async(a,s)=>q(t=>L.GET("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:a}},signal:t}),s),fs=async(a,s,t)=>{const r={ai_enabled:s.ai_enabled??!1,auto_adjust_price_enabled:s.auto_adjust_price_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return q(n=>L.PUT("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:a}},body:r,signal:n}),t)},ys=a=>{if(Array.isArray(a))return a.filter(Boolean);if(typeof a!="string"||!a.trim())return[];try{const s=JSON.parse(a);if(Array.isArray(s))return s.filter(Boolean)}catch{}return a.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},js=async a=>{const s=await q(r=>L.GET("/api/v1/notifications/channels",{signal:r}),a);return{success:!0,data:Ae(s,["data","channels","items"]).map(r=>{const n={},c=r.type==="ding_talk"?"dingtalk":r.type==="lark"?"feishu":r.type;return{id:String(r.id),name:r.name,type:c,config:n,event_types:ys(r.event_types),enabled:r.enabled}})}},_s=async(a,s)=>{const t=await q(n=>L.GET("/api/v1/notifications/accounts/{cid}/bindings",{params:{path:{cid:a}},signal:n}),s),r=Pe(t,["data","result"])||{};return Array.isArray(r.channel_ids)?r.channel_ids:[]},ws=({account:a,settings:s,saving:t,onChange:r,onClose:n,onSave:c})=>{const i=y=>r({...s,...y}),d=()=>i(s.ai_enabled?{ai_enabled:!1,auto_adjust_price_enabled:!1}:{ai_enabled:!0}),m=()=>{s.ai_enabled&&i({auto_adjust_price_enabled:!s.auto_adjust_price_enabled})},x=y=>i({max_discount_percent:parseInt(y.target.value,10)||0}),f=y=>i({max_discount_amount:parseInt(y.target.value,10)||0}),b=y=>i({max_bargain_rounds:parseInt(y.target.value,10)||1}),h=y=>i({custom_prompts:y.target.value});return ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(de,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.nickname||a.remark||a.id})]}),e.jsx("button",{onClick:n,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0","aria-label":"关闭 AI 设置",children:e.jsx(ce,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:d,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.ai_enabled?"bg-brand":"bg-gray-300"}`,"aria-label":"切换 AI 自动回复",children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${s.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-amber-50 border border-amber-200 rounded-xl",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx("div",{className:"font-bold text-gray-900",children:"自动执行 AI 报价改价"}),e.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"AI 明确报价后,买家在 30 分钟内拍下对应商品时自动修改待付款订单价格。开启 AI 议价后,固定自动化规则改价将不能同时启用。"})]}),e.jsx("button",{type:"button",onClick:m,disabled:!s.ai_enabled,className:`w-14 h-8 rounded-full transition-colors duration-300 relative flex-shrink-0 ${s.auto_adjust_price_enabled?"bg-amber-500":"bg-gray-300"} ${s.ai_enabled?"":"opacity-50 cursor-not-allowed"}`,"aria-label":"切换 AI 自动改价",children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${s.auto_adjust_price_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:s.max_discount_percent,onChange:x,className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10 表示最多降价 10%;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:s.max_discount_amount,onChange:f,className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100 表示最多降价 100 元;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:s.max_bargain_rounds,onChange:b,className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:s.custom_prompts,onChange:h,placeholder:`输入自定义的AI回复规则或风格指引...
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 只有开启自动改价后,已发送给买家的有效报价才会用于真实订单改价"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:n,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:t,children:"取消"}),e.jsxs("button",{onClick:(()=>void c()),className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:t,children:[t?e.jsx(H,{className:"w-4 h-4 animate-spin"}):e.jsx(Te,{className:"w-4 h-4"}),t?"保存中...":"保存"]})]})})]})}),document.body)},Ce=a=>({account_id:a.id,auto_rate_enabled:a.auto_rate_enabled===!0,rate_content:a.rate_content||"不错的买家,交易愉快",auto_polish_enabled:a.auto_polish_enabled===!0,polish_time:a.polish_time||"03:00",last_rate_scan_at:a.last_rate_scan_at,last_polish_date:a.last_polish_date,last_polish_at:a.last_polish_at}),Z=(a,s,t)=>a===s&&!t.aborted,ye=(a,s)=>a instanceof Error?a.message:s,je=a=>a instanceof Error&&a.message==="请求已取消",Se=(a,s)=>!a&&s==="",Ns=({account:a,onSaved:s})=>{const[t,r]=l.useState(()=>Ce(a)),[n,c]=l.useState(!0),[i,d]=l.useState(!1),[m,x]=l.useState(""),[f,b]=l.useState(""),[h,y]=l.useState(null),[C,g]=l.useState(null),p=l.useRef(0),I=l.useRef(null);l.useEffect(()=>{var v;const R=++p.current;(v=I.current)==null||v.abort();const _=new AbortController;return I.current=_,r(Ce(a)),y(null),b(""),d(!1),x(""),g(null),c(!0),ve(a.id,{signal:_.signal}).then(A=>{Z(p.current,R,_.signal)&&r(A)}).catch(A=>{Z(p.current,R,_.signal)&&!je(A)&&b(ye(A,"加载任务设置失败"))}).finally(()=>{Z(p.current,R,_.signal)&&c(!1)}),(()=>_.abort())},[a.id]),l.useEffect(()=>(()=>{var R;return(R=I.current)==null?void 0:R.abort()}),[]);const B=l.useCallback(async()=>{var v;if(!Se(i,m))return;const R=++p.current;(v=I.current)==null||v.abort();const _=new AbortController;I.current=_,d(!0),b(""),g(null);try{const A=await ke(a.id,t,{signal:_.signal});if(!Z(p.current,R,_.signal))return;r(A),s(A)}catch(A){Z(p.current,R,_.signal)&&!je(A)&&(b(ye(A,"保存失败")),g(()=>B))}finally{Z(p.current,R,_.signal)&&d(!1)}},[a.id,t,s,m,i]),G=l.useCallback(async R=>{var A;if(!Se(i,m)||!a.enabled)return;const _=++p.current;(A=I.current)==null||A.abort();const v=new AbortController;I.current=v,x(R),b(""),y(null),g(null);try{await ke(a.id,t,{signal:v.signal});const N=await ss(a.id,R,{signal:v.signal}),P=await ve(a.id,{signal:v.signal});if(!Z(p.current,_,v.signal))return;y(N.summary),r(P),s(P)}catch(N){Z(p.current,_,v.signal)&&!je(N)&&(b(ye(N,"任务执行失败")),g(()=>(()=>G(R))))}finally{Z(p.current,_,v.signal)&&x("")}},[a.enabled,a.id,t,s,m,i]),D=l.useCallback(async()=>{C&&await C()},[C]);return{form:t,loading:n,saving:i,running:m,summary:h,error:f,retryAvailable:C!==null,setForm:r,save:B,run:G,retry:D}},Re=({checked:a,onChange:s,label:t})=>e.jsx("button",{type:"button","aria-label":t,"aria-pressed":a,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${a?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${a?"translate-x-6":""}`})}),vs=({account:a,onClose:s,onSaved:t})=>{const{form:r,loading:n,saving:c,running:i,error:d,summary:m,retryAvailable:x,setForm:f,save:b,run:h,retry:y}=Ns({account:a,onSaved:t});return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:a.nickname||a.remark||a.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(ce,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[n&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",children:"正在读取任务设置..."}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(Ge,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Re,{checked:r.auto_rate_enabled,onChange:(()=>f(C=>({...C,auto_rate_enabled:!C.auto_rate_enabled}))),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:r.rate_content,maxLength:500,onChange:(C=>f(g=>({...g,rate_content:C.target.value}))),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",r.last_rate_scan_at?new Date(r.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:i!==""||!a.enabled,onClick:(()=>void h("auto_rate")),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[i==="auto_rate"?e.jsx(H,{className:"h-4 w-4 animate-spin"}):e.jsx(Oe,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(qe,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(Re,{checked:r.auto_polish_enabled,onChange:(()=>f(C=>({...C,auto_polish_enabled:!C.auto_polish_enabled}))),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:r.polish_time,onChange:(C=>f(g=>({...g,polish_time:C.target.value}))),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:i!==""||!a.enabled,onClick:(()=>void h("auto_polish")),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[i==="auto_polish"?e.jsx(H,{className:"h-4 w-4 animate-spin"}):e.jsx(Le,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",r.last_polish_at?new Date(r.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),m&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",m.found," 项,成功 ",m.success,",失败 ",m.failed,",跳过 ",m.skipped,"。",m.message||""]}),d&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[e.jsx("span",{children:d}),x&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void y()),children:"重试"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:c||i!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:(()=>void b()),disabled:c||i!==""||r.auto_rate_enabled&&!r.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[c?e.jsx(H,{className:"h-4 w-4 animate-spin"}):e.jsx(Te,{className:"h-4 w-4"}),"保存"]})]})})]})})},ks=(a,s)=>{if(!a||!s)return!1;const t=Date.parse(a),r=Date.parse(s);return Number.isFinite(t)&&Number.isFinite(r)&&r<t},Cs=(a,s)=>a.map(t=>{const r=s[t.id];return!r||ks(t.runtime_updated_at,r.updated_at)?t:{...t,runtime_state:r.state,runtime_message:r.message||"",runtime_connected:r.connected,runtime_updated_at:r.updated_at}}),Ss=a=>{if(!a.enabled||a.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(a.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"runtime_conflict":return{label:"运行状态冲突",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},Rs=Me.memo(function({account:s,refreshing:t,deleting:r,onRefreshProfile:n,onReauthorize:c,onEdit:i,onAI:d,onTasks:m,onToggle:x,onDelete:f}){const b=Ss(s),h=s.runtime_state==="auth_expired"||s.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(Ie,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${b.dot}`,children:s.runtime_state==="online"&&e.jsx(te,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:s.nickname||s.remark||`账号 ${s.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${b.badge}`,children:b.label}),s.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(de,{className:"w-3 h-3"})," AI"]}),s.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(ze,{className:"h-3 w-3"})," 自动评价"]}),s.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(qe,{className:"h-3 w-3"})," 每日擦亮"]}),s.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(te,{className:"h-3 w-3"})," 自动确认发货"]}),s.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:s.profile_error,children:[e.jsx(_e,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:s.remark||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",s.id]})]}),s.runtime_message&&s.runtime_state!=="online"&&s.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${h?"text-red-700":"text-amber-700"}`,children:[e.jsx(_e,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:s.runtime_message}),h&&e.jsxs("button",{type:"button",onClick:(()=>c(s)),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(we,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),s.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(Ee,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:(()=>n(s)),disabled:t,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(We,{className:`w-5 h-5 ${t?"animate-spin":""}`})}),e.jsx("button",{onClick:(()=>c(s)),className:`p-3 rounded-xl transition-colors ${h?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(we,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>i(s)),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(Ve,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>d(s)),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(de,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>m(s)),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(Le,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>x(s.id,s.enabled)),className:`p-3 rounded-xl transition-colors ${s.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:s.enabled?"停用账号":"启用账号",children:e.jsx(Je,{className:"w-5 h-5"})}),e.jsx("button",{onClick:(()=>f(s)),disabled:r,className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:r?"删除中…":`删除账号 ${s.nickname||s.remark||s.id}`,children:r?e.jsx(H,{className:"w-5 h-5 animate-spin"}):e.jsx(Ne,{className:"w-5 h-5"})})]})]})]})]})})}),As=({account:a,deleting:s,error:t,onClose:r,onConfirm:n})=>ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Ne,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:r,disabled:s,className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(ce,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:a.nickname||a.remark||"未命名账号"}),a.remark&&a.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",a.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",a.id]})]}),s&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(H,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),t&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(_e,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:t})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:r,disabled:s,className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:(()=>void n()),disabled:s,className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:s?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),De=({src:a,alt:s,className:t=""})=>e.jsx("img",{src:a,alt:s,className:`block aspect-square h-auto w-full object-contain ${t}`.trim()}),Ps=({account:a,editForm:s,setEditForm:t,saving:r,onClose:n,onSave:c,onRestartPause:i,longLogin:d,onToggleLongLogin:m,passwordLoginView:x,onPasswordLogin:f,onCancelPasswordLogin:b,notifChannels:h,selectedChannelIds:y,bindingsLoaded:C,bindingsLoading:g,bindingsLoadError:p,onRetryBindings:I,onToggleChannel:B,onSettingsDirty:G})=>{const D=(S,J)=>{t(se=>({...se,[S]:J}))},R=()=>void n(),_=()=>void c(),v=S=>D("remark",S.target.value),A=S=>D("cookie",S.target.value),N=()=>D("auto_confirm",!s.auto_confirm),P=S=>D("pause_duration",parseInt(S.target.value,10)||0),U=()=>void i(),Y=()=>void m(),X=S=>D("username",S.target.value),V=S=>t(J=>({...J,login_password:S.target.value,clear_password:!1})),K=()=>D("showLoginPassword",!s.showLoginPassword),z=S=>t(J=>({...J,clear_password:S.target.checked,login_password:S.target.checked?"":J.login_password})),E=()=>D("show_browser",!s.show_browser),W=()=>void b(),$=()=>void f(),M=()=>void I(),ee=S=>{C&&(B(S),G())},re=S=>{const J=y.includes(Number(S.id)),se=()=>ee(Number(S.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:se,disabled:!C,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${J?"bg-brand border-brand":"bg-white border-gray-300"}`,children:J&&e.jsx(te,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:S.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[S.type,S.enabled?"":" · 已停用"]})]})]},S.id)};return ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.nickname||a.remark||a.id})]}),e.jsx("button",{onClick:R,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(ce,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:a.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:s.remark,onChange:v,placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:s.cookie,onChange:A,placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",s.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:N,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.auto_confirm?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${s.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:s.pause_duration,onChange:P,placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),s.pause_duration>0&&!a.paused&&s.pause_duration===(a.pause_duration||0)&&e.jsx("button",{type:"button",disabled:r,onClick:U,className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",children:"立即按当前时长重新暂停"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(Ke,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),d.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:d.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:d.loading||d.saving||!d.canOpen,onClick:Y,className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${d.enabled?"bg-brand":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${d.enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:s.username,onChange:X,placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:s.showLoginPassword?"text":"password",value:s.login_password,onChange:V,placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:K,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:s.showLoginPassword?e.jsx(He,{className:"w-5 h-5"}):e.jsx(Xe,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.clear_password,onChange:z,className:"w-4 h-4 accent-brand"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:E,className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${s.show_browser?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${s.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),x.status==="processing"||x.status==="verification_required"?e.jsx("button",{type:"button",onClick:W,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:$,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),x.message&&e.jsx("div",{className:`text-sm font-medium ${x.status==="failed"?"text-red-700":x.status==="success"?"text-green-700":"text-blue-800"}`,children:x.message}),x.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),x.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(De,{src:x.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(h.length>0||g||p)&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(Ye,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),g&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(H,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),p&&!g&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:p}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:M,children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:h.map(re)})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:R,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:r,children:"取消"}),e.jsxs("button",{onClick:_,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:r,children:[r?e.jsx(H,{className:"w-4 h-4 animate-spin"}):e.jsx(te,{className:"w-4 h-4"}),r?"保存中...":"保存"]})]})})]})}),document.body)},Ts=({faceQrUrl:a,verificationScreenshot:s})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(Ze,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:a?e.jsx("img",{src:a,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(H,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),qs=({target:a,status:s,codeUrl:t,errorMessage:r,faceQrUrl:n,verificationScreenshot:c,onClose:i})=>ie.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:i,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors","aria-label":"关闭二维码登录",children:e.jsx(ce,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:a?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:a?`请用闲鱼APP扫码,为「${a.nickname||a.remark||a.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${s==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[s==="loading"&&e.jsx(H,{className:"w-10 h-10 text-brand animate-spin"}),s==="waiting"&&e.jsx(De,{src:t,alt:"闲鱼登录二维码",className:"p-2"}),s==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(te,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),s==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:r||"请关闭窗口后重新发起扫码登录。"})]}),s==="verification"&&e.jsx(Ts,{faceQrUrl:n,verificationScreenshot:c})]}),s!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),Ls=(a,s)=>a.map(t=>{var r,n,c,i,d,m;return{...t,ai_enabled:((r=s[t.id])==null?void 0:r.ai_enabled)??!1,auto_adjust_price_enabled:((n=s[t.id])==null?void 0:n.auto_adjust_price_enabled)??!1,max_discount_percent:((c=s[t.id])==null?void 0:c.max_discount_percent)??10,max_discount_amount:((i=s[t.id])==null?void 0:i.max_discount_amount)??100,max_bargain_rounds:((d=s[t.id])==null?void 0:d.max_bargain_rounds)??3,custom_prompts:((m=s[t.id])==null?void 0:m.custom_prompts)??""}}),Is=()=>{const[a,s]=l.useState([]),[t,r]=l.useState(!0),n=l.useRef(0),c=l.useRef(null),i=l.useCallback(async()=>{var x;const d=++n.current;(x=c.current)==null||x.abort();const m=new AbortController;c.current=m,r(!0);try{const f={signal:m.signal},[b,h]=await Promise.allSettled([es(f),gs(f)]);if(d!==n.current)return;if(b.status==="rejected")throw b.reason;const y=h.status==="fulfilled"?h.value:{};h.status==="rejected"&&console.error("加载 AI 设置失败:",h.reason),s(Ls(b.value,y))}catch(f){d===n.current&&!m.signal.aborted&&console.error("加载账号失败:",f)}finally{d===n.current&&r(!1)}},[]);return l.useEffect(()=>{let d=!1,m=null;const x=new AbortController,f=async()=>{try{const h=await as({signal:x.signal,timeoutMs:1e4});d||s(y=>Cs(y,h))}catch(h){d||console.error("加载账号运行状态失败:",h)}finally{d||(m=window.setTimeout(()=>void f(),2e3))}};return i().finally(()=>{d||f()}),()=>{var h;d=!0,x.abort(),n.current+=1,(h=c.current)==null||h.abort(),m!==null&&window.clearTimeout(m)}},[i]),{accounts:a,setAccounts:s,loading:t,loadAccounts:i}},Es=new Set(["expired","cancelled","error","not_found"]),Ds=()=>{let a=0;return{next:()=>(a+=1,a),cancel:()=>{a+=1},isCurrent:(s=>s===a)}},Qs=(a={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,t=null,r=-1,n=0;const c=()=>{n+=1,t==null||t.abort(),t=null,s!==null&&(a.clearInterval(s),s=null)};return{start:(d,m,x,f=2e3)=>{c();const b=n;t=new AbortController;const h=t.signal;s=a.setInterval(()=>{r===b||b!==n||(r=b,(async()=>{var y,C;try{const g=await m(d,h);if(g.status==="success"){c(),await x.onSuccess(g);return}if(g.status==="scanned"){(y=x.onScanned)==null||y.call(x,g);return}if(g.status==="verification_required"){(C=x.onVerificationRequired)==null||C.call(x,g);return}g.status&&Es.has(g.status)&&(c(),x.onTerminalError(g))}catch(g){if(h.aborted||b!==n)return;c(),x.onPollError(g)}finally{r===b&&(r=-1)}})())},f)},stop:c,isActive:(()=>s!==null)}},Us=({onLoginSuccess:a})=>{const[s,t]=l.useState(!1),[r,n]=l.useState(""),[c,i]=l.useState("pending"),[d,m]=l.useState(""),[x,f]=l.useState(""),[b,h]=l.useState(""),[y,C]=l.useState(null),g=l.useRef(null),p=l.useRef(null),I=l.useRef(null),B=l.useRef(null);g.current===null&&(g.current=Qs()),p.current===null&&(p.current=Ds());const G=()=>{B.current!==null&&(window.clearTimeout(B.current),B.current=null)},D=()=>{var N;(N=g.current)==null||N.stop()},R=()=>{var N,P;(N=I.current)==null||N.abort(),(P=p.current)==null||P.cancel(),D(),G(),t(!1)},_=()=>{G(),B.current=window.setTimeout(()=>{B.current=null,t(!1),a()},1e3)};l.useEffect(()=>()=>{var P,U;D(),(P=p.current)==null||P.cancel(),(U=I.current)==null||U.abort(),G()},[]);const v=async(N,P)=>{const U=await ns(N,P==null?void 0:P.id);if(!U.success||!U.account_id)throw new Error("保存扫码授权失败");return U.account_id};return{showQRModal:s,qrCodeUrl:r,qrStatus:c,qrErrorMessage:d,verificationScreenshot:x,faceQrUrl:b,qrReauthTarget:y,startQRLogin:async N=>{var X,V,K,z;D(),(X=I.current)==null||X.abort();const P=new AbortController;I.current=P;const U=p.current.next();G();const Y=N||null;C(Y),t(!0),i("loading"),m(""),n(""),f(""),h("");try{const E=await ts({signal:P.signal});if(!((V=p.current)!=null&&V.isCurrent(U)))return;if(!E.success||!E.qr_code_url||!E.session_id)throw new Error(E.message||"闲鱼未返回可用的登录二维码");const W=E.session_id;n(E.qr_code_url),i("waiting"),(K=g.current)==null||K.start(W,rs,{onSuccess:(async()=>{try{await v(W,Y)}catch($){console.error("保存扫码授权失败",$),i("error");return}i("success"),_()}),onScanned:(()=>{i("waiting")}),onTerminalError:(()=>{i("error")}),onPollError:($=>{console.error("轮询扫码状态失败",$),i("error")}),onVerificationRequired:($=>{i("verification"),$.face_qr_url&&h($.face_qr_url),$.verification_screenshot&&f($.verification_screenshot)})})}catch(E){if(!((z=p.current)!=null&&z.isCurrent(U))||P.signal.aborted)return;m(E instanceof Error?E.message:"二维码获取失败,请稍后重试"),i("error")}finally{I.current===P&&(I.current=null)}},closeQRModal:R}},$s=(a,s)=>a&&s,Ms=(a,s)=>a!==(s.pause_duration||0),Bs=(a,s)=>{const t=s.username!==(a.username||""),r=s.show_browser!==(a.show_browser||!1),n=s.login_password!=="",c=s.clear_password===!0;if(!t&&!r&&!n&&!c)return null;const i={username:s.username,show_browser:s.show_browser};return c?i.clear_password=!0:n&&(i.login_password=s.login_password),i},F=(a,s,t,r)=>a===s&&t===r,Gs=a=>a.status==="success"?{sessionId:"",status:"success",message:a.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}:a.status==="processing"||a.status==="verification_required"?{sessionId:"",status:a.status,message:a.message||(a.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:a.qr_code_url||""}:{sessionId:"",status:"failed",message:a.error||a.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""},Os=({editingAccount:a,setEditingAccount:s,setActiveModal:t,editForm:r,setEditForm:n,loadAccounts:c})=>{const[i,d]=l.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[m,x]=l.useState([]),[f,b]=l.useState([]),[h,y]=l.useState(!1),[C,g]=l.useState(!1),[p,I]=l.useState(!1),[B,G]=l.useState(""),[D,R]=l.useState({ai_enabled:!1,auto_adjust_price_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[_,v]=l.useState(!1),[A,N]=l.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),P=l.useRef(0),U=l.useRef(null),Y=l.useRef(0),X=l.useRef(null),V=l.useRef(0),K=l.useRef(null),z=l.useRef(0),E=l.useRef(""),W=l.useRef(null),$=l.useRef(null),M=l.useCallback(()=>{$.current!==null&&(window.clearTimeout($.current),$.current=null)},[]),ee=l.useCallback(async o=>{var O;const u=++P.current;(O=U.current)==null||O.abort();const k=new AbortController;U.current=k,g(!0),y(!1),I(!1),G("");const[Q,w]=await Promise.allSettled([js({signal:k.signal}),_s(o,{signal:k.signal})]);F(u,P.current,o,o)&&(Q.status==="fulfilled"?x(Q.value.data||[]):(x([]),G("通知渠道列表加载失败,请重试")),w.status==="fulfilled"?(b(w.value||[]),y(!0)):(b([]),G("通知绑定加载失败;本次保存不会修改现有绑定")),g(!1))},[]),re=l.useCallback(o=>{b(u=>u.includes(o)?u.filter(k=>k!==o):[...u,o]),I(!0)},[]),S=l.useCallback(async o=>{var w,O;const u=++Y.current;(w=X.current)==null||w.abort();const k=new AbortController;X.current=k,z.current+=1,E.current=o.id,(O=W.current)==null||O.abort(),M(),N({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),s(o),n({remark:o.remark||"",cookie:"",auto_confirm:o.auto_confirm||!1,pause_duration:o.pause_duration||0,username:o.username||"",login_password:"",show_browser:o.show_browser||!1,showLoginPassword:!1,clear_password:!1}),t("edit"),d({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,Q]=await Promise.allSettled([ee(o.id),ds(o.id,{signal:k.signal})]);u===Y.current&&(Q.status==="fulfilled"?d({loading:!1,saving:!1,canOpen:Q.value.can_open_long_login,enabled:Q.value.enabled,error:""}):d({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"}))},[M,ee,t,n,s]),J=l.useCallback(async()=>{if(!a||i.loading||i.saving||!i.canOpen)return;const o=!i.enabled;d(u=>({...u,saving:!0,error:""}));try{const u=await us(a.id,o);d({loading:!1,saving:!1,canOpen:u.can_open_long_login,enabled:u.enabled,error:""})}catch(u){d(k=>({...k,saving:!1,error:u instanceof Error?u.message:"保存登录信息设置失败"}))}},[a,i]),se=l.useCallback(async o=>{var Q;const u=++V.current;(Q=K.current)==null||Q.abort();const k=new AbortController;K.current=k,s(o),t("ai-settings"),v(!0);try{const w=await ps(o.id,{signal:k.signal});if(!F(u,V.current,o.id,o.id))return;R({ai_enabled:w.ai_enabled??!1,auto_adjust_price_enabled:w.auto_adjust_price_enabled??!1,max_discount_percent:w.max_discount_percent??10,max_discount_amount:w.max_discount_amount??100,max_bargain_rounds:w.max_bargain_rounds??3,custom_prompts:w.custom_prompts??""})}catch(w){F(u,V.current,o.id,o.id)&&console.error("加载 AI 设置失败:",w)}finally{F(u,V.current,o.id,o.id)&&v(!1)}},[t,s]),ue=l.useCallback(async()=>{if(!(!a||_)){v(!0);try{await fs(a.id,D),t(null),await c()}catch(o){console.error("更新 AI 设置失败:",o)}finally{v(!1)}}},[D,a,c,_,t]),xe=l.useCallback(async()=>{if(!(!a||_)){v(!0);try{const o={};r.remark!==(a.remark||"")&&(o.remark=r.remark),r.cookie&&(o.cookie=r.cookie),r.auto_confirm!==a.auto_confirm&&(o.auto_confirm=r.auto_confirm),Ms(r.pause_duration,a)&&(o.pause_duration=r.pause_duration);const u=Bs(a,r);u&&Object.assign(o,u),$s(h,p)&&(o.channel_ids=f),Object.keys(o).length>0&&await cs(a.id,o),t(null),await c()}catch(o){console.error("更新账号失败:",o)}finally{v(!1)}}},[p,h,r,a,c,f,_,t]),me=l.useCallback(async()=>{if(!(!a||r.pause_duration<=0||_)){v(!0);try{const o=await is(a.id,r.pause_duration);s(u=>u&&{...u,pause_duration:r.pause_duration,paused:(o==null?void 0:o.paused)===!0,paused_until:Number((o==null?void 0:o.paused_until)||0)}),await c()}catch(o){console.error("重新暂停失败:",o)}finally{v(!1)}}},[r.pause_duration,a,c,_,s]),ne=l.useCallback(async(o,u,k)=>{var w;(w=W.current)==null||w.abort();const Q=new AbortController;W.current=Q;try{const O=await ms(o,Q.signal);if(!F(u,z.current,k,E.current))return;const oe={...Gs(O),sessionId:o};if(O.status==="success"){M(),N(oe),n(pe=>({...pe,login_password:"",showLoginPassword:!1})),await c();return}if(O.status==="processing"||O.status==="verification_required"){N(oe),M(),$.current=window.setTimeout(()=>void ne(o,u,k),1500);return}M(),N(oe)}catch(O){if(!F(u,z.current,k,E.current))return;M(),N({sessionId:o,status:"failed",message:O instanceof Error?O.message:"查询密码登录状态失败",qrCodeUrl:""})}},[M,c,n]),be=l.useCallback(async()=>{var Q;if(!a)return;const o=r.username.trim();if(!o||!r.login_password)return;M(),(Q=W.current)==null||Q.abort();const u=++z.current;E.current=a.id;const k=new AbortController;W.current=k,N({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const w=await xs({account_id:a.id,account:o,password:r.login_password,show_browser:r.show_browser},{signal:k.signal});if(!F(u,z.current,a.id,E.current))return;if(!w.success||!w.session_id)throw new Error(w.message||"无法启动密码登录");N({sessionId:w.session_id,status:"processing",message:w.message||"登录处理中",qrCodeUrl:""}),await ne(w.session_id,u,a.id)}catch(w){if(!F(u,z.current,a.id,E.current))return;N({sessionId:"",status:"failed",message:w instanceof Error?w.message:"启动密码登录失败",qrCodeUrl:""})}},[M,r.login_password,r.show_browser,r.username,a,ne]),le=l.useCallback(async()=>{var u;const o=A.sessionId;z.current+=1,E.current="",(u=W.current)==null||u.abort(),M(),o&&await bs(o).catch(()=>{}),N({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},[M,A.sessionId]),he=l.useCallback(async()=>{var o,u,k;(o=U.current)==null||o.abort(),Y.current+=1,(u=X.current)==null||u.abort(),(k=K.current)==null||k.abort(),(A.status==="processing"||A.status==="verification_required")&&await le(),t(null)},[le,A.status,t]),ge=l.useCallback(()=>{var o;V.current+=1,(o=K.current)==null||o.abort(),t(null)},[t]);return l.useEffect(()=>(()=>{var o,u,k,Q;(o=U.current)==null||o.abort(),(u=X.current)==null||u.abort(),(k=K.current)==null||k.abort(),(Q=W.current)==null||Q.abort(),M()}),[M]),{longLogin:i,notifChannels:m,selectedChannelIds:f,bindingsLoaded:h,bindingsLoading:C,bindingsDirty:p,bindingsLoadError:B,aiSettings:D,saving:_,passwordLoginView:A,setAiSettings:R,setBindingsDirty:I,setEditForm:n,openEditModal:S,closeEditModal:he,openAIModal:se,closeAIModal:ge,loadNotificationBindings:ee,toggleNotificationChannel:re,handleLongLoginToggle:J,handleSaveAISettings:ue,handleSaveEdit:xe,handleRestartPause:me,handlePasswordLogin:be,handleCancelPasswordLogin:le}},Hs=()=>{const{accounts:a,setAccounts:s,loading:t,loadAccounts:r}=Is(),[n,c]=l.useState(""),[i,d]=l.useState(""),[m,x]=l.useState(""),[f,b]=l.useState(null),[h,y]=l.useState(""),[C,g]=l.useState(null),[p,I]=l.useState(null),[B,G]=l.useState(null),[D,R]=l.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),_=Os({editingAccount:p,setEditingAccount:I,setActiveModal:g,editForm:D,setEditForm:R,loadAccounts:r}),{longLogin:v,notifChannels:A,selectedChannelIds:N,bindingsLoaded:P,bindingsLoading:U,bindingsLoadError:Y,aiSettings:X,saving:V,passwordLoginView:K,setAiSettings:z,setBindingsDirty:E,openEditModal:W,closeEditModal:$,openAIModal:M,closeAIModal:ee,loadNotificationBindings:re,toggleNotificationChannel:S,handleLongLoginToggle:J,handleSaveAISettings:se,handleSaveEdit:ue,handleRestartPause:xe,handlePasswordLogin:me,handleCancelPasswordLogin:ne}=_,be=Us({onLoginSuccess:r}),{showQRModal:le,qrCodeUrl:he,qrStatus:ge,qrErrorMessage:o,verificationScreenshot:u,faceQrUrl:k,qrReauthTarget:Q,startQRLogin:w,closeQRModal:O}=be,oe=async(j,T)=>{await ls(j,!T),r()},pe=j=>{m||(y(""),b(j))},Qe=()=>{m||(y(""),b(null))},Ue=async()=>{const j=f;if(!(!j||m)){x(j.id),y("");try{await os(j.id),s(T=>T.filter(ae=>ae.id!==j.id)),b(null)}catch(T){console.error("删除账号失败:",T),y((T==null?void 0:T.message)||"删除账号失败,请稍后重试")}finally{x("")}}},$e=async j=>{d(j.id);try{const T=await hs(j.id);T!=null&&T.profile_error&&alert("资料刷新失败:"+T.profile_error),await r()}catch(T){console.error("刷新账号资料失败:",T),alert((T==null?void 0:T.message)||"刷新账号资料失败,请先重新授权该账号")}finally{d("")}};if(t)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(H,{className:"w-8 h-8 text-brand animate-spin"})});const fe=a.filter(j=>{const T=n.trim().toLowerCase();return T?[j.id,j.nickname,j.remark,j.username,j.runtime_message].some(ae=>(ae||"").toLowerCase().includes(T)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:n,onChange:(j=>c(j.target.value)),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:(()=>w()),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(we,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",fe.length," / ",a.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[fe.map(j=>e.jsx(Rs,{account:j,refreshing:i===j.id,deleting:m===j.id,onRefreshProfile:$e,onReauthorize:w,onEdit:W,onAI:M,onTasks:G,onToggle:oe,onDelete:pe},j.id)),a.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Ie,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),a.length>0&&fe.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),B&&ie.createPortal(e.jsx(vs,{account:B,onClose:(()=>G(null)),onSaved:(j=>{s(T=>T.map(ae=>ae.id===B.id?{...ae,auto_rate_enabled:j.auto_rate_enabled,rate_content:j.rate_content,auto_polish_enabled:j.auto_polish_enabled,polish_time:j.polish_time,last_rate_scan_at:j.last_rate_scan_at,last_polish_date:j.last_polish_date,last_polish_at:j.last_polish_at}:ae))})}),document.body),f&&e.jsx(As,{account:f,deleting:m===f.id,error:h,onClose:Qe,onConfirm:Ue}),le&&e.jsx(qs,{target:Q,status:ge,codeUrl:he,errorMessage:o,faceQrUrl:k,verificationScreenshot:u,onClose:O}),C==="edit"&&p&&e.jsx(Ps,{account:p,editForm:D,setEditForm:R,saving:V,onClose:$,onSave:ue,onRestartPause:xe,longLogin:v,onToggleLongLogin:J,passwordLoginView:K,onPasswordLogin:me,onCancelPasswordLogin:ne,notifChannels:A,selectedChannelIds:N,bindingsLoaded:P,bindingsLoading:U,bindingsLoadError:Y,onRetryBindings:(()=>re(p.id)),onToggleChannel:S,onSettingsDirty:(()=>E(!0))}),C==="ai-settings"&&p&&e.jsx(ws,{account:p,settings:X,saving:V,onChange:z,onClose:ee,onSave:se})]})};export{Hs as default};