hunter-mate 0.1.32 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/assets/extension/build-info.json +1 -1
  2. package/dist/assets/extension/manifest.json +3 -3
  3. package/dist/assets/server/main.mjs +275 -7
  4. package/dist/index.js +1 -1
  5. package/dist/web/dist/404.html +1 -1
  6. package/dist/web/dist/_next/static/chunks/502-4776504e89a09b68.js +32 -0
  7. package/dist/web/dist/_next/static/chunks/587-a93e5177e3d3ccaf.js +1 -0
  8. package/dist/web/dist/_next/static/chunks/606-9bac5cf9187e9901.js +1 -0
  9. package/dist/web/dist/_next/static/chunks/659-bf056de14f6162b6.js +1 -0
  10. package/dist/web/dist/_next/static/chunks/706-babd57b15a93f415.js +12 -0
  11. package/dist/web/dist/_next/static/chunks/865-422919f47ebce4d3.js +1 -0
  12. package/dist/web/dist/_next/static/chunks/882-5952b675dc02794a.js +1 -0
  13. package/dist/web/dist/_next/static/chunks/{935-0ec6bca7ef6e2dfc.js → 935-79d8aba674c09f7b.js} +2 -2
  14. package/dist/web/dist/_next/static/chunks/app/admin/data/page-31aa598c712a211d.js +1 -0
  15. package/dist/web/dist/_next/static/chunks/app/jobs/page-0a0ee2f8b389a147.js +1 -0
  16. package/dist/web/dist/_next/static/chunks/app/layout-56e9f652ec460661.js +1 -0
  17. package/dist/web/dist/_next/static/chunks/app/memory/page-9b20447ec495bc36.js +1 -0
  18. package/dist/web/dist/_next/static/chunks/app/parselog/page-a9321ca64f1272d1.js +1 -0
  19. package/dist/web/dist/_next/static/chunks/app/recordings/page-959163edef1ef99e.js +1 -0
  20. package/dist/web/dist/_next/static/chunks/app/resource-usage/page-f32cf255cec94d08.js +1 -0
  21. package/dist/web/dist/_next/static/chunks/app/shared/[token]/{page-7189e27de66ecb09.js → page-7666e080dadae190.js} +1 -1
  22. package/dist/web/dist/_next/static/chunks/app/talents/{page-426470ca404838cb.js → page-42a62dae374c5354.js} +1 -1
  23. package/dist/web/dist/_next/static/chunks/app/team/insights/page-4ec3304e214e7c20.js +1 -0
  24. package/dist/web/dist/_next/static/chunks/{main-8b470f167e9bfe73.js → main-69905dba7a812e36.js} +1 -1
  25. package/dist/web/dist/_next/static/chunks/{main-app-ee5c87be3671889b.js → main-app-e02edafef1318e75.js} +1 -1
  26. package/dist/web/dist/_next/static/chunks/pages/{_app-20aa9e4f679a6d47.js → _app-6b02259ee4822d36.js} +3 -3
  27. package/dist/web/dist/_next/static/css/03e3fa723e374884.css +3 -0
  28. package/dist/web/dist/admin/data.html +1 -1
  29. package/dist/web/dist/admin/data.txt +3 -3
  30. package/dist/web/dist/auth/verify.html +1 -1
  31. package/dist/web/dist/auth/verify.txt +2 -2
  32. package/dist/web/dist/companies.html +1 -1
  33. package/dist/web/dist/companies.txt +2 -2
  34. package/dist/web/dist/company/admin.html +1 -1
  35. package/dist/web/dist/company/admin.txt +2 -2
  36. package/dist/web/dist/entity.html +1 -1
  37. package/dist/web/dist/entity.txt +2 -2
  38. package/dist/web/dist/index.html +1 -1
  39. package/dist/web/dist/index.txt +2 -2
  40. package/dist/web/dist/jobs.html +1 -1
  41. package/dist/web/dist/jobs.txt +3 -3
  42. package/dist/web/dist/login.html +2 -2
  43. package/dist/web/dist/login.txt +2 -2
  44. package/dist/web/dist/logs.html +1 -1
  45. package/dist/web/dist/logs.txt +2 -2
  46. package/dist/web/dist/matching/jobs/placeholder/talents.html +1 -1
  47. package/dist/web/dist/matching/jobs/placeholder/talents.txt +2 -2
  48. package/dist/web/dist/matching/portraits/placeholder/jobs.html +1 -1
  49. package/dist/web/dist/matching/portraits/placeholder/jobs.txt +2 -2
  50. package/dist/web/dist/memory.html +1 -0
  51. package/dist/web/dist/memory.txt +7 -0
  52. package/dist/web/dist/parselog.html +1 -1
  53. package/dist/web/dist/parselog.txt +3 -3
  54. package/dist/web/dist/recordings.html +1 -1
  55. package/dist/web/dist/recordings.txt +3 -3
  56. package/dist/web/dist/resource-usage.html +1 -1
  57. package/dist/web/dist/resource-usage.txt +3 -3
  58. package/dist/web/dist/shared/placeholder.html +1 -1
  59. package/dist/web/dist/shared/placeholder.txt +3 -3
  60. package/dist/web/dist/snapshots/placeholder/agent-prompt.html +1 -1
  61. package/dist/web/dist/snapshots/placeholder/agent-prompt.txt +2 -2
  62. package/dist/web/dist/talents.html +1 -1
  63. package/dist/web/dist/talents.txt +3 -3
  64. package/dist/web/dist/team/insights.html +1 -1
  65. package/dist/web/dist/team/insights.txt +3 -3
  66. package/package.json +1 -1
  67. package/dist/web/dist/_next/static/chunks/187-48dc1acca97c62ba.js +0 -1
  68. package/dist/web/dist/_next/static/chunks/353-845111f2789c5a03.js +0 -12
  69. package/dist/web/dist/_next/static/chunks/587-a1defe5c7e3e1e1b.js +0 -1
  70. package/dist/web/dist/_next/static/chunks/603-0878bd28159f4fe7.js +0 -32
  71. package/dist/web/dist/_next/static/chunks/659-85c4e54826b8bd18.js +0 -1
  72. package/dist/web/dist/_next/static/chunks/865-8e1d8c34192526ed.js +0 -1
  73. package/dist/web/dist/_next/static/chunks/882-1bcdfd2499403efd.js +0 -1
  74. package/dist/web/dist/_next/static/chunks/app/admin/data/page-efbbb1ea584df5a4.js +0 -1
  75. package/dist/web/dist/_next/static/chunks/app/jobs/page-af06cb0c0686ebdd.js +0 -1
  76. package/dist/web/dist/_next/static/chunks/app/layout-e93c294bf845144d.js +0 -1
  77. package/dist/web/dist/_next/static/chunks/app/parselog/page-d11c8ce5545a86af.js +0 -1
  78. package/dist/web/dist/_next/static/chunks/app/recordings/page-4a11e105b956cd72.js +0 -1
  79. package/dist/web/dist/_next/static/chunks/app/resource-usage/page-9591bf89800bebb6.js +0 -1
  80. package/dist/web/dist/_next/static/chunks/app/team/insights/page-db663ad28356ff73.js +0 -1
  81. package/dist/web/dist/_next/static/css/ad396c8df7280fac.css +0 -3
  82. /package/dist/assets/extension/background/{service-worker.20261027115924.js → service-worker.20261028162720.js} +0 -0
  83. /package/dist/web/dist/_next/static/{MJuXtJSgMhtSDdWY9q8kk → Rmj7zlgoj2IjJB_RWslV8}/_buildManifest.js +0 -0
  84. /package/dist/web/dist/_next/static/{MJuXtJSgMhtSDdWY9q8kk → Rmj7zlgoj2IjJB_RWslV8}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0076c486-7258-48ff-97fb-dd3320b5022e",e._sentryDebugIdIdentifier="sentry-dbid-0076c486-7258-48ff-97fb-dd3320b5022e")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[116],{87126:function(e,t,n){Promise.resolve().then(n.bind(n,84042))},84042:function(e,t,n){"use strict";n.d(t,{AdminDataPage:function(){return c}});var l=n(72835),s=n(4025),a=n(78606),r=n(60635),i=n(65777),u=n(82182),o=n(8448);let d=[{value:"talent_profiles",label:"人才"},{value:"jobcases",label:"职位"},{value:"company_profiles",label:"公司"},{value:"customers",label:"客户"}];function c(){var e,t,n;let{session:c,utoken:h}=(0,i.nu)(),f=null!==(e=null==c?void 0:c.hmUserId)&&void 0!==e?e:null,[x,m]=(0,r.useState)(""),[y,v]=(0,r.useState)("talent_profiles"),[g,p]=(0,r.useState)("all"),[b,N]=(0,r.useState)(1),[j,w]=(0,r.useState)(null),[S,I]=(0,r.useState)(!1),[k,E]=(0,r.useState)(null),[C,_]=(0,r.useState)(new Set),[U,T]=(0,r.useState)(null),[R,z]=(0,r.useState)(!1),[A,O]=(0,r.useState)(null);(0,r.useEffect)(()=>{null==f||x||m(String(f))},[f,x]);let P=(0,r.useCallback)(async(e,t)=>(0,s.k)(e,null!=t?t:{}),[]),D=(0,r.useCallback)(async()=>{if(x){I(!0),E(null);try{let n=new URLSearchParams({hmUserId:x,entity:y,softDeleted:g,page:String(b),pageSize:String(50)}),l=await P("/admin/entities?".concat(n));if(403===l.status){var e,t;let n=await l.json().catch(()=>null),s=null!==(t=null==n?void 0:null===(e=n.message)||void 0===e?void 0:e.code)&&void 0!==t?t:null==n?void 0:n.code;E("ADMIN_NOT_CONFIGURED"===s?"管理功能未开启":"你没有管理权限"),w(null);return}if(!l.ok){E("加载失败(HTTP ".concat(l.status,")")),w(null);return}let s=await l.json();w(s),_(e=>{let t=new Set(s.items.map(e=>e.entityRef)),n=new Set(Array.from(e).filter(e=>t.has(e)));return n.size===e.size?e:n})}finally{I(!1)}}},[P,x,y,g,b]);(0,r.useEffect)(()=>{D()},[D]);let M=(0,r.useMemo)(()=>j?Math.max(1,Math.ceil(j.total/50)):1,[j]),J=(0,r.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),X=(0,r.useCallback)(async()=>{if(!(null==U?void 0:U.length))return;z(!0),O(null);let e=async()=>{let e=await (0,s.k)("/admin/purge",{method:"POST",body:JSON.stringify({hmUserId:Number(x),entity:y,entityRefs:U})});if(!e.ok){let t=await e.json().catch(()=>null),n=null==t?void 0:t.message;return O("string"==typeof n?n:"清除失败,请稍后重试"),!1}return O("已清除 ".concat(U.length," 条,所有设备会同步删除")),_(new Set),await D(),!0};try{let n=await P("/admin/purge",{method:"POST",body:JSON.stringify({hmUserId:Number(x),entity:y,entityRefs:U})});if(!n.ok){if(401===n.status){var t;O("登录已过期,请在弹窗中重新登录;登录后自动继续清除"),(0,u.jr)({message:"登录已过期,请重新登录",oldUserId:null!==(t=null==c?void 0:c.hmUserId)&&void 0!==t?t:null,retry:()=>e()});return}let l=await n.json().catch(()=>null),s=null==l?void 0:l.message;O("string"==typeof s?s:"清除失败,请稍后重试");return}O("已清除 ".concat(U.length," 条,所有设备会同步删除")),_(new Set),await D()}finally{z(!1),T(null)}},[P,U,x,y,D,h,null==c?void 0:c.hmUserId]);return(0,l.jsxs)("div",{className:"flex h-full flex-col bg-white",children:[(0,l.jsxs)("div",{className:"border-b border-gray-200 px-6 py-4",children:[(0,l.jsx)("h1",{className:"text-lg font-semibold text-gray-900",children:"数据管理"}),(0,l.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"查看并清理有问题的数据。彻底删除后无法恢复,所有设备同步清除。"})]}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border-b border-gray-100 px-6 py-3",children:[(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-sm text-gray-600",children:["用户编号",(0,l.jsx)("input",{type:"number",value:x,onChange:e=>m(e.target.value),className:"w-24 rounded border border-gray-300 px-2 py-1 text-sm"})]}),(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-sm text-gray-600",children:["数据类型",(0,l.jsx)(a.Z,{size:"small",style:{minWidth:140},value:y,onChange:e=>{v(e),N(1)},options:d.map(e=>({value:e.value,label:e.label}))})]}),(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-sm text-gray-600",children:["删除状态",(0,l.jsx)(a.Z,{size:"small",style:{minWidth:110},value:g,onChange:e=>{p(e),N(1)},options:[{value:"all",label:"全部"},{value:"yes",label:"已删除的"},{value:"no",label:"正常的"}]})]}),(0,l.jsx)("button",{type:"button",onClick:()=>void D(),disabled:S,className:"rounded-lg bg-blue-600 px-4 py-1 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:S?"加载中…":"查询"}),C.size>0&&(0,l.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[(0,l.jsxs)("span",{className:"text-gray-500",children:["已选 ",C.size," 条"]}),(0,l.jsx)("button",{type:"button",onClick:()=>T(Array.from(C)),className:"rounded-lg bg-red-600 px-3 py-1 text-white hover:bg-red-700",children:"彻底删除"})]}),A&&(0,l.jsx)("span",{className:"text-xs text-green-600",children:A}),k&&(0,l.jsx)("span",{className:"text-xs text-red-500",children:k})]}),(0,l.jsxs)("div",{className:"flex-1 overflow-auto px-6 py-3",children:[k&&!j?(0,l.jsx)("div",{className:"py-12 text-center text-sm text-gray-400",children:k}):(0,l.jsxs)("table",{className:"w-full text-sm",children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{className:"border-b border-gray-100 text-left text-xs text-gray-400",children:[(0,l.jsx)("th",{className:"w-8 py-2",children:(0,l.jsx)("input",{type:"checkbox",className:"accent-blue-600",checked:!!(null==j?void 0:j.items.length)&&C.size===j.items.length,onChange:()=>{var e;return _(C.size===(null==j?void 0:j.items.length)?new Set:new Set(null!==(e=null==j?void 0:j.items.map(e=>e.entityRef))&&void 0!==e?e:[]))}})}),(0,l.jsx)("th",{className:"py-2",children:"编号"}),(0,l.jsx)("th",{className:"py-2",children:"数据类型"}),(0,l.jsx)("th",{className:"py-2",children:"状态"}),(0,l.jsx)("th",{className:"py-2",children:"更新时间"})]})}),(0,l.jsx)("tbody",{className:"divide-y divide-gray-50",children:(null!==(t=null==j?void 0:j.items)&&void 0!==t?t:[]).map(e=>{var t,n;let s=1===e.deleted,a=!s&&null!=e.softDeleted;return(0,l.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,l.jsx)("td",{className:"py-2",children:(0,l.jsx)("input",{type:"checkbox",className:"accent-blue-600",checked:C.has(e.entityRef),onChange:()=>J(e.entityRef)})}),(0,l.jsx)("td",{className:"py-2 font-mono text-xs text-gray-700",children:e.entityRef}),(0,l.jsx)("td",{className:"py-2 text-gray-600",children:null!==(n=null===(t=d.find(t=>t.value===e.entity))||void 0===t?void 0:t.label)&&void 0!==n?n:e.entity}),(0,l.jsx)("td",{className:"py-2",children:s?(0,l.jsx)("span",{className:"rounded bg-red-100 px-1.5 py-0.5 text-[10px] text-red-600",children:"已清除"}):a?(0,l.jsx)("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500",children:"已删除"}):(0,l.jsx)("span",{className:"rounded bg-green-100 px-1.5 py-0.5 text-[10px] text-green-600",children:"正常"})}),(0,l.jsx)("td",{className:"py-2 text-xs text-gray-400",children:(0,o.d3)(e.updatedAt)})]},e.entityRef)})})]}),j&&!j.items.length&&!k&&(0,l.jsx)("div",{className:"py-12 text-center text-sm text-gray-400",children:"没有符合条件的数据"})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-2 text-sm text-gray-500",children:[(0,l.jsxs)("span",{children:["共 ",null!==(n=null==j?void 0:j.total)&&void 0!==n?n:0," 条"]}),(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[(0,l.jsx)("button",{type:"button",disabled:b<=1,onClick:()=>N(e=>e-1),className:"rounded border border-gray-300 px-3 py-1 hover:bg-gray-50 disabled:opacity-40",children:"上一页"}),(0,l.jsxs)("span",{children:[b," / ",M]}),(0,l.jsx)("button",{type:"button",disabled:b>=M,onClick:()=>N(e=>e+1),className:"rounded border border-gray-300 px-3 py-1 hover:bg-gray-50 disabled:opacity-40",children:"下一页"})]})]}),U&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:(0,l.jsxs)("div",{className:"w-96 rounded-xl bg-white p-6 shadow-xl",children:[(0,l.jsx)("h3",{className:"text-base font-semibold text-gray-900",children:"彻底删除确认"}),(0,l.jsxs)("p",{className:"mt-3 text-sm text-gray-600",children:["选中的 ",U.length," 条数据会被永久清除,无法恢复,所有设备同步删除。确定继续吗?"]}),(0,l.jsxs)("div",{className:"mt-6 flex justify-end gap-2",children:[(0,l.jsx)("button",{type:"button",disabled:R,onClick:()=>T(null),className:"rounded-lg px-4 py-1.5 text-sm text-gray-600 hover:bg-gray-100",children:"取消"}),(0,l.jsx)("button",{type:"button",disabled:R,onClick:()=>void X(),className:"rounded-lg bg-red-600 px-4 py-1.5 text-sm text-white hover:bg-red-700 disabled:opacity-50",children:R?"处理中…":"确定删除"})]})]})})]})}},65777:function(e,t,n){"use strict";let l;n.d(t,{Cd:function(){return U},Xc:function(){return R},aG:function(){return C},cp:function(){return _},nu:function(){return E},tQ:function(){return T}});var s=n(60635),a=n(74431),r=n(67002),i=n(33447),u=n(21260),o=n(28431),d=n(60529);let c=null,h=null,f=null,x=new Set;function m(){x.forEach(e=>e())}function y(e){c=c?{...c,refreshing:e}:{...S,refreshing:e},m()}function v(e){if(void 0===l){l=e;return}if(e!==l){l=e;try{window.localStorage.removeItem("hm-view-mode")}catch(e){}}}async function g(){try{return await (0,a.requestJson)("/auth/session")}catch(e){return null}}async function p(e){let t=new Headers,n=(0,r.Xc)();n&&t.set("Authorization","UTOKEN ".concat(n));try{return await (0,a.requestJson)(e,{headers:t})}catch(e){return null}}async function b(){y(!0);try{var e,t,n,l,s,r,i,d,h;let f=(0,u.xq)();if(!f){(0,o.nZ)(),c={...S,session:{loggedIn:!1},refreshing:!1,authStatus:"out"},m();return}let x=await (0,a.requestJson)("/hunter-mate/sync/state?heads=0");(0,o.YZ)(null!==(e=x.activeTenantId)&&void 0!==e?e:null);let y=(0,u.OG)(f);v(null!==(n=null!==(t=x.hmUserId)&&void 0!==t?t:y.hmUserId)&&void 0!==n?n:null),c={session:{loggedIn:!0,email:null!==(l=y.email)&&void 0!==l?l:void 0,hmUserId:null!==(r=null!==(s=x.hmUserId)&&void 0!==s?s:y.hmUserId)&&void 0!==r?r:void 0,token:f},sync:{loggedIn:!0,enabled:!0,activeTenantId:(0,o.MA)(),serverSuggestedTenantId:null!==(i=x.activeTenantId)&&void 0!==i?i:null,memberships:null!==(d=x.memberships)&&void 0!==d?d:[],pendingCounts:null!==(h=x.pendingCounts)&&void 0!==h?h:[]},utoken:f,loadError:null,refreshing:!1,authStatus:"in",refresh:j},m()}catch(e){c=c?{...c,loadError:"云端无响应"}:{...S,loadError:"云端无响应"},m()}finally{(null==c?void 0:c.refreshing)&&y(!1)}}async function N(){if((0,i.K5)())return b();y(!0);try{var e;let[t,n]=await Promise.all([g(),p("/datasync/state")]),l=(null==t?void 0:t.loggedIn)&&t.token?t.token:null,s=null!=n?n:null;!s&&t&&l&&l!==(0,r.Xc)()?((0,r.GK)(l),s=await p("/datasync/state")):(0,r.GK)(l),v((null==t?void 0:t.loggedIn)&&null!==(e=t.hmUserId)&&void 0!==e?e:null);let a=!!((null==t?void 0:t.loggedIn)||(null==s?void 0:s.loggedIn));if(!t&&!s){c=c?{...c,loadError:"本地服务无响应"}:{...S,loadError:"本地服务无响应"},m();return}c={session:null!=t?t:{loggedIn:!1},sync:s,utoken:(0,r.Xc)(),loadError:null,refreshing:!1,authStatus:a?"in":"out",refresh:j},m()}finally{(null==c?void 0:c.refreshing)&&y(!1)}}function j(){return h||(h=N().finally(()=>{h=null}))}function w(e){return x.add(e),1===x.size&&(j(),f=setInterval(()=>void j(),6e4)),()=>{x.delete(e),0===x.size&&f&&(clearInterval(f),f=null)}}let S={session:null,sync:null,utoken:null,loadError:null,refreshing:!1,authStatus:"loading",refresh:j};function I(){return null!=c?c:S}function k(){return I()}function E(){return(0,s.useSyncExternalStore)(w,I,k)}function C(e){var t;return(null!==(t=null==e?void 0:e.memberships)&&void 0!==t?t:[]).filter(e=>!e.isPersonal&&!e.leftAt)}function _(e){var t,n;let l=null!==(t=null==e?void 0:e.activeTenantId)&&void 0!==t?t:null;if(null==l)return null;let s=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===l&&!e.leftAt);return!s||s.isPersonal?null:l}function U(e,t){var n,l;if(!t)return null;let s=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===t&&!e.leftAt&&!e.isPersonal);return null!==(l=null==s?void 0:s.role)&&void 0!==l?l:null}function T(){return d.env.NEXT_PUBLIC_HUNTER_MATE_SERVER_URL||""}function R(){return(0,r.Xc)()}},4025:function(e,t,n){"use strict";n.d(t,{k:function(){return o}});var l=n(33447),s=n(21260),a=n(28431),r=n(26416),i=n(67002),u=n(60529);async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Headers(t.headers);if(n.has("Content-Type")||n.set("Content-Type","application/json"),(0,l.K5)()){var o,d;let i=(0,s.xq)();i&&n.set("Authorization","HMJWT ".concat(i));let u=(0,a.MA)();null!==u&&n.set("x-hm-active-tenant",String(u));let c=(0,r._)(null!==(o=t.method)&&void 0!==o?o:"GET",e);if(null===c)throw new r.e(null!==(d=t.method)&&void 0!==d?d:"GET",e);return fetch("".concat((0,l.XJ)()).concat(c.path),{...t,headers:n,cache:"no-store"})}let c=(0,i.Xc)();return c&&n.set("Authorization","UTOKEN ".concat(c)),fetch("".concat(u.env.HUNTER_MATE_SERVER_URL||"").concat(e),{...t,headers:n})}},82182:function(e,t,n){"use strict";n.d(t,{H7:function(){return d},jr:function(){return r},mn:function(){return o},nk:function(){return u},qd:function(){return i}});let l=null,s=new Set;function a(){s.forEach(e=>e())}function r(e){l=e,a()}function i(){l&&(l=null,a())}function u(){return l}function o(e){return s.add(e),()=>s.delete(e)}function d(e){if(!e)return null;try{var t,n,l,s,a;let r=e.split(".")[1],i=JSON.parse(decodeURIComponent(escape(atob(r.replace(/-/g,"+").replace(/_/g,"/"))))),u=null!==(a=null!==(s=null!==(l=null==i?void 0:null===(t=i.data)||void 0===t?void 0:t._id)&&void 0!==l?l:null==i?void 0:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==s?s:null==i?void 0:i.sub)&&void 0!==a?a:null;return"number"==typeof u?u:null}catch(e){return null}}},8448:function(e,t,n){"use strict";function l(e){return e?("string"==typeof e?new Date(e):e).toLocaleString("zh-CN",{hour12:!1}):""}n.d(t,{d3:function(){return l}})}},function(e){e.O(0,[502,606,431,400,935,744],function(){return e(e.s=87126)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1a8d197a-72cf-41b8-b3c5-b123c0dd9355",e._sentryDebugIdIdentifier="sentry-dbid-1a8d197a-72cf-41b8-b3c5-b123c0dd9355")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[109],{74843:function(e,t,s){Promise.resolve().then(s.bind(s,5311))},5311:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return et}});var l=s(72835),a=s(59659),n=s(60635),r=s(27473),i=s(74431),d=s(33447),o=s(8448),c=s(94518),u=s(63718),m=s(86777),x=s(27828),h=s(26119),p=s(93464),b=s(65777),g=s(12789),y=s(58574),v=s(38119),j=s(27485),f=s(6443),N=s(33365),w=s(78606),k=s(59998),S=s(31595),C=s(74435),I=s(67002),O=s(21717);let z=[{hours:24,label:"1 天"},{hours:72,label:"3 天"},{hours:168,label:"7 天"},{hours:720,label:"30 天"}];function T(e){var t;let s,{jobCaseId:a,onClose:r}=e,[d,o]=(0,n.useState)(null),[c,u]=(0,n.useState)("tenant"),[m,x]=(0,n.useState)(new Set),[h,p]=(0,n.useState)(168),[b,g]=(0,n.useState)(""),[y,v]=(0,n.useState)(!1),[j,f]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),[S,C]=(0,n.useState)(!1);async function O(){v(!0),f(null);try{let e=await (0,i.requestJson)("/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jobCaseId:a,scope:"users"===c?{type:"users",hmUserIds:Array.from(m)}:{type:"tenant"},ttlHours:h,note:b.trim()||void 0})});if(!(null==e?void 0:e.token)){f("创建失败:未登录云端账号 / 云服务不可达 / 该职位未同步上云");return}k(e)}catch(e){f("创建失败:未登录云端账号 / 云服务不可达 / 该职位未同步上云")}finally{v(!1)}}(0,n.useEffect)(()=>{let e=()=>{(async()=>{try{let e=await (0,i.requestJson)("/team/members");o(Array.isArray(e.items)?e.items:[])}catch(e){o([])}})()};return e(),(0,I.Lc)(e)},[]);let T=N?(t=N.urlPath,"".concat(window.location.origin).concat(t)):null;return s=null===d?(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"加载同事目录…(未登录云端账号时为空)"}):d.length?d.map(e=>(0,l.jsxs)("label",{className:"flex items-center gap-2 py-1 text-sm",children:[(0,l.jsx)("input",{type:"checkbox",checked:m.has(e.hmUserId),onChange:t=>{let s=new Set(m);t.target.checked?s.add(e.hmUserId):s.delete(e.hmUserId),x(s)}}),(0,l.jsx)("span",{children:e.name}),(0,l.jsx)("span",{className:"text-xs text-gray-400",children:e.email})]},e.hmUserId)):(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"暂无公司租户同事"}),(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:r,children:(0,l.jsxs)("div",{className:"w-[520px] max-w-[92vw] rounded-lg bg-white p-5 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,l.jsxs)("h3",{className:"text-base font-semibold",children:["分享职位推荐(职位 #",a,")"]}),(0,l.jsx)("button",{onClick:r,className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),N?(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"mb-2 rounded bg-emerald-50 px-3 py-2 text-sm text-emerald-800",children:["分享已创建,有效期至 ",new Date(N.expiresAt).toLocaleString()]}),(0,l.jsx)("div",{className:"mb-1 text-xs text-gray-500",children:"把链接发给同事(对方在自己本地 hm 打开):"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("input",{readOnly:!0,value:null!=T?T:"",className:"flex-1 rounded border border-gray-300 px-2 py-1.5 font-mono text-xs",onFocus:e=>e.target.select()}),(0,l.jsx)("button",{onClick:()=>{T&&navigator.clipboard.writeText(T).then(()=>{C(!0),setTimeout(()=>C(!1),2500)})},className:"rounded bg-blue-600 px-3 py-1.5 text-xs text-white hover:bg-blue-700",children:S?"已复制 ✓":"复制"})]}),(0,l.jsx)("div",{className:"mt-4 text-right",children:(0,l.jsx)("button",{onClick:r,className:"rounded border border-gray-300 px-4 py-1.5 text-sm hover:bg-gray-50",children:"完成"})})]}):(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-1 text-xs font-medium text-gray-600",children:"分享范围"}),(0,l.jsxs)("label",{className:"mr-4 text-sm",children:[(0,l.jsx)("input",{type:"radio",checked:"tenant"===c,onChange:()=>u("tenant")})," 租户内所有同事"]}),(0,l.jsxs)("label",{className:"text-sm",children:[(0,l.jsx)("input",{type:"radio",checked:"users"===c,onChange:()=>u("users")})," 指定同事"]}),"users"===c?(0,l.jsx)("div",{className:"mt-2 max-h-36 overflow-auto rounded border border-gray-200 p-2",children:s}):null]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-1 text-xs font-medium text-gray-600",children:"有效期"}),(0,l.jsx)(w.Z,{size:"small",style:{minWidth:130},value:h,onChange:e=>p(e),options:z.map(e=>({value:e.hours,label:e.label}))})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-1 text-xs font-medium text-gray-600",children:"备注(可选,给查看者的说明)"}),(0,l.jsx)("input",{value:b,onChange:e=>g(e.target.value),maxLength:200,placeholder:"例如:这 10 位是本周重点推荐,请 op 优先跟进",className:"w-full rounded border border-gray-300 px-2 py-1.5 text-sm"})]}),j?(0,l.jsx)("div",{className:"text-xs text-red-600",children:j}):null,(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)("button",{onClick:r,className:"rounded border border-gray-300 px-4 py-1.5 text-sm hover:bg-gray-50",children:"取消"}),(0,l.jsx)("button",{onClick:()=>void O(),disabled:y||"users"===c&&!m.size,className:"rounded bg-blue-600 px-4 py-1.5 text-sm text-white hover:bg-blue-700 disabled:opacity-40",children:y?"创建中…":"生成分享链接"})]})]})]})})}let P=null;function J(e,t,s){return(0,i.requestJson)(e,{method:t,headers:{"Content-Type":"application/json"},body:null!=s?JSON.stringify(s):void 0})}let U={create:"建档",move:"阶段迁移",form:"保存表单",invite:"记录邀请",invite_approved:"批准邀请",note:"备注",delete:"移出流程"};function Z(e){return(0,l.jsx)(y.Z,{children:(0,l.jsx)(q,{...e})})}function q(e){var t,s,a,r,c;let{jobCaseId:u,canOperate:m=!0}=e,h=encodeURIComponent(String(u)),p=Number(String(u).split(":").pop()),{message:b}=y.Z.useApp(),[g,z]=(0,n.useState)(P),[Z,q]=(0,n.useState)("recommended"),[E,A]=(0,n.useState)([]),[R,D]=(0,n.useState)({}),[L,_]=(0,n.useState)(null),[F,M]=(0,n.useState)({}),[B,K]=(0,n.useState)(!1),[W,H]=(0,n.useState)(new Set),[Y,X]=(0,n.useState)(new Set),[G,Q]=(0,n.useState)(null),[V,$]=(0,n.useState)(!1),[ee,et]=(0,n.useState)([]),[es,el]=(0,n.useState)(String(u)),[ea,en]=(0,n.useState)(""),[er,ei]=(0,n.useState)(!1),[ed,eo]=(0,n.useState)(null),[ec,eu]=function(){let[e,t]=(0,n.useState)(null);return[e,(0,n.useCallback)((e,s)=>{navigator.clipboard.writeText(s).then(()=>{t(e),setTimeout(()=>t(t=>t===e?null:t),2500)})},[])]}(),[em,ex]=(0,n.useState)(!1),[eh]=v.Z.useForm(),[ep,eb]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(P)return;let e=!0,t=()=>{P||(0,i.requestJson)("/recommendations/meta").then(t=>{t&&e&&(P=t,z(t))}).catch(()=>{})};t();let s=(0,I.Lc)(t);return()=>{e=!1,s()}},[g]);let eg=(0,n.useMemo)(()=>{var e;return null!==(e=null==g?void 0:g.stages.map(e=>e.key))&&void 0!==e?e:[]},[g]),ey=(0,n.useCallback)(async()=>{K(!0);try{var e;let t=await (0,i.requestJson)("/job-cases/".concat(h,"/recommendations"));A(t.items),D(null!==(e=t.counts)&&void 0!==e?e:{}),H(new Set)}catch(e){b.error("列表刷新失败,请手动刷新页面")}finally{K(!1)}},[u,b]);(0,n.useEffect)(()=>{q("recommended"),Q(null),_(null),ey()},[ey]),(0,n.useEffect)(()=>{"matched"===Z&&null===L&&(async()=>{var e,t;let[s,l]=await Promise.all([(0,i.requestJson)("/matching/jobs/".concat(p,"/talents")).catch(()=>[]),(0,i.requestJson)("/talent-portraits").catch(()=>[])]);_(s);let a={};for(let s of l)a[s.id]=null!==(t=null===(e=s.identity)||void 0===e?void 0:e.displayName)&&void 0!==t?t:"(未命名)";M(a)})()},[Z,L,u]);let ev=(0,n.useCallback)(async(e,t)=>{try{let s=await t();(null==s?void 0:s.prompt)&&eu(e,s.prompt)}catch(e){}},[eu]),ej=(e,t,s)=>{let l=new Set(e);l.has(t)?l.delete(t):l.add(t),s(l)},ef=e=>{var t;return e&&g?null!==(t=g.stageLabels[e])&&void 0!==t?t:e:""},eN=async()=>{var e;if(!ea||!g)return;let t=null!==(e=g.formTemplates[ea])&&void 0!==e?e:[],s={};if(t.length)try{s=await eh.validateFields()}catch(e){return}let l={};for(let e of t){let t="string"==typeof s[e.key]?s[e.key].trim():s[e.key];null!=t&&""!==t&&(l[e.key]=t)}let a=W.size;ei(!0),eo(null);try{await J("/recommendations/batch-move","POST",{ids:Array.from(W),stage:ea,jobRef:es,formData:Object.keys(l).length?l:void 0})}catch(e){ei(!1),b.error("移动失败,请重试");return}ei(!1),$(!1),eh.resetFields(),b.success("已移动 ".concat(a," 人到「").concat(ef(ea),"」")),await ey()},ew=async()=>{ei(!0),eo(null);let e=Array.from(Y),t=(await Promise.all(e.map(e=>J("/recommendations/adopt","POST",{matchId:e}).then(()=>!0,()=>!1)))).filter(e=>!e).length;ei(!1),X(new Set),await ey(),t&&b.warning("".concat(t," 个采纳失败,请重试"))},ek=async()=>{el(String(u)),en(""),eh.resetFields(),$(!0);try{var e;let t=await (0,i.requestJson)("/job-cases?limit=200");et((null!==(e=t.items)&&void 0!==e?e:[]).map(e=>{var t,s;return{...e,caseKey:null!==(s=e.caseKey)&&void 0!==s?s:null!==(t=e.ref)&&void 0!==t?t:Number.isInteger(e.id)?String(e.id):void 0}}))}catch(e){}};if(!g)return(0,l.jsx)("div",{className:"p-4 text-sm text-gray-400",children:"加载推荐流水线定义…"});let eS=[...g.stages.map(e=>{var t;return{key:e.key,label:"".concat(e.label,"(").concat(null!==(t=R[e.key])&&void 0!==t?t:0,")")}})];eS.splice(1,0,{key:"matched",label:"匹配人才(".concat(null!==(s=null==L?void 0:L.length)&&void 0!==s?s:"…",")")});let eC="matched"===Z?[]:E.filter(e=>e.stage===Z),eI=ea&&null!==(a=g.formTemplates[ea])&&void 0!==a?a:[];return(0,l.jsxs)("div",{children:[(0,l.jsx)(j.Z,{size:"small",activeKey:Z,onChange:e=>{q(e),Q(null)},items:eS.map(e=>({key:e.key,label:e.label}))}),m?(0,l.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:["recommended"!==Z||(0,d.K5)()?null:(0,l.jsx)(f.ZP,{size:"small",color:"gold",variant:"solid",onClick:()=>void ev("recommend",()=>(0,i.requestJson)("/job-cases/".concat(p,"/recommend-prompt"))),children:"recommend"===ec?"已复制 ✓ 请发给 agent":"再推荐(复制 prompt)"}),"matched"===Z?(0,l.jsxs)(l.Fragment,{children:[(0,d.K5)()?null:(0,l.jsx)(f.ZP,{size:"small",color:"gold",variant:"solid",onClick:()=>void ev("match",()=>(0,i.requestJson)("/job-cases/".concat(p,"/match-prompt"))),children:"match"===ec?"已复制 ✓ 请发给 agent":"打分分析推荐(复制 prompt)"}),(0,l.jsxs)(f.ZP,{size:"small",color:"green",variant:"solid",disabled:!Y.size||er,onClick:()=>void ew(),children:["采纳为推荐(",Y.size,")"]})]}):null,"pending_invite"===Z&&W.size&&!(0,d.K5)()?(0,l.jsx)(f.ZP,{size:"small",color:"blue",variant:"solid",onClick:()=>void ev("invite",()=>J("/recommendations/invite-prompt","POST",{ids:Array.from(W)})),children:"invite"===ec?"已复制 ✓ 请发给 agent":"发送邀请(".concat(W.size,")")}):null,"invited"===Z&&W.size&&!(0,d.K5)()?(0,l.jsx)(f.ZP,{size:"small",color:"blue",variant:"solid",onClick:()=>void ev("reply",()=>J("/recommendations/reply-check-prompt","POST",{ids:Array.from(W)})),children:"reply"===ec?"已复制 ✓ 请发给 agent":"检查回复(".concat(W.size,")")}):null,"matched"!==Z&&W.size?(0,l.jsxs)(f.ZP,{size:"small",onClick:()=>void ek(),children:["移动到…(",W.size,")"]}):null,W.size||Y.size?(0,l.jsx)(f.ZP,{size:"small",type:"text",onClick:()=>{H(new Set),X(new Set)},children:"清除选择"}):null,(0,l.jsx)(f.ZP,{size:"small",color:"purple",variant:"solid",className:"ml-auto",onClick:()=>ex(!0),children:"分享给同事"})]}):(0,l.jsx)("div",{className:"mb-3 rounded border border-amber-100 bg-amber-50 px-2 py-1 text-xs text-amber-600",children:"仅该职位的 op/rs 可操作推荐流程,你可查看"}),em?(0,l.jsx)(T,{jobCaseId:p,onClose:()=>ex(!1)}):null,ed?(0,l.jsx)("div",{className:"mb-2 text-xs text-red-500",children:ed}):null,B?(0,l.jsx)("div",{className:"py-8 text-center text-sm text-gray-400",children:"加载中…"}):"matched"===Z?(0,l.jsx)(function(e){return null===e.matches?(0,l.jsx)("div",{className:"py-8 text-center text-sm text-gray-400",children:"计算匹配中…"}):e.matches.length?(0,l.jsx)("div",{className:"space-y-2",children:e.matches.map(t=>{var s,a,n,r,i,d;return(0,l.jsxs)("div",{className:"rounded border border-gray-200 bg-white p-2",children:[(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[e.canOperate?(0,l.jsx)(S.Z,{checked:e.selected.has(t.id),onChange:()=>e.onToggle(t.id),className:"mt-1"}):null,(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium text-gray-900",children:null!==(r=e.names[t.portraitId])&&void 0!==r?r:t.portraitId}),(0,l.jsxs)("span",{className:"rounded bg-emerald-100 px-1.5 py-0.5 text-xs text-emerald-700",children:[null!==(i=null===(s=t.scores)||void 0===s?void 0:s.overall)&&void 0!==i?i:"?","分"]}),t.humanFeedback?(0,l.jsx)("span",{className:"rounded bg-purple-100 px-1.5 py-0.5 text-xs text-purple-700",children:t.humanFeedback.isRecommended?"已采纳":"已排除"}):null]}),(0,l.jsx)("button",{onClick:()=>e.onExpand(t.id),className:"mt-0.5 text-xs text-blue-500 hover:underline",children:e.expanded===t.id?"收起":"AI 推荐理由"})]})]}),e.expanded===t.id?(0,l.jsxs)("div",{className:"mt-2 border-t border-gray-100 pt-2 text-xs text-gray-600",children:[null!==(d=null===(a=t.recommendation)||void 0===a?void 0:a.aiReason)&&void 0!==d?d:"(无推荐理由)",(null===(n=t.humanFeedback)||void 0===n?void 0:n.reason)?(0,l.jsxs)("div",{className:"mt-1 text-purple-600",children:["人工反馈:",t.humanFeedback.reason]}):null]}):null]},t.id)})}):(0,l.jsx)("div",{className:"py-8 text-center text-sm text-gray-400",children:"暂无人岗匹配数据"})},{matches:L,names:F,selected:Y,onToggle:e=>ej(Y,e,X),expanded:G,onExpand:e=>Q(G===e?null:e),canOperate:m}):0===eC.length?(0,l.jsxs)("div",{className:"py-8 text-center text-sm text-gray-400",children:["本阶段暂无人选","recommended"===Z?",点上方「再推荐」让 agent 寻访":"","pending_invite"===Z?",可在人才详情「加入推荐流程」":""]}):(0,l.jsx)("div",{className:"space-y-2",children:eC.map(e=>(0,l.jsx)(eO,{row:e,meta:g,checked:W.has(e.id),onToggle:()=>ej(W,e.id,H),expanded:G===e.id,onExpand:()=>Q(G===e.id?null:e.id),onChanged:ey,canOperate:m,stageLabelOf:ef,onOpenDrawer:()=>eb(e)},e.id))}),(0,l.jsx)(O.I,{entityId:null!==(r=null==ep?void 0:ep.entityId)&&void 0!==r?r:null,name:null!==(c=null==ep?void 0:null===(t=ep.snapshot)||void 0===t?void 0:t.name)&&void 0!==c?c:"(未命名)",open:null!==ep,onClose:()=>eb(null)}),(0,l.jsx)(N.Z,{title:"批量移动(".concat(W.size," 人)"),open:V,onCancel:()=>$(!1),onOk:()=>void eN(),okText:er?"移动中…":"确认移动",cancelText:"取消",confirmLoading:er,okButtonProps:{disabled:!ea},destroyOnHidden:!0,width:480,children:(0,l.jsxs)(v.Z,{form:eh,layout:"vertical",preserve:!1,children:[(0,l.jsx)(v.Z.Item,{label:"目标职位",className:"mb-3",children:(0,l.jsx)(w.Z,{size:"small",value:es,onChange:e=>{el(e),en("")},options:(()=>{let e=ee.filter(e=>null!=e.caseKey).map(e=>({value:e.caseKey,label:e.title||e.externalId}));return ee.find(e=>e.caseKey===String(u))||e.unshift({value:String(u),label:"当前职位"}),e})()})}),(0,l.jsx)(v.Z.Item,{label:"目标阶段(当前职位的当前阶段不可选)",className:"mb-3",children:(0,l.jsx)(w.Z,{size:"small",placeholder:"选择阶段…",value:ea||void 0,onChange:e=>en(e),options:eg.filter(e=>!(es===String(u)&&e===Z)).map(e=>({value:e,label:ef(e)}))})}),ea?eI.length?(0,l.jsxs)("div",{className:"rounded border border-gray-100 bg-gray-50 p-3",children:[(0,l.jsxs)("div",{className:"mb-2 text-xs font-medium text-gray-600",children:["阶段表单\xb7",ef(ea),"(将写入全部 ",W.size," 人)"]}),eI.map(e=>(0,l.jsx)(v.Z.Item,{name:e.key,label:e.label,className:"mb-2",rules:e.required?[{required:!0,message:"请填写".concat(e.label)}]:void 0,children:(0,l.jsx)(k.Z.TextArea,{rows:2,size:"small",placeholder:e.required?"必填":"选填"})},e.key))]}):(0,l.jsx)("div",{className:"rounded border border-gray-100 bg-gray-50 px-3 py-2 text-xs text-gray-400",children:"该阶段无需填写表单信息"}):null]},ea||"no-stage")})]});function eO(e){var t,s,a,r,i,d,c,u,m,h,p,b,g,y,v,j,N,w;let I=e.row,O=null!==(m=e.meta.formTemplates[I.stage])&&void 0!==m?m:[],[z,T]=(0,n.useState)(!1),[P,Z]=(0,n.useState)({}),q=async()=>{var t;let s={},l=null!==(t=I.formData)&&void 0!==t?t:{};for(let[e,t]of Object.entries(P)){let a="string"==typeof t?t.trim():t;""===a||void 0===a?e in l&&(s[e]=null):l[e]!==a&&(s[e]=a)}for(let e of Object.keys(l))e in P||(s[e]=null);try{await J("/recommendations/".concat(I.id),"PATCH",Object.keys(s).length?{formData:s}:{})}catch(e){eo("保存表单失败,请重试");return}T(!1),await e.onChanged()},E=async()=>{try{await J("/recommendations/".concat(I.id),"DELETE")}catch(e){eo("移出流程失败,请重试");return}await e.onChanged()};return(0,l.jsxs)("div",{className:"rounded border border-gray-200 bg-white p-2",children:[(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[e.canOperate?(0,l.jsx)(S.Z,{checked:e.checked,onChange:e.onToggle,className:"mt-1"}):null,(0,l.jsx)("button",{className:"min-w-0 flex-1 text-left",onClick:e.onExpand,children:(0,l.jsx)(x.h5,{name:null!==(h=null===(t=I.snapshot)||void 0===t?void 0:t.name)&&void 0!==h?h:"(未命名)",headline:null===(s=I.snapshot)||void 0===s?void 0:s.headline,aiReason:null!==(p=null===(a=I.scores)||void 0===a?void 0:a.aiReason)&&void 0!==p?p:null,overall:null!==(b=null===(i=I.scores)||void 0===i?void 0:null===(r=i.dimensions)||void 0===r?void 0:r.overall)&&void 0!==b?b:null,invitationChannel:null!==(g=null===(d=I.invitation)||void 0===d?void 0:d.channel)&&void 0!==g?g:null,stageLabel:e.stageLabelOf(I.stage),updatedAt:I.updatedAt,onNameClick:I.entityId?e.onOpenDrawer:void 0})}),e.canOperate?(0,l.jsx)(C.Z,{title:"把 ".concat(null!==(y=null===(c=I.snapshot)||void 0===c?void 0:c.name)&&void 0!==y?y:"(未命名)"," 移出推荐流程?"),description:"删除后不可恢复",okText:"确认移出",okButtonProps:{danger:!0},cancelText:"取消",onConfirm:()=>void E(),children:(0,l.jsx)("button",{className:"mt-1 text-xs text-gray-300 hover:text-red-500",title:"移出流程",children:"\xd7"})}):null]}),e.expanded?(0,l.jsxs)("div",{className:"mt-2 space-y-3 border-t border-gray-100 pt-2",children:[(0,l.jsxs)("section",{children:[(0,l.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,l.jsxs)("h4",{className:"text-xs font-medium text-gray-700",children:[e.stageLabelOf(I.stage),"\xb7阶段表单"]}),z?(0,l.jsxs)("span",{className:"flex gap-2",children:[(0,l.jsx)(f.ZP,{size:"small",type:"primary",onClick:()=>void q(),children:"保存"}),(0,l.jsx)(f.ZP,{size:"small",onClick:()=>T(!1),children:"取消"})]}):e.canOperate?(0,l.jsx)(f.ZP,{size:"small",type:"link",onClick:()=>{var e;let t={...null!==(e=I.formData)&&void 0!==e?e:{}};for(let e of O)e.key in t||(t[e.key]="");Z(t),T(!0)},children:"编辑表单"}):null]}),z?(0,l.jsxs)("div",{className:"space-y-1.5",children:[Object.entries(P).map(e=>{var t,s;let[a,n]=e,r=null!==(s=null===(t=O.find(e=>e.key===a))||void 0===t?void 0:t.label)&&void 0!==s?s:a;return(0,l.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,l.jsx)("span",{className:"w-40 shrink-0 truncate text-gray-500",title:r,children:r}),(0,l.jsx)(k.Z,{size:"small",value:String(null!=n?n:""),onChange:e=>Z({...P,[a]:e.target.value}),className:"min-w-0 flex-1"}),(0,l.jsx)("button",{onClick:()=>{let e={...P};delete e[a],Z(e)},className:"text-gray-300 hover:text-red-500",children:"\xd7"})]},a)}),(0,l.jsx)(ez,{onAdd:(e,t)=>Z({...P,[e]:t}),existing:Object.keys(P)})]}):(0,l.jsxs)("dl",{className:"space-y-1 text-xs",children:[Object.entries(null!==(v=I.formData)&&void 0!==v?v:{}).length?Object.entries(null!==(j=I.formData)&&void 0!==j?j:{}).map(e=>{var t,s;let[a,n]=e;return(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("dt",{className:"w-40 shrink-0 truncate text-gray-500",children:null!==(s=null===(t=O.find(e=>e.key===a))||void 0===t?void 0:t.label)&&void 0!==s?s:a}),(0,l.jsx)("dd",{className:"min-w-0 flex-1 whitespace-pre-wrap text-gray-800",children:String(n)})]},a)}):(0,l.jsx)("div",{className:"text-gray-400",children:"(表单为空)"}),(null===(u=I.invitation)||void 0===u?void 0:u.sentAt)?(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("dt",{className:"w-40 shrink-0 text-gray-500",children:"邀请发送时间"}),(0,l.jsx)("dd",{className:"text-gray-800",children:(0,o.d3)(I.invitation.sentAt)})]}):null]})]}),(0,l.jsxs)("section",{children:[(0,l.jsx)("h4",{className:"mb-1 text-xs font-medium text-gray-700",children:"操作历史"}),(0,l.jsxs)("ol",{className:"space-y-1 text-xs text-gray-500",children:[[...null!==(N=I.history)&&void 0!==N?N:[]].reverse().map((t,s)=>{var a;return(0,l.jsxs)("li",{className:"flex flex-wrap gap-x-2",children:[(0,l.jsx)("span",{className:"text-gray-400",children:(0,o.d3)(t.at)}),(0,l.jsx)("span",{className:"text-gray-700",children:null!==(a=U[t.action])&&void 0!==a?a:t.action}),t.fromStage?(0,l.jsxs)("span",{children:[e.stageLabelOf(t.fromStage)," → ",e.stageLabelOf(t.toStage)]}):null,t.note?(0,l.jsxs)("span",{className:"text-gray-500",children:["\xb7 ",t.note]}):null,(0,l.jsxs)("span",{className:"text-gray-300",children:["by ",t.by]})]},s)}),(null!==(w=I.history)&&void 0!==w?w:[]).length?null:(0,l.jsx)("li",{className:"text-gray-400",children:"(暂无)"})]})]})]}):null]})}function ez(e){let{onAdd:t,existing:s}=e,[a,r]=(0,n.useState)(""),[i,d]=(0,n.useState)("");return(0,l.jsxs)("div",{className:"flex items-center gap-2 border-t border-dashed border-gray-200 pt-1.5 text-xs",children:[(0,l.jsx)(k.Z,{size:"small",value:a,onChange:e=>r(e.target.value),placeholder:"新字段名",className:"w-32"}),(0,l.jsx)(k.Z,{size:"small",value:i,onChange:e=>d(e.target.value),placeholder:"内容",className:"min-w-0 flex-1"}),(0,l.jsx)(f.ZP,{size:"small",onClick:()=>{let e=a.trim();!e||s.includes(e)||(t(e,i),r(""),d(""))},children:"加一行"})]})}}var E=s(49616);function A(e){var t;return null!==(t=e.ref)&&void 0!==t?t:String(e.id)}let R=[{key:"active",label:"启动中",cls:"bg-emerald-100 text-emerald-700"},{key:"closed",label:"结束",cls:"bg-gray-300 text-gray-700"}],D=[{key:"op",label:"我是 op",cls:"bg-blue-100 text-blue-700"},{key:"rs",label:"我是 rs",cls:"bg-cyan-100 text-cyan-700"}],L=[{key:"recommended",label:"有推荐"},{key:"invite",label:"邀约中"},{key:"replied",label:"已回复"},{key:"to_client",label:"已推客户"},{key:"interview",label:"面试"},{key:"offer",label:"offer"},{key:"onboarding",label:"入职"}],_=["liepin","linkedin","lagou","zhaopin","51job","boss"];function F(e){var t,s,l;let a;let n=(null!==(t=e.folderPath)&&void 0!==t?t:"").split("/").filter(Boolean).filter(e=>!["job","jd","raw"].includes(e));return(a=e.title)&&!["job","jd","raw"].includes(a)?e.title:null!==(l=n.at(-1))&&void 0!==l?l:"职位 ".concat(null!==(s=e.ref)&&void 0!==s?s:"#".concat(e.id))}function M(e){let t=e.requirements;if(!t)return;let s=[t.company,t.location,t.salary].map(e=>"string"==typeof e?e.trim():"").filter(Boolean);return s.length?s.join(" \xb7 "):void 0}function B(){var e,t;let s=(0,r.useRouter)(),a=(0,r.useSearchParams)(),d=a.get("id"),o=a.get("job"),m=null!=o?o:d,[g,y]=(0,n.useState)({}),[v,j]=(0,n.useState)(new Set),[f,N]=(0,n.useState)(""),[S,C]=(0,n.useState)(""),[I,O]=(0,n.useState)(null),[z,T]=(0,n.useState)(!1),[P,J]=(0,n.useState)(!1),[U,Z]=(0,n.useState)(0),{session:q,sync:E}=(0,b.nu)(),B=null!==(e=null==q?void 0:q.hmUserId)&&void 0!==e?e:null,W=null!==(t=null==E?void 0:E.activeTenantId)&&void 0!==t?t:null,H=a.get("st")||"",Y=a.get("rel")||"",X=a.get("cust")||"",G=a.get("stage")||"",Q=a.get("ch")||"",V=(0,n.useMemo)(()=>H.split(",").map(e=>e.trim()).filter(Boolean),[H]),$=(0,n.useMemo)(()=>G?G.split(",").map(e=>e.trim()).filter(Boolean):[],[G]),ee=(0,n.useMemo)(()=>Q?Q.split(",").map(e=>e.trim()).filter(Boolean):[],[Q]),et=!!(H||Y||X||G||Q),es=(0,n.useMemo)(()=>Y?Y.split(",").map(e=>e.trim()).filter(Boolean):et?[]:["op","rs"],[Y,et]),[el,ea]=(0,n.useState)(!1),[en,er]=(0,n.useState)(!1),ei=(0,n.useMemo)(()=>et||en||!el?es:[],[et,en,el,es]),[ed,eo]=(0,n.useState)({active:0,closed:0}),[ec,eu]=(0,n.useState)({}),[em,ex]=(0,n.useState)({}),[eh,ep]=(0,n.useState)({}),[eb,eg]=(0,n.useState)(!1),[ey,ev]=(0,n.useState)(""),[ej,ef]=(0,n.useState)(!1),[eN,ew]=(0,n.useState)(null),ek=(0,h.B)({deleteUrl:"/job-cases",label:"职位",onDeleted:()=>eC.refresh(),currentUserId:B}),eS=(0,n.useMemo)(()=>Array.from(ek.selectedIds),[ek.selectedIds]),eC=(0,p.k)({fetchPage:(0,n.useCallback)(async(e,t)=>{var s;let l=new URLSearchParams;l.set("q",S),l.set("limit",String(t)),l.set("offset",String(e)),V.length&&l.set("status",V.join(",")),ei.length&&l.set("relation",ei.join(",")),X&&l.set("customerId",X),G&&l.set("stage",G),Q&&l.set("channel",Q);let a=await (0,i.requestJson)("/job-cases?".concat(l.toString()));eo(null!==(s=a.statusCounts)&&void 0!==s?s:{active:0,closed:0});let n=a.items.map(e=>A(e));if(n.length){let e=n.some(e=>e.includes(":"))?"refs=".concat(encodeURIComponent(n.join(","))):"ids=".concat(n.join(","));(0,i.requestJson)("/recommendations/summary?".concat(e)).then(e=>{eu(t=>({...t,...e}))}).catch(()=>{});let t=a.items.map(e=>e.id).filter(e=>Number.isInteger(e));t.length&&(0,i.requestJson)("/job-case-postings?ids=".concat(t.join(","))).then(e=>{ex(t=>({...t,...e}))}).catch(()=>{})}return{items:a.items,total:a.total}},[S,V,ei,X,G,Q,W]),pageSize:50,deps:[S,V,ei,X,G,Q,W]});(0,n.useEffect)(()=>{et||el||en||eC.loading||eC.error||0!==eC.total||ea(!0)},[et,el,en,eC.loading,eC.error,eC.total]),(0,n.useEffect)(()=>{ea(!1),er(!1)},[W]),(0,n.useEffect)(()=>{let e=setTimeout(()=>C(f.trim()),300);return()=>clearTimeout(e)},[f]),(0,n.useEffect)(()=>{(0,i.requestJson)("/customers").then(e=>{let t={},s=new Set;for(let a of e){var l;t[a.id]=a.canonicalName,(null===(l=a.dedupKey)||void 0===l?void 0:l.startsWith("placeholder:"))&&s.add(a.id)}y(t),j(s)}).catch(()=>{y({}),j(new Set)})},[W]),(0,n.useEffect)(()=>{(0,i.requestJson)("/job-cases/tenant-members").then(e=>{var t;let s={};for(let l of null!==(t=e.items)&&void 0!==t?t:[])s[l.hmUserId]=l;ep(s)}).catch(()=>{ep({})})},[W]);let eI=(0,n.useCallback)(e=>{var t,s;return null==e?void 0:null!==(s=null===(t=eh[e])||void 0===t?void 0:t.label)&&void 0!==s?s:e===B?"我":"用户 #".concat(e)},[eh,B]);(0,n.useEffect)(()=>{ek.prune(eC.items.map(e=>String(e.id)))},[eC.items,ek]),(0,n.useEffect)(()=>{if(!m){O(null),J(!1);return}T(!0),J(!1),(0,i.requestJson)("/job-cases/".concat(encodeURIComponent(m))).then(e=>{O(e)}).catch(()=>{O(null),J(!0)}).finally(()=>{T(!1)})},[m,W,U]);let eO=(0,n.useCallback)(e=>{let t=new URLSearchParams(a.toString());e.id?e.id.includes(":")?(t.set("job",e.id),t.delete("id")):(t.set("id",e.id),t.delete("job")):null===e.id&&(t.delete("id"),t.delete("job")),void 0!==e.st&&(e.st.length?t.set("st",e.st.join(",")):t.delete("st")),void 0!==e.rel&&(e.rel.length?t.set("rel",e.rel.join(",")):t.delete("rel")),void 0!==e.cust&&(e.cust?t.set("cust",e.cust):t.delete("cust")),void 0!==e.stage&&(e.stage.length?t.set("stage",e.stage.join(",")):t.delete("stage")),void 0!==e.ch&&(e.ch.length?t.set("ch",e.ch.join(",")):t.delete("ch")),s.replace("/jobs?".concat(t.toString()))},[s,a]),ez=(0,n.useCallback)(e=>{var t;return null==B?null:e.ownerId===B?"op":(null!==(t=e.rsUserIds)&&void 0!==t?t:[]).includes(B)?"rs":null},[B]),eT=(0,n.useMemo)(()=>eC.items.map(e=>{var t,s,a,n,r,i;return{id:A(e),content:(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[Number.isInteger(e.id)?ek.checkbox(String(e.id)):null,(0,l.jsx)(x.dy,{title:null!==(s=F(e))&&void 0!==s?s:"(职位 ".concat(null!==(t=e.ref)&&void 0!==t?t:"#".concat(e.id),")"),status:e.status,hmhLocal:(null!==(a=e.folderPath)&&void 0!==a?a:"").includes("/local/clients/"),subtitle:M(e),customerName:null!==(r=e.customerName)&&void 0!==r?r:e.customerId?null!==(n=g[e.customerId])&&void 0!==n?n:"客户 #".concat(e.customerId):"未关联客户",opName:null!=e.ownerId?eI(e.ownerId):void 0,rsNames:(null!==(i=e.rsUserIds)&&void 0!==i?i:[]).map(e=>{var t;return null!==(t=eI(e))&&void 0!==t?t:"用户 #".concat(e)}),updatedAt:e.updatedAt,createdAt:e.createdAt,stages:ec[A(e)],platforms:em[e.id],myRole:ez(e)})]})}}),[eC.items,g,ek,ec,em,ez,eI]),eP=(0,n.useMemo)(()=>{let e=new Set;for(let t of Object.values(em))for(let s of t)e.add(s);for(let t of _)e.add(t);return Array.from(e)},[em]),eJ=async()=>{let e;let t=Number(ey),s=eS.map(Number).filter(e=>e!==t);if(!t||!s.length)return;ef(!0);try{e=await (0,i.requestJson)("/job-cases/merge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetId:t,sourceIds:s})})}catch(e){ef(!1),eg(!1),ew("合并失败(服务无响应),请重试");return}ef(!1),eg(!1);let l=Object.values(e.moved).reduce((e,t)=>e+t,0);ew("已合并 ".concat(e.sourceIds.length," 个职位 → #").concat(e.targetId,",迁移 ").concat(l," 条关联")+(e.matchConflicts?",匹配冲突按高分保留 ".concat(e.matchConflicts," 处"):"")),ek.clear(),eC.refresh(),setTimeout(()=>ew(null),8e3)},eU=m?z?(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"加载中…"}):P?(0,l.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-red-500",children:["加载失败",(0,l.jsx)("button",{type:"button",onClick:()=>Z(e=>e+1),className:"text-blue-500 hover:underline",children:"重试"})]}):I?(0,l.jsx)(K,{detail:I,customers:g,placeholderCusts:v,myUserId:B}):(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-red-500",children:"未找到该职位"}):(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"请在左侧选择一个职位查看详情"}),eZ=V.length>0||es.length>0||X||G||Q||el;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.m,{filterBar:(0,l.jsxs)("div",{className:"space-y-2 border-b border-gray-200 bg-white p-3",children:[(0,l.jsx)(k.Z,{allowClear:!0,size:"small",value:f,onChange:e=>N(e.target.value),placeholder:"搜索职位/客户/路径…"}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,l.jsx)("span",{className:"w-12 shrink-0 text-gray-400",children:"状态:"}),R.map(e=>{let t=V.includes(e.key);return(0,l.jsxs)("button",{type:"button",title:t?"点击取消该状态筛选":"点击按该状态过滤(可多选)",onClick:()=>eO({st:t?V.filter(t=>t!==e.key):[...V,e.key]}),className:"rounded px-1.5 py-0.5 text-xs transition ".concat(t?"".concat(e.cls," ring-1 ring-current"):"".concat(e.cls," opacity-40 hover:opacity-80")),children:[e.label," ",ed[e.key]]},e.key)}),(0,l.jsx)("span",{className:"mx-1 text-gray-300",children:"|"}),(0,l.jsx)("span",{className:"text-gray-400",children:"关系:"}),D.map(e=>{let t=es.includes(e.key);return(0,l.jsx)("button",{type:"button",title:t?"点击取消该关系筛选":"点击按该关系过滤(op∨rs=我操作的)",onClick:()=>eO({rel:t?es.filter(t=>t!==e.key):[...es,e.key]}),className:"rounded px-1.5 py-0.5 text-xs transition ".concat(t?"".concat(e.cls," ring-1 ring-current"):"".concat(e.cls," opacity-40 hover:opacity-80")),children:e.label},e.key)}),(0,l.jsx)("span",{className:"mx-1 text-gray-300",children:"|"}),(0,l.jsx)("button",{type:"button",title:"unlinked"===X?"点击取消未关联客户筛选":"只显示未关联客户的职位",onClick:()=>eO({cust:"unlinked"===X?"":"unlinked"}),className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-700 transition ".concat("unlinked"===X?"ring-1 ring-current":"opacity-40 hover:opacity-80"),children:"未关联客户"}),(0,l.jsxs)("span",{className:"ml-auto text-gray-400",children:["共 ",eC.total," 个"]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,l.jsx)("span",{className:"w-12 shrink-0 text-gray-400",children:"客户:"}),(0,l.jsx)(w.Z,{size:"small",showSearch:!0,allowClear:!0,placeholder:"全部客户",style:{minWidth:220},value:X&&"unlinked"!==X?Number(X):void 0,onChange:e=>eO({cust:e?String(e):""}),options:Object.entries(g).sort((e,t)=>e[1].localeCompare(t[1],"zh")).map(e=>{let[t,s]=e;return{value:Number(t),label:s}})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,l.jsx)("span",{className:"w-12 shrink-0 text-gray-400",children:"招聘状态:"}),(0,l.jsx)(w.Z,{mode:"multiple",size:"small",allowClear:!0,maxTagCount:"responsive",placeholder:"全部",style:{minWidth:260},value:$,onChange:e=>eO({stage:e}),options:L.map(e=>({value:e.key,label:e.label}))})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,l.jsx)("span",{className:"w-12 shrink-0 text-gray-400",children:"渠道:"}),(0,l.jsx)(w.Z,{mode:"multiple",size:"small",allowClear:!0,maxTagCount:"responsive",placeholder:"全部",style:{minWidth:220},value:ee,onChange:e=>eO({ch:e}),options:eP.map(e=>({value:e,label:e}))})]}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[eZ&&(0,l.jsx)("button",{type:"button",onClick:()=>{ea(!1),er(!1),eO({st:[],rel:[],cust:"",stage:[],ch:[]})},className:"text-xs text-gray-400 hover:text-gray-600",children:"清除筛选"}),!el||en||et?null:(0,l.jsx)("button",{type:"button",title:"无我操作的职位,已显示全部;点击恢复只看自己参与的",onClick:()=>er(!0),className:"rounded bg-indigo-50 px-1.5 py-0.5 text-xs text-indigo-600 hover:bg-indigo-100",children:"已显示全部(无我操作的)→ 只看我的"})]}),ek.bar(eT),eS.length>=2?(0,l.jsxs)("button",{type:"button",onClick:()=>{ev(eS[0]),eg(!0)},className:"mt-1 rounded bg-indigo-600 px-2.5 py-1 text-xs text-white hover:bg-indigo-700",children:["合并所选职位(",eS.length,")"]}):null,eN?(0,l.jsx)("div",{className:"mt-1 text-xs text-emerald-600",children:eN}):null]}),listPanel:eC.error?(0,l.jsxs)("div",{className:"flex-1 overflow-auto p-4 text-center text-sm",children:[(0,l.jsx)("span",{className:"text-red-500",children:"加载失败"}),(0,l.jsx)("button",{type:"button",onClick:()=>eC.refresh(),className:"ml-2 text-blue-500 hover:underline",children:"重试"})]}):(0,l.jsx)(u.L,{items:eT,selectedId:null!=m?m:void 0,onSelect:e=>eO({id:e}),loading:eC.loading,emptyText:"暂无职位",onLoadMore:eC.loadMore,loadingMore:eC.loadingMore,exhausted:eC.exhausted}),detailPanel:eU}),ek.modal(),eb?(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",children:(0,l.jsxs)("div",{className:"w-96 rounded-lg bg-white p-4 shadow-xl",children:[(0,l.jsxs)("h3",{className:"mb-2 text-sm font-semibold text-gray-900",children:["合并职位(保留目标,其余 ",eS.length-1," 个结束)"]}),(0,l.jsx)("p",{className:"mb-3 text-xs text-gray-500",children:"源职位的推荐流水/发布/简历/画像/评估/沟通记录全部迁到目标职位;同人才匹配冲突保留高分。"}),(0,l.jsx)("div",{className:"mb-3 max-h-48 space-y-1 overflow-auto",children:eS.map(e=>{var t;let s=eC.items.find(t=>String(t.id)===e);return(0,l.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-700",children:[(0,l.jsx)("input",{type:"radio",name:"merge-target",checked:ey===e,onChange:()=>ev(e)}),(0,l.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:["#",e," ",s?F(s):"",s?(0,l.jsxs)("span",{className:"text-xs text-gray-400",children:[" ",null!==(t=M(s))&&void 0!==t?t:""]}):null]})]},e)})}),(0,l.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:()=>eg(!1),className:"rounded border border-gray-300 px-3 py-1 text-xs text-gray-600",children:"取消"}),(0,l.jsx)("button",{type:"button",onClick:()=>void eJ(),disabled:!ey||ej,className:"rounded bg-indigo-600 px-3 py-1 text-xs text-white hover:bg-indigo-700 disabled:opacity-40",children:ej?"合并中…":"确认合并"})]})]})}):null]})}function K(e){var t,s,a,r,i;let{detail:c,customers:u,placeholderCusts:m,myUserId:x}=e,[h,p]=(0,n.useState)("info"),b=null!=x&&(c.ownerId===x||(null!==(t=c.rsUserIds)&&void 0!==t?t:[]).includes(x));return(0,l.jsxs)("div",{className:"h-full overflow-y-auto p-4",children:[(0,l.jsx)("h2",{className:"mb-1 text-lg font-semibold text-gray-900",children:null!==(a=c.title)&&void 0!==a?a:"职位 ".concat(null!==(s=c.ref)&&void 0!==s?s:"#".concat(c.id))}),(0,l.jsxs)("div",{className:"mb-3 text-xs text-gray-400",children:["externalId: ",c.externalId," \xb7 更新于 ",(0,o.d3)(c.updatedAt)]}),(0,l.jsx)("div",{className:"mb-4 flex gap-1 border-b border-gray-200",children:[{key:"info",label:"职位信息"},{key:"members",label:"成员"},{key:"criteria",label:"找人条件"},{key:"history",label:"历史"},{key:"pipeline",label:"推荐流程"},{key:"publish",label:"发布管理"}].map(e=>(0,l.jsx)("button",{onClick:()=>p(e.key),className:"rounded-t px-3 py-1.5 text-sm ".concat(h===e.key?"bg-gray-100 font-medium text-gray-900":"text-gray-500 hover:text-gray-700"),children:e.label},e.key))}),"info"===h?(0,l.jsx)(W,{detail:c,customers:u,placeholderCusts:m,myUserId:x}):"members"===h?(0,l.jsx)(H,{detail:c,myUserId:x},"".concat(A(c),"-").concat(null!=x?x:"anon")):"criteria"===h?(0,l.jsx)(Y,{detail:c,myUserId:x},"".concat(A(c),"-").concat(null!=x?x:"anon")):"history"===h?(0,l.jsx)(Q,{jobCaseId:A(c)},A(c)):"pipeline"===h?(0,l.jsx)(Z,{jobCaseId:A(c),canOperate:b},A(c)):(0,d.K5)()?(0,l.jsx)(g.X,{feature:"职位发布",localPath:"/jobs"}):(0,l.jsx)(E.I,{jobCaseId:c.id,caseTitle:null!==(i=c.title)&&void 0!==i?i:"职位 ".concat(null!==(r=c.ref)&&void 0!==r?r:"#".concat(c.id)),canOperate:b},c.id)]})}function W(e){var t,s,a;let{detail:d,customers:o,placeholderCusts:c,myUserId:u}=e,x=(0,r.useRouter)(),[h,p]=(0,n.useState)(!1),[b,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[j,f]=(0,n.useState)(null!==(t=d.title)&&void 0!==t?t:""),[N,k]=(0,n.useState)(d.customerId?String(d.customerId):""),[S,C]=(0,n.useState)(!1),I=null!=u&&d.ownerId===u,O=null==d.customerId||c.has(d.customerId),z=async(e,t)=>{let s;p(!0),g(null);try{s=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(d))),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){return p(!1),g(t),null}return p(!1),x.refresh(),location.reload(),s},T=async()=>{C(!0),g(null);try{await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(d)),"/op/claim"),{method:"POST"})}catch(e){C(!1),g("申请 op 失败:该职位可能已有 op,或服务无响应");return}C(!1),location.reload()};return(0,l.jsxs)("div",{children:[O&&I?(0,l.jsxs)("div",{className:"mb-4 rounded border border-amber-300 bg-amber-50 p-3",children:[(0,l.jsx)("div",{className:"mb-2 text-sm font-medium text-amber-800",children:"该职位尚未关联客户,请先选择客户公司(客户不能为空)"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(w.Z,{size:"small",allowClear:!0,placeholder:"选择客户…",style:{minWidth:180},value:N||void 0,onChange:e=>k(null!=e?e:""),options:Object.entries(o).sort((e,t)=>e[1].localeCompare(t[1],"zh")).map(e=>{let[t,s]=e;return{value:t,label:s}})}),(0,l.jsx)("button",{type:"button",disabled:!N||h,onClick:()=>void z({customerId:Number(N)},"关联客户失败,请重试"),className:"rounded bg-amber-600 px-3 py-1.5 text-xs text-white hover:bg-amber-700 disabled:opacity-40",children:h?"保存中…":"确认关联"})]})]}):null,O&&!I?(0,l.jsx)("div",{className:"mb-4 rounded border border-gray-200 bg-gray-50 p-3 text-sm text-gray-500",children:"该职位尚未关联客户,请联系 op 选择客户公司"}):null,(0,l.jsxs)("div",{className:"mb-4 rounded border border-gray-200 bg-gray-50 p-2",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,l.jsx)("span",{className:"text-gray-500",children:"状态:"}),(0,l.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs ".concat("active"===d.status?"bg-emerald-100 text-emerald-700":"bg-gray-300 text-gray-700"),children:"active"===d.status?"启动中":"结束"}),null==d.ownerId?(0,l.jsx)("button",{type:"button",disabled:S,onClick:()=>void T(),className:"rounded bg-blue-600 px-2.5 py-1 text-xs text-white hover:bg-blue-700 disabled:opacity-40",children:S?"申请中…":"申请做 op(无人管理,直接生效)"}):null,I&&!O?"active"===d.status?(0,l.jsx)("button",{type:"button",disabled:h,onClick:()=>void z({status:"closed"},"状态更新失败(仅 op 可操作)"),className:"rounded border border-gray-300 px-2.5 py-1 text-xs text-gray-600 hover:bg-gray-100",children:"结束职位"}):(0,l.jsx)("button",{type:"button",disabled:h,onClick:()=>void z({status:"active"},"状态更新失败(仅 op 可操作)"),className:"rounded bg-emerald-600 px-2.5 py-1 text-xs text-white hover:bg-emerald-700",children:"重新启动"}):null,I||null==d.ownerId?null:(0,l.jsx)("span",{className:"text-xs text-gray-400",children:"仅 op 可切换状态"})]}),b?(0,l.jsx)("div",{className:"mt-1 text-xs text-red-500",children:b}):null]}),d.customerId?(0,l.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[(0,l.jsxs)("a",{href:"/companies?id=".concat(d.customerId),className:"inline-flex items-center gap-2 rounded border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800 hover:border-amber-400",children:[(0,l.jsx)("span",{className:"text-gray-500",children:"客户公司:"}),(0,l.jsx)("span",{className:"font-medium",children:null!==(s=o[d.customerId])&&void 0!==s?s:"#".concat(d.customerId)}),(0,l.jsx)("span",{className:"text-xs text-amber-500",children:"查看公司详情 →"})]}),I?(0,l.jsx)(w.Z,{size:"small",style:{minWidth:180},value:d.customerId,onChange:e=>{e!==d.customerId&&z({customerId:e},"更换客户失败:同客户下可能已有同名职位")},options:Object.entries(o).sort((e,t)=>e[1].localeCompare(t[1],"zh")).map(e=>{let[t,s]=e;return{value:Number(t),label:s}})}):null]}):null,(0,l.jsxs)("div",{className:"mb-4",children:[(0,l.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:"职位名"}),I&&!y?(0,l.jsx)("button",{type:"button",onClick:()=>{var e;f(null!==(e=d.title)&&void 0!==e?e:""),v(!0)},className:"text-xs text-blue-600 hover:underline",children:"修改"}):null]}),y?(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("input",{type:"text",value:j,onChange:e=>f(e.target.value),className:"rounded border border-gray-300 px-2 py-1 text-sm"}),(0,l.jsx)("button",{type:"button",disabled:!j.trim()||h,onClick:()=>{z({title:j.trim()},"改名失败:同客户下可能已有同名职位").then(e=>{e&&v(!1)})},className:"rounded bg-blue-600 px-2.5 py-1 text-xs text-white hover:bg-blue-700 disabled:opacity-40",children:"保存"}),(0,l.jsx)("button",{type:"button",onClick:()=>v(!1),className:"rounded border border-gray-300 px-2.5 py-1 text-xs text-gray-600",children:"取消"})]}):(0,l.jsx)("div",{className:"text-sm text-gray-700",children:null!==(a=d.title)&&void 0!==a?a:"—"})]}),d.folderPath?(0,l.jsxs)("div",{className:"mb-4 break-all text-xs text-gray-500",children:["文件夹:",d.folderPath]}):null,d.requirements&&Object.keys(d.requirements).length>0?(0,l.jsxs)("section",{className:"mb-4",children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"职位要求(requirements)"}),(0,l.jsx)(m.Y,{data:d.requirements})]}):null,d.rawFiles&&Object.keys(d.rawFiles).length>0?(0,l.jsxs)("section",{children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"原始文件(rawFiles)"}),(0,l.jsx)(m.Y,{data:d.rawFiles})]}):null]})}function H(e){let{detail:t,myUserId:s}=e,[a,r]=(0,n.useState)({op:null,rs:[]}),[d,o]=(0,n.useState)([]),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(!1),[h,p]=(0,n.useState)(""),[b,g]=(0,n.useState)(""),y=(0,n.useCallback)(()=>{(async()=>{try{let e=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(t)),"/members"));r(e)}catch(e){}})()},[t.id]);(0,n.useEffect)(()=>{y(),(async()=>{try{let e=await (0,i.requestJson)("/job-cases/tenant-members");o(e.items)}catch(e){}})()},[y]);let v=e=>{var t,l;return null!==(l=null===(t=d.find(t=>t.hmUserId===e))||void 0===t?void 0:t.label)&&void 0!==l?l:e===s?"我":"用户 #".concat(e)},j=null!=s&&a.op===s,f=async function(e,s){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"操作失败(仅 op 可操作)";x(!0),u(null);try{await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(t))).concat(e),{method:e.startsWith("/rs/")?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:null!=s?JSON.stringify(s):void 0})}catch(e){x(!1),u(l);return}x(!1),y()},N=d.filter(e=>e.hmUserId!==a.op&&!a.rs.includes(e.hmUserId));return(0,l.jsxs)("div",{children:[(0,l.jsxs)("section",{className:"mb-4",children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"op(职位管理者,唯一)"}),null!=a.op?(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,l.jsxs)("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-blue-700",children:[v(a.op),a.op===s?"(我)":""]}),j?(0,l.jsxs)("span",{className:"flex items-center gap-1 text-xs",children:[(0,l.jsx)(w.Z,{size:"small",allowClear:!0,placeholder:"转移给…",style:{minWidth:140},value:h||void 0,onChange:e=>p(null!=e?e:""),options:d.filter(e=>e.hmUserId!==a.op).map(e=>{var t;return{value:String(e.hmUserId),label:null!==(t=e.label)&&void 0!==t?t:"用户 #".concat(e.hmUserId)}})}),(0,l.jsx)("button",{type:"button",disabled:!h||m,onClick:()=>void f("/op/transfer",{userId:Number(h)},"转移失败,请重试").then(()=>p("")),className:"rounded border border-blue-300 px-2 py-0.5 text-blue-600 hover:bg-blue-50 disabled:opacity-40",children:"确认转移"}),(0,l.jsx)("span",{className:"text-gray-400",children:"直接生效,无需对方确认"})]}):null]}):(0,l.jsx)("div",{className:"text-sm text-gray-500",children:"当前无 op——到「职位信息」tab 点「申请做 op」即可直接接管(无需审批)"})]}),(0,l.jsxs)("section",{className:"mb-4",children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"rs(协作成员,可多个)"}),a.rs.length?(0,l.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.rs.map(e=>(0,l.jsxs)("span",{className:"flex items-center gap-1 rounded bg-cyan-100 px-2 py-0.5 text-cyan-700",children:[v(e),e===s?"(我)":"",j?(0,l.jsx)("button",{type:"button",disabled:m,onClick:()=>void(0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(t)),"/rs/").concat(e),{method:"DELETE"}).then(()=>y()).catch(()=>u("移除失败(仅 op 可操作)")),className:"text-cyan-500 hover:text-red-500",title:"移除该 rs",children:"\xd7"}):null]},e))}):(0,l.jsx)("div",{className:"text-sm text-gray-400",children:"暂无 rs"}),j?(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-1 text-xs",children:[(0,l.jsx)(w.Z,{size:"small",allowClear:!0,placeholder:"添加 rs(限同租户成员)…",style:{minWidth:160},value:b||void 0,onChange:e=>g(null!=e?e:""),options:N.map(e=>{var t;return{value:String(e.hmUserId),label:null!==(t=e.label)&&void 0!==t?t:"用户 #".concat(e.hmUserId)}})}),(0,l.jsx)("button",{type:"button",disabled:!b||m,onClick:()=>void f("/rs",{userId:Number(b)},"添加失败:目标须为同租户在租成员").then(()=>g("")),className:"rounded bg-cyan-600 px-2 py-0.5 text-white hover:bg-cyan-700 disabled:opacity-40",children:"添加"})]}):null]}),c?(0,l.jsx)("div",{className:"text-xs text-red-500",children:c}):null]})}function Y(e){var t;let{detail:s,myUserId:a}=e,[r,o]=(0,n.useState)([]),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[h,p]=(0,n.useState)(!1),[b,g]=(0,n.useState)(!1),[y,v]=(0,n.useState)([]),j=(0,n.useCallback)(()=>{(async()=>{try{let e=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(s)),"/criteria"));o(e.items)}catch(e){}})()},[s.id]);(0,n.useEffect)(()=>{j()},[j]);let f=r.find(e=>e.userId===(null!=a?a:0));r.find(e=>{var t;return e.userId===(null!==(t=s.ownerId)&&void 0!==t?t:-1)});let N=null!=a&&(s.ownerId===a||(null!==(t=s.rsUserIds)&&void 0!==t?t:[]).includes(a)),w=()=>{var e;v((null!==(e=null==f?void 0:f.criteria)&&void 0!==e?e:[]).map(e=>{var t;return{dimension:e.dimension,value:"string"==typeof e.value?e.value:JSON.stringify(e.value),weight:String(null!==(t=e.weight)&&void 0!==t?t:1)}})),g(!0),u(null)},k=async()=>{let e;let t=y.filter(e=>e.dimension.trim()&&e.value.trim()).map(e=>{let t=e.value.trim();try{t=JSON.parse(e.value)}catch(e){}return{dimension:e.dimension.trim(),value:t,weight:Number(e.weight)||1}});if(!t.length){u("至少保留一条条件(dimension + value)");return}p(!0),u(null);try{e=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(s)),"/criteria"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:t})})}catch(e){p(!1),u("保存失败,请重试");return}p(!1),o(e.items),g(!1)},S=async e=>{let t;p(!0),u(null),x(null);try{t=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(A(s)),"/criteria/merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fromUserId:e,mode:"apply"})})}catch(e){p(!1),u("叠加失败,请重试");return}p(!1),x("已叠加 ".concat(t.applied," 条新条件到我的条件")),j()},C=e=>(0,l.jsx)("ul",{className:"space-y-1",children:e.map((e,t)=>(0,l.jsxs)("li",{className:"text-xs text-gray-600",children:[(0,l.jsx)("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-gray-500",children:e.dimension})," ","string"==typeof e.value?e.value:JSON.stringify(e.value),1!==e.weight?(0,l.jsxs)("span",{className:"text-gray-400",children:["(权重 ",e.weight,")"]}):null]},t))});return(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("p",{className:"text-xs text-gray-400",children:"招人条件按人维护:op 一份(=职位共享规则),每个 rs 一份。agent 找人默认按「op 条件 + 自己那份」;可叠加他人条件后选择是否更新自己那份。"}),null==a?(0,l.jsx)("div",{className:"rounded border border-gray-200 bg-gray-50 p-2 text-xs text-gray-500",children:"未登录同步用户,展示全部条件(本机工具视角)"}):null,null==a||N?null:(0,l.jsx)("div",{className:"rounded border border-amber-100 bg-amber-50 p-2 text-xs text-amber-600",children:"仅该职位的 op/rs 可维护找人条件,你可查看"}),0!==r.length||b?r.map(e=>{let t=null!=a&&e.userId===a,n=null!=s.ownerId&&e.userId===s.ownerId,r=t?"我的条件":n?"op 的条件(职位共享,#".concat(e.userId,")"):"用户 #".concat(e.userId," 的条件");return(0,l.jsxs)("section",{className:"rounded border border-gray-200 p-3",children:[(0,l.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:r}),t&&null!=a&&!b&&N?(0,l.jsx)("button",{type:"button",onClick:w,className:"text-xs text-blue-600 hover:underline",children:"编辑我的条件"}):null,t||null==a||b||!N?null:(0,d.K5)()?(0,l.jsx)("span",{className:"text-xs text-amber-600",title:"条件叠加需在本机 HunterMate 使用",children:"叠加需本机"}):(0,l.jsx)("button",{type:"button",disabled:h,onClick:()=>void S(e.userId),className:"text-xs text-indigo-600 hover:underline disabled:opacity-40",children:"叠加到我的条件"})]}),t&&b?(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"(正在下方编辑我的条件)"}):e.criteria.length?C(e.criteria):(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"(空)"})]},e.userId)}):(0,l.jsx)("div",{className:"text-sm text-gray-400",children:"暂无找人条件"}),null!=a&&b&&N?(0,l.jsxs)("section",{className:"rounded border border-gray-200 p-3",children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"我的条件(编辑中)"}),(0,l.jsxs)("div",{className:"space-y-2",children:[y.map((e,t)=>(0,l.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,l.jsx)("input",{type:"text",value:e.dimension,placeholder:"维度,如 city/skill/school",onChange:e=>v(y.map((s,l)=>l===t?{...s,dimension:e.target.value}:s)),className:"w-36 rounded border border-gray-300 px-1.5 py-0.5"}),(0,l.jsx)("input",{type:"text",value:e.value,placeholder:"值(字符串或 JSON)",onChange:e=>v(y.map((s,l)=>l===t?{...s,value:e.target.value}:s)),className:"w-56 rounded border border-gray-300 px-1.5 py-0.5"}),(0,l.jsx)("input",{type:"text",value:e.weight,placeholder:"权重",onChange:e=>v(y.map((s,l)=>l===t?{...s,weight:e.target.value}:s)),className:"w-14 rounded border border-gray-300 px-1.5 py-0.5"}),(0,l.jsx)("button",{type:"button",onClick:()=>v(y.filter((e,s)=>s!==t)),className:"text-gray-400 hover:text-red-500",children:"\xd7"})]},t)),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:()=>v([...y,{dimension:"",value:"",weight:"1"}]),className:"rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-600",children:"+ 加一条"}),(0,l.jsx)("button",{type:"button",disabled:h,onClick:()=>void k(),className:"rounded bg-blue-600 px-2.5 py-0.5 text-xs text-white hover:bg-blue-700 disabled:opacity-40",children:h?"保存中…":"保存(整体替换我的条件)"}),(0,l.jsx)("button",{type:"button",onClick:()=>g(!1),className:"rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-600",children:"取消"})]})]})]}):null,null==a||f||b||!N?null:(0,l.jsx)("button",{type:"button",onClick:w,className:"rounded bg-blue-600 px-2.5 py-1 text-xs text-white hover:bg-blue-700",children:"添加我的条件"}),m?(0,l.jsx)("div",{className:"text-xs text-emerald-600",children:m}):null,c?(0,l.jsx)("div",{className:"text-xs text-red-500",children:c}):null,(0,l.jsx)(X,{externalId:s.externalId})]})}function X(e){let{externalId:t}=e,[s,a]=(0,n.useState)(null),[r,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)("");(0,n.useEffect)(()=>{let e=!0;return(async()=>{try{var s;let l=await (0,i.requestJson)("/searchlog?jobCaseExternalId=".concat(encodeURIComponent(t),"&limit=100"));e&&a(null!==(s=l.items)&&void 0!==s?s:[])}catch(t){e&&(a([]),d(!0))}})(),()=>{e=!1}},[t]);let m=Array.from(new Set((null!=s?s:[]).map(e=>e.actorEmail).filter(Boolean))),x=(null!=s?s:[]).filter(e=>!c||e.actorEmail===c),h=e=>{let t="string"==typeof e?e:JSON.stringify(e);return t&&t.length>160?"".concat(t.slice(0,160),"…"):null!=t?t:""};return(0,l.jsxs)("section",{className:"rounded border border-gray-200 p-3",children:[(0,l.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:"agent 找人历史"}),m.length>1?(0,l.jsxs)("label",{className:"flex items-center gap-1 text-xs text-gray-500",children:["按用户:",(0,l.jsx)(w.Z,{size:"small",allowClear:!0,placeholder:"全部",style:{minWidth:160},value:c||void 0,onChange:e=>u(null!=e?e:""),options:m.map(e=>({value:e,label:e}))})]}):null]}),null===s?(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"加载中…"}):0===x.length?(0,l.jsx)("div",{className:"text-xs text-gray-400",children:r?"历史服务不可用(需 hm 0.1.23+ 且已登录),不影响找人条件":"暂无搜索历史——agent 每轮搜索后会自动登记"}):(0,l.jsx)("ul",{className:"space-y-2",children:x.map(e=>{var t;return(0,l.jsxs)("li",{className:"rounded border border-gray-100 bg-gray-50 p-2 text-xs text-gray-600",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between text-gray-500",children:[(0,l.jsxs)("span",{children:[(0,l.jsx)("span",{className:"rounded bg-blue-50 px-1.5 py-0.5 text-blue-600",children:e.platform})," ",null!==(t=e.actorEmail)&&void 0!==t?t:"#".concat(e.actorHmUserId),e.model&&"unknown"!==e.model?(0,l.jsxs)("span",{className:"text-gray-400",children:[" \xb7 ",e.model]}):null]}),(0,l.jsx)("span",{children:(0,o.d3)(e.createdAt)})]}),(0,l.jsxs)("div",{className:"mt-1",children:[(0,l.jsx)("span",{className:"text-gray-400",children:"条件:"})," ",h(e.conditions)]}),(0,l.jsxs)("div",{className:"mt-0.5",children:[(0,l.jsx)("span",{className:"text-gray-400",children:"结果:"})," ",h(e.stats)]}),e.note?(0,l.jsxs)("div",{className:"mt-0.5",children:[(0,l.jsx)("span",{className:"text-gray-400",children:"备注:"})," ",e.note]}):null]},e.id)})})]})}let G={created:"创建职位",status_change:"状态切换",op_claim:"申请成为 op",op_transfer:"转移 op",op_cleared:"退租清空 op",rs_add:"添加 rs",rs_remove:"移除 rs",customer_change:"客户变更",info_update:"信息更新"};function Q(e){let{jobCaseId:t}=e,[s,a]=(0,n.useState)([]);return((0,n.useEffect)(()=>{let e=!0;return(async()=>{try{let s=await (0,i.requestJson)("/job-cases/".concat(encodeURIComponent(String(t)),"/history?limit=100"));e&&a(s.items)}catch(e){}})(),()=>{e=!1}},[t]),s.length)?(0,l.jsx)("ol",{className:"relative ml-2 space-y-3 border-l border-gray-200 pl-4",children:s.map(e=>{var t;return(0,l.jsxs)("li",{className:"relative",children:[(0,l.jsx)("span",{className:"absolute -left-[21px] top-1 h-2.5 w-2.5 rounded-full bg-blue-300"}),(0,l.jsx)("div",{className:"text-xs text-gray-400",children:(0,o.d3)(e.createdAt)}),(0,l.jsxs)("div",{className:"text-sm text-gray-800",children:[null!==(t=G[e.action])&&void 0!==t?t:e.action,null!=e.actorId?(0,l.jsxs)("span",{className:"text-gray-400",children:[" \xb7 操作人 #",e.actorId]}):null]}),e.detail&&Object.keys(e.detail).length?(0,l.jsx)("div",{className:"mt-0.5 text-xs text-gray-500",children:JSON.stringify(e.detail)}):null]},e.id)})}):(0,l.jsx)("div",{className:"text-sm text-gray-400",children:"暂无历史记录"})}function V(){return(0,l.jsx)(n.Suspense,{fallback:(0,l.jsx)("div",{className:"p-6 text-gray-500",children:"加载中…"}),children:(0,l.jsx)(B,{})})}function $(){var e;let[t,s]=(0,n.useState)(""),[a,r]=(0,n.useState)(""),[d,o]=(0,n.useState)(""),[m,x]=(0,n.useState)([]),[h,p]=(0,n.useState)(0),[g,y]=(0,n.useState)(!1),[v,j]=(0,n.useState)(null),[f,N]=(0,n.useState)(null),{sync:w}=(0,b.nu)(),k=null!==(e=null==w?void 0:w.activeTenantId)&&void 0!==e?e:null,S=(0,n.useCallback)(async()=>{y(!0);let e=new URLSearchParams;a&&e.set("q",a),d&&e.set("touched",d),e.set("limit","200");try{let t=await (0,i.requestJson)("/market/jobs?".concat(e.toString()));j(null),x(t.items),p(t.total)}catch(e){j("加载失败")}finally{y(!1)}},[a,d,k]);(0,n.useEffect)(()=>{let e=setTimeout(()=>r(t.trim()),300);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>{S()},[S]);let C=(0,n.useMemo)(()=>{var e;return null!==(e=m.find(e=>e.key===f))&&void 0!==e?e:null},[m,f]),I=(0,n.useMemo)(()=>m.map(e=>({id:e.key,content:(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("span",{className:"truncate font-medium text-gray-900",children:e.title}),e.touched?(0,l.jsx)("span",{className:"rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] text-emerald-700",children:"已操作"}):null]}),e.company?(0,l.jsx)("div",{className:"truncate text-xs text-gray-500",children:e.company}):null,(0,l.jsxs)("div",{className:"mt-0.5 flex items-center gap-0.5",children:[e.sources.map(e=>(0,l.jsx)(E.v,{platform:e},e)),(0,l.jsxs)("span",{className:"ml-1 text-[10px] text-gray-400",children:[e.postings.length," 个发布"]})]})]})})),[m]);return(0,l.jsx)(c.m,{filterBar:(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-gray-200 bg-white p-3",children:[(0,l.jsx)("input",{type:"text",value:t,onChange:e=>s(e.target.value),placeholder:"搜索职位/公司…",className:"w-56 rounded border border-gray-300 px-2 py-1.5 text-sm outline-none focus:border-blue-500"}),["","1","0"].map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>o(e),className:"rounded px-2 py-1 text-xs ".concat(d===e?"bg-[color:var(--brand-soft)] font-medium text-[color:var(--brand-strong)]":"text-gray-500 hover:bg-gray-100"),children:""===e?"全部":"1"===e?"已操作过":"未操作"},e)),(0,l.jsxs)("span",{className:"ml-auto text-xs text-gray-400",children:["共 ",h," 组(BD 市场视角)"]})]}),listPanel:v?(0,l.jsxs)("div",{className:"flex-1 overflow-auto p-4 text-center text-sm",children:[(0,l.jsx)("span",{className:"text-red-500",children:v}),(0,l.jsx)("button",{type:"button",onClick:()=>void S(),className:"ml-2 text-blue-500 hover:underline",children:"重试"})]}):(0,l.jsx)(u.L,{items:I,selectedId:null!=f?f:void 0,onSelect:N,loading:g,emptyText:"暂无市场职位(解析库暂无数据)"}),detailPanel:C?(0,l.jsxs)("div",{className:"h-full overflow-y-auto p-4",children:[(0,l.jsx)("h2",{className:"mb-1 text-lg font-semibold text-gray-900",children:C.title}),(0,l.jsxs)("div",{className:"mb-4 text-xs text-gray-400",children:[C.company?"".concat(C.company," \xb7 "):"",C.touched?"本租户已操作过":"本租户未操作"," \xb7 ",C.postings.length," 个平台发布"]}),C.jobCaseIds.length>0?(0,l.jsxs)("div",{className:"mb-4 rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm",children:[(0,l.jsx)("span",{className:"text-emerald-800",children:"我们交付中的案件:"}),C.jobCaseIds.map(e=>(0,l.jsxs)("a",{href:"/jobs?id=".concat(e),className:"ml-2 font-medium text-emerald-700 underline",children:["案件 #",e]},e))]}):null,(0,l.jsxs)("section",{children:[(0,l.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-800",children:"平台发布"}),(0,l.jsx)("div",{className:"space-y-1",children:C.postings.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 rounded border border-gray-100 px-2 py-1.5 text-sm",children:[(0,l.jsx)(E.v,{platform:e.source}),(0,l.jsx)("a",{href:e.sourceUrl,target:"_blank",rel:"noreferrer",className:"min-w-0 flex-1 truncate text-blue-600 hover:underline",children:e.sourceUrl}),(0,l.jsx)("span",{className:"text-xs text-gray-400",children:e.updatedAt.slice(0,10)})]},e.id))})]})]}):(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"选择左侧职位查看各平台发布"})})}var ee=s(88801);function et(){let e=(0,ee.mJ)();return"1"===new URLSearchParams(window.location.search).get("entities")?(0,l.jsx)("div",{className:"flex h-full flex-col",children:(0,l.jsx)("div",{className:"min-h-0 flex-1",children:(0,l.jsx)(a.EntityListPage,{type:"job",label:"职位",batchDelete:!0})})}):(0,l.jsxs)("div",{className:"flex h-full flex-col",children:["bd"===e?(0,l.jsx)("div",{className:"flex border-b border-gray-200 bg-white px-3 py-1.5",children:(0,l.jsx)("span",{className:"ml-auto rounded bg-[color:var(--brand-soft)] px-2 py-0.5 text-xs text-[color:var(--brand-strong)]",children:"\uD83E\uDDED BD 市场视角"})}):null,(0,l.jsx)("div",{className:"min-h-0 flex-1",children:"bd"===e?(0,l.jsx)($,{}):(0,l.jsx)(V,{})})]})}},21717:function(e,t,s){"use strict";s.d(t,{I:function(){return u}});var l=s(72835),a=s(60635),n=s(95909),r=s(86892),i=s(87018),d=s(6443),o=s(74431),c=s(32587);function u(e){var t;let{entityId:s,name:u,open:m,onClose:x}=e,[h,p]=(0,a.useState)(null),[b,g]=(0,a.useState)([]),[y,v]=(0,a.useState)(null),[j,f]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1),[k,S]=(0,a.useState)(!1),[C,I]=(0,a.useState)(0);return(0,a.useEffect)(()=>{if(!m||null==s)return;let e=!0;return w(!0),S(!1),p(null),g([]),v(null),f(null),Promise.all([(0,o.requestJson)("/entities/talent/".concat(s)),(0,o.requestJson)("/entities/talent/".concat(s,"/sources")).catch(()=>null),(0,o.requestJson)("/entities/talent/".concat(s,"/matches")).catch(()=>null)]).then(t=>{var s,l;let[a,n,r]=t;e&&(p(a.entity),g(n?n.items:[]),v(null!==(s=null==r?void 0:r.portraitId)&&void 0!==s?s:null),f(null!==(l=null==r?void 0:r.matches)&&void 0!==l?l:[]))}).catch(()=>{e&&S(!0)}).finally(()=>{e&&w(!1)}),()=>{e=!1}},[m,s,C]),(0,l.jsx)(n.Z,{title:null!==(t=null==h?void 0:h.name)&&void 0!==t?t:u,placement:"right",width:860,open:m,onClose:x,destroyOnHidden:!0,children:N?(0,l.jsx)(r.Z,{active:!0,paragraph:{rows:8}}):k?(0,l.jsx)(i.Z,{type:"error",message:"人才详情加载失败",description:(0,l.jsx)(d.ZP,{size:"small",onClick:()=>I(e=>e+1),children:"重试"})}):h?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.n,{entity:h}),(0,l.jsx)(c.z,{entity:h,portraitId:y,matches:j,sources:b})]}):null})}}},function(e){e.O(0,[502,606,882,706,431,587,987,659,686,400,935,744],function(){return e(e.s=74843)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8afe6351-a7c5-4ca1-80af-de4452ffb793",e._sentryDebugIdIdentifier="sentry-dbid-8afe6351-a7c5-4ca1-80af-de4452ffb793")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{866:function(e,t,n){Promise.resolve().then(n.t.bind(n,61115,23)),Promise.resolve().then(n.t.bind(n,20166,23)),Promise.resolve().then(n.bind(n,75946))},5111:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default={items_per_page:"条/页",jump_to:"跳至",jump_to_confirm:"确定",page:"页",prev_page:"上一页",next_page:"下一页",prev_5:"向前 5 页",next_5:"向后 5 页",prev_3:"向前 3 页",next_3:"向后 3 页",page_size:"页码"}},39721:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonLocale=void 0,t.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0}},6972:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;let l={...n(39721).commonLocale,locale:"zh_CN",today:"今天",now:"此刻",backToToday:"返回今天",ok:"确定",timeSelect:"选择时间",dateSelect:"选择日期",weekSelect:"选择周",clear:"清除",week:"周",month:"月",year:"年",previousMonth:"上个月",nextMonth:"下个月",monthSelect:"选择月份",yearSelect:"选择年份",decadeSelect:"选择年代",previousYear:"上一年",nextYear:"下一年",previousDecade:"上一年代",nextDecade:"下一年代",previousCentury:"上一世纪",nextCentury:"下一世纪",yearFormat:"YYYY年",cellDateFormat:"D",monthBeforeYear:!1};t.default=l},54539:function(e,t,n){"use strict";var l=n(50129).default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=l(n(47034));t.default=a.default},47034:function(e,t,n){"use strict";var l=n(50129).default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=l(n(6972)),r=l(n(53523));let s={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...a.default},timePickerLocale:{...r.default}};s.lang.ok="确定",t.default=s},26499:function(e,t,n){"use strict";var l=n(50129).default;t.Z=void 0;var a=l(n(5111)),r=l(n(54539)),s=l(n(47034)),i=l(n(53523));let o="${label}不是一个有效的${type}",c={locale:"zh-cn",Pagination:a.default,DatePicker:s.default,TimePicker:i.default,Calendar:r.default,global:{placeholder:"请选择",close:"关闭",sortable:"可排序",show:"显示",hide:"隐藏"},Table:{filterTitle:"筛选",filterConfirm:"确定",filterReset:"重置",filterEmptyText:"无筛选项",filterCheckAll:"全选",filterSearchPlaceholder:"在筛选项中搜索",emptyText:"暂无数据",selectAll:"全选当页",selectInvert:"反选当页",selectNone:"清空所有",selectionAll:"全选所有",sortTitle:"排序",expand:"展开行",collapse:"关闭行",triggerDesc:"点击降序",triggerAsc:"点击升序",cancelSort:"取消排序"},Modal:{okText:"确定",cancelText:"取消",justOkText:"知道了"},Tour:{Next:"下一步",Previous:"上一步",Finish:"结束导览"},Popconfirm:{cancelText:"取消",okText:"确定"},Transfer:{titles:["",""],searchPlaceholder:"请输入搜索内容",itemUnit:"项",itemsUnit:"项",remove:"删除",selectCurrent:"全选当页",removeCurrent:"删除当页",selectAll:"全选所有",deselectAll:"取消全选",removeAll:"删除全部",selectInvert:"反选当页"},Upload:{uploading:"文件上传中",removeFile:"删除文件",uploadError:"上传错误",previewFile:"预览文件",downloadFile:"下载文件"},Empty:{description:"暂无数据"},Icon:{icon:"图标"},Text:{edit:"编辑",copy:"复制",copied:"复制成功",expand:"展开",collapse:"收起"},Carousel:{prevSlide:"上一张幻灯片",nextSlide:"下一张幻灯片"},Form:{optional:"(可选)",defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label}须为${len}个字符",min:"${label}最少${min}个字符",max:"${label}最多${max}个字符",range:"${label}须在${min}-${max}字符之间"},number:{len:"${label}必须等于${len}",min:"${label}最小值为${min}",max:"${label}最大值为${max}",range:"${label}须在${min}-${max}之间"},array:{len:"须为${len}个${label}",min:"最少${min}个${label}",max:"最多${max}个${label}",range:"${label}数量须在${min}-${max}之间"},pattern:{mismatch:"${label}与模式不匹配${pattern}"}}},QRCode:{expired:"二维码过期",refresh:"点击刷新",scanned:"已扫描"},ColorPicker:{presetEmpty:"暂无",transparent:"无色",singleColor:"单色",gradientColor:"渐变色"}};t.Z=c},53523:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]}},27473:function(e,t,n){"use strict";var l=n(38321);n.o(l,"useParams")&&n.d(t,{useParams:function(){return l.useParams}}),n.o(l,"usePathname")&&n.d(t,{usePathname:function(){return l.usePathname}}),n.o(l,"useRouter")&&n.d(t,{useRouter:function(){return l.useRouter}}),n.o(l,"useSearchParams")&&n.d(t,{useSearchParams:function(){return l.useSearchParams}}),n.o(l,"useServerInsertedHTML")&&n.d(t,{useServerInsertedHTML:function(){return l.useServerInsertedHTML}})},71873:function(e,t,n){"use strict";n.d(t,{D:function(){return m},l:function(){return d}});var l=n(72835),a=n(60635),r=n(21260);let s="hm-cloud-login-draft",i="hm-cloud-login-resend-at",o="hm-cloud-last-email";function c(){let e={email:"",step:"email",code:""};try{let t=window.sessionStorage.getItem(s);if(!t)return e;let n=JSON.parse(t);return{email:"string"==typeof n.email?n.email:"",step:"code"===n.step?"code":"email",code:"string"==typeof n.code?n.code:""}}catch(t){return e}}function u(){try{var e;let t=Number(null!==(e=window.sessionStorage.getItem(i))&&void 0!==e?e:0);return Math.max(0,Math.ceil((t-Date.now())/1e3))}catch(e){return 0}}function d(e){let{onDone:t}=e,[n,d]=(0,a.useState)(c),[m,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(u),[y,g]=(0,a.useState)(null),[b,v]=(0,a.useState)(null),p=(0,a.useRef)(null),{email:j,step:w,code:N}=n;(0,a.useEffect)(()=>{if(!j){let e=function(){try{var e;return null!==(e=window.localStorage.getItem(o))&&void 0!==e?e:""}catch(e){return""}}();e&&S({email:e})}},[]),(0,a.useEffect)(()=>{if(!(h<=0)&&!p.current)return p.current=setInterval(()=>{f(e=>(e<=1&&p.current&&(clearInterval(p.current),p.current=null),Math.max(0,e-1)))},1e3),()=>{p.current&&clearInterval(p.current),p.current=null}},[h]);let S=e=>{d(t=>{let n={...t,...e};try{window.sessionStorage.setItem(s,JSON.stringify(n))}catch(e){}return n})},C=e=>{try{window.localStorage.setItem(o,e)}catch(e){}},k=()=>{try{window.sessionStorage.removeItem(s),window.sessionStorage.removeItem(i)}catch(e){}},I=()=>{try{window.sessionStorage.setItem(i,String(Date.now()+6e4))}catch(e){}f(60)},T=/^[^@\s]+@[^@\s]+\.[^@\s]+$/,P=async()=>{let e=j.trim().toLowerCase();if(!T.test(e)){v("请输入有效邮箱");return}x(!0),v(null),g(null);let t=await fetch("/hunter-mate/auth/email/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(x(!1),!t.ok){let e=await t.json().catch(()=>null);v((null==e?void 0:e.message)||"发送失败(HTTP ".concat(t.status,")"));return}C(e),S({email:e,step:"code"}),I(),g("验证码已发送,请查收邮件")},D=async()=>{if(!/^\d{6}$/.test(N.trim())){v("请输入 6 位数字验证码");return}x(!0),v(null);let e=await fetch("/hunter-mate/auth/email/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:j.trim().toLowerCase(),code:N.trim()})});if(x(!1),!e.ok){let t=await e.json().catch(()=>null);v((null==t?void 0:t.message)||"验证失败(HTTP ".concat(e.status,")"));return}let n=await e.json().catch(()=>null);if(!(null==n?void 0:n.access_token)){v("登录响应缺少凭证,请重试");return}C(j.trim().toLowerCase()),(0,r.VA)(n.access_token),k(),(0,r.notifyCloudTokenChanged)(),t()};return(0,l.jsxs)("div",{children:["email"===w?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"email",autoFocus:!0,value:j,onFocus:e=>e.target.select(),onChange:e=>S({email:e.target.value}),onBlur:e=>S({email:e.target.value.trim().toLowerCase()}),placeholder:"you@example.com",className:"mb-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,l.jsx)("button",{onClick:P,disabled:m,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:m?"发送中…":"发送验证码"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mb-2 text-left text-xs text-gray-500",children:["验证码已发送至 ",j,",请查收邮件"]}),(0,l.jsx)("input",{type:"text",inputMode:"numeric",autoFocus:!0,maxLength:6,value:N,onChange:e=>S({code:e.target.value}),placeholder:"6 位验证码",className:"mb-3 w-full rounded-md border border-gray-300 px-3 py-2 text-center text-sm tracking-[0.5em]"}),(0,l.jsx)("button",{onClick:D,disabled:m,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:m?"登录中…":"登录"}),(0,l.jsxs)("div",{className:"mt-3 flex items-center justify-between text-xs",children:[(0,l.jsx)("button",{onClick:()=>S({step:"email"}),className:"text-gray-400 hover:text-gray-600",children:"换个邮箱"}),(0,l.jsx)("button",{onClick:P,disabled:h>0||m,className:"text-blue-600 hover:text-blue-700 disabled:text-gray-300",children:h>0?"重新发送(".concat(h,"s)"):"重新发送"})]})]}),y&&(0,l.jsx)("div",{className:"mt-3 text-xs text-green-600",children:y}),b&&(0,l.jsx)("div",{className:"mt-3 text-xs text-red-500",children:b})]})}function m(e){let{children:t}=e,[n,s]=(0,a.useState)(null);return((0,a.useEffect)(()=>{let e=()=>s(null!==(0,r.xq)());return e(),(0,r.RB)(e)},[]),null===n)?(0,l.jsxs)("div",{className:"flex h-screen w-screen flex-col items-center justify-center bg-gray-50",children:[(0,l.jsx)("span",{className:"hm-spinner","aria-label":"加载中"}),(0,l.jsx)("div",{className:"mt-4 text-sm text-gray-400",children:"正在加载,请稍候…"})]}):n?(0,l.jsx)(l.Fragment,{children:t}):(0,l.jsx)("div",{className:"flex h-screen w-screen flex-col items-center justify-center bg-gray-50",children:(0,l.jsxs)("div",{className:"w-80 rounded-2xl border border-gray-200 bg-white p-8 text-center shadow-sm",children:[(0,l.jsx)("div",{className:"mb-2 text-3xl",children:"\uD83E\uDD1D"}),(0,l.jsx)("div",{className:"mb-1 text-lg font-semibold text-gray-900",children:"HunterMate 云工作台"}),(0,l.jsx)("div",{className:"mb-4 text-xs text-gray-400",children:"登录后,随时随地访问你的协作数据"}),(0,l.jsx)(d,{onDone:()=>s(!0)})]})})}},75946:function(e,t,n){"use strict";n.d(t,{GateByRoute:function(){return R}});var l=n(72835),a=n(27473),r=n(60635),s=n(65777),i=n(82182),o=n(4025),c=n(33447),u=n(28431);function d(){var e,t,a;let{session:o,sync:d,utoken:h,loadError:f,refresh:y}=(0,s.nu)(),[g,b]=(0,r.useState)(!1),[v,j]=(0,r.useState)(!1),[w,N]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),k=(null==o?void 0:o.loggedIn)||(null==d?void 0:d.loggedIn),I=(0,s.aG)(d),T=(0,s.cp)(d),P=null==T?null:null!==(t=null===(e=I.find(e=>e.tenantId===T))||void 0===e?void 0:e.name)&&void 0!==t?t:null,D=async e=>{C(!0);try{var t,l,a,r;let m=null!==(a=null==d?void 0:null===(l=d.memberships)||void 0===l?void 0:null===(t=l.find(e=>e.isPersonal))||void 0===t?void 0:t.tenantId)&&void 0!==a?a:null,x=null!=e?e:m;if((0,c.K5)()){let{requestJson:e}=await Promise.resolve().then(n.bind(n,74431));await e("/hunter-mate/tenant/last-active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tenantId:x})}),(0,u.bw)(x),await y();return}let f=new Headers({"Content-Type":"application/json"});h&&f.set("Authorization","UTOKEN ".concat(h));let g=await fetch("".concat((0,s.tQ)(),"/datasync/active-tenant"),{method:"POST",headers:f,body:JSON.stringify({id:x})});if(401===g.status){(0,i.jr)({message:"登录已过期,请重新登录",oldUserId:null!==(r=null==o?void 0:o.hmUserId)&&void 0!==r?r:null,retry:async()=>{let t=new Headers({"Content-Type":"application/json"}),n=(0,s.Xc)();return n&&t.set("Authorization","UTOKEN ".concat(n)),!!(await fetch("".concat((0,s.tQ)(),"/datasync/active-tenant"),{method:"POST",headers:t,body:JSON.stringify({id:e})})).ok&&(await y(),!0)}});return}await y()}finally{C(!1)}},E=async()=>{if((0,c.K5)()){let{clearCloudToken:e,notifyCloudTokenChanged:t}=await Promise.resolve().then(n.bind(n,21260));e(),(0,u.nZ)(),t(),await y();return}let e=new Headers({"Content-Type":"application/json"});h&&e.set("Authorization","UTOKEN ".concat(h)),await fetch("".concat((0,s.tQ)(),"/datasync/logout"),{method:"POST",headers:e}).catch(()=>null),await y()},_=null===d?{text:"同步状态加载中…",cls:"bg-gray-100 text-gray-400"}:d.enabled?d.authFailed?{text:"登录态失效",cls:"bg-red-100 text-red-600"}:d.remoteError?{text:"云端不可达",cls:"bg-amber-100 text-amber-600"}:{text:"同步正常",cls:"bg-green-100 text-green-600"}:{text:"同步未启用",cls:"bg-gray-100 text-gray-500"};return(0,l.jsxs)("div",{className:"relative border-t border-gray-200 px-3 py-3",children:[f?(0,l.jsxs)("div",{className:"text-xs text-red-500",children:[f,"(本地服务未启动?)"]}):k?(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"truncate text-sm font-medium text-gray-900",children:(null==o?void 0:o.email)||"已登录"}),(0,l.jsx)("span",{className:"inline-block rounded-full px-2 py-0.5 text-xs ".concat(_.cls),children:_.text})]}),(0,l.jsx)("button",{onClick:E,title:"退出登录",className:"shrink-0 rounded-md px-2 py-1 text-xs text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:"退出"})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("button",{onClick:()=>j(e=>!e),disabled:S,className:"flex w-full items-center justify-between rounded-md border border-gray-200 bg-white px-2 py-1.5 text-sm text-gray-700 hover:border-gray-300 disabled:opacity-50",children:[(0,l.jsx)("span",{className:"truncate",children:null==T?"个人使用(不归属公司)":null!=P?P:"未知公司"}),(0,l.jsx)("span",{className:"text-xs text-gray-400",children:S?"切换中…":"▾"})]}),(0,l.jsx)("div",{className:"mt-1 truncate whitespace-nowrap text-xs text-gray-400",children:"当前归属公司;公司内数据互通"})]})]}):(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm text-gray-500",children:"未登录"}),(0,l.jsx)("div",{className:"text-xs text-gray-400",children:"登录后可跨设备同步数据"})]}),(0,l.jsx)("button",{onClick:()=>b(!0),className:"rounded-lg bg-blue-600 px-3 py-1.5 text-sm text-white hover:bg-blue-700",children:"登录"})]}),v&&k&&(0,l.jsx)(m,{sync:d,companies:I,activeTenantId:T,onPick:async e=>{j(!1),await D(e)},onCreateJoin:()=>{j(!1),N(!0)},onClose:()=>j(!1)}),w&&k&&(0,l.jsx)(x,{utoken:h,oldUserId:null!==(a=null==o?void 0:o.hmUserId)&&void 0!==a?a:null,onDone:async e=>{N(!1),null!=e&&await D(e),await y()},onClose:()=>N(!1)}),g&&(0,l.jsx)(p,{onClose:()=>b(!1),onDone:()=>{b(!1),y()}})]})}function m(e){let{sync:t,companies:n,activeTenantId:a,onPick:s,onCreateJoin:i,onClose:o}=e,c=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&o()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,l.jsxs)("div",{ref:c,className:"absolute bottom-full left-2 right-2 z-40 mb-1 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl",children:[(0,l.jsx)("div",{className:"border-b border-gray-100 px-3 py-2 text-xs font-medium text-gray-400",children:"切换公司"}),(0,l.jsxs)("div",{className:"max-h-64 overflow-auto py-1",children:[(0,l.jsxs)("button",{onClick:()=>s(null),className:"flex w-full items-center justify-between px-3 py-2 text-left text-sm hover:bg-gray-50",children:[(0,l.jsx)("span",{className:"text-gray-700",children:"个人使用(不归属公司)"}),null==a&&(0,l.jsx)("span",{className:"text-blue-600",children:"✓"})]}),n.map(e=>{var t;return(0,l.jsxs)("button",{onClick:()=>s(e.tenantId),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[(0,l.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,l.jsx)("span",{className:"truncate text-gray-700",children:e.name}),"owner"===(t=e.role)?(0,l.jsx)("span",{className:"text-[10px] text-amber-600",children:"归属者"}):"admin"===t?(0,l.jsx)("span",{className:"text-[10px] text-blue-600",children:"管理员"}):null]}),a===e.tenantId&&(0,l.jsx)("span",{className:"shrink-0 text-blue-600",children:"✓"})]},e.tenantId)}),0===n.length&&(0,l.jsx)("div",{className:"px-3 py-2 text-xs text-gray-400",children:"尚未加入任何公司"})]}),(0,l.jsx)("button",{onClick:i,className:"w-full border-t border-gray-100 px-3 py-2 text-left text-sm text-blue-600 hover:bg-blue-50",children:"+ 创建或加入公司"})]})}function x(e){let{utoken:t,oldUserId:n,onDone:a,onClose:s}=e,[c,u]=(0,r.useState)(""),[d,m]=(0,r.useState)(!1),[x,h]=(0,r.useState)([]),[f,y]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),[v,p]=(0,r.useState)(null),[j,w]=(0,r.useState)(null),N=(0,r.useCallback)(async(e,t)=>(0,o.k)(e,null!=t?t:{}),[t]);(0,r.useEffect)(()=>{let e=c.trim();if(!e){h([]),m(!1);return}m(!0);let t=setTimeout(async()=>{var t;let n=await N("/company/search?q=".concat(encodeURIComponent(e)));if(!n.ok){h([]),m(!1);return}h(null!==(t=(await n.json()).items)&&void 0!==t?t:[]),m(!1)},300);return()=>clearTimeout(t)},[c,N]);let S=(e,t)=>{(null==t?void 0:t.already)?w("已申请过「".concat(e.name,"」,等待管理员审批")):w("已申请加入「".concat(e.name,"」,管理员通过后即可数据互通")),h(t=>t.map(t=>t.id===e.id?{...t,myApplication:"pending"}:t))},C=async()=>{let e=c.trim();if(e){y(!0),p(null);try{var t;let l=await N("/company",{method:"POST",body:JSON.stringify({name:e})}),r=await l.json().catch(()=>null);if(!l.ok){if(401===l.status){p("登录已过期,请在弹窗中重新登录;登录后自动继续创建"),(0,i.jr)({message:"登录已过期,请重新登录",oldUserId:null!=n?n:null,retry:async()=>{var t;let n=await (0,o.k)("/company",{method:"POST",body:JSON.stringify({name:e})}),l=await n.json().catch(()=>null);return n.ok?(a(null!==(t=null==l?void 0:l.id)&&void 0!==t?t:null),!0):(p((null==l?void 0:l.message)||"创建失败(HTTP ".concat(n.status,")")),!1)}});return}p((null==r?void 0:r.message)||"创建失败(HTTP ".concat(l.status,")"));return}a(null!==(t=null==r?void 0:r.id)&&void 0!==t?t:null)}finally{y(!1)}}},k=async e=>{b(e.id),p(null),w(null);try{let t=await N("/company/".concat(e.id,"/apply"),{method:"POST",body:JSON.stringify({})}),l=await t.json().catch(()=>null);if(!t.ok){if(401===t.status){p("登录已过期,请在弹窗中重新登录;登录后自动继续申请"),(0,i.jr)({message:"登录已过期,请重新登录",oldUserId:null!=n?n:null,retry:async()=>{let t=await (0,o.k)("/company/".concat(e.id,"/apply"),{method:"POST",body:JSON.stringify({})}),n=await t.json().catch(()=>null);return t.ok?(S(e,n),!0):(p((null==n?void 0:n.message)||"申请失败(HTTP ".concat(t.status,")")),!1)}});return}p((null==l?void 0:l.message)||"申请失败(HTTP ".concat(t.status,")"));return}S(e,l)}finally{b(null)}},I=e=>"owner"===e.myRole?{label:"归属者",disabled:!0}:"admin"===e.myRole||"member"===e.myRole?{label:"已加入",disabled:!0}:"pending"===e.myApplication?{label:"待审批",disabled:!0}:{label:"申请加入",disabled:!1};return(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:s,children:(0,l.jsxs)("div",{className:"w-96 rounded-xl bg-white p-5 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h3",{className:"mb-3 text-base font-semibold text-gray-900",children:"创建或加入公司"}),(0,l.jsx)("input",{autoFocus:!0,value:c,onChange:e=>u(e.target.value),placeholder:"输入公司名称,检索是否已存在",className:"mb-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,l.jsx)("div",{className:"mb-3 max-h-56 min-h-16 overflow-auto rounded-md border border-gray-100",children:""===c.trim()?(0,l.jsx)("div",{className:"px-3 py-4 text-center text-xs text-gray-400",children:"输入关键词可检索已存在的公司并申请加入"}):d?(0,l.jsx)("div",{className:"px-3 py-4 text-center text-xs text-gray-400",children:"检索中…"}):0===x.length?(0,l.jsxs)("div",{className:"px-3 py-4 text-center text-xs text-gray-400",children:["没有匹配「",c.trim(),"」的公司,可直接创建"]}):x.map(e=>{let t=I(e);return(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-gray-50 px-3 py-2 last:border-0",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"truncate text-sm text-gray-800",children:e.name}),(0,l.jsxs)("div",{className:"text-xs text-gray-400",children:[e.memberCount," 名成员"]})]}),(0,l.jsx)("button",{onClick:()=>!t.disabled&&k(e),disabled:t.disabled||g===e.id,className:"shrink-0 rounded-md px-2.5 py-1 text-xs ".concat(t.disabled?"bg-gray-100 text-gray-400":"bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50"),children:g===e.id?"申请中…":t.label})]},e.id)})}),(0,l.jsx)("button",{onClick:C,disabled:f||""===c.trim(),className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:f?"创建中…":"创建公司「".concat(c.trim()||"…","」")}),j&&(0,l.jsx)("div",{className:"mt-2 text-xs text-green-600",children:j}),v&&(0,l.jsx)("div",{className:"mt-2 text-xs text-red-500",children:v}),(0,l.jsx)("button",{onClick:s,className:"mt-2 w-full py-1 text-xs text-gray-400 hover:text-gray-600",children:"关闭"})]})})}let h="hm-login-draft",f="hm-login-resend-at",y="hm-last-email";function g(){let e={email:"",step:"email",code:""};try{let t=window.sessionStorage.getItem(h);if(!t)return e;let n=JSON.parse(t);return{email:"string"==typeof n.email?n.email:"",step:"code"===n.step?"code":"email",code:"string"==typeof n.code?n.code:""}}catch(t){return e}}function b(){try{var e;let t=Number(null!==(e=window.sessionStorage.getItem(f))&&void 0!==e?e:0);return Math.max(0,Math.ceil((t-Date.now())/1e3))}catch(e){return 0}}function v(e){let{onDone:t}=e,[n,a]=(0,r.useState)(g),[i,o]=(0,r.useState)(!1),[c,u]=(0,r.useState)(b),[d,m]=(0,r.useState)(null),[x,v]=(0,r.useState)(null),p=(0,r.useRef)(null),{email:j,step:w,code:N}=n;(0,r.useEffect)(()=>{if(!j){let e=function(){try{var e;return null!==(e=window.localStorage.getItem(y))&&void 0!==e?e:""}catch(e){return""}}();e&&S({email:e})}},[]),(0,r.useEffect)(()=>()=>{p.current&&clearInterval(p.current)},[]);let S=e=>{a(t=>{let n={...t,...e};try{window.sessionStorage.setItem(h,JSON.stringify(n))}catch(e){}return n})},C=e=>{try{window.localStorage.setItem(y,e)}catch(e){}},k=()=>{try{window.sessionStorage.removeItem(h),window.sessionStorage.removeItem(f)}catch(e){}},I=()=>{try{window.sessionStorage.setItem(f,String(Date.now()+6e4))}catch(e){}u(60),p.current&&clearInterval(p.current),p.current=setInterval(()=>{u(e=>(e<=1&&p.current&&clearInterval(p.current),Math.max(0,e-1)))},1e3)},T=/^[^@\s]+@[^@\s]+\.[^@\s]+$/,P=async()=>{let e=j.trim().toLowerCase();if(!T.test(e)){v("请输入有效邮箱");return}o(!0),v(null),m(null);let t=await fetch("".concat((0,s.tQ)(),"/auth/email/send-code"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(o(!1),!t.ok){let e=await t.json().catch(()=>null);v((null==e?void 0:e.message)||"发送失败(HTTP ".concat(t.status,")"));return}C(e),S({email:e,step:"code"}),I(),m("验证码已发送,请查收邮件")},D=async()=>{if(!/^\d{6}$/.test(N.trim())){v("请输入 6 位数字验证码");return}o(!0),v(null);let e=await fetch("".concat((0,s.tQ)(),"/auth/email/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:j.trim().toLowerCase(),code:N.trim()})});if(o(!1),!e.ok){let t=await e.json().catch(()=>null);v((null==t?void 0:t.message)||"验证失败(HTTP ".concat(e.status,")"));return}C(j.trim().toLowerCase()),k(),t()};return(0,l.jsxs)("div",{children:["email"===w?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"email",autoFocus:!0,value:j,onFocus:e=>e.target.select(),onChange:e=>S({email:e.target.value}),onBlur:e=>S({email:e.target.value.trim().toLowerCase()}),placeholder:"you@example.com",className:"mb-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,l.jsx)("button",{onClick:P,disabled:i,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:i?"发送中…":"发送验证码"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mb-2 text-left text-xs text-gray-500",children:["验证码已发送至 ",j,",请查收邮件"]}),(0,l.jsx)("input",{type:"text",inputMode:"numeric",autoFocus:!0,maxLength:6,value:N,onChange:e=>S({code:e.target.value}),placeholder:"6 位验证码",className:"mb-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm tracking-widest"}),(0,l.jsx)("button",{onClick:D,disabled:i,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:i?"登录中…":"登录"}),(0,l.jsxs)("div",{className:"mt-2 flex items-center justify-between text-xs",children:[(0,l.jsx)("button",{onClick:P,disabled:i||c>0,className:"text-gray-400 hover:text-gray-600 disabled:text-gray-300",children:c>0?"重新发送(".concat(c,"s)"):"重新发送"}),(0,l.jsx)("button",{onClick:()=>{S({step:"email",code:""}),v(null)},className:"text-gray-400 hover:text-gray-600",children:"返回修改邮箱"})]})]}),d&&(0,l.jsx)("div",{className:"mt-2 text-xs text-green-600",children:d}),x&&(0,l.jsx)("div",{className:"mt-2 text-xs text-red-500",children:x})]})}function p(e){let{onClose:t,onDone:n}=e;return(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",children:(0,l.jsxs)("div",{className:"w-80 rounded-xl bg-white p-5 shadow-xl",children:[(0,l.jsx)("h3",{className:"mb-3 text-base font-semibold text-gray-900",children:"邮箱验证码登录"}),(0,l.jsx)(v,{onDone:n}),(0,l.jsx)("button",{onClick:t,className:"mt-2 w-full py-1 text-xs text-gray-400 hover:text-gray-600",children:"关闭"})]})})}var j=n(71873);function w(e){let{children:t}=e;return(0,c.K5)()?(0,l.jsx)(j.D,{children:t}):(0,l.jsx)(N,{children:t})}function N(e){let{children:t}=e,{authStatus:n,refreshing:a,loadError:r,refresh:i}=(0,s.nu)();return r&&"loading"===n?(0,l.jsxs)(S,{children:[(0,l.jsxs)("div",{className:"text-sm text-red-500",children:[r,"(本地服务未启动?)"]}),(0,l.jsx)("button",{onClick:()=>void i(),className:"mt-4 rounded-lg bg-blue-600 px-4 py-2 text-sm text-white hover:bg-blue-700",children:"重试"})]}):"loading"===n?(0,l.jsxs)(S,{children:[(0,l.jsx)("span",{className:"hm-spinner","aria-label":"加载中"}),(0,l.jsx)("div",{className:"mt-4 text-sm text-gray-400",children:"正在加载,请稍候…"})]}):"out"===n?(0,l.jsx)("div",{className:"flex h-screen w-screen flex-col items-center justify-center bg-gray-50",children:(0,l.jsxs)("div",{className:"w-80 rounded-2xl border border-gray-200 bg-white p-8 text-center shadow-sm",children:[(0,l.jsx)("div",{className:"mb-2 text-3xl",children:"\uD83E\uDD1D"}),(0,l.jsx)("div",{className:"mb-1 text-lg font-semibold text-gray-900",children:"HunterMate"}),(0,l.jsx)("div",{className:"mb-4 text-xs text-gray-400",children:"登录后,你的数据在任何设备同步"}),r&&(0,l.jsx)("div",{className:"mb-3 text-xs text-red-500",children:r}),a&&(0,l.jsxs)("div",{className:"mb-3 flex items-center justify-center gap-2 rounded-lg bg-blue-50 py-2 text-sm text-blue-600",children:[(0,l.jsx)("span",{className:"hm-spinner hm-spinner-sm","aria-label":"加载中"}),"登录中,正在加载你的数据…"]}),(0,l.jsx)(v,{onDone:()=>{i()}})]})}):(0,l.jsxs)(l.Fragment,{children:[a&&(0,l.jsx)(C,{}),t]})}function S(e){let{children:t}=e;return(0,l.jsx)("div",{className:"flex h-screen w-screen flex-col items-center justify-center bg-gray-50",children:t})}function C(){let[e,t]=(0,r.useState)(!1);return((0,r.useEffect)(()=>{let e=setTimeout(()=>t(!0),250);return()=>clearTimeout(e)},[]),e)?(0,l.jsx)("div",{className:"hm-top-bar","aria-hidden":!0}):null}var k=n(55589);function I(){let e=(0,r.useSyncExternalStore)(i.mn,i.nk,()=>null),{session:t,sync:n,refresh:a}=(0,s.nu)(),[o,c]=(0,r.useState)(""),[u,d]=(0,r.useState)(""),[m,x]=(0,r.useState)("email"),[h,f]=(0,r.useState)(!1),[y,g]=(0,r.useState)(null),[b,v]=(0,r.useState)(!1),[p,j]=(0,r.useState)(0),w=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(e){var n;x("email"),c(null!==(n=null==t?void 0:t.email)&&void 0!==n?n:""),d(""),g(null),v(!1),j(0)}w.current&&clearInterval(w.current)},[null==e?void 0:e.message]);let N=(0,r.useRef)(!1);if((0,r.useEffect)(()=>{var e;if(!(null==n?void 0:n.authFailed)){N.current=!1;return}!N.current&&((0,i.nk)()||(N.current=!0,(0,i.jr)({message:"登录态已失效,需要登录才可以继续使用",oldUserId:null!==(e=null==t?void 0:t.hmUserId)&&void 0!==e?e:null,retry:async()=>(await a(),!0)})))},[null==n?void 0:n.authFailed,null==t?void 0:t.hmUserId,a]),(0,r.useEffect)(()=>()=>{w.current&&clearInterval(w.current)},[]),!e)return null;let S=()=>{j(60),w.current&&clearInterval(w.current),w.current=setInterval(()=>{j(e=>(e<=1&&w.current&&clearInterval(w.current),Math.max(0,e-1)))},1e3)},C=async()=>{if(!o.includes("@")){g("请输入有效邮箱");return}f(!0),g(null);try{let e=await fetch("".concat((0,s.tQ)(),"/auth/email/send-code"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o})});if(!e.ok){let t=await e.json().catch(()=>null);g((null==t?void 0:t.message)||"发送失败(HTTP ".concat(e.status,")"));return}x("code"),S()}finally{f(!1)}},k=async()=>{if(!/^\d{4,8}$/.test(u)){g("请输入验证码(4-8 位数字)");return}f(!0),g(null);try{var t;let n=await fetch("".concat((0,s.tQ)(),"/auth/email/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,code:u})}),l=await n.json().catch(()=>null);if(!n.ok||!(null==l?void 0:l.access_token)){g((null==l?void 0:l.message)||"验证失败(HTTP ".concat(n.status,")"));return}let r=(0,i.H7)(l.access_token),c=null!==(t=e.oldUserId)&&void 0!==t?t:null;if(null!=c&&null!=r&&c!==r){window.location.reload();return}v(!0),(0,i.qd)(),await a(),await e.retry()||v(!1)}finally{f(!1)}};return(0,l.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40",children:(0,l.jsxs)("div",{className:"w-80 rounded-xl bg-white p-5 shadow-xl",children:[(0,l.jsx)("h3",{className:"text-base font-semibold text-gray-900",children:"登录已过期"}),(0,l.jsxs)("p",{className:"mt-1 text-xs text-gray-500",children:[e.message,"。重新登录后将自动继续刚才的操作;若登录其他账号,页面将重新加载。"]}),b?(0,l.jsx)("div",{className:"mt-4 rounded bg-blue-50 p-3 text-sm text-blue-700",children:"正在继续刚才的操作…"}):(0,l.jsx)(l.Fragment,{children:"email"===m?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"email",autoFocus:!0,value:o,onChange:e=>c(e.target.value),placeholder:"you@example.com",className:"mb-3 mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm"}),(0,l.jsx)("button",{onClick:C,disabled:h,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:h?"发送中…":"发送验证码"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mb-2 mt-3 text-xs text-gray-500",children:["验证码已发送至 ",o,",请查收邮件后输入"]}),(0,l.jsx)("input",{type:"text",inputMode:"numeric",autoFocus:!0,value:u,onChange:e=>d(e.target.value),placeholder:"6 位验证码",className:"mb-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm tracking-widest"}),(0,l.jsx)("button",{onClick:k,disabled:h,className:"w-full rounded-lg bg-blue-600 py-2 text-sm text-white hover:bg-blue-700 disabled:opacity-50",children:h?"验证中…":"登录并继续"}),(0,l.jsx)("button",{type:"button",onClick:C,disabled:h||p>0,className:"mt-2 w-full rounded-lg border border-blue-600 py-1.5 text-sm text-blue-600 disabled:border-gray-300 disabled:text-gray-400",children:p>0?"".concat(p,"s 后重发"):"重发验证码"}),(0,l.jsx)("button",{onClick:()=>{x("email"),g(null)},className:"mt-1 w-full py-1 text-xs text-gray-400 hover:text-gray-600",children:"返回修改邮箱"})]})}),y&&(0,l.jsx)("div",{className:"mt-2 text-xs text-red-500",children:y}),!b&&(0,l.jsx)("button",{onClick:i.qd,className:"mt-2 w-full py-1 text-xs text-gray-400 hover:text-gray-600",children:"取消(放弃本次操作)"})]})})}var T=n(88801);let P=[{key:"delivery",label:"交付",icon:"\uD83C\uDFAF"},{key:"bd",label:"BD",icon:"\uD83E\uDDED"}];function D(){let e=(0,T.mJ)();return(0,l.jsx)("div",{className:"mx-2 mb-2 rounded-lg bg-gray-100 p-1",title:"角色视角:列表与详情按视角展示内容,记住上次选择",children:(0,l.jsx)("div",{className:"grid grid-cols-2 gap-1",children:P.map(t=>{let n=e===t.key;return(0,l.jsxs)("button",{type:"button",onClick:()=>(0,T.hm)(t.key),className:"rounded-md px-2 py-1.5 text-xs font-medium transition ".concat(n?"bg-white shadow-sm":"text-gray-500 hover:text-gray-700"),style:n?{color:"var(--brand-strong)"}:void 0,children:[t.icon," ",t.label]},t.key)})})})}let E=null,_=[{href:"/",label:"仪表盘",icon:"\uD83D\uDCCA"},{href:"/talents",label:"人才",icon:"\uD83D\uDC64"},{href:"/jobs",label:"职位",icon:"\uD83D\uDCBC"},{href:"/companies",label:"公司",icon:"\uD83C\uDFE2"},{href:"/parselog",label:"解析日志",icon:"\uD83D\uDCCB"},{href:"/recordings",label:"录制",icon:"\uD83D\uDD34"},{href:"/resource-usage",label:"资源占用",icon:"\uD83D\uDCBD"},{href:"/team/insights",label:"团队统计",icon:"\uD83D\uDCC8"},{href:"/memory",label:"记忆与知识",icon:"\uD83E\uDDE0"}];function O(){var e,t,n,i;let o=(0,a.usePathname)()||"/",{sync:c,utoken:u}=(0,s.nu)();(0,r.useEffect)(()=>(0,T.oU)(),[]);let m=(0,s.cp)(c),x=(0,s.Cd)(c,m),h=null!==(n=null===(e=(null!==(t=null==c?void 0:c.pendingCounts)&&void 0!==t?t:[]).find(e=>e.tenantId===m))||void 0===e?void 0:e.count)&&void 0!==n?n:0,[f,y]=(0,r.useState)(null!==(i=null==E?void 0:E.isAdmin)&&void 0!==i&&i);return(0,r.useEffect)(()=>{if(!u){y(!1);return}if((null==E?void 0:E.utoken)===u){y(E.isAdmin);return}let e=!1;return(async()=>{try{let t=await fetch("/admin/entities?pageSize=1&hmUserId=1",{headers:{Authorization:"UTOKEN ".concat(u)}}),n=403!==t.status&&401!==t.status;E={utoken:u,isAdmin:n},e||y(n)}catch(t){e||y(!1)}})(),()=>{e=!0}},[u]),(0,l.jsxs)("aside",{className:"flex h-screen w-56 flex-col border-r border-gray-200 bg-white",style:{borderTopColor:"var(--brand)"},children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 border-b border-gray-200 px-4 py-3",style:{boxShadow:"inset 3px 0 0 var(--brand)"},children:[(0,l.jsx)("span",{className:"text-xl",children:"\uD83E\uDD1D"}),(0,l.jsx)("span",{className:"font-semibold text-gray-900",children:"HunterMate"})]}),(0,l.jsxs)("nav",{className:"flex-1 overflow-auto py-3",children:[_.map(e=>{let t=o===e.href||o.startsWith("".concat(e.href,"/"));return(0,l.jsxs)(k.default,{href:e.href,className:"mx-2 flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors ".concat(t?"hm-active":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"),children:[(0,l.jsx)("span",{className:"text-base",children:e.icon}),e.label]},e.href)}),null!=m&&("owner"===x||"admin"===x)&&(0,l.jsxs)(k.default,{href:"/company/admin",className:"mx-2 flex items-center justify-between rounded-lg px-3 py-2 text-sm transition-colors ".concat(o.startsWith("/company/admin")?"hm-active":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"),children:[(0,l.jsxs)("span",{className:"flex items-center gap-3",children:[(0,l.jsx)("span",{className:"text-base",children:"⚙️"}),"企业管理"]}),h>0&&(0,l.jsx)("span",{className:"rounded-full bg-red-500 px-1.5 text-[10px] leading-4 text-white",children:h>99?"99+":h})]}),f&&(0,l.jsxs)(k.default,{href:"/admin/data",className:"mx-2 flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors ".concat(o.startsWith("/admin")?"hm-active":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"),children:[(0,l.jsx)("span",{className:"text-base",children:"\uD83E\uDDF9"}),"数据管理"]})]}),(0,l.jsx)(D,{}),(0,l.jsx)(d,{}),(0,l.jsx)(I,{})]})}var $=n(60662);function M(){return(M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e}).apply(this,arguments)}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=Array(t);n<t;n++)l[n]=e[n];return l}var U=function(e){var t,n=(function(e){if(Array.isArray(e))return e}(t=(0,r.useState)(function(){return(0,$.Df)()}))||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var l,a,r,s,i=[],o=!0,c=!1;try{for(r=(n=n.call(e)).next;!(o=(l=r.call(n)).done)&&(i.push(l.value),1!==i.length);o=!0);}catch(e){c=!0,a=e}finally{try{if(!o&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw a}}return i}}(t,1)||function(e,t){if(e){if("string"==typeof e)return A(e,1);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,1)}}(t,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,a.useServerInsertedHTML)(function(){var e=(0,$.EN)(n,{plain:!0,once:!0});return e.includes('.data-ant-cssinjs-cache-path{content:"";}')?null:r.createElement("style",{id:"antd-cssinjs","data-rc-order":"prepend","data-rc-priority":"-1000",dangerouslySetInnerHTML:{__html:e}})}),r.createElement($.V9,M({},e,{cache:n}))},F=n(12502),H=n(26499);function J(e){let{children:t}=e;return(0,l.jsx)(U,{children:(0,l.jsx)(F.ZP,{locale:H.Z,children:t})})}function R(e){let{children:t}=e;return"/login"===(0,a.usePathname)()?(0,l.jsx)(J,{children:t}):(0,l.jsx)(w,{children:(0,l.jsxs)(J,{children:[(0,l.jsx)(O,{}),t]})})}},65777:function(e,t,n){"use strict";let l;n.d(t,{Cd:function(){return D},Xc:function(){return _},aG:function(){return T},cp:function(){return P},nu:function(){return I},tQ:function(){return E}});var a=n(60635),r=n(74431),s=n(67002),i=n(33447),o=n(21260),c=n(28431),u=n(60529);let d=null,m=null,x=null,h=new Set;function f(){h.forEach(e=>e())}function y(e){d=d?{...d,refreshing:e}:{...S,refreshing:e},f()}function g(e){if(void 0===l){l=e;return}if(e!==l){l=e;try{window.localStorage.removeItem("hm-view-mode")}catch(e){}}}async function b(){try{return await (0,r.requestJson)("/auth/session")}catch(e){return null}}async function v(e){let t=new Headers,n=(0,s.Xc)();n&&t.set("Authorization","UTOKEN ".concat(n));try{return await (0,r.requestJson)(e,{headers:t})}catch(e){return null}}async function p(){y(!0);try{var e,t,n,l,a,s,i,u,m;let x=(0,o.xq)();if(!x){(0,c.nZ)(),d={...S,session:{loggedIn:!1},refreshing:!1,authStatus:"out"},f();return}let h=await (0,r.requestJson)("/hunter-mate/sync/state?heads=0");(0,c.YZ)(null!==(e=h.activeTenantId)&&void 0!==e?e:null);let y=(0,o.OG)(x);g(null!==(n=null!==(t=h.hmUserId)&&void 0!==t?t:y.hmUserId)&&void 0!==n?n:null),d={session:{loggedIn:!0,email:null!==(l=y.email)&&void 0!==l?l:void 0,hmUserId:null!==(s=null!==(a=h.hmUserId)&&void 0!==a?a:y.hmUserId)&&void 0!==s?s:void 0,token:x},sync:{loggedIn:!0,enabled:!0,activeTenantId:(0,c.MA)(),serverSuggestedTenantId:null!==(i=h.activeTenantId)&&void 0!==i?i:null,memberships:null!==(u=h.memberships)&&void 0!==u?u:[],pendingCounts:null!==(m=h.pendingCounts)&&void 0!==m?m:[]},utoken:x,loadError:null,refreshing:!1,authStatus:"in",refresh:w},f()}catch(e){d=d?{...d,loadError:"云端无响应"}:{...S,loadError:"云端无响应"},f()}finally{(null==d?void 0:d.refreshing)&&y(!1)}}async function j(){if((0,i.K5)())return p();y(!0);try{var e;let[t,n]=await Promise.all([b(),v("/datasync/state")]),l=(null==t?void 0:t.loggedIn)&&t.token?t.token:null,a=null!=n?n:null;!a&&t&&l&&l!==(0,s.Xc)()?((0,s.GK)(l),a=await v("/datasync/state")):(0,s.GK)(l),g((null==t?void 0:t.loggedIn)&&null!==(e=t.hmUserId)&&void 0!==e?e:null);let r=!!((null==t?void 0:t.loggedIn)||(null==a?void 0:a.loggedIn));if(!t&&!a){d=d?{...d,loadError:"本地服务无响应"}:{...S,loadError:"本地服务无响应"},f();return}d={session:null!=t?t:{loggedIn:!1},sync:a,utoken:(0,s.Xc)(),loadError:null,refreshing:!1,authStatus:r?"in":"out",refresh:w},f()}finally{(null==d?void 0:d.refreshing)&&y(!1)}}function w(){return m||(m=j().finally(()=>{m=null}))}function N(e){return h.add(e),1===h.size&&(w(),x=setInterval(()=>void w(),6e4)),()=>{h.delete(e),0===h.size&&x&&(clearInterval(x),x=null)}}let S={session:null,sync:null,utoken:null,loadError:null,refreshing:!1,authStatus:"loading",refresh:w};function C(){return null!=d?d:S}function k(){return C()}function I(){return(0,a.useSyncExternalStore)(N,C,k)}function T(e){var t;return(null!==(t=null==e?void 0:e.memberships)&&void 0!==t?t:[]).filter(e=>!e.isPersonal&&!e.leftAt)}function P(e){var t,n;let l=null!==(t=null==e?void 0:e.activeTenantId)&&void 0!==t?t:null;if(null==l)return null;let a=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===l&&!e.leftAt);return!a||a.isPersonal?null:l}function D(e,t){var n,l;if(!t)return null;let a=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===t&&!e.leftAt&&!e.isPersonal);return null!==(l=null==a?void 0:a.role)&&void 0!==l?l:null}function E(){return u.env.NEXT_PUBLIC_HUNTER_MATE_SERVER_URL||""}function _(){return(0,s.Xc)()}},4025:function(e,t,n){"use strict";n.d(t,{k:function(){return c}});var l=n(33447),a=n(21260),r=n(28431),s=n(26416),i=n(67002),o=n(60529);async function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Headers(t.headers);if(n.has("Content-Type")||n.set("Content-Type","application/json"),(0,l.K5)()){var c,u;let i=(0,a.xq)();i&&n.set("Authorization","HMJWT ".concat(i));let o=(0,r.MA)();null!==o&&n.set("x-hm-active-tenant",String(o));let d=(0,s._)(null!==(c=t.method)&&void 0!==c?c:"GET",e);if(null===d)throw new s.e(null!==(u=t.method)&&void 0!==u?u:"GET",e);return fetch("".concat((0,l.XJ)()).concat(d.path),{...t,headers:n,cache:"no-store"})}let d=(0,i.Xc)();return d&&n.set("Authorization","UTOKEN ".concat(d)),fetch("".concat(o.env.HUNTER_MATE_SERVER_URL||"").concat(e),{...t,headers:n})}},82182:function(e,t,n){"use strict";n.d(t,{H7:function(){return u},jr:function(){return s},mn:function(){return c},nk:function(){return o},qd:function(){return i}});let l=null,a=new Set;function r(){a.forEach(e=>e())}function s(e){l=e,r()}function i(){l&&(l=null,r())}function o(){return l}function c(e){return a.add(e),()=>a.delete(e)}function u(e){if(!e)return null;try{var t,n,l,a,r;let s=e.split(".")[1],i=JSON.parse(decodeURIComponent(escape(atob(s.replace(/-/g,"+").replace(/_/g,"/"))))),o=null!==(r=null!==(a=null!==(l=null==i?void 0:null===(t=i.data)||void 0===t?void 0:t._id)&&void 0!==l?l:null==i?void 0:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==a?a:null==i?void 0:i.sub)&&void 0!==r?r:null;return"number"==typeof o?o:null}catch(e){return null}}},88801:function(e,t,n){"use strict";n.d(t,{hm:function(){return c},mJ:function(){return d},oU:function(){return u}});var l=n(60635);let a="hm-view-mode",r=new Set;function s(){return"bd"===window.localStorage.getItem(a)?"bd":"delivery"}function i(e){return r.add(e),()=>r.delete(e)}function o(e){"undefined"!=typeof document&&(document.documentElement.dataset.view=e)}function c(e){window.localStorage.setItem(a,e),o(e),r.forEach(e=>e())}function u(){o(s())}function d(e){let t=(0,l.useSyncExternalStore)(i,s,()=>"delivery");return null!=e?e:t}},20166:function(){},61115:function(){},50129:function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports}},function(e){e.O(0,[633,502,589,431,400,935,744],function(){return e(e.s=866)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="da1c0d84-0fe1-45db-b78a-807fcdf5a424",e._sentryDebugIdIdentifier="sentry-dbid-da1c0d84-0fe1-45db-b78a-807fcdf5a424")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[872],{80368:function(e,t,n){Promise.resolve().then(n.bind(n,69406))},69406:function(e,t,n){"use strict";n.d(t,{default:function(){return x}});var l=n(72835),s=n(60635),r=n(74431),a=n(67002),d=n(65777);let i=[{key:"mine",label:"\uD83D\uDC64 我的记忆"},{key:"tenant",label:"\uD83C\uDFE2 团队知识"},{key:"system",label:"\uD83C\uDF10 平台知识"},{key:"cloud",label:"☁️ 云端状态"}],o={lesson:"教训",fact:"事实",preference:"偏好",sop_delta:"SOP 修订"},c={lesson:"\uD83D\uDCCC",fact:"\uD83D\uDD0E",preference:"⚙️",sop_delta:"\uD83D\uDCDD"},u={active:{label:"生效",cls:"bg-emerald-100 text-emerald-700"},candidate:{label:"候选",cls:"bg-amber-100 text-amber-700"},quarantined:{label:"已隔离",cls:"bg-red-100 text-red-700"},deprecated:{label:"已废弃",cls:"bg-gray-100 text-gray-400"}};function m(e){var t,n;let{e:s,editable:r}=e,a=null!==(t=u[s.status])&&void 0!==t?t:u.active;return(0,l.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white p-3 shadow-sm",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,l.jsx)("span",{title:o[s.kind],children:c[s.kind]}),(0,l.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs ".concat(a.cls),children:a.label}),null!=s.corroborationUsers&&s.corroborationUsers>0&&(0,l.jsxs)("span",{className:"rounded bg-blue-50 px-1.5 py-0.5 text-xs text-blue-700",children:["★佐证 ",s.corroborationUsers," 人 \xd7 ",null!==(n=s.corroborationSessions)&&void 0!==n?n:0," 会话"]}),"candidate"===s.status&&null!=s.corroborationUsers&&(0,l.jsxs)("span",{className:"rounded bg-amber-50 px-1.5 py-0.5 text-xs text-amber-700",children:["佐证 ",s.corroborationUsers,"/4 人"]})]}),(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-1 text-xs",children:[r&&"deprecated"!==s.status&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{className:"rounded px-2 py-1 text-gray-600 hover:bg-gray-100",onClick:()=>{var t;return null===(t=e.onEdit)||void 0===t?void 0:t.call(e,s)},children:"✎ 编辑"}),(0,l.jsx)("button",{className:"rounded px-2 py-1 text-red-600 hover:bg-red-50",onClick:()=>{var t;return null===(t=e.onDelete)||void 0===t?void 0:t.call(e,s)},children:"\uD83D\uDDD1 删除"})]}),e.onFeedback&&"quarantined"!==s.status&&"deprecated"!==s.status&&(0,l.jsx)("button",{className:"rounded px-2 py-1 text-orange-600 hover:bg-orange-50",title:"举报错误记忆 → 隔离待审",onClick:()=>{var t;return null===(t=e.onFeedback)||void 0===t?void 0:t.call(e,s)},children:"⚑ 纠错"})]})]}),(0,l.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-sm text-gray-800",children:s.content}),(0,l.jsxs)("p",{className:"mt-2 text-xs text-gray-400",children:[o[s.kind]," \xb7 更新于 ",function(e){let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString("zh-CN",{hour12:!1})}(s.updatedAt),s.feedbackCount>0?" \xb7 被纠错 ".concat(s.feedbackCount," 次"):""]})]})}function x(){var e;let[t,n]=(0,s.useState)("mine"),{utoken:c}=(0,d.nu)(),[u,x]=(0,s.useState)(null),[g,h]=(0,s.useState)(null),[b,f]=(0,s.useState)(null),[p,v]=(0,s.useState)(null),[y,N]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[D,k]=(0,s.useState)(""),[C,E]=(0,s.useState)(null),[S,I]=(0,s.useState)(""),_=(0,s.useCallback)(async()=>{if(c){w(null);try{let[e,t,n,l]=await Promise.all([Promise.all(["active","candidate","quarantined"].map(e=>(0,r.requestJson)("/memory?scope=user&status=".concat(e,"&limit=200")))),(0,r.requestJson)("/memory?scope=tenant&limit=200"),(0,r.requestJson)("/memory?scope=system&limit=200"),(0,r.requestJson)("/memory/context")]),s=new Set,a=[];for(let t of e)for(let e of t.items)s.has(e.id)||(s.add(e.id),a.push(e));a.sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)),x(a),h(t.items),f(n.items),v(l),N(new Date)}catch(e){w(e instanceof Error?e.message:String(e))}}},[c]);(0,s.useEffect)(()=>{let e=!1;(async()=>{e||await _()})();let t=(0,a.Lc)(()=>{e||_()});return()=>{e=!0,t()}},[_]);let q=(0,s.useMemo)(()=>(null!=u?u:[]).filter(e=>!D||e.kind===D),[u,D]),T=async()=>{if(C&&S.trim())try{await (0,r.requestJson)("/memory/".concat(C.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S.trim()})}),E(null),await _()}catch(e){w(e instanceof Error?e.message:String(e))}},U=async e=>{if(window.confirm("删除后不可恢复,确定删除这条个人记忆?"))try{await (0,r.requestJson)("/memory/".concat(e.id),{method:"DELETE"}),await _()}catch(e){w(e instanceof Error?e.message:String(e))}},J=async e=>{if(window.confirm("举报后该条将进入隔离待审,期间不再被检索到。确定举报?"))try{await (0,r.requestJson)("/memory/".concat(e.id,"/feedback"),{method:"POST"}),await _()}catch(e){w(e instanceof Error?e.message:String(e))}};return(0,l.jsx)("div",{className:"h-full overflow-auto p-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-4xl",children:[(0,l.jsx)("h1",{className:"mb-1 text-xl font-semibold",children:"\uD83E\uDDE0 记忆与知识"}),(0,l.jsx)("p",{className:"mb-4 text-sm text-gray-500",children:"个人积累自动沉淀,团队知识经佐证晋升,平台知识由全平台蒸馏而成。"}),(0,l.jsx)("div",{className:"mb-4 flex flex-wrap gap-2 border-b border-gray-200 pb-3",children:i.map(e=>(0,l.jsx)("button",{className:"rounded-lg px-3 py-1.5 text-sm ".concat(t===e.key?"bg-blue-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"),onClick:()=>n(e.key),children:e.label},e.key))}),j&&(0,l.jsxs)("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700",children:["⚠️ ",j,(0,l.jsx)("button",{className:"ml-2 underline",onClick:()=>void _(),children:"重试"})]}),"mine"===t&&(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,l.jsx)("span",{className:"text-gray-500",children:"筛选:"}),["","lesson","fact","preference","sop_delta"].map(e=>(0,l.jsx)("button",{className:"rounded px-2 py-1 text-xs ".concat(D===e?"bg-blue-100 text-blue-700":"bg-gray-100 text-gray-600 hover:bg-gray-200"),onClick:()=>k(e),children:""===e?"全部":o[e]},e||"all")),(0,l.jsxs)("span",{className:"ml-auto text-xs text-gray-400",children:["共 ",q.length," 条",y?" \xb7 更新于 ".concat(y.toLocaleTimeString("zh-CN",{hour12:!1})):""]})]}),null===u?(0,l.jsx)("p",{className:"py-10 text-center text-sm text-gray-400",children:"加载中…"}):0===q.length?(0,l.jsxs)("div",{className:"rounded-lg border border-dashed border-gray-300 p-10 text-center text-sm text-gray-400",children:["完成几次寻访任务后,这里会自动积累你的偏好与教训。",(0,l.jsx)("br",{}),"会话收尾时说「记忆候选: …」也会进入候选池,佐证后生效。"]}):q.map(e=>(0,l.jsx)(m,{e:e,editable:"user"===e.scope,onEdit:e=>{E(e),I(e.content)},onDelete:e=>void U(e),onFeedback:e=>void J(e)},e.id))]}),"tenant"===t&&(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("p",{className:"rounded-lg bg-blue-50 p-3 text-xs text-blue-700",children:"团队知识由候选经多人佐证晋升,全员只读。发现错误请点 ⚑ 纠错,隔离后运营会复核。"}),null===g?(0,l.jsx)("p",{className:"py-10 text-center text-sm text-gray-400",children:"加载中…"}):0===g.length?(0,l.jsx)("div",{className:"rounded-lg border border-dashed border-gray-300 p-10 text-center text-sm text-gray-400",children:"本租户还没有团队知识。多人在不同任务里写下同一条经验,佐证达标后自动晋升到这里。"}):g.map(e=>(0,l.jsx)(m,{e:e,editable:!1,onFeedback:e=>void J(e)},e.id))]}),"system"===t&&(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("p",{className:"rounded-lg bg-purple-50 p-3 text-xs text-purple-700",children:"平台知识由全平台多租户蒸馏 + 脱敏 + 人工审批产生,只读。修改诉求走团队知识提交候选,蒸馏后回流。"}),null===b?(0,l.jsx)("p",{className:"py-10 text-center text-sm text-gray-400",children:"加载中…"}):0===b.length?(0,l.jsx)("div",{className:"rounded-lg border border-dashed border-gray-300 p-10 text-center text-sm text-gray-400",children:"还没有平台级知识。跨 ≥3 个租户反复验证的经验蒸馏后会出现在这里。"}):b.map(e=>(0,l.jsx)(m,{e:e,editable:!1,onFeedback:e=>void J(e)},e.id))]}),"cloud"===t&&(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[["\uD83D\uDC64 个人层",null==p?void 0:p.user],["\uD83C\uDFE2 租户层",null==p?void 0:p.tenant],["\uD83C\uDF10 系统层",null==p?void 0:p.system]].map(e=>{var t;let[n,s]=e;return(0,l.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:[(0,l.jsx)("p",{className:"mb-1 font-medium",children:n}),(0,l.jsx)("p",{className:"text-2xl font-semibold text-gray-800",children:null!==(t=null==s?void 0:s.length)&&void 0!==t?t:"—"}),(0,l.jsx)("p",{className:"text-xs text-gray-400",children:"注入上下文条数(含候选)"})]},n)})}),(0,l.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:[(0,l.jsx)("p",{className:"mb-2 font-medium",children:"我的候选队列"}),null===u?(0,l.jsx)("p",{className:"text-gray-400",children:"加载中…"}):(0,l.jsxs)("div",{className:"flex gap-6 text-xs",children:[(0,l.jsxs)("span",{children:["待佐证/生效 ",u.filter(e=>"candidate"===e.status).length," 条"]}),(0,l.jsxs)("span",{className:"text-emerald-700",children:["已生效 ",u.filter(e=>"active"===e.status).length," 条"]}),(0,l.jsxs)("span",{className:"text-red-700",children:["被隔离 ",u.filter(e=>"quarantined"===e.status).length," 条"]})]})]}),(0,l.jsxs)("p",{className:"text-xs text-gray-400",children:[y?"最近拉取:".concat(y.toLocaleString("zh-CN",{hour12:!1})," \xb7 上下文预算 ").concat(null!==(e=null==p?void 0:p.budgetChars)&&void 0!==e?e:"—"," 字符"):"尚未拉取",(0,l.jsx)("button",{className:"ml-2 underline",onClick:()=>void _(),children:"刷新"})]})]}),C&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-white p-4 shadow-xl",children:[(0,l.jsx)("p",{className:"mb-2 font-medium",children:"编辑记忆(版本会 +1)"}),(0,l.jsx)("textarea",{className:"h-32 w-full rounded border border-gray-300 p-2 text-sm",value:S,onChange:e=>I(e.target.value)}),(0,l.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,l.jsx)("button",{className:"rounded px-3 py-1.5 text-gray-600 hover:bg-gray-100",onClick:()=>E(null),children:"取消"}),(0,l.jsx)("button",{className:"rounded bg-blue-600 px-3 py-1.5 text-white hover:bg-blue-700",onClick:()=>void T(),children:"保存"})]})]})})]})})}},65777:function(e,t,n){"use strict";let l;n.d(t,{Cd:function(){return _},Xc:function(){return T},aG:function(){return S},cp:function(){return I},nu:function(){return E},tQ:function(){return q}});var s=n(60635),r=n(74431),a=n(67002),d=n(33447),i=n(21260),o=n(28431),c=n(60529);let u=null,m=null,x=null,g=new Set;function h(){g.forEach(e=>e())}function b(e){u=u?{...u,refreshing:e}:{...D,refreshing:e},h()}function f(e){if(void 0===l){l=e;return}if(e!==l){l=e;try{window.localStorage.removeItem("hm-view-mode")}catch(e){}}}async function p(){try{return await (0,r.requestJson)("/auth/session")}catch(e){return null}}async function v(e){let t=new Headers,n=(0,a.Xc)();n&&t.set("Authorization","UTOKEN ".concat(n));try{return await (0,r.requestJson)(e,{headers:t})}catch(e){return null}}async function y(){b(!0);try{var e,t,n,l,s,a,d,c,m;let x=(0,i.xq)();if(!x){(0,o.nZ)(),u={...D,session:{loggedIn:!1},refreshing:!1,authStatus:"out"},h();return}let g=await (0,r.requestJson)("/hunter-mate/sync/state?heads=0");(0,o.YZ)(null!==(e=g.activeTenantId)&&void 0!==e?e:null);let b=(0,i.OG)(x);f(null!==(n=null!==(t=g.hmUserId)&&void 0!==t?t:b.hmUserId)&&void 0!==n?n:null),u={session:{loggedIn:!0,email:null!==(l=b.email)&&void 0!==l?l:void 0,hmUserId:null!==(a=null!==(s=g.hmUserId)&&void 0!==s?s:b.hmUserId)&&void 0!==a?a:void 0,token:x},sync:{loggedIn:!0,enabled:!0,activeTenantId:(0,o.MA)(),serverSuggestedTenantId:null!==(d=g.activeTenantId)&&void 0!==d?d:null,memberships:null!==(c=g.memberships)&&void 0!==c?c:[],pendingCounts:null!==(m=g.pendingCounts)&&void 0!==m?m:[]},utoken:x,loadError:null,refreshing:!1,authStatus:"in",refresh:j},h()}catch(e){u=u?{...u,loadError:"云端无响应"}:{...D,loadError:"云端无响应"},h()}finally{(null==u?void 0:u.refreshing)&&b(!1)}}async function N(){if((0,d.K5)())return y();b(!0);try{var e;let[t,n]=await Promise.all([p(),v("/datasync/state")]),l=(null==t?void 0:t.loggedIn)&&t.token?t.token:null,s=null!=n?n:null;!s&&t&&l&&l!==(0,a.Xc)()?((0,a.GK)(l),s=await v("/datasync/state")):(0,a.GK)(l),f((null==t?void 0:t.loggedIn)&&null!==(e=t.hmUserId)&&void 0!==e?e:null);let r=!!((null==t?void 0:t.loggedIn)||(null==s?void 0:s.loggedIn));if(!t&&!s){u=u?{...u,loadError:"本地服务无响应"}:{...D,loadError:"本地服务无响应"},h();return}u={session:null!=t?t:{loggedIn:!1},sync:s,utoken:(0,a.Xc)(),loadError:null,refreshing:!1,authStatus:r?"in":"out",refresh:j},h()}finally{(null==u?void 0:u.refreshing)&&b(!1)}}function j(){return m||(m=N().finally(()=>{m=null}))}function w(e){return g.add(e),1===g.size&&(j(),x=setInterval(()=>void j(),6e4)),()=>{g.delete(e),0===g.size&&x&&(clearInterval(x),x=null)}}let D={session:null,sync:null,utoken:null,loadError:null,refreshing:!1,authStatus:"loading",refresh:j};function k(){return null!=u?u:D}function C(){return k()}function E(){return(0,s.useSyncExternalStore)(w,k,C)}function S(e){var t;return(null!==(t=null==e?void 0:e.memberships)&&void 0!==t?t:[]).filter(e=>!e.isPersonal&&!e.leftAt)}function I(e){var t,n;let l=null!==(t=null==e?void 0:e.activeTenantId)&&void 0!==t?t:null;if(null==l)return null;let s=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===l&&!e.leftAt);return!s||s.isPersonal?null:l}function _(e,t){var n,l;if(!t)return null;let s=(null!==(n=null==e?void 0:e.memberships)&&void 0!==n?n:[]).find(e=>e.tenantId===t&&!e.leftAt&&!e.isPersonal);return null!==(l=null==s?void 0:s.role)&&void 0!==l?l:null}function q(){return c.env.NEXT_PUBLIC_HUNTER_MATE_SERVER_URL||""}function T(){return(0,a.Xc)()}}},function(e){e.O(0,[431,400,935,744],function(){return e(e.s=80368)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4704ae34-93d6-40c9-9c94-5a2eca9e1eab",e._sentryDebugIdIdentifier="sentry-dbid-4704ae34-93d6-40c9-9c94-5a2eca9e1eab")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[788],{10793:function(e,t,s){Promise.resolve().then(s.bind(s,4895))},27473:function(e,t,s){"use strict";var r=s(38321);s.o(r,"useParams")&&s.d(t,{useParams:function(){return r.useParams}}),s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}}),s.o(r,"useServerInsertedHTML")&&s.d(t,{useServerInsertedHTML:function(){return r.useServerInsertedHTML}})},4895:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return N}});var r=s(72835),l=s(60635),n=s(27473),a=s(74431),c=s(37202),i=s(94518),o=s(63718),u=s(19036),d=s(55589),x=s(8448);let m={ok:"正常",empty:"关键字段为空","no-snapshot":"缺快照","no-rule":"无规则"},f={ok:"bg-green-50 text-green-700",empty:"bg-yellow-50 text-yellow-700","no-snapshot":"bg-red-50 text-red-700","no-rule":"bg-gray-100 text-gray-600"};function h(e){var t,s;let{item:l}=e;return(0,r.jsxs)("div",{className:"mx-auto max-w-4xl",children:[(0,r.jsx)(d.default,{href:"/parselog",className:"text-sm text-blue-600 hover:underline",children:"← 返回解析日志列表"}),(0,r.jsxs)("header",{className:"mt-4 mb-6",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("h1",{className:"text-2xl font-bold text-gray-900",children:["解析记录 #",l.id]}),(0,r.jsx)("span",{className:"rounded px-2 py-0.5 text-xs ".concat(f[l.status]),children:null!==(s=m[l.status])&&void 0!==s?s:l.status}),l.hasSnapshot?(0,r.jsx)("span",{className:"rounded bg-green-50 px-2 py-0.5 text-xs text-green-700",children:"有录制快照"}):null]}),(0,r.jsxs)("p",{className:"mt-1 text-sm text-gray-500",children:[l.domain," \xb7 ",l.pageClass," \xb7 ",(0,x.d3)(l.createdAt)]})]}),(0,r.jsxs)("section",{className:"rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,r.jsx)("h2",{className:"mb-3 text-lg font-semibold",children:"来源"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsx)("span",{className:"text-gray-500",children:"sessionId: "}),(0,r.jsx)("span",{className:"font-mono",children:l.sessionId})]}),(0,r.jsx)("a",{href:l.sourceUrl,target:"_blank",rel:"noreferrer",className:"break-all text-sm text-blue-600 hover:underline",children:l.sourceUrl}),l.entityId?(0,r.jsxs)("div",{className:"pt-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-500",children:"关联实体: "}),(0,r.jsxs)(d.default,{href:"/".concat(l.pageClass,"s?id=").concat(l.entityId),className:"text-sm text-blue-600 hover:underline",children:["#",l.entityId," (",l.pageClass,")"]})]}):null]})]}),l.extractedFields?(0,r.jsxs)("section",{className:"mt-4 rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,r.jsx)("h2",{className:"mb-3 text-lg font-semibold",children:"提取字段"}),(0,r.jsx)("pre",{className:"max-h-96 overflow-auto rounded bg-gray-50 p-3 text-xs text-gray-700",children:JSON.stringify(l.extractedFields,null,2)})]}):null,(null===(t=l.missingFields)||void 0===t?void 0:t.length)?(0,r.jsxs)("section",{className:"mt-4 rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,r.jsx)("h2",{className:"mb-3 text-lg font-semibold",children:"缺失字段(疑似站点改版)"}),(0,r.jsx)("ul",{className:"list-inside list-disc text-sm text-gray-700",children:l.missingFields.map(e=>(0,r.jsx)("li",{children:e},e))})]}):null]})}var g=s(12789),b=s(33447);let p=[{value:"ok",label:"正常"},{value:"empty",label:"关键字段为空"},{value:"no-snapshot",label:"缺快照"},{value:"no-rule",label:"无规则"}],v={ok:"bg-green-50 text-green-700",empty:"bg-yellow-50 text-yellow-700","no-snapshot":"bg-red-50 text-red-700","no-rule":"bg-gray-100 text-gray-600"};function y(e){let t=new URLSearchParams;Object.entries(e).forEach(e=>{let[s,r]=e;r&&t.set(s,r)});let s=t.toString();return s?"?".concat(s):""}function j(){let e=(0,n.useRouter)(),t=(0,n.usePathname)(),s=(0,n.useSearchParams)(),d=s.get("id")||"",m=(0,l.useMemo)(()=>({q:s.get("q")||"",status:s.get("status")||"",from:s.get("from")||"",to:s.get("to")||""}),[s]),[f,g]=(0,l.useState)(null),[b,j]=(0,l.useState)(!1),[N,w]=(0,l.useState)(null),[S,k]=(0,l.useState)(!0),[C,I]=(0,l.useState)(!1),[q,E]=(0,l.useState)(!1),[L,P]=(0,l.useState)(0),[M,R]=(0,l.useState)(0),_=(0,l.useCallback)(s=>{var r,l;let n=null!==(r=s.filters)&&void 0!==r?r:m,a=y({id:null!==(l=s.id)&&void 0!==l?l:d,q:n.q,status:n.status,from:n.from,to:n.to});e.replace("".concat(t).concat(a))},[m,d,t,e]),D=(0,l.useCallback)(()=>{R(e=>e+1)},[]),H=(0,l.useCallback)(()=>{let e=null==f?void 0:f.items[0];return null==e?void 0:e.createdAt},[f]);(0,l.useEffect)(()=>{k(!0),j(!1);let e=y({q:m.q,status:m.status,from:m.from,to:m.to});(0,a.requestJson)("/parse-log?limit=200".concat(e.replace("?","&"))).then(e=>{g(e)}).catch(()=>{j(!0)}).finally(()=>{k(!1)})},[m.q,m.status,m.from,m.to,M]),(0,l.useEffect)(()=>{if(!d){w(null),E(!1);return}I(!0),E(!1),(0,a.requestJson)("/parse-log/".concat(d)).then(e=>{w(e)}).catch(()=>{w(null),E(!0)}).finally(()=>{I(!1)})},[d,L]);let T=(0,l.useMemo)(()=>{var e;return(null!==(e=null==f?void 0:f.items)&&void 0!==e?e:[]).map(e=>({id:String(e.id),content:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs ".concat(v[e.status]),children:e.status}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:e.pageClass})]}),(0,r.jsx)("div",{className:"mt-0.5 text-sm font-medium text-gray-900",children:e.domain}),(0,r.jsx)("div",{className:"text-xs text-gray-400",children:(0,x.d3)(e.createdAt)})]})}))},[f]),O=d?C?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"加载中…"}):q?(0,r.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-red-500",children:["加载失败",(0,r.jsx)("button",{type:"button",onClick:()=>P(e=>e+1),className:"text-blue-500 hover:underline",children:"重试"})]}):N?(0,r.jsx)(h,{item:N}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-red-500",children:"未找到该解析日志"}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"请在左侧选择一条解析日志查看详情"});return(0,r.jsx)(i.m,{filterBar:(0,r.jsxs)("div",{className:"border-b border-gray-200 bg-white",children:[(0,r.jsx)(c.f,{value:m,showStatus:!0,statusOptions:p,onChange:e=>_({filters:e})}),f?(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 pb-2 text-xs text-gray-500",children:[(0,r.jsxs)("span",{children:["共 ",f.total," 条"]}),f.abnormal>0?(0,r.jsxs)("span",{className:"rounded bg-red-50 px-1.5 py-0.5 text-red-700",children:["异常 ",f.abnormal]}):null]}):null,(0,r.jsx)(u.Y,{pollUrl:"/parse-log/count",getLatestTimestamp:H,onRefresh:D,label:"解析日志"})]}),listPanel:b?(0,r.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-red-500",children:["加载失败",(0,r.jsx)("button",{type:"button",onClick:D,className:"text-blue-500 hover:underline",children:"重试"})]}):(0,r.jsx)(o.L,{items:T,selectedId:d,onSelect:e=>_({id:e}),loading:S,emptyText:"暂无解析日志"}),detailPanel:O})}function N(){return(0,b.K5)()?(0,r.jsx)(g.D,{feature:"解析日志",localPath:"/parselog"}):(0,r.jsx)(l.Suspense,{fallback:(0,r.jsx)("div",{className:"p-6 text-gray-500",children:"加载中…"}),children:(0,r.jsx)(j,{})})}},37202:function(e,t,s){"use strict";s.d(t,{f:function(){return a}});var r=s(72835),l=s(60635),n=s(78606);function a(e){let{value:t,showStatus:s,statusOptions:a,onChange:c}=e,[i,o]=(0,l.useState)(t);return(0,l.useEffect)(()=>{o(t)},[t.q,t.status,t.from,t.to]),(0,l.useEffect)(()=>{let e=setTimeout(()=>{(i.q!==t.q||i.status!==t.status||i.from!==t.from||i.to!==t.to)&&c(i)},300);return()=>clearTimeout(e)},[i.q,i.status,i.from,i.to]),(0,r.jsxs)("div",{className:"space-y-2 border-b border-gray-200 bg-white p-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",value:i.q,onChange:e=>o(t=>({...t,q:e.target.value})),placeholder:"搜索关键词...",className:"w-full rounded border border-gray-300 px-2 py-1.5 pr-8 text-sm outline-none focus:border-blue-500"}),(0,r.jsx)("button",{type:"button",onClick:()=>c({q:"",status:"",from:"",to:""}),title:"重置筛选",className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 disabled:opacity-30",disabled:!i.q&&!i.status&&!i.from&&!i.to,children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),s?(0,r.jsx)(n.Z,{size:"small",allowClear:!0,placeholder:"全部状态",style:{minWidth:130},value:i.status||void 0,onChange:e=>o(t=>({...t,status:null!=e?e:""})),options:(a||[]).map(e=>({value:e.value,label:e.label}))}):null]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"date",value:i.from,onChange:e=>o(t=>({...t,from:e.target.value})),className:"rounded border border-gray-300 px-2 py-1.5 text-sm outline-none focus:border-blue-500"}),(0,r.jsx)("span",{className:"text-sm text-gray-400",children:"-"}),(0,r.jsx)("input",{type:"date",value:i.to,onChange:e=>o(t=>({...t,to:e.target.value})),className:"rounded border border-gray-300 px-2 py-1.5 text-sm outline-none focus:border-blue-500"})]})]})}},94518:function(e,t,s){"use strict";s.d(t,{m:function(){return l}});var r=s(72835);function l(e){let{filterBar:t,listPanel:s,detailPanel:l}=e;return(0,r.jsxs)("div",{className:"flex h-full",children:[(0,r.jsxs)("div",{className:"flex w-80 flex-col border-r border-gray-200 bg-white",children:[t,s]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto bg-gray-50 p-6",children:l})]})}},63718:function(e,t,s){"use strict";s.d(t,{L:function(){return n}});var r=s(72835),l=s(60635);function n(e){let{items:t,selectedId:s,onSelect:n,loading:a,emptyText:c="暂无数据",onLoadMore:i,loadingMore:o,exhausted:u}=e,d=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!i)return;let e=d.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i()},{root:e.closest(".overflow-auto"),rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[i]),(0,r.jsxs)("div",{className:"flex-1 overflow-auto",children:[a?(0,r.jsx)("div",{className:"p-4 text-center text-sm text-gray-400",children:"加载中…"}):0===t.length?(0,r.jsx)("div",{className:"p-4 text-center text-sm text-gray-400",children:c}):(0,r.jsx)("ul",{className:"divide-y divide-gray-100",children:t.map(e=>(0,r.jsx)("li",{role:"button",tabIndex:0,onClick:()=>n(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&n(e.id)},className:"cursor-pointer px-3 py-2 text-sm transition-colors ".concat(s===e.id?"bg-blue-50":"hover:bg-gray-50"),children:e.content},e.id))}),i&&!a&&t.length>0&&(0,r.jsx)("div",{ref:d,className:"p-3 text-center text-xs text-gray-400",children:o?"加载更多…":u?"没有更多了":""})]})}},12789:function(e,t,s){"use strict";s.d(t,{D:function(){return i},X:function(){return c}});var r=s(72835),l=s(60635),n=s(33447);function a(){var e;return null!==(e=window.hmdDesktop)&&void 0!==e?e:null}function c(e){var t;let{feature:s,localPath:c,children:i}=e,[o,u]=(0,l.useState)(null),d=!!(null===(t=a())||void 0===t?void 0:t.probeLocalServer);return((0,l.useEffect)(()=>{var e,t;if(!(0,n.K5)()||!d)return;let s=!1;return null===(t=a())||void 0===t||null===(e=t.probeLocalServer)||void 0===e||e.call(t).then(e=>{s||u((null==e?void 0:e.online)===!0)}).catch(()=>{s||u(!1)}),()=>{s=!0}},[d]),(0,n.K5)())?(0,r.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-5 py-8 text-center",children:[(0,r.jsxs)("div",{className:"text-sm font-medium text-amber-900",children:[s,"需在本机 HunterMate 中使用"]}),(0,r.jsx)("p",{className:"mx-auto mt-2 max-w-md text-xs leading-5 text-amber-700",children:"这部分数据只保存在你的电脑上,云端工作台访问不到;数据互通不受影响。"}),d&&c?(0,r.jsx)("div",{className:"mt-4",children:!0===o?(0,r.jsx)("button",{onClick:()=>{var e,t;null===(t=a())||void 0===t||null===(e=t.openLocal)||void 0===e||e.call(t,c)},className:"rounded-lg bg-amber-600 px-4 py-2 text-sm text-white hover:bg-amber-700",children:"在本机 HunterMate 中打开"}):(0,r.jsx)("span",{className:"text-xs text-amber-600",children:"本机 HunterMate 未在运行,启动后即可跳转"})}):(0,r.jsx)("p",{className:"mt-4 text-xs text-amber-600",children:"请在本机打开 HunterMate 后使用此功能。"})]}):(0,r.jsx)(r.Fragment,{children:i})}function i(e){let{feature:t,localPath:s}=e;return(0,n.K5)()?(0,r.jsx)("div",{className:"flex h-full items-center justify-center p-6",children:(0,r.jsx)("div",{className:"w-full max-w-lg",children:(0,r.jsx)(c,{feature:t,localPath:s})})}):null}},19036:function(e,t,s){"use strict";s.d(t,{Y:function(){return a}});var r=s(72835),l=s(60635),n=s(74431);function a(e){let{pollUrl:t,intervalMs:s=5e3,onRefresh:a,getLatestTimestamp:c,label:i="新数据"}=e,[o,u]=(0,l.useState)(0),[d,x]=(0,l.useState)(!1),m=(0,l.useRef)(void 0);return((0,l.useEffect)(()=>{let e=()=>x(document.hidden);return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),(0,l.useEffect)(()=>{m.current=c(),u(0)},[c]),(0,l.useEffect)(()=>{if(d)return;let e=async()=>{let e=m.current;if(!e)return;let s=t.includes("?")?"&":"?",r=0;try{var l;let a=await (0,n.requestJson)("".concat(t).concat(s,"since=").concat(encodeURIComponent(e)));r=null!==(l=a.count)&&void 0!==l?l:0}catch(e){}u(e=>Math.max(e,r))};e();let r=setInterval(e,s);return()=>clearInterval(r)},[t,s,d]),o<=0)?null:(0,r.jsxs)("button",{type:"button",onClick:()=>{u(0),a()},className:"w-full bg-blue-50 px-3 py-2 text-center text-sm text-blue-700 hover:bg-blue-100 active:bg-blue-200",children:["有 ",o," 条",i,",点击刷新"]})}},8448:function(e,t,s){"use strict";function r(e){return e?("string"==typeof e?new Date(e):e).toLocaleString("zh-CN",{hour12:!1}):""}s.d(t,{d3:function(){return r}})}},function(e){e.O(0,[502,606,589,431,400,935,744],function(){return e(e.s=10793)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dd0e8a55-fcec-41d4-a494-e72604edfb69",e._sentryDebugIdIdentifier="sentry-dbid-dd0e8a55-fcec-41d4-a494-e72604edfb69")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[370],{71428:function(e,t,r){Promise.resolve().then(r.bind(r,3402))},3402:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return F}});var s=r(72835),n=r(60635),l=r(27473),a=r(74431),i=r(37202),o=r(94518),d=r(14590);let c=null,u="";function x(){let e="".concat((0,a.Ox)(),"/api/recordings-view");return c&&u===e||(c=new d.kE(e),u=e),c}var m=r(8448);function v(e){let{sessionId:t,eventCount:r,sourceUrl:n,startedAt:l,lastEventAt:a,counts:i}=e,o=[{label:"页面轨迹",value:null==i?void 0:i.rrwebCount},{label:"网络请求",value:null==i?void 0:i.networkCount},{label:"控制台消息",value:null==i?void 0:i.consoleCount},{label:"简历提取",value:null==i?void 0:i.resumeCount},{label:"操作记录",value:null==i?void 0:i.actionCount}].filter(e=>{var t;return(null!==(t=e.value)&&void 0!==t?t:0)>0});return(0,s.jsxs)("section",{className:"rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-gray-500",children:"事件数"}),(0,s.jsx)("div",{className:"text-lg font-semibold",children:r})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-gray-500",children:"来源页面"}),n?(0,s.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:"break-all text-sm text-blue-600 hover:underline",children:n}):(0,s.jsx)("div",{className:"text-sm text-gray-400",children:"-"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-gray-500",children:"开始时间"}),(0,s.jsx)("div",{className:"text-sm",children:(0,m.d3)(l)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm text-gray-500",children:"最近事件"}),(0,s.jsx)("div",{className:"text-sm",children:(0,m.d3)(a)})]})]}),o.length>0?(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-2 border-t border-gray-100 pt-3",children:o.map(e=>(0,s.jsxs)("span",{className:"rounded bg-gray-100 px-2 py-1 text-xs text-gray-700",children:[e.label,": ",e.value]},e.label))}):null,(0,s.jsx)("div",{className:"mt-3 border-t border-gray-100 pt-3",children:(0,s.jsx)("div",{className:"font-mono text-xs text-gray-400",children:t})})]})}let h={rrweb:"rrweb",network:"network",console:"console",resume:"简历",action:"操作"},b={rrweb:"bg-purple-100 text-purple-700",network:"bg-blue-100 text-blue-700",console:"bg-yellow-100 text-yellow-700",resume:"bg-green-100 text-green-700",action:"bg-gray-100 text-gray-700"};function f(e){var t,r;let{type:n}=e,l=null!==(t=h[n])&&void 0!==t?t:n,a=null!==(r=b[n])&&void 0!==r?r:"bg-gray-100 text-gray-600";return(0,s.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium ".concat(a),children:l})}function g(e){let{data:t}=e;return(0,s.jsx)("pre",{className:"max-h-64 overflow-auto rounded bg-gray-50 p-3 text-xs text-gray-700",children:JSON.stringify(t,null,2)})}function p(e){var t;let{event:r}=e,n=r.payload;return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"text-sm font-medium",children:null!==(t=null==n?void 0:n.title)&&void 0!==t?t:"简历提取事件"}),(null==n?void 0:n.source)?(0,s.jsxs)("div",{className:"text-xs text-gray-500",children:["来源:"," ",(0,s.jsx)("a",{href:n.source,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:n.source})]}):null,(null==n?void 0:n.fields)?(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1 text-xs text-gray-500",children:"提取到的字段"}),(0,s.jsx)(g,{data:n.fields})]}):(0,s.jsx)(g,{data:r.payload})]})}function y(e){var t;let{event:r}=e,n=r.payload;return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"text-sm font-medium",children:null!==(t=null==n?void 0:n.action)&&void 0!==t?t:"操作事件"}),(0,s.jsx)(g,{data:r.payload})]})}function j(e){let{sessionId:t}=e,[r,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)(null),[u,x]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let e=!0;return l(null),o(!1),c(null),(0,a.requestJson)("/api/recordings-view/recordings/".concat(encodeURIComponent(t),"/business")).then(t=>{var r;e&&l(null!==(r=t.items)&&void 0!==r?r:[])}).catch(()=>{e&&o(!0)}),()=>{e=!1}},[t,u]),(0,s.jsxs)("section",{className:"rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,s.jsx)("h2",{className:"mb-3 text-lg font-semibold",children:"本次操作与简历"}),i?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-red-500",children:["加载失败",(0,s.jsx)("button",{type:"button",onClick:()=>x(e=>e+1),className:"text-blue-500 hover:underline",children:"重试"})]}):null===r?(0,s.jsx)("div",{className:"text-sm text-gray-400",children:"加载中…"}):0===r.length?(0,s.jsx)("div",{className:"text-sm text-gray-400",children:"本次录制没有捕捉到简历提取或操作记录"}):(0,s.jsx)("ul",{className:"space-y-1",children:r.map((e,t)=>(0,s.jsxs)("li",{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>c(e=>e===t?null:t),className:"flex w-full items-start gap-3 rounded p-2 text-left text-sm hover:bg-gray-50",children:[(0,s.jsx)(f,{type:e.eventType}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"truncate text-gray-900",children:function(e){var t,r;if("resume"===e.eventType){let r=e.payload;return null!==(t=null==r?void 0:r.title)&&void 0!==t?t:"简历提取事件"}let s=e.payload;return null!==(r=null==s?void 0:s.action)&&void 0!==r?r:"操作事件"}(e)}),(0,s.jsx)("div",{className:"text-xs text-gray-400",children:(0,m.d3)(e.createdAt)})]}),(0,s.jsx)("span",{className:"text-xs text-gray-400",children:d===t?"收起":"展开"})]}),d===t?(0,s.jsx)("div",{className:"ml-2 mt-1 border-l-2 border-gray-100 pl-4 pb-2",children:"resume"===e.eventType?(0,s.jsx)(p,{event:e}):(0,s.jsx)(y,{event:e})}):null]},t))})]})}function N(e){let{sessionId:t}=e,[r,l]=(0,n.useState)("idle"),[i,o]=(0,n.useState)(null);async function d(){l("loading");try{let e=await (0,a.requestJson)("/api/recordings/".concat(encodeURIComponent(t),"/parse"),{method:"POST"});o(e),l("success")}catch(e){console.error("[recordings] 解析失败:",e),l("error")}}let c=i&&"object"==typeof i&&"entity"in i&&i.entity&&"object"==typeof i.entity&&"id"in i.entity&&"type"in i.entity?"/entity?type=".concat(encodeURIComponent(String(i.entity.type)),"&id=").concat(encodeURIComponent(String(i.entity.id))):null;return(0,s.jsxs)("section",{className:"rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"解析"}),(0,s.jsx)("button",{type:"button",onClick:d,disabled:"loading"===r,className:"rounded bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",children:"loading"===r?"解析中,请稍候…":"开始解析"})]}),"success"===r?(0,s.jsxs)("div",{className:"mt-3 rounded border border-green-200 bg-green-50 p-3 text-sm text-green-700",children:[(0,s.jsx)("div",{children:"解析完成"}),c?(0,s.jsx)("a",{href:c,className:"mt-1 inline-block text-blue-600 hover:underline",children:"查看解析结果 →"}):null]}):null,"error"===r?(0,s.jsx)("div",{className:"mt-3 rounded border border-red-200 bg-red-50 p-3 text-sm text-red-700",children:(0,s.jsx)("div",{children:"解析失败,请稍后重试"})}):null]})}function w(e){if(!e.sourceUrl)return"录制会话";try{return new URL(e.sourceUrl).hostname||"录制会话"}catch(t){return e.sourceUrl}}function I(e){var t;let{session:r,onCompare:n}=e;return(0,s.jsxs)("div",{className:"mx-auto max-w-4xl",children:[(0,s.jsxs)("header",{className:"mb-6 flex items-center gap-3",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-gray-900",children:w(r)}),n&&(0,s.jsx)("button",{type:"button",onClick:n,className:"rounded border border-gray-300 px-3 py-1 text-sm text-gray-600 hover:bg-gray-50 hover:text-gray-900",children:"与其他录制对比"})]}),(0,s.jsx)(v,{sessionId:r.sessionId,eventCount:r.eventCount,sourceUrl:null!==(t=r.sourceUrl)&&void 0!==t?t:null,startedAt:r.startedAt,lastEventAt:r.lastEventAt,counts:r.counts}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(d.$q,{api:x(),sessionId:r.sessionId,renderError:(e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-600",children:[(0,s.jsx)("span",{children:"回放加载失败"}),(0,s.jsx)("button",{type:"button",onClick:t,className:"rounded border border-red-300 px-3 py-1 hover:bg-red-100",children:"重试"})]})},r.sessionId)}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(j,{sessionId:r.sessionId})}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(N,{sessionId:r.sessionId})})]})}var C=r(78606);function k(e){if(e.urlKey)return e.urlKey;let t=e.sourceUrl;if(!t)return"";try{return new URL(t).hostname||""}catch(e){return t}}function E(e){let t=Date.parse(e.startedAt.replace(" ","T"));return Number.isFinite(t)?t:0}function S(e,t){let r=e.find(e=>e.sessionId===t),s=r?k(r):"";return e.filter(e=>e.sessionId!==t).sort((e,t)=>{let r=""!==s&&k(e)===s?0:1,n=""!==s&&k(t)===s?0:1;return r!==n?r-n:E(t)-E(e)})}function L(e){if("number"==typeof e.duration)return e.duration;let t=Date.parse(e.startedAt.replace(" ","T")),r=Date.parse(e.lastEventAt.replace(" ","T"));if(!Number.isFinite(t)||!Number.isFinite(r))return null;let s=r-t;return s>=0?s:null}function q(e){var t,r,s;let n=null!==(t=e.sourceUrl)&&void 0!==t?t:"",l="";if(n)try{l=new URL(n).hostname||""}catch(e){l=""}let a=Date.parse(e.lastEventAt.replace(" ","T"));return{sessionId:e.sessionId,title:n||e.sessionId,status:"completed",startTime:E(e),endTime:Number.isFinite(a)?a:null,duration:L(e),startUrl:n,domain:l,url:n,urlKey:null!==(r=e.urlKey)&&void 0!==r?r:"",tabId:null!==(s=e.tabId)&&void 0!==s?s:null,tags:[]}}let U={rrweb:[],network:[],console:[],exceptions:[]};function A(e,t){let[r,s]=(0,n.useState)({events:null,error:null,loading:!1});return(0,n.useEffect)(()=>{s({events:null,error:null,loading:!1})},[e]),(0,n.useEffect)(()=>{if(!e)return;let t=!1;return s(e=>({...e,error:null,loading:!0})),x().events(e).then(e=>{t||s({events:e,error:null,loading:!1})}).catch(()=>{t||s({events:null,error:"network_error",loading:!1})}),()=>{t=!0}},[e,t]),r}function T(e){var t,r,l;let{base:a,target:i,sessions:o,onSelectTarget:c,onSwap:u,onExit:x}=e,m=S(o,a.sessionId),[v,h]=(0,n.useState)(0),b=(0,n.useCallback)(()=>h(e=>e+1),[]);(0,n.useEffect)(()=>h(0),[a.sessionId,null==i?void 0:i.sessionId]);let f=A(a.sessionId,v),g=A(null!==(t=null==i?void 0:i.sessionId)&&void 0!==t?t:null,v),p=f.loading||!!i&&g.loading,y={meta:q(a),events:null!==(r=f.events)&&void 0!==r?r:U},j=i?{meta:q(i),events:null!==(l=g.events)&&void 0!==l?l:U}:null;return(0,s.jsxs)("div",{className:"mx-auto max-w-6xl",children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm",children:[(0,s.jsx)("span",{className:"text-gray-500",children:"基准:"}),(0,s.jsxs)("span",{title:"基准为当前选中会话,不可更改",className:"cursor-not-allowed select-none rounded border border-gray-200 bg-gray-50 px-2 py-1 text-gray-700",children:[w(a),(0,s.jsx)("span",{className:"ml-1 text-xs text-gray-400",children:"(本次)▾"})]}),(0,s.jsx)("button",{type:"button",onClick:u,disabled:!i,title:i?"互换基准与对照":"请先选择对照录制",className:"rounded border border-gray-300 px-2 py-1 text-gray-600 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-40",children:"⇄ 互换"}),(0,s.jsx)("span",{className:"text-gray-500",children:"对照:"}),0===m.length?(0,s.jsx)("span",{className:"text-gray-400",children:"还需要至少另一条录制才能对比"}):(0,s.jsx)(C.Z,{size:"small","aria-label":"选择对照录制",placeholder:"选择对照录制",style:{minWidth:220},value:null==i?void 0:i.sessionId,onChange:e=>c(e),options:m.map(e=>({value:e.sessionId,label:function(e){let t=e.startedAt.length>=16?e.startedAt.slice(5,16):e.startedAt;return"".concat(t," \xb7 ").concat(function(e){let t=L(e);if(null===t)return"—";let r=Math.floor(t/1e3);if(r<1)return"不足1秒";let s=Math.floor(r/60),n=r%60;return s>0?"".concat(s,"分").concat(n,"秒"):"".concat(n,"秒")}(e)," \xb7 ").concat(e.eventCount," 事件")}(e)}))}),(0,s.jsx)("button",{type:"button",onClick:x,className:"ml-auto rounded border border-gray-300 px-3 py-1 text-gray-600 hover:bg-gray-50",children:"退出对比"})]}),i?p?(0,s.jsx)("div",{className:"flex h-64 items-center justify-center text-gray-400",children:"加载回放中…"}):(0,s.jsx)(d._f,{base:y,target:j,baseError:f.error,targetError:g.error,onRetryError:b,renderError:(e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-600",children:[(0,s.jsxs)("span",{children:["对比加载失败:",e]}),(0,s.jsx)("button",{type:"button",onClick:t,className:"rounded border border-red-300 px-3 py-1 hover:bg-red-100",children:"重试"})]})},"".concat(a.sessionId,":").concat(i.sessionId)):(0,s.jsx)("div",{className:"flex h-64 items-center justify-center text-gray-400",children:"从上方对照下拉选择另一条录制后开始对比"})]})}var _=r(63718);function D(e){let{session:t}=e;return(0,s.jsxs)("div",{children:[t.sourceUrl?(0,s.jsx)("div",{className:"truncate text-sm font-medium text-gray-900",children:t.sourceUrl}):(0,s.jsx)("div",{className:"text-sm font-medium text-gray-400",children:"无来源页面"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[(0,s.jsxs)("span",{children:[t.eventCount," 事件"]}),"number"==typeof t.tabId?(0,s.jsxs)("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-xs text-gray-600",children:["tab #",t.tabId]}):null]}),(0,s.jsx)("div",{className:"text-xs text-gray-400",children:(0,m.d3)(t.lastEventAt)}),(0,s.jsx)("div",{className:"truncate font-mono text-[10px] text-gray-300",children:t.sessionId})]})}function R(e){let{sessions:t,selectedId:r,onSelect:n,loading:l}=e,a=t.map(e=>({id:e.sessionId,content:(0,s.jsx)(D,{session:e})}));return(0,s.jsx)(_.L,{items:a,selectedId:r,onSelect:n,loading:l,emptyText:"暂无录制会话"})}function M(e){let t=new URLSearchParams;Object.entries(e).forEach(e=>{let[r,s]=e;void 0!==s&&(s||"compare"===r)&&t.set(r,s)});let r=t.toString();return r?"?".concat(r):""}function K(){let e=(0,l.useRouter)(),t=(0,l.usePathname)(),r=(0,l.useSearchParams)(),d=r.get("sessionId")||"",c=r.get("compare"),u=r.has("compare"),x=(0,n.useMemo)(()=>({q:r.get("q")||"",status:"",from:r.get("from")||"",to:r.get("to")||""}),[r]),[m,v]=(0,n.useState)([]),[h,b]=(0,n.useState)(!1),[f,g]=(0,n.useState)(!1),[p,y]=(0,n.useState)(!0),j=(0,n.useCallback)(r=>{var s,n;let l=null!==(s=r.filters)&&void 0!==s?s:x,a=void 0===r.compare?null!=c?c:void 0:null===r.compare?void 0:r.compare,i=M({sessionId:null!==(n=r.sessionId)&&void 0!==n?n:d,q:l.q,from:l.from,to:l.to,compare:a});e.replace("".concat(t).concat(i))},[x,d,c,t,e]),N=(0,n.useCallback)(()=>{let e=S(m,d)[0];j({compare:e?e.sessionId:""})},[m,d,j]),w=(0,n.useCallback)(()=>j({compare:null}),[j]),C=(0,n.useCallback)(e=>j({compare:e}),[j]),k=(0,n.useCallback)(()=>{c&&j({sessionId:c,compare:d})},[c,d,j]),E=(0,n.useCallback)(e=>{(null==e?void 0:e.withLoading)&&y(!0);let t=M({q:x.q,from:x.from,to:x.to});(0,a.requestJson)("/api/recordings-view/recordings?limit=200".concat(t.replace("?","&"))).then(e=>{v(t=>{var r;return function(e,t){let r=new Map(e.map(e=>[e.sessionId,e]));return t.map(e=>{let t=r.get(e.sessionId);return t&&t.eventCount===e.eventCount&&t.lastEventAt===e.lastEventAt&&t.tabId===e.tabId?t:{...e}})}(t,null!==(r=e.recordings)&&void 0!==r?r:[])}),b(!1),g(!1)}).catch(()=>{(null==e?void 0:e.withLoading)?b(!0):g(!0)}).finally(()=>{(null==e?void 0:e.withLoading)&&y(!1)})},[x.q,x.from,x.to]);(0,n.useEffect)(()=>{E({withLoading:!0})},[E]),(0,n.useEffect)(()=>{let e=setInterval(()=>E({withLoading:!1}),1e4);return()=>clearInterval(e)},[E]);let L=h?(0,s.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-red-500",children:["加载失败",(0,s.jsx)("button",{type:"button",onClick:()=>E({withLoading:!0}),className:"text-blue-500 hover:underline",children:"重试"})]}):(0,s.jsxs)(s.Fragment,{children:[f&&(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-amber-100 bg-amber-50 px-3 py-1.5 text-xs text-amber-600",children:[(0,s.jsx)("span",{children:"列表更新失败,显示上次数据"}),(0,s.jsx)("button",{type:"button",onClick:()=>E({withLoading:!1}),className:"text-blue-500 hover:underline",children:"重试"})]}),(0,s.jsx)(R,{sessions:m,selectedId:d,onSelect:e=>j({sessionId:e}),loading:p})]}),q=d?m.find(e=>e.sessionId===d):void 0,U=u&&d?m.find(e=>e.sessionId===d):void 0,A=u&&c?m.find(e=>e.sessionId===c):void 0,_=d?u?U?(0,s.jsx)(T,{base:U,target:null!=A?A:null,sessions:m,onSelectTarget:C,onSwap:k,onExit:w}):p?(0,s.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"加载中…"}):(0,s.jsx)("div",{className:"flex h-full items-center justify-center text-red-500",children:"未找到该录制会话"}):q?(0,s.jsx)(I,{session:q,onCompare:N}):(0,s.jsx)("div",{className:"flex h-full items-center justify-center text-red-500",children:"未找到该录制会话"}):(0,s.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:"请在左侧选择一个录制会话查看详情"});return(0,s.jsx)(o.m,{filterBar:(0,s.jsx)(i.f,{value:x,onChange:e=>j({filters:e})}),listPanel:L,detailPanel:_})}var P=r(12789),O=r(33447);function F(){return(0,O.K5)()?(0,s.jsx)(P.D,{feature:"录制回放",localPath:"/recordings"}):(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{className:"p-6 text-gray-500",children:"加载中…"}),children:(0,s.jsx)(K,{})})}},37202:function(e,t,r){"use strict";r.d(t,{f:function(){return a}});var s=r(72835),n=r(60635),l=r(78606);function a(e){let{value:t,showStatus:r,statusOptions:a,onChange:i}=e,[o,d]=(0,n.useState)(t);return(0,n.useEffect)(()=>{d(t)},[t.q,t.status,t.from,t.to]),(0,n.useEffect)(()=>{let e=setTimeout(()=>{(o.q!==t.q||o.status!==t.status||o.from!==t.from||o.to!==t.to)&&i(o)},300);return()=>clearTimeout(e)},[o.q,o.status,o.from,o.to]),(0,s.jsxs)("div",{className:"space-y-2 border-b border-gray-200 bg-white p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)("input",{type:"text",value:o.q,onChange:e=>d(t=>({...t,q:e.target.value})),placeholder:"搜索关键词...",className:"w-full rounded border border-gray-300 px-2 py-1.5 pr-8 text-sm outline-none focus:border-blue-500"}),(0,s.jsx)("button",{type:"button",onClick:()=>i({q:"",status:"",from:"",to:""}),title:"重置筛选",className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 disabled:opacity-30",disabled:!o.q&&!o.status&&!o.from&&!o.to,children:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),r?(0,s.jsx)(l.Z,{size:"small",allowClear:!0,placeholder:"全部状态",style:{minWidth:130},value:o.status||void 0,onChange:e=>d(t=>({...t,status:null!=e?e:""})),options:(a||[]).map(e=>({value:e.value,label:e.label}))}):null]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"date",value:o.from,onChange:e=>d(t=>({...t,from:e.target.value})),className:"rounded border border-gray-300 px-2 py-1.5 text-sm outline-none focus:border-blue-500"}),(0,s.jsx)("span",{className:"text-sm text-gray-400",children:"-"}),(0,s.jsx)("input",{type:"date",value:o.to,onChange:e=>d(t=>({...t,to:e.target.value})),className:"rounded border border-gray-300 px-2 py-1.5 text-sm outline-none focus:border-blue-500"})]})]})}},94518:function(e,t,r){"use strict";r.d(t,{m:function(){return n}});var s=r(72835);function n(e){let{filterBar:t,listPanel:r,detailPanel:n}=e;return(0,s.jsxs)("div",{className:"flex h-full",children:[(0,s.jsxs)("div",{className:"flex w-80 flex-col border-r border-gray-200 bg-white",children:[t,r]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto bg-gray-50 p-6",children:n})]})}},63718:function(e,t,r){"use strict";r.d(t,{L:function(){return l}});var s=r(72835),n=r(60635);function l(e){let{items:t,selectedId:r,onSelect:l,loading:a,emptyText:i="暂无数据",onLoadMore:o,loadingMore:d,exhausted:c}=e,u=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!o)return;let e=u.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&o()},{root:e.closest(".overflow-auto"),rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[o]),(0,s.jsxs)("div",{className:"flex-1 overflow-auto",children:[a?(0,s.jsx)("div",{className:"p-4 text-center text-sm text-gray-400",children:"加载中…"}):0===t.length?(0,s.jsx)("div",{className:"p-4 text-center text-sm text-gray-400",children:i}):(0,s.jsx)("ul",{className:"divide-y divide-gray-100",children:t.map(e=>(0,s.jsx)("li",{role:"button",tabIndex:0,onClick:()=>l(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&l(e.id)},className:"cursor-pointer px-3 py-2 text-sm transition-colors ".concat(r===e.id?"bg-blue-50":"hover:bg-gray-50"),children:e.content},e.id))}),o&&!a&&t.length>0&&(0,s.jsx)("div",{ref:u,className:"p-3 text-center text-xs text-gray-400",children:d?"加载更多…":c?"没有更多了":""})]})}},12789:function(e,t,r){"use strict";r.d(t,{D:function(){return o},X:function(){return i}});var s=r(72835),n=r(60635),l=r(33447);function a(){var e;return null!==(e=window.hmdDesktop)&&void 0!==e?e:null}function i(e){var t;let{feature:r,localPath:i,children:o}=e,[d,c]=(0,n.useState)(null),u=!!(null===(t=a())||void 0===t?void 0:t.probeLocalServer);return((0,n.useEffect)(()=>{var e,t;if(!(0,l.K5)()||!u)return;let r=!1;return null===(t=a())||void 0===t||null===(e=t.probeLocalServer)||void 0===e||e.call(t).then(e=>{r||c((null==e?void 0:e.online)===!0)}).catch(()=>{r||c(!1)}),()=>{r=!0}},[u]),(0,l.K5)())?(0,s.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-5 py-8 text-center",children:[(0,s.jsxs)("div",{className:"text-sm font-medium text-amber-900",children:[r,"需在本机 HunterMate 中使用"]}),(0,s.jsx)("p",{className:"mx-auto mt-2 max-w-md text-xs leading-5 text-amber-700",children:"这部分数据只保存在你的电脑上,云端工作台访问不到;数据互通不受影响。"}),u&&i?(0,s.jsx)("div",{className:"mt-4",children:!0===d?(0,s.jsx)("button",{onClick:()=>{var e,t;null===(t=a())||void 0===t||null===(e=t.openLocal)||void 0===e||e.call(t,i)},className:"rounded-lg bg-amber-600 px-4 py-2 text-sm text-white hover:bg-amber-700",children:"在本机 HunterMate 中打开"}):(0,s.jsx)("span",{className:"text-xs text-amber-600",children:"本机 HunterMate 未在运行,启动后即可跳转"})}):(0,s.jsx)("p",{className:"mt-4 text-xs text-amber-600",children:"请在本机打开 HunterMate 后使用此功能。"})]}):(0,s.jsx)(s.Fragment,{children:o})}function o(e){let{feature:t,localPath:r}=e;return(0,l.K5)()?(0,s.jsx)("div",{className:"flex h-full items-center justify-center p-6",children:(0,s.jsx)("div",{className:"w-full max-w-lg",children:(0,s.jsx)(i,{feature:t,localPath:r})})}):null}},8448:function(e,t,r){"use strict";function s(e){return e?("string"==typeof e?new Date(e):e).toLocaleString("zh-CN",{hour12:!1}):""}r.d(t,{d3:function(){return s}})}},function(e){e.O(0,[502,606,896,431,400,935,744],function(){return e(e.s=71428)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92f9c082-7514-47f5-a952-75916e68f32d",e._sentryDebugIdIdentifier="sentry-dbid-92f9c082-7514-47f5-a952-75916e68f32d")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[514],{19155:function(e,t,s){Promise.resolve().then(s.bind(s,80611))},80611:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return K}});var r=s(72835),a=s(60635),l=s(78606),n=s(74431),i=s(51140),c=s(96049),o=s(85018),d=s(5200),u=s(85673),m=s(86583),h=s(74800),x=s(16308),p=s(8425),y=s(95090);let f=["#2563eb","#16a34a","#f59e0b","#dc2626","#7c3aed","#0891b2"],j={hm:"hunter-mate",hmh:"harness 工具链",extra:"其他"},g={hm:"#2563eb",hmh:"#16a34a",extra:"#94a3b8"};function b(e){if(!Number.isFinite(e)||e<0)return"-";let t=["B","KB","MB","GB","TB"],s=e,r=0;for(;s>=1024&&r<t.length-1;)s/=1024,r++;return"".concat(s>=100||0===r?Math.round(s):s.toFixed(1)," ").concat(t[r])}function v(e){let t=new Date(e);return"".concat(String(t.getMonth()+1).padStart(2,"0"),"-").concat(String(t.getDate()).padStart(2,"0")," ").concat(String(t.getHours()).padStart(2,"0"),":").concat(String(t.getMinutes()).padStart(2,"0"))}function N(e){let t=new Date(e);return"".concat(String(t.getHours()).padStart(2,"0"),":").concat(String(t.getMinutes()).padStart(2,"0"),":").concat(String(t.getSeconds()).padStart(2,"0"))}function w(e){return e.group?e.group:e.key.startsWith("hunter-mate-h")?"hmh":e.key.startsWith("hunter-mate-")?"hm":"extra"}function S(e){return e.group?e.group:/hunter-mate-harness|chromepilot|hmx/i.test(e.cmd)||/hmx|chromepilot/i.test(e.name)?"hmh":"hm"}function k(e){let{title:t,children:s}=e;return(0,r.jsxs)("section",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-medium text-gray-700",children:t}),s]})}let B=(0,a.memo)(function(e){let{items:t}=e,s=Array.from(new Set(t.flatMap(e=>e.paths.map(e=>e.key)))),a=t.map(e=>{let t={ts:v(e.ts)};for(let s of e.paths)t[s.key]=Number((s.totalBytes/1073741824).toFixed(3));return t});return(0,r.jsx)(k,{title:"磁盘占用趋势(按受监控路径,GB)",children:(0,r.jsx)(i.h,{width:"100%",height:260,children:(0,r.jsxs)(c.T,{data:a,margin:{top:4,right:12,bottom:0,left:0},children:[(0,r.jsx)(o.q,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),(0,r.jsx)(d.K,{dataKey:"ts",tick:{fontSize:11},minTickGap:40}),(0,r.jsx)(u.B,{tick:{fontSize:11},width:56}),(0,r.jsx)(m.u,{formatter:e=>["".concat(e," GB"),void 0]}),(0,r.jsx)(h.D,{}),s.map((e,t)=>(0,r.jsx)(x.uN,{type:"monotone",dataKey:e,stroke:f[t%f.length],fill:f[t%f.length],fillOpacity:.15,name:e,connectNulls:!0},e))]})})})}),M=(0,a.memo)(function(e){let{p:t,diskTotalBytes:s}=e,a=w(t),l=s>0?(t.totalBytes/s*100).toFixed(1):null;return(0,r.jsx)(k,{title:"路径构成:".concat(t.key,"(").concat(j[a],")(").concat(t.path,")— 共 ").concat(b(t.totalBytes)).concat(null!==l?" \xb7 占总磁盘 ".concat(l,"%"):""),children:(0,r.jsx)(i.h,{width:"100%",height:Math.max(120,26*t.topEntries.length+40),children:(0,r.jsxs)(p.v,{data:t.topEntries,layout:"vertical",margin:{top:0,right:16,bottom:0,left:8},children:[(0,r.jsx)(o.q,{strokeDasharray:"3 3",stroke:"#e5e7eb",horizontal:!1}),(0,r.jsx)(d.K,{type:"number",tick:{fontSize:11},tickFormatter:e=>b(e)}),(0,r.jsx)(u.B,{type:"category",dataKey:"name",tick:{fontSize:11},width:180}),(0,r.jsx)(m.u,{formatter:e=>b(Number(e))}),(0,r.jsx)(y.$Q,{dataKey:"bytes",name:"占用",fill:g[a],radius:[0,3,3,0]})]})})})}),P=(0,a.memo)(function(e){var t,s,a;let{items:l}=e,n=l[l.length-1];if(!n)return null;let i=new Map;for(let e of n.paths.filter(e=>e.exists)){let t=w(e);i.set(t,(null!==(s=i.get(t))&&void 0!==s?s:0)+e.totalBytes)}let c=Array.from(i.entries()).sort((e,t)=>t[1]-e[1]),o=null!==(a=null===(t=n.totals)||void 0===t?void 0:t.diskTotalBytes)&&void 0!==a?a:0;return(0,r.jsx)(k,{title:"磁盘分组概览(hm / harness 工具链,占总磁盘比例)",children:(0,r.jsxs)("table",{className:"w-full text-xs text-gray-600",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-gray-100 text-left",children:[(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"分组"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"占用"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"占总磁盘"}),(0,r.jsx)("th",{className:"py-1 font-medium",children:"占比条"})]})}),(0,r.jsxs)("tbody",{children:[c.map(e=>{let[t,s]=e,a=o>0?s/o*100:null;return(0,r.jsxs)("tr",{className:"border-b border-gray-50",children:[(0,r.jsx)("td",{className:"py-1 pr-4",children:j[t]}),(0,r.jsx)("td",{className:"py-1 pr-4",children:b(s)}),(0,r.jsx)("td",{className:"py-1 pr-4",children:null===a?"-":"".concat(a.toFixed(1),"%")}),(0,r.jsx)("td",{className:"py-1",children:null!==a&&(0,r.jsx)("div",{className:"h-2 w-full min-w-[120px] rounded bg-gray-100",children:(0,r.jsx)("div",{className:"h-2 rounded",style:{width:"".concat(Math.min(100,a),"%"),background:g[t]}})})})]},t)}),!c.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:4,className:"py-2 text-gray-400",children:"本帧无路径数据"})})]})]})})}),F=(0,a.memo)(function(e){let{items:t,liveSamples:s}=e,a=s.length>0,l=a?s[s.length-1]:null,n=t[t.length-1],p=a?s.map(e=>{var t,s,r,a;if(e.groups)return{ts:N(e.ts),rssMBHm:Number((e.groups.hm.rssBytes/1048576).toFixed(1)),rssMBHmh:Number((e.groups.hmh.rssBytes/1048576).toFixed(1)),cpuHm:Number((null!==(t=e.groups.hm.cpuPercent)&&void 0!==t?t:0).toFixed(1)),cpuHmh:Number((null!==(s=e.groups.hmh.cpuPercent)&&void 0!==s?s:0).toFixed(1))};let l=0,n=0,i=0,c=0;for(let t of e.processes)"hmh"===S(t)?(n+=t.rssBytes,c+=null!==(r=t.cpuPercent)&&void 0!==r?r:0):(l+=t.rssBytes,i+=null!==(a=t.cpuPercent)&&void 0!==a?a:0);return{ts:N(e.ts),rssMBHm:Number((l/1048576).toFixed(1)),rssMBHmh:Number((n/1048576).toFixed(1)),cpuHm:Number(i.toFixed(1)),cpuHmh:Number(c.toFixed(1))}}):t.map(e=>{let t=0,s=0,r=0,a=0;for(let l of e.processes)"hmh"===S(l)?(s+=l.rssBytes,a+=l.cpuPercent):(t+=l.rssBytes,r+=l.cpuPercent);return{ts:v(e.ts),rssMBHm:Number((t/1048576).toFixed(1)),rssMBHmh:Number((s/1048576).toFixed(1)),cpuHm:Number(r.toFixed(1)),cpuHmh:Number(a.toFixed(1))}}),y=l?l.processes:n.processes;return(0,r.jsxs)(k,{title:a?"相关进程占用趋势(准实时 5s \xb7 按 hm / 工具链分开 \xb7 内存 MB / CPU %)":"相关进程占用趋势(按 hm / harness 工具链分开 \xb7 内存 MB / CPU %)",children:[(0,r.jsx)(i.h,{width:"100%",height:240,children:(0,r.jsxs)(c.T,{data:p,margin:{top:4,right:12,bottom:0,left:0},children:[(0,r.jsx)(o.q,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),(0,r.jsx)(d.K,{dataKey:"ts",tick:{fontSize:11},minTickGap:40}),(0,r.jsx)(u.B,{yAxisId:"mb",tick:{fontSize:11},width:52}),(0,r.jsx)(u.B,{yAxisId:"pct",orientation:"right",tick:{fontSize:11},width:44}),(0,r.jsx)(m.u,{}),(0,r.jsx)(h.D,{}),(0,r.jsx)(x.uN,{yAxisId:"mb",type:"monotone",dataKey:"rssMBHm",name:"hm 内存(MB)",stroke:g.hm,fill:g.hm,fillOpacity:.15,isAnimationActive:!1}),(0,r.jsx)(x.uN,{yAxisId:"mb",type:"monotone",dataKey:"rssMBHmh",name:"工具链内存(MB)",stroke:g.hmh,fill:g.hmh,fillOpacity:.15,isAnimationActive:!1}),(0,r.jsx)(x.uN,{yAxisId:"pct",type:"monotone",dataKey:"cpuHm",name:"hm CPU(%)",stroke:"#dc2626",fill:"#dc2626",fillOpacity:.1,isAnimationActive:!1}),(0,r.jsx)(x.uN,{yAxisId:"pct",type:"monotone",dataKey:"cpuHmh",name:"工具链 CPU(%)",stroke:"#f59e0b",fill:"#f59e0b",fillOpacity:.1,isAnimationActive:!1})]})}),(0,r.jsx)("div",{className:"mt-3 overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-xs text-gray-600",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-gray-100 text-left",children:[(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"分组"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"PID"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"进程"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"RSS"}),(0,r.jsx)("th",{className:"py-1 pr-4 font-medium",children:"CPU%"})]})}),(0,r.jsxs)("tbody",{children:[y.map(e=>(0,r.jsxs)("tr",{className:"border-b border-gray-50",children:[(0,r.jsx)("td",{className:"py-1 pr-4",children:"hmh"===S(e)?"工具链":"hm"}),(0,r.jsx)("td",{className:"py-1 pr-4",children:e.pid}),(0,r.jsx)("td",{className:"max-w-[360px] truncate py-1 pr-4",title:e.cmd,children:e.cmd||e.name}),(0,r.jsx)("td",{className:"py-1 pr-4",children:b(e.rssBytes)}),(0,r.jsx)("td",{className:"py-1 pr-4",children:null===e.cpuPercent?"—":"".concat(e.cpuPercent,"%")})]},e.pid)),!y.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:5,className:"py-2 text-gray-400",children:"本帧无匹配进程"})})]})]})})]})});function H(e){var t;let{items:s,liveSamples:a=[]}=e,l=s[s.length-1];if(!l)return null;let n=l.paths.filter(e=>e.exists),i=null!==(t=l.totals)&&void 0!==t?t:null;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("section",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsx)("h3",{className:"mb-2 text-sm font-medium text-gray-700",children:"系统信息"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-xs text-gray-600",children:[(0,r.jsxs)("span",{children:["主机:",l.system.hostname]}),(0,r.jsxs)("span",{children:["用户:",l.system.username]}),(0,r.jsxs)("span",{children:["系统:",l.system.platform," ",l.system.osRelease,"(",l.system.arch,")"]}),(0,r.jsxs)("span",{children:["CPU:",l.system.cpuModel," \xd7 ",l.system.cpuCores," 核"]}),(0,r.jsxs)("span",{children:["内存:",b(l.system.totalMemBytes)]}),(0,r.jsxs)("span",{children:["快照:",new Date(l.ts).toLocaleString()]})]}),i&&(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap gap-x-6 gap-y-1 border-t border-gray-100 pt-2 text-xs text-gray-600",children:[(0,r.jsxs)("span",{children:["整机 CPU:",i.cpuPercent,"%"]}),(0,r.jsxs)("span",{children:["整机内存:",b(i.memUsedBytes)," / ",b(i.memTotalBytes),"(",i.memUsedPercent,"%)"]}),(0,r.jsxs)("span",{children:["整机磁盘:",b(i.diskUsedBytes)," / ",b(i.diskTotalBytes),"(",i.diskUsedPercent,"%)"]})]})]}),(0,r.jsx)(P,{items:s}),(0,r.jsx)(B,{items:s}),(0,r.jsx)(F,{items:s,liveSamples:a}),n.map(e=>{var t;return(0,r.jsx)(M,{p:e,diskTotalBytes:null!==(t=null==i?void 0:i.diskTotalBytes)&&void 0!==t?t:0},e.key)})]})}var C=s(12789),D=s(33447);let I=[{value:24,label:"最近 1 天"},{value:72,label:"最近 3 天"},{value:168,label:"最近 7 天"}];function K(){if((0,D.K5)())return(0,r.jsx)(C.D,{feature:"资源监控",localPath:"/resource-usage"});let[e,t]=(0,a.useState)(72),[s,i]=(0,a.useState)([]),[c,o]=(0,a.useState)([]),[d,u]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!0),[x,p]=(0,a.useState)(!1),[y,f]=(0,a.useState)(""),j=(0,a.useRef)(e),g=(0,a.useRef)(null),b=(0,a.useRef)(null);(0,a.useEffect)(()=>{j.current=e},[e]);let v=(0,a.useCallback)(async e=>{h(!0);try{var t;let s=await (0,n.requestJson)("/resource-usage/history?hours=".concat(e)),r=null!==(t=null==s?void 0:s.items)&&void 0!==t?t:[];i(r);let a=r[r.length-1];a&&(g.current=a.ts)}catch(e){i([]),f("历史快照加载失败,请稍后重试")}finally{h(!1)}},[]);(0,a.useEffect)(()=>{v(e)},[e,v]),(0,a.useEffect)(()=>{let e,t=!1,s=e=>{if(!t){if(!e.sampleIntervalMs||e.sampleIntervalMs<=0){u(!1);return}if(u(!0),e.last&&e.last.ts!==b.current){b.current=e.last.ts;let t=e.last;o(e=>{let s=[...e,t];return s.length>720?s.slice(s.length-720):s})}e.lastFullSnapshotTs&&e.lastFullSnapshotTs!==g.current&&(g.current=e.lastFullSnapshotTs,v(j.current))}};return(async()=>{var r,a,l,i;try{let e=await (0,n.requestJson)("/resource-usage/samples");if(t)return;if(null==e?void 0:null===(r=e.samples)||void 0===r?void 0:r.length){let t=e.samples.slice(-720);o(t),b.current=null!==(l=null===(a=t[t.length-1])||void 0===a?void 0:a.ts)&&void 0!==l?l:null}}catch(e){}(0,n.requestJson)("/resource-usage/collect-now",{method:"POST",headers:{"Content-Type":"application/json"}}).catch(()=>{});let c=null;try{c=await (0,n.requestJson)("/resource-usage/live")}catch(e){}c&&s(c),t||(e=setInterval(()=>{(0,n.requestJson)("/resource-usage/live").then(s).catch(()=>{})},Math.max(null!==(i=null==c?void 0:c.sampleIntervalMs)&&void 0!==i?i:5e3,2e3)))})(),()=>{t=!0,e&&clearInterval(e)}},[v]);let N=async()=>{p(!0),f("");try{var e;let t=await (0,n.requestJson)("/resource-usage/collect-now",{method:"POST",headers:{"Content-Type":"application/json"}});f((null===(e=t.report)||void 0===e?void 0:e.reported)?"已采集并上报 ".concat(t.report.reported," 条"):"已采集(本地)"),v(j.current)}catch(e){f("采集失败(查看 server 日志)")}finally{p(!1)}};return(0,r.jsx)("div",{className:"h-full overflow-auto bg-gray-50 p-6",children:(0,r.jsxs)("div",{className:"mx-auto max-w-5xl",children:[(0,r.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-gray-900",children:"资源占用"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["hunter-mate / hunter-mate-harness 磁盘占用、相关进程内存 CPU 与系统配置(默认保留 3 天)",d&&" \xb7 进程准实时 5s"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(l.Z,{size:"small",style:{minWidth:110},value:e,onChange:e=>t(e),options:I.map(e=>({value:e.value,label:e.label}))}),(0,r.jsx)("button",{type:"button",onClick:N,disabled:x,className:"rounded-lg bg-blue-600 px-3 py-1.5 text-sm text-white transition-colors hover:bg-blue-700 disabled:opacity-50",children:x?"采集中…":"立即采集"})]})]}),y&&(0,r.jsx)("p",{className:"mb-3 text-xs text-gray-500",children:y}),m?(0,r.jsx)("div",{className:"py-20 text-center text-sm text-gray-400",children:"加载中…"}):0===s.length?(0,r.jsxs)("div",{className:"rounded-xl border border-dashed border-gray-300 bg-white py-20 text-center",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"窗口内暂无快照"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-400",children:"server 每 5 分钟自动采集一帧,也可点「立即采集」"})]}):(0,r.jsx)(H,{items:s,liveSamples:c})]})})}},12789:function(e,t,s){"use strict";s.d(t,{D:function(){return c},X:function(){return i}});var r=s(72835),a=s(60635),l=s(33447);function n(){var e;return null!==(e=window.hmdDesktop)&&void 0!==e?e:null}function i(e){var t;let{feature:s,localPath:i,children:c}=e,[o,d]=(0,a.useState)(null),u=!!(null===(t=n())||void 0===t?void 0:t.probeLocalServer);return((0,a.useEffect)(()=>{var e,t;if(!(0,l.K5)()||!u)return;let s=!1;return null===(t=n())||void 0===t||null===(e=t.probeLocalServer)||void 0===e||e.call(t).then(e=>{s||d((null==e?void 0:e.online)===!0)}).catch(()=>{s||d(!1)}),()=>{s=!0}},[u]),(0,l.K5)())?(0,r.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-5 py-8 text-center",children:[(0,r.jsxs)("div",{className:"text-sm font-medium text-amber-900",children:[s,"需在本机 HunterMate 中使用"]}),(0,r.jsx)("p",{className:"mx-auto mt-2 max-w-md text-xs leading-5 text-amber-700",children:"这部分数据只保存在你的电脑上,云端工作台访问不到;数据互通不受影响。"}),u&&i?(0,r.jsx)("div",{className:"mt-4",children:!0===o?(0,r.jsx)("button",{onClick:()=>{var e,t;null===(t=n())||void 0===t||null===(e=t.openLocal)||void 0===e||e.call(t,i)},className:"rounded-lg bg-amber-600 px-4 py-2 text-sm text-white hover:bg-amber-700",children:"在本机 HunterMate 中打开"}):(0,r.jsx)("span",{className:"text-xs text-amber-600",children:"本机 HunterMate 未在运行,启动后即可跳转"})}):(0,r.jsx)("p",{className:"mt-4 text-xs text-amber-600",children:"请在本机打开 HunterMate 后使用此功能。"})]}):(0,r.jsx)(r.Fragment,{children:c})}function c(e){let{feature:t,localPath:s}=e;return(0,l.K5)()?(0,r.jsx)("div",{className:"flex h-full items-center justify-center p-6",children:(0,r.jsx)("div",{className:"w-full max-w-lg",children:(0,r.jsx)(i,{feature:t,localPath:s})})}):null}}},function(e){e.O(0,[502,606,865,431,400,935,744],function(){return e(e.s=19155)}),_N_E=e.O()}]);