From 154f849f57c77543642b2bd460ade616c2758b00 Mon Sep 17 00:00:00 2001 From: whm <973418690@qq.com> Date: Fri, 7 Aug 2026 17:34:15 +0800 Subject: [PATCH] fix: close remaining Z39 slug isolation gaps Bind preview rows and published API base paths to the active module slug so cloned or stale state cannot address another module. Co-authored-by: Cursor --- platform/internal/logic/applogic/publish.go | 9 +++------ web/dist/assets/{index-Pe8anoMp.js => index-D2ZGs_V_.js} | 2 +- web/dist/index.html | 2 +- web/src/api.ts | 7 ++++++- 联调后修改意见-宇恒松离线.md | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) rename web/dist/assets/{index-Pe8anoMp.js => index-D2ZGs_V_.js} (85%) diff --git a/platform/internal/logic/applogic/publish.go b/platform/internal/logic/applogic/publish.go index a55b73c..3e244f0 100644 --- a/platform/internal/logic/applogic/publish.go +++ b/platform/internal/logic/applogic/publish.go @@ -186,9 +186,8 @@ func (l *PublishLogic) Publish(slug string, req *types.PublishReq) (*types.Publi if slug != "" && slug != incoming.Meta.Slug { incoming.Meta.Slug = slug } - if incoming.Apis.BasePath == "" || strings.Contains(incoming.Apis.BasePath, "-") { - incoming.Apis.BasePath = "/api/v1/apps/" + slug - } + // Z39:API 地址只由本次发布路径 slug 决定,禁止克隆蓝图沿用旧模块 base_path。 + incoming.Apis.BasePath = "/api/v1/apps/" + slug mode := strings.ToLower(strings.TrimSpace(req.Mode)) if mode == "" { @@ -568,9 +567,7 @@ func (l *PublishLogic) publishHostMetaOnly( bp := existing.Blueprint bp.Meta.Name = moduleName bp.Meta.Slug = slug - if bp.Apis.BasePath == "" { - bp.Apis.BasePath = "/api/v1/apps/" + slug - } + bp.Apis.BasePath = "/api/v1/apps/" + slug rec := existing rec.Name = moduleName diff --git a/web/dist/assets/index-Pe8anoMp.js b/web/dist/assets/index-D2ZGs_V_.js similarity index 85% rename from web/dist/assets/index-Pe8anoMp.js rename to web/dist/assets/index-D2ZGs_V_.js index 71b6ab7..dee95ab 100644 --- a/web/dist/assets/index-Pe8anoMp.js +++ b/web/dist/assets/index-D2ZGs_V_.js @@ -372,7 +372,7 @@ html body { ${t}-collapse, ${t}-edit, ${t}-copy:not(${t}-copy-icon-only) - `]:{marginInlineStart:0,marginInlineEnd:e.marginXXS}},...TX(e),..._X(e),...MX(),"&-rtl":{direction:"rtl"}}}},zX=()=>({titleMarginTop:"1.2em",titleMarginBottom:"0.5em"}),t_=zt("Typography",OX,zX),jX=e=>{const{prefixCls:t,"aria-label":n,className:r,style:o,classNames:s,styles:i,direction:l,maxLength:c,autoSize:u=!0,value:d,onSave:m,onCancel:f,onEnd:p,component:h,enterIcon:b=a.createElement(EX,null)}=e,x=a.useRef(null),v=a.useRef(!1),g=a.useRef(null),[y,$]=a.useState(d);a.useEffect(()=>{$(d)},[d]),a.useEffect(()=>{var O;if((O=x.current)!=null&&O.resizableTextArea){const{textArea:k}=x.current.resizableTextArea;k.focus();const{length:B}=k.value;k.setSelectionRange(B,B)}},[]);const w=({target:O})=>{$(O.value.replace(/[\n\r]/g,""))},I=()=>{v.current=!0},C=()=>{v.current=!1},N=({keyCode:O})=>{v.current||(g.current=O)},E=()=>{m(y.trim())},R=({keyCode:O,ctrlKey:k,altKey:B,metaKey:j,shiftKey:z})=>{g.current!==O||v.current||k||B||j||z||(O===it.ENTER?(E(),p==null||p()):O===it.ESC&&f())},P=()=>{E()},[T,_]=t_(t),M=F(t,`${t}-edit-content`,{[`${t}-rtl`]:l==="rtl",[`${t}-${h}`]:!!h},r,s.root,T,_);return a.createElement("div",{className:M,style:{...i.root,...o}},a.createElement(J4,{ref:x,maxLength:c,value:y,onChange:w,onKeyDown:N,onKeyUp:R,onCompositionStart:I,onCompositionEnd:C,onBlur:P,"aria-label":n,rows:1,autoSize:u,className:s.textarea,style:i.textarea}),b!==null?Wn(b,{className:`${t}-edit-content-confirm`}):null)},BX=(e,t)=>{let n=!1;const r=o=>{var s,i,l;o.stopPropagation(),o.preventDefault(),(s=o.clipboardData)==null||s.clearData(),(i=o.clipboardData)==null||i.setData("text/plain",e),t&&((l=o.clipboardData)==null||l.setData("text/html",e)),n=!0};try{return document.addEventListener("copy",r,{capture:!0}),document.execCommand("copy"),n}catch{return!1}finally{document.removeEventListener("copy",r,{capture:!0})}},LX=async(e,t)=>{try{return t?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})})]):await navigator.clipboard.writeText(e),!0}catch{return!1}};async function kX(e,t){if(typeof e!="string")return!1;const n=(t==null?void 0:t.format)==="text/html";return!!(await LX(e,n)||BX(e,n))}const AX=({copyConfig:e,children:t})=>{const[n,r]=a.useState(!1),[o,s]=a.useState(!1),i=a.useRef(null),l=()=>{i.current&&clearTimeout(i.current)},c={};e.format&&(c.format=e.format),a.useEffect(()=>l,[]);const u=bt(async d=>{var m;d==null||d.preventDefault(),d==null||d.stopPropagation(),s(!0);try{const f=xt(e.text)?await e.text():e.text;await kX(f||a6(t,{skipEmpty:!0}).join("")||"",c),s(!1),r(!0),l(),i.current=setTimeout(()=>{r(!1)},3e3),(m=e.onCopy)==null||m.call(e,d)}catch(f){throw s(!1),f}});return{copied:n,copyLoading:o,onClick:u}},Ig=(e,t)=>{const n=!!e;return a.useMemo(()=>{const r={...t,...n&&pt(e)?e:null};return[n,r]},[n,e,t])},DX=e=>{const t=a.useRef(void 0);return a.useEffect(()=>{t.current=e}),t.current},FX=(e,t,n)=>a.useMemo(()=>e===!0?{title:t??n}:a.isValidElement(e)?{title:e}:pt(e)?{title:t??n,...e}:{title:e},[e,t,n]),n_=(e,t,n,r,o)=>{const{getPrefixCls:s,direction:i,className:l,style:c,classNames:u,styles:d}=Rt("typography"),m=r??i,f=s("typography",e),p={...o,prefixCls:f,direction:m},h=a.useMemo(()=>({root:l}),[l]),b=a.useMemo(()=>({root:c}),[c]),[x,v]=Bt([h,u,t],[b,d,n],{props:p});return[x,v,f,m]},r_=a.forwardRef((e,t)=>{const{component:n="article",className:r,rootClassName:o,children:s,direction:i,style:l,classNames:c,styles:u,prefixCls:d,...m}=e,[f,p]=t_(d),h=F(d,{[`${d}-rtl`]:i==="rtl"},r,o,f,p,c==null?void 0:c.root),b={...u==null?void 0:u.root,...l};return a.createElement(n,{...m,className:h,style:b,ref:t},s)}),HX=a.forwardRef((e,t)=>{const{prefixCls:n,className:r,rootClassName:o,direction:s,classNames:i,styles:l,...c}=e,[u,d,m,f]=n_(n,i,l,s,e);return a.createElement(r_,{ref:t,className:F(r,o),direction:f,classNames:u,styles:d,prefixCls:m,...c})});var o_={};Object.defineProperty(o_,"__esModule",{value:!0});var VX={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"}}]},name:"copy",theme:"outlined"},WX=o_.default=VX;function h0(){return h0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,h0({},e,{ref:t,icon:WX})),UX=a.forwardRef(KX),cE=e=>e===!1?[!1,!1]:a6(e);function Pg(e,t,n){return e===!0||e===void 0?t:e||n&&t}function qX(e){const t=document.createElement("em");e.appendChild(t);const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.removeChild(t),n.left>r.left||r.right>n.right||n.top>r.top||r.bottom>n.bottom}const h$=e=>["string","number"].includes(typeof e),GX=e=>{const{prefixCls:t,copied:n,locale:r,iconOnly:o,tooltips:s,icon:i,tabIndex:l,onCopy:c,loading:u,className:d,style:m}=e,f=cE(s),p=cE(i),{copied:h,copy:b}=r??{},x=n?h:b,v=Pg(f[n?1:0],x),g=typeof v=="string"?v:x;return a.createElement($o,{title:v},a.createElement("button",{type:"button",className:F(`${t}-copy`,d,{[`${t}-copy-success`]:n,[`${t}-copy-icon-only`]:o}),style:m,onClick:c,"aria-label":g,tabIndex:l},n?Pg(p[1],a.createElement(zx,null),!0):Pg(p[0],u?a.createElement(ki,null):a.createElement(UX,null),!0)))},Zu=a.forwardRef(({style:e,children:t},n)=>{const r=a.useRef(null);return a.useImperativeHandle(n,()=>({isExceed:()=>{const o=r.current;return o.scrollHeight>o.clientHeight},getHeight:()=>r.current.clientHeight})),a.createElement("span",{"aria-hidden":!0,ref:r,style:{position:"fixed",display:"block",left:0,top:0,pointerEvents:"none",backgroundColor:"rgba(255, 0, 0, 0.65)",...e}},t)}),XX=e=>e.reduce((t,n)=>t+(h$(n)?String(n).length:1),0);function uE(e,t){let n=0;const r=[];for(let o=0;ot){const u=t-n;return r.push(String(s).slice(0,u)),r}r.push(s),n=c}return e}const Ng=0,Rg=1,Tg=2,_g=3,dE=4,ed={display:"-webkit-box",overflow:"hidden",WebkitBoxOrient:"vertical"};function YX(e){const{enableMeasure:t,width:n,text:r,children:o,rows:s,expanded:i,measureDeps:l,miscDeps:c,onEllipsis:u}=e,d=a.useMemo(()=>Ln(r),[r]),m=a.useMemo(()=>XX(d),[r]),f=a.useMemo(()=>o(d,!1),[r].concat($t(l))),[p,h]=a.useState(null),b=a.useRef(null),x=a.useRef(null),v=a.useRef(null),g=a.useRef(null),y=a.useRef(null),[$,w]=a.useState(!1),[I,C]=a.useState(Ng),[N,E]=a.useState(0),[R,P]=a.useState(null);Nt(()=>{C(t&&n&&m?Rg:Ng)},[n,r,s,t,d].concat($t(l))),Nt(()=>{var O,k,B,j;if(I===Rg){C(Tg);const z=x.current&&getComputedStyle(x.current).whiteSpace;P(z)}else if(I===Tg){const z=!!((O=v.current)!=null&&O.isExceed());C(z?_g:dE),h(z?[0,m]:null),w(z);const A=((k=v.current)==null?void 0:k.getHeight())||0,D=s===1?0:((B=g.current)==null?void 0:B.getHeight())||0,L=((j=y.current)==null?void 0:j.getHeight())||0,H=Math.max(A,D+L);E(H+1),u(z)}},[I]);const T=p?Math.ceil((p[0]+p[1])/2):0;Nt(()=>{var B;const[O,k]=p||[0,0];if(O!==k){const z=(((B=b.current)==null?void 0:B.getHeight())||0)>N;let A=T;k-O===1&&(A=z?O:k),h(z?[O,A]:[A,k])}},[p,T]);const _=a.useMemo(()=>{if(!t)return o(d,!1);if(I!==_g||!p||p[0]!==p[1]){const O=o(d,!1);return[dE,Ng].includes(I)?O:a.createElement("span",{style:{...ed,WebkitLineClamp:s}},O)}return o(i?d:uE(d,p[0]),$)},[i,I,p,d].concat($t(c))),M={width:n,margin:0,padding:0,whiteSpace:R==="nowrap"?"normal":"inherit"};return a.createElement(a.Fragment,null,_,I===Tg&&a.createElement(a.Fragment,null,a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:s},ref:v},f),a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:s-1},ref:g},f),a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:1},ref:y},o([],!0))),I===_g&&p&&p[0]!==p[1]&&a.createElement(Zu,{style:{...M,top:400},ref:b},o(uE(d,T),!0)),I===Rg&&a.createElement("span",{style:{whiteSpace:"inherit"},ref:x}))}const QX=({enableEllipsis:e,isEllipsis:t,open:n,children:r,tooltipProps:o})=>{if(!(o!=null&&o.title)||!e)return r;const s=n&&t;return a.createElement($o,{open:s,...o},r)};function JX({mark:e,code:t,underline:n,delete:r,strong:o,keyboard:s,italic:i},l){let c=l;function u(d,m){m&&(c=a.createElement(d,{},c))}return u("strong",o),u("u",n),u("del",r),u("code",t),u("mark",e),u("kbd",s),u("i",i),c}const ZX="...",fE=["delete","mark","code","underline","strong","keyboard","italic"],Gm=a.forwardRef((e,t)=>{const{prefixCls:n,className:r,style:o,classNames:s,styles:i,direction:l,type:c,disabled:u,children:d,ellipsis:m,editable:f,copyable:p,actions:h,component:b,title:x,onMouseEnter:v,onMouseLeave:g,...y}=e,[$]=Ar("Text"),w=a.useRef(null),I=a.useRef(null),[C,N,E,R]=n_(n,s,i,l,e),P=Vt(y,fE),[T,_]=Ig(f),[M,O]=sn(!1,_.editing),{triggerType:k=["icon"]}=_,B=Pe=>{var ve;Pe&&((ve=_.onStart)==null||ve.call(_)),O(Pe)},j=DX(M);Nt(()=>{var Pe;!M&&j&&((Pe=I.current)==null||Pe.focus())},[M]);const z=Pe=>{Pe==null||Pe.preventDefault(),B(!0)},A=Pe=>{var ve;(ve=_.onChange)==null||ve.call(_,Pe),B(!1)},D=()=>{var Pe;(Pe=_.onCancel)==null||Pe.call(_),B(!1)},[L,H]=Ig(p),{placement:K="end"}=h??{},{copied:V,copyLoading:W,onClick:q}=AX({copyConfig:H,children:d}),[ee,se]=a.useState(!1),[le,ce]=a.useState(!1),[G,ne]=a.useState(!1),[re,U]=a.useState(!1),[J,oe]=a.useState(!0),[Z,Q]=Ig(m,{expandable:!1,symbol:Pe=>Pe?$==null?void 0:$.collapse:$==null?void 0:$.expand}),[ae,te]=sn(Q.defaultExpanded||!1,Q.expanded),Y=Z&&(!ae||Q.expandable==="collapsible"),{rows:de=1}=Q,ue=a.useMemo(()=>Y&&(Q.suffix!==void 0||Q.onEllipsis||Q.expandable||T||L),[Y,Q,T,L]);Nt(()=>{Z&&!ue&&(se(FS("webkitLineClamp")),ce(FS("textOverflow")))},[ue,Z]);const[ge,we]=a.useState(Y),he=a.useMemo(()=>ue?!1:de===1?le:ee,[ue,de,ee,le]);Nt(()=>{we(he&&Y)},[he,Y]);const Be=FX(Q.tooltip,_.text,d),be=ge&&!!Be.title,Fe=Y&&(ge?be&&re:G),_e=Y&&de===1&&ge,Ee=Y&&de>1&&ge,Te=(Pe,ve)=>{var Se;te(ve.expanded),(Se=Q.onExpand)==null||Se.call(Q,Pe,ve)},[$e,Ce]=a.useState(0),[qe,Qe]=a.useState(!1),[ye,Ne]=a.useState(!1),Re=({offsetWidth:Pe})=>{Ce(Pe)},Xe=Pe=>{var ve;ne(Pe),G!==Pe&&((ve=Q.onEllipsis)==null||ve.call(Q,Pe))};a.useEffect(()=>{const Pe=w.current;if(Z&&be&&Pe){const ve=qX(Pe);re!==ve&&U(ve)}},[Z,be,d,Ee,J,$e]),a.useEffect(()=>{const Pe=w.current;if(typeof IntersectionObserver>"u"||!Pe||!be||!Y)return;const ve=new IntersectionObserver(()=>{oe(!!Pe.offsetParent)});return ve.observe(Pe),()=>{ve.disconnect()}},[be,Y]);const Ye=a.useMemo(()=>{if(!(!Z||ge))return[_.text,d,x,Be.title].find(h$)},[Z,ge,x,Be.title,Fe,_.text]);if(M)return a.createElement(jX,{value:_.text??(typeof d=="string"?d:""),onSave:A,onCancel:D,onEnd:_.onEnd,prefixCls:E,className:r,style:o,direction:R,component:b,maxLength:_.maxLength,autoSize:_.autoSize,enterIcon:_.enterIcon,classNames:C,styles:N});const Ve=()=>{const{expandable:Pe,symbol:ve}=Q;return Pe?a.createElement("button",{type:"button",key:"expand",className:F(`${E}-${ae?"collapse":"expand"}`,C.action),style:N.action,onClick:Se=>Te(Se,{expanded:!ae}),"aria-label":ae?$.collapse:$==null?void 0:$.expand},xt(ve)?ve(ae):ve):null},at=()=>{if(!T)return;const{icon:Pe,tooltip:ve,tabIndex:Se}=_,Me=Ln(ve)[0]||($==null?void 0:$.edit),Ie=typeof Me=="string"?Me:"";return k.includes("icon")?a.createElement($o,{key:"edit",title:ve===!1?"":Me},a.createElement("button",{type:"button",ref:I,className:F(`${E}-edit`,C.action),style:N.action,onClick:z,"aria-label":Ie,tabIndex:Se},Pe||a.createElement(mu,{role:"button"}))):null},xe=()=>L?a.createElement(GX,{key:"copy",...H,prefixCls:E,copied:V,locale:$,onCopy:q,loading:W,iconOnly:!wn(d),className:C.action,style:N.action}):null,Le=Pe=>{const ve=Pe&&Ve(),Se=at(),Me=xe();return!ve&&!Se&&!Me?null:a.createElement("span",{key:"operations",className:F(`${E}-actions`,C.actions,{[`${E}-actions-start`]:K==="start"}),style:N.actions,onMouseEnter:()=>Qe(!0),onMouseLeave:()=>Qe(!1)},ve,Se,Me)},me=Pe=>[Pe&&!ae&&a.createElement("span",{"aria-hidden":!0,key:"ellipsis"},ZX),Q.suffix];return a.createElement(lr,{onResize:Re,disabled:!Y},Pe=>a.createElement(QX,{tooltipProps:Be,enableEllipsis:Y,isEllipsis:Fe,open:ye&&!qe},a.createElement(r_,{onMouseEnter:ve=>{Ne(!0),v==null||v(ve)},onMouseLeave:ve=>{Ne(!1),g==null||g(ve)},className:F({[`${E}-${c}`]:c,[`${E}-disabled`]:u,[`${E}-ellipsis`]:Z,[`${E}-ellipsis-single-line`]:_e,[`${E}-ellipsis-multiple-line`]:Ee,[`${E}-link`]:b==="a"},r),classNames:C,styles:N,prefixCls:E,style:{...o,WebkitLineClamp:Ee?de:void 0},component:b,ref:On(Pe,w,t),direction:R,onClick:k.includes("text")?z:void 0,"aria-label":Ye==null?void 0:Ye.toString(),title:x,...P},a.createElement(YX,{enableMeasure:Y&&!ge,text:d,rows:de,width:$e,onEllipsis:Xe,expanded:ae,measureDeps:[K],miscDeps:[V,ae,W,T,L,K,$].concat($t(fE.map(ve=>e[ve])))},(ve,Se)=>JX(e,a.createElement(a.Fragment,null,K==="start"?Le(Se):null,ve.length>0&&Se&&!ae&&Ye?a.createElement("span",{key:"show-content","aria-hidden":!0},ve):ve,me(Se),K==="start"?null:Le(Se)))))))}),eY=a.forwardRef((e,t)=>{const{ellipsis:n,rel:r,children:o,navigate:s,...i}=e,l={...i,rel:r===void 0&&i.target==="_blank"?"noopener noreferrer":r};return a.createElement(Gm,{...l,ref:t,ellipsis:!!n,component:"a"},o)}),tY=a.forwardRef((e,t)=>{const{children:n,...r}=e;return a.createElement(Gm,{ref:t,...r,component:"div"},n)}),nY=a.forwardRef((e,t)=>{const{ellipsis:n,children:r,...o}=e,s=a.useMemo(()=>pt(n)?Vt(n,["expandable","rows"]):n,[n]);return a.createElement(Gm,{ref:t,...o,ellipsis:s,component:"span"},r)}),rY=[1,2,3,4,5],oY=a.forwardRef((e,t)=>{const{level:n=1,children:r,...o}=e,s=rY.includes(n)?`h${n}`:"h1";return a.createElement(Gm,{ref:t,...o,component:s},r)}),Oe=HX;Oe.Text=nY;Oe.Link=eY;Oe.Title=oY;Oe.Paragraph=tY;var Xm={},s_={exports:{}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(s_);var y$=s_.exports,Ym={};Object.defineProperty(Ym,"__esModule",{value:!0});Ym.default=void 0;const sY={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:"页码"};Ym.default=sY;var Qm={},pu={},Jm={},Zm={};Object.defineProperty(Zm,"__esModule",{value:!0});Zm.commonLocale=void 0;Zm.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0};Object.defineProperty(Jm,"__esModule",{value:!0});Jm.default=void 0;var iY=Zm;const aY={...iY.commonLocale,locale:"zh_CN",today:"今天",now:"此刻",backToToday:"返回今天",ok:"确定",timeSelect:"选择时间",dateSelect:"选择日期",weekSelect:"选择周",clear:"清除",week:"周",month:"月",year:"年",previousMonth:"上个月 (翻页上键)",nextMonth:"下个月 (翻页下键)",monthSelect:"选择月份",yearSelect:"选择年份",decadeSelect:"选择年代",previousYear:"上一年 (Control键加左方向键)",nextYear:"下一年 (Control键加右方向键)",previousDecade:"上一年代",nextDecade:"下一年代",previousCentury:"上一世纪",nextCentury:"下一世纪",yearFormat:"YYYY年",cellDateFormat:"D",monthBeforeYear:!1};Jm.default=aY;var gu={};Object.defineProperty(gu,"__esModule",{value:!0});gu.default=void 0;const lY={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]};gu.default=lY;var i_=y$.default;Object.defineProperty(pu,"__esModule",{value:!0});pu.default=void 0;var cY=i_(Jm),uY=i_(gu);const a_={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...cY.default},timePickerLocale:{...uY.default}};a_.lang.ok="确定";pu.default=a_;var dY=y$.default;Object.defineProperty(Qm,"__esModule",{value:!0});Qm.default=void 0;var fY=dY(pu);Qm.default=fY.default;var ep=y$.default;Object.defineProperty(Xm,"__esModule",{value:!0});Xm.default=void 0;var mY=ep(Ym),pY=ep(Qm),gY=ep(pu),hY=ep(gu);const Pr="${label}不是一个有效的${type}",yY={locale:"zh-cn",Pagination:mY.default,DatePicker:gY.default,TimePicker:hY.default,Calendar:pY.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:"收起"},Form:{optional:"(可选)",defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:Pr,method:Pr,array:Pr,object:Pr,number:Pr,date:Pr,boolean:Pr,integer:Pr,float:Pr,regexp:Pr,email:Pr,url:Pr,hex:Pr},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:"渐变色"}};Xm.default=yY;var vY=Xm;const bY=W0(vY);let v$=null;function xY(){return v$}function Mg(){v$=null}function mE(e){v$=e}function $Y(e){const t=typeof window<"u"?window.__AJZ_PREVIEW__:void 0;return!(t!=null&&t.blueprint)||t.id&&t.id!==e?null:{id:String(t.id||e),blueprint:t.blueprint,rows:Array.isArray(t.rows)?t.rows:[],resource:String(t.resource||"records")}}async function SY(e){const t=$Y(e);if(t)return mE(t),t;const n=await fetch(`/ai/api/v1/preview/${encodeURIComponent(e)}`),r=await n.json();if(!n.ok||!(r!=null&&r.ok))throw new Error((r==null?void 0:r.error)||`预览不存在或已过期 (${n.status})`);const o={id:String(r.id||e),blueprint:r.blueprint,rows:Array.isArray(r.rows)?r.rows:[],resource:String(r.resource||"records")};return mE(o),o}function td(){const t=(window.location.hash||"").replace(/^#/,"").match(/^\/?preview\/([a-zA-Z0-9_-]{6,32})\/?$/);return t?t[1]:null}const l_=[{title:"模块",items:[{id:"读取模块",label:"读取模块"},{id:"写入模块",label:"写入模块"},{id:"发布模块",label:"发布模块"}]},{title:"数据",items:[{id:"查询数据",label:"查询数据"},{id:"新增数据",label:"新增数据"},{id:"更新数据",label:"更新数据"},{id:"删除数据",label:"删除数据"},{id:"导入数据",label:"导入数据"},{id:"导出数据",label:"导出数据"}]},{title:"其他",items:[{id:"下载文件",label:"下载文件"},{id:"上传文件",label:"上传文件"},{id:"查看审计",label:"查看审计"}]}],c_={"app.read":"读取模块","app.write":"写入模块","app.admin":"发布模块","row.create":"新增数据","row.read":"查询数据","row.update":"更新数据","row.delete":"删除数据","row.export":"导出数据","row.import":"导入数据","audit.read":"查看审计","storage.write":"上传文件","storage.read":"下载文件","agent.admin":"管理智能体","tenant.invite":"邀请成员","org.admin":"管理组织","sync.admin":"数据同步"},CY={...Object.fromEntries(l_.flatMap(e=>e.items.map(t=>[t.id,t.label]))),管理智能体:"管理智能体",邀请成员:"邀请成员",管理组织:"管理组织",数据同步:"数据同步"};function Ma(e){const t=c_[e]||e;return CY[t]||t}function tp(e){switch(e){case"platform_admin":case"super_admin":case"超级管理员":return"超级管理员";case"owner":case"管理员":return"管理员";case"editor":case"编辑":return"编辑";case"viewer":case"只读":return"只读";case"pending":case"待加入":return"待加入";case"agent":case"智能体":return"智能体";default:return e}}function rc(e){return tp(e)}function Nr(e){return tp(e||"")==="超级管理员"}function jl(e){return tp(e||"")==="管理员"}function wY(e){var r;const t=((r=e.allowedModules)!=null&&r.length?e.allowedModules:l_.map(o=>({title:o.title,items:o.items.map(s=>({perm:s.id,desc:s.label}))}))).map(o=>({title:o.title,items:o.items||(o.perms||[]).map(s=>({perm:s,desc:Ma(s)}))})),n=e.value.map(o=>c_[o]||o);return S.jsx(Mt,{direction:"vertical",size:"middle",style:{width:"100%"},children:t.map(o=>{const s=o.items.map(i=>i.perm);return S.jsxs("div",{children:[S.jsx(Oe.Text,{type:"secondary",strong:!0,children:o.title}),S.jsx("div",{style:{marginTop:8},children:S.jsx(go.Group,{style:{width:"100%",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},value:n.filter(i=>s.includes(i)),onChange:i=>{const l=new Set(s),c=n.filter(u=>!l.has(u));e.onChange([...c,...i])},options:o.items.map(i=>({label:S.jsxs("span",{children:[Ma(i.perm),i.desc?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:i.desc})]}):null]}),value:i.perm}))})})]},o.title)})})}function EY(e,t){return e==null?!0:e.includes(t)}const Un="",Dc="/ai",b$="ajz_session";function Og(e){if(!e)return!1;const t=tp(e.role||"");return t==="超级管理员"||e.username==="ljk_admin"?!1:t==="待加入"||e.status==="pending"||!e.tenantId}function u_(e){if(!e||e.split(".").length<2)return"";try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),r=atob(n),o=Uint8Array.from(r,i=>i.charCodeAt(0)),s=JSON.parse(new TextDecoder().decode(o));return typeof(s==null?void 0:s.role)=="string"?s.role:""}catch{return""}}function Oa(e){try{localStorage.removeItem(b$)}catch{}(e==null?void 0:e.emit)!==!1&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("ajz:session-expired"))}function zg(){try{const e=localStorage.getItem(b$);if(!e)return null;const t=JSON.parse(e);return!(t!=null&&t.accessToken)||typeof t.accessToken!="string"||t.accessToken.split(".").length!==3?(Oa({emit:!1}),null):t.expiresAt&&t.expiresAt*1e3Object.entries(r).every(([x,v])=>!v||String(b[x]??"")===String(v))));const h=Math.max(0,(o-1)*s);return{items:p.slice(h,h+s),total:p.length}}const d={};e!=null&&e.accessToken&&(d.Authorization=`Bearer ${e.accessToken}`);const m=await tt(c,{headers:d,cache:"no-store"}),f=await nt(m);return ot(m,f,"list failed"),f}async function BY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"create failed"),s}async function LY(e,t,n,r,o){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const s=await tt(`${Un}/api/v1/apps/${t}/${n}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(o)}),i=await nt(s);return ot(s,i,"update failed"),i}async function kY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}/${r}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}});if(!o.ok&&o.status!==204){const s=await nt(o).catch(()=>({}));ot(o,s,"delete failed")}}async function AY(e,t,n,r,o){const s=new URLSearchParams;r&&s.set("group_by",r),o&&s.set("sum",o);const i={};e!=null&&e.accessToken&&(i.Authorization=`Bearer ${e.accessToken}`);const l=await tt(`${Un}/api/v1/apps/${t}/${n}/aggregate?${s}`,{headers:i}),c=await nt(l);return ot(l,c,"aggregate failed"),c}async function DY(e,t){const n=await tt(`${Un}/api/v1/apps/${t}/agent-capsule`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"capsule failed"),r}async function FY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=new FormData;o.append("file",r);const s=await tt(`${Un}/api/v1/apps/${t}/${n}/import`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:o}),i=await nt(s);return ot(s,i,"import failed"),i}async function HY(e,t,n,r="xlsx"){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}/export?format=${r}`,{headers:{Authorization:`Bearer ${e.accessToken}`}});if(!o.ok){const c=await nt(o).catch(()=>({}));ot(o,c,"export failed")}const s=await o.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=`${n}.${r==="csv"?"csv":"xlsx"}`,l.click(),URL.revokeObjectURL(i)}async function VY(e,t=1){const n=await tt(`/api/v1/audit/logs?page=${t}&page_size=50`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"audit failed"),r}async function d_(e){const t=await tt("/api/v1/admin/agents",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list agents failed"),n}async function WY(e,t){const n=await tt("/api/v1/admin/agents",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create agent failed"),r}async function gE(e,t,n){const r=await tt(`/api/v1/admin/agents/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update agent failed"),o}async function KY(e,t){const n=await tt(`/api/v1/admin/agents/${t}/rotate-secret`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"rotate secret failed"),r}async function UY(e,t){const n=await tt(`/api/v1/admin/agents/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete agent failed")}async function f_(e){const t=await tt("/api/v1/admin/roles",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list roles failed"),n}async function qY(e,t){const n=await tt("/api/v1/admin/roles",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create role failed"),r}async function GY(e,t,n){const r=await tt(`/api/v1/admin/roles/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update role failed"),o}async function XY(e,t){const n=await tt(`/api/v1/admin/roles/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete role failed")}async function YY(e,t){const n=await tt("/api/v1/auth/invites/accept",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({code:t})}),r=await nt(n);return ot(n,r,"accept invite failed"),cl(r)}async function QY(e,t){const n=await tt("/api/v1/tenants",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:t})}),r=await nt(n);return ot(n,r,"create tenant failed"),cl(r)}async function JY(e){const t=await tt("/api/v1/admin/invites",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list invites failed"),n}async function ZY(e,t){const n=await tt("/api/v1/admin/invites",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create invite failed"),r}async function eQ(e,t){const n=await tt(`/api/v1/admin/invites/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"revoke invite failed")}async function x$(e){const t=await tt("/api/v1/admin/org-units",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list org units failed"),n}async function tQ(e,t){const n=await tt("/api/v1/admin/org-units",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create org unit failed"),r}async function nQ(e,t,n){const r=await tt(`/api/v1/admin/org-units/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update org unit failed"),o}async function rQ(e,t){const n=await tt(`/api/v1/admin/org-units/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete org unit failed")}async function m_(e){const t=await tt("/api/v1/admin/sync/channels",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list sync channels failed"),n}async function oQ(e,t){const n=await tt("/api/v1/admin/sync/channels",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create sync channel failed"),r}async function sQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update sync channel failed"),o}async function iQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"delete sync channel failed"),r}async function aQ(e,t){const n=await tt("/api/v1/admin/sync/test",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"test sync failed"),r}async function hE(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/start`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"start sync failed"),r}async function lQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/stop`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"stop sync failed"),r}async function cQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/reconcile`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"reconcile failed"),r}async function uQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/checkpoint`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"get checkpoint failed"),r}async function dQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/restore`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"restore failed"),o}async function fQ(e,t,n){const r=(n==null?void 0:n.side)||"remote",o=new URLSearchParams({side:r});o.set("include_sync_meta","1");const s=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/inspect?${o}`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),i=await nt(s);return ot(s,i,"inspect failed"),i}async function mQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/preview`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"preview failed"),o}async function pQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/drop-table`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"drop table failed"),o}async function gQ(e){const t=await tt("/api/v1/admin/bind-codes",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list bind codes failed"),n}async function hQ(e,t){const n=await tt("/api/v1/admin/bind-codes",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t||{})}),r=await nt(n);return ot(n,r,"create bind code failed"),r}async function yQ(e,t){const n=await tt(`/api/v1/admin/bind-codes/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"revoke bind code failed"),r}async function p_(e,t){const r=await tt("/api/v1/admin/sync/bindings",{headers:{Authorization:`Bearer ${e.accessToken}`}}),o=await nt(r);return ot(r,o,"list bindings failed"),o}async function vQ(e,t){const n=new URLSearchParams;t!=null&&t.tenant_id&&n.set("tenant_id",String(t.tenant_id)),t!=null&&t.channel_id&&n.set("channel_id",t.channel_id),n.set("limit",String(t.limit));const r=n.toString(),o=await tt(`/api/v1/platform/dbsync/lww-overrides${r?`?${r}`:""}`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),s=await nt(o);return ot(o,s,"list lww overrides failed"),s}async function bQ(e,t){const n=await tt(`/api/v1/platform/dbsync/lww-overrides/${encodeURIComponent(t)}/rollback`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"lww rollback failed"),r}async function xQ(e){const t=await tt("/api/v1/platform/tenants",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list tenants failed"),n}async function $Q(e){const t=await tt("/api/v1/platform/perm-modules",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list perm modules failed"),n}async function SQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/permissions`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"get tenant perms failed"),r}async function CQ(e,t,n){const r=await tt(`/api/v1/platform/tenants/${t}/permissions`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({permissions:n})}),o=await nt(r);return ot(r,o,"set tenant perms failed"),o}async function wQ(e,t,n=!1,r="",o=""){const s=await tt("/api/v1/platform/tenants",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:t,slug:r||void 0,with_admin_invite:n,admin_phone:o.trim()||void 0})}),i=await nt(s);return ot(s,i,"create tenant failed"),i}async function EQ(e,t,n,r=""){const o=await tt(`/api/v1/platform/tenants/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:n,slug:r||void 0})}),s=await nt(o);return ot(o,s,"update tenant failed"),s}async function IQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/admin-invite`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"admin invite failed"),r}async function PQ(e,t,n){const r=await tt(`/api/v1/platform/tenants/${t}/admin-account`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({phone:n.trim()})}),o=await nt(r);return ot(r,o,"admin account failed"),o}async function NQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/admins`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"list admins failed"),r}async function RQ(e,t,n,r){const o=await tt(`/api/v1/platform/tenants/${t}/admins/${n}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"update admin failed"),s}async function TQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/enter`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"enter tenant failed"),cl(r)}async function g_(e){const t=await tt("/api/v1/platform/exit",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"exit tenant failed"),cl(n)}async function h_(e){const t=await tt("/api/v1/admin/entitlements",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"get entitlements failed"),n}async function _Q(e){const t=await tt("/api/v1/admin/members",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list members failed"),n}async function MQ(e,t){const n=await tt("/api/v1/admin/members",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create member failed"),r}async function OQ(e,t,n){const r=await tt("/api/v1/auth/password",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({old_password:t,new_password:n})}),o=await nt(r);return ot(r,o,"change password failed"),o}async function zQ(e,t,n){const r={phone:t},o=await tt("/api/v1/auth/phone",{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"bind phone failed"),s}async function yE(e,t,n){const r=await tt(`/api/v1/admin/members/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update member failed"),o}async function jQ(e,t){const n=new FormData;n.append("file",t);const r=await tt("/api/v1/storage",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:n}),o=await nt(r);return ot(r,o,"upload failed"),o}var y_={};Object.defineProperty(y_,"__esModule",{value:!0});var BQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M908 640H804V488c0-4.4-3.6-8-8-8H548v-96h108c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16H368c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h108v96H228c-4.4 0-8 3.6-8 8v152H116c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16H292v-88h440v88H620c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16zm-564 76v168H176V716h168zm84-408V140h168v168H428zm420 576H680V716h168v168z"}}]},name:"apartment",theme:"outlined"},LQ=y_.default=BQ;function v0(){return v0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,v0({},e,{ref:t,icon:LQ})),AQ=a.forwardRef(kQ);var v_={};Object.defineProperty(v_,"__esModule",{value:!0});var DQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 00-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 000 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3 2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4-186.8-186.8 59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7 35.3 0 68.4 13.7 93.4 38.7 24.9 24.9 38.7 58.1 38.7 93.4 0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 00-11.3 0L501 613.3 410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 00-11.3 0L363 475.3l-43-43a7.85 7.85 0 00-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 000 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3 51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43 66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 01-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 01-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4 186.8 186.8-59.4 59.4z"}}]},name:"api",theme:"outlined"},FQ=v_.default=DQ;function b0(){return b0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,b0({},e,{ref:t,icon:FQ})),b_=a.forwardRef(HQ);var x_={};Object.defineProperty(x_,"__esModule",{value:!0});var VQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"}}]},name:"appstore",theme:"outlined"},WQ=x_.default=VQ;function x0(){return x0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,x0({},e,{ref:t,icon:WQ})),UQ=a.forwardRef(KQ);var $_={};Object.defineProperty($_,"__esModule",{value:!0});var qQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M872 474H286.9l350.2-304c5.6-4.9 2.2-14-5.2-14h-88.5c-3.9 0-7.6 1.4-10.5 3.9L155 487.8a31.96 31.96 0 000 48.3L535.1 866c1.5 1.3 3.3 2 5.2 2h91.5c7.4 0 10.8-9.2 5.2-14L286.9 550H872c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"arrow-left",theme:"outlined"},GQ=$_.default=qQ;function $0(){return $0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,$0({},e,{ref:t,icon:GQ})),YQ=a.forwardRef(XQ);var S_={};Object.defineProperty(S_,"__esModule",{value:!0});var QQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M296 250c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H296zm184 144H296c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zm-48 458H208V148h560v320c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V108c0-17.7-14.3-32-32-32H168c-17.7 0-32 14.3-32 32v784c0 17.7 14.3 32 32 32h264c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm440-88H728v-36.6c46.3-13.8 80-56.6 80-107.4 0-61.9-50.1-112-112-112s-112 50.1-112 112c0 50.7 33.7 93.6 80 107.4V764H520c-8.8 0-16 7.2-16 16v152c0 8.8 7.2 16 16 16h352c8.8 0 16-7.2 16-16V780c0-8.8-7.2-16-16-16zM646 620c0-27.6 22.4-50 50-50s50 22.4 50 50-22.4 50-50 50-50-22.4-50-50zm180 266H566v-60h260v60z"}}]},name:"audit",theme:"outlined"},JQ=S_.default=QQ;function S0(){return S0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,S0({},e,{ref:t,icon:JQ})),eJ=a.forwardRef(ZQ);var C_={};Object.defineProperty(C_,"__esModule",{value:!0});var tJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M894 462c30.9 0 43.8-39.7 18.7-58L530.8 126.2a31.81 31.81 0 00-37.6 0L111.3 404c-25.1 18.2-12.2 58 18.8 58H192v374h-72c-4.4 0-8 3.6-8 8v52c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-52c0-4.4-3.6-8-8-8h-72V462h62zM512 196.7l271.1 197.2H240.9L512 196.7zM264 462h117v374H264V462zm189 0h117v374H453V462zm307 374H642V462h118v374z"}}]},name:"bank",theme:"outlined"},nJ=C_.default=tJ;function C0(){return C0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,C0({},e,{ref:t,icon:nJ})),vE=a.forwardRef(rJ);var w_={};Object.defineProperty(w_,"__esModule",{value:!0});var oJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M811.4 368.9C765.6 248 648.9 162 512.2 162S258.8 247.9 213 368.8C126.9 391.5 63.5 470.2 64 563.6 64.6 668 145.6 752.9 247.6 762c4.7.4 8.7-3.3 8.7-8v-60.4c0-4-3-7.4-7-7.9-27-3.4-52.5-15.2-72.1-34.5-24-23.5-37.2-55.1-37.2-88.6 0-28 9.1-54.4 26.2-76.4 16.7-21.4 40.2-36.9 66.1-43.7l37.9-10 13.9-36.7c8.6-22.8 20.6-44.2 35.7-63.5 14.9-19.2 32.6-36 52.4-50 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.3c19.9 14 37.5 30.8 52.4 50 15.1 19.3 27.1 40.7 35.7 63.5l13.8 36.6 37.8 10c54.2 14.4 92.1 63.7 92.1 120 0 33.6-13.2 65.1-37.2 88.6-19.5 19.2-44.9 31.1-71.9 34.5-4 .5-6.9 3.9-6.9 7.9V754c0 4.7 4.1 8.4 8.8 8 101.7-9.2 182.5-94 183.2-198.2.6-93.4-62.7-172.1-148.6-194.9z"}},{tag:"path",attrs:{d:"M376.9 656.4c1.8-33.5 15.7-64.7 39.5-88.6 25.4-25.5 60-39.8 96-39.8 36.2 0 70.3 14.1 96 39.8 1.4 1.4 2.7 2.8 4.1 4.3l-25 19.6a8 8 0 003 14.1l98.2 24c5 1.2 9.9-2.6 9.9-7.7l.5-101.3c0-6.7-7.6-10.5-12.9-6.3L663 532.7c-36.6-42-90.4-68.6-150.5-68.6-107.4 0-195 85.1-199.4 191.7-.2 4.5 3.4 8.3 8 8.3H369c4.2-.1 7.7-3.4 7.9-7.7zM703 664h-47.9c-4.2 0-7.7 3.3-8 7.6-1.8 33.5-15.7 64.7-39.5 88.6-25.4 25.5-60 39.8-96 39.8-36.2 0-70.3-14.1-96-39.8-1.4-1.4-2.7-2.8-4.1-4.3l25-19.6a8 8 0 00-3-14.1l-98.2-24c-5-1.2-9.9 2.6-9.9 7.7l-.4 101.4c0 6.7 7.6 10.5 12.9 6.3l23.2-18.2c36.6 42 90.4 68.6 150.5 68.6 107.4 0 195-85.1 199.4-191.7.2-4.5-3.4-8.3-8-8.3z"}}]},name:"cloud-sync",theme:"outlined"},sJ=w_.default=oJ;function w0(){return w0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,w0({},e,{ref:t,icon:sJ})),aJ=a.forwardRef(iJ);var E_={};Object.defineProperty(E_,"__esModule",{value:!0});var lJ={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM653.3 424.6l52.2 52.2a8.01 8.01 0 01-4.7 13.6l-179.4 21c-5.1.6-9.5-3.7-8.9-8.9l21-179.4c.8-6.6 8.9-9.4 13.6-4.7l52.4 52.4 256.2-256.2c3.1-3.1 8.2-3.1 11.3 0l42.4 42.4c3.1 3.1 3.1 8.2 0 11.3L653.3 424.6z"}}]},name:"import",theme:"outlined"},cJ=E_.default=lJ;function E0(){return E0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,E0({},e,{ref:t,icon:cJ})),dJ=a.forwardRef(uJ);var I_={};Object.defineProperty(I_,"__esModule",{value:!0});var fJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5L255.8 713.6l-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l110.3 111.2c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.1 304.1 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112m161.2 465.2C726.2 620.3 668.9 644 608 644s-118.2-23.7-161.2-66.8C403.7 534.2 380 476.9 380 416s23.7-118.2 66.8-161.2c43-43.1 100.3-66.8 161.2-66.8s118.2 23.7 161.2 66.8c43.1 43 66.8 100.3 66.8 161.2s-23.7 118.2-66.8 161.2"}}]},name:"key",theme:"outlined"},mJ=I_.default=fJ;function I0(){return I0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,I0({},e,{ref:t,icon:mJ})),jf=a.forwardRef(pJ);var P_={};Object.defineProperty(P_,"__esModule",{value:!0});var gJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M521.7 82c-152.5-.4-286.7 78.5-363.4 197.7-3.4 5.3.4 12.3 6.7 12.3h70.3c4.8 0 9.3-2.1 12.3-5.8 7-8.5 14.5-16.7 22.4-24.5 32.6-32.5 70.5-58.1 112.7-75.9 43.6-18.4 90-27.8 137.9-27.8 47.9 0 94.3 9.3 137.9 27.8 42.2 17.8 80.1 43.4 112.7 75.9 32.6 32.5 58.1 70.4 76 112.5C865.7 417.8 875 464.1 875 512c0 47.9-9.4 94.2-27.8 137.8-17.8 42.1-43.4 80-76 112.5s-70.5 58.1-112.7 75.9A352.8 352.8 0 01520.6 866c-47.9 0-94.3-9.4-137.9-27.8A353.84 353.84 0 01270 762.3c-7.9-7.9-15.3-16.1-22.4-24.5-3-3.7-7.6-5.8-12.3-5.8H165c-6.3 0-10.2 7-6.7 12.3C234.9 863.2 368.5 942 520.6 942c236.2 0 428-190.1 430.4-425.6C953.4 277.1 761.3 82.6 521.7 82zM395.02 624v-76h-314c-4.4 0-8-3.6-8-8v-56c0-4.4 3.6-8 8-8h314v-76c0-6.7 7.8-10.5 13-6.3l141.9 112a8 8 0 010 12.6l-141.9 112c-5.2 4.1-13 .4-13-6.3z"}}]},name:"login",theme:"outlined"},hJ=P_.default=gJ;function P0(){return P0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,P0({},e,{ref:t,icon:hJ})),vJ=a.forwardRef(yJ);var N_={};Object.defineProperty(N_,"__esModule",{value:!0});var bJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M868 732h-70.3c-4.8 0-9.3 2.1-12.3 5.8-7 8.5-14.5 16.7-22.4 24.5a353.84 353.84 0 01-112.7 75.9A352.8 352.8 0 01512.4 866c-47.9 0-94.3-9.4-137.9-27.8a353.84 353.84 0 01-112.7-75.9 353.28 353.28 0 01-76-112.5C167.3 606.2 158 559.9 158 512s9.4-94.2 27.8-137.8c17.8-42.1 43.4-80 76-112.5s70.5-58.1 112.7-75.9c43.6-18.4 90-27.8 137.9-27.8 47.9 0 94.3 9.3 137.9 27.8 42.2 17.8 80.1 43.4 112.7 75.9 7.9 7.9 15.3 16.1 22.4 24.5 3 3.7 7.6 5.8 12.3 5.8H868c6.3 0 10.2-7 6.7-12.3C798 160.5 663.8 81.6 511.3 82 271.7 82.6 79.6 277.1 82 516.4 84.4 751.9 276.2 942 512.4 942c152.1 0 285.7-78.8 362.3-197.7 3.4-5.3-.4-12.3-6.7-12.3zm88.9-226.3L815 393.7c-5.3-4.2-13-.4-13 6.3v76H488c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h314v76c0 6.7 7.8 10.5 13 6.3l141.9-112a8 8 0 000-12.6z"}}]},name:"logout",theme:"outlined"},xJ=N_.default=bJ;function N0(){return N0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,N0({},e,{ref:t,icon:xJ})),R_=a.forwardRef($J);var T_={};Object.defineProperty(T_,"__esModule",{value:!0});var SJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 000 13.8z"}}]},name:"menu-fold",theme:"outlined"},CJ=T_.default=SJ;function R0(){return R0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,R0({},e,{ref:t,icon:CJ})),EJ=a.forwardRef(wJ);var __={};Object.defineProperty(__,"__esModule",{value:!0});var IJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 000-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0014.4 7z"}}]},name:"menu-unfold",theme:"outlined"},PJ=__.default=IJ;function T0(){return T0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,T0({},e,{ref:t,icon:PJ})),RJ=a.forwardRef(NJ);var M_={};Object.defineProperty(M_,"__esModule",{value:!0});var TJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M744 62H280c-35.3 0-64 28.7-64 64v768c0 35.3 28.7 64 64 64h464c35.3 0 64-28.7 64-64V126c0-35.3-28.7-64-64-64zm-8 824H288V134h448v752zM472 784a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"mobile",theme:"outlined"},_J=M_.default=TJ;function _0(){return _0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,_0({},e,{ref:t,icon:_J})),bE=a.forwardRef(MJ);var O_={};Object.defineProperty(O_,"__esModule",{value:!0});var OJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm-88-532h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8zm224 0h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8z"}}]},name:"pause-circle",theme:"outlined"},zJ=O_.default=OJ;function M0(){return M0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,M0({},e,{ref:t,icon:zJ})),BJ=a.forwardRef(jJ);var z_={};Object.defineProperty(z_,"__esModule",{value:!0});var LJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"},kJ=z_.default=LJ;function O0(){return O0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,O0({},e,{ref:t,icon:kJ})),DJ=a.forwardRef(AJ);var j_={};Object.defineProperty(j_,"__esModule",{value:!0});var FJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"},HJ=j_.default=FJ;function z0(){return z0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,z0({},e,{ref:t,icon:HJ})),WJ=a.forwardRef(VJ);var B_={};Object.defineProperty(B_,"__esModule",{value:!0});var KJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M866.9 169.9L527.1 54.1C523 52.7 517.5 52 512 52s-11 .7-15.1 2.1L157.1 169.9c-8.3 2.8-15.1 12.4-15.1 21.2v482.4c0 8.8 5.7 20.4 12.6 25.9L499.3 968c3.5 2.7 8 4.1 12.6 4.1s9.2-1.4 12.6-4.1l344.7-268.6c6.9-5.4 12.6-17 12.6-25.9V191.1c.2-8.8-6.6-18.3-14.9-21.2zM810 654.3L512 886.5 214 654.3V226.7l298-101.6 298 101.6v427.6zm-405.8-201c-3-4.1-7.8-6.6-13-6.6H336c-6.5 0-10.3 7.4-6.5 12.7l126.4 174a16.1 16.1 0 0026 0l212.6-292.7c3.8-5.3 0-12.7-6.5-12.7h-55.2c-5.1 0-10 2.5-13 6.6L468.9 542.4l-64.7-89.1z"}}]},name:"safety-certificate",theme:"outlined"},UJ=B_.default=KJ;function j0(){return j0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,j0({},e,{ref:t,icon:UJ})),GJ=a.forwardRef(qJ);var L_={};Object.defineProperty(L_,"__esModule",{value:!0});var XJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372 0-89 31.3-170.8 83.5-234.8l523.3 523.3C682.8 852.7 601 884 512 884zm288.5-137.2L277.2 223.5C341.2 171.3 423 140 512 140c205.4 0 372 166.6 372 372 0 89-31.3 170.8-83.5 234.8z"}}]},name:"stop",theme:"outlined"},YJ=L_.default=XJ;function B0(){return B0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,B0({},e,{ref:t,icon:YJ})),k_=a.forwardRef(QJ);var A_={};Object.defineProperty(A_,"__esModule",{value:!0});var JJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 208H676V232h212v136zm0 224H676V432h212v160zM412 432h200v160H412V432zm200-64H412V232h200v136zm-476 64h212v160H136V432zm0-200h212v136H136V232zm0 424h212v136H136V656zm276 0h200v136H412V656zm476 136H676V656h212v136z"}}]},name:"table",theme:"outlined"},ZJ=A_.default=JJ;function L0(){return L0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,L0({},e,{ref:t,icon:ZJ})),tZ=a.forwardRef(eZ);var D_={};Object.defineProperty(D_,"__esModule",{value:!0});var nZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"}}]},name:"team",theme:"outlined"},rZ=D_.default=nZ;function k0(){return k0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,k0({},e,{ref:t,icon:rZ})),sZ=a.forwardRef(oZ);var F_={};Object.defineProperty(F_,"__esModule",{value:!0});var iZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M848 359.3H627.7L825.8 109c4.1-5.3.4-13-6.3-13H436c-2.8 0-5.5 1.5-6.9 4L170 547.5c-3.1 5.3.7 12 6.9 12h174.4l-89.4 357.6c-1.9 7.8 7.5 13.3 13.3 7.7L853.5 373c5.2-4.9 1.7-13.7-5.5-13.7zM378.2 732.5l60.3-241H281.1l189.6-327.4h224.6L487 427.4h211L378.2 732.5z"}}]},name:"thunderbolt",theme:"outlined"},aZ=F_.default=iZ;function A0(){return A0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,A0({},e,{ref:t,icon:aZ})),cZ=a.forwardRef(lZ);var H_={};Object.defineProperty(H_,"__esModule",{value:!0});var uZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M678.3 642.4c24.2-13 51.9-20.4 81.4-20.4h.1c3 0 4.4-3.6 2.2-5.6a371.67 371.67 0 00-103.7-65.8c-.4-.2-.8-.3-1.2-.5C719.2 505 759.6 431.7 759.6 349c0-137-110.8-248-247.5-248S264.7 212 264.7 349c0 82.7 40.4 156 102.6 201.1-.4.2-.8.3-1.2.5-44.7 18.9-84.8 46-119.3 80.6a373.42 373.42 0 00-80.4 119.5A373.6 373.6 0 00137 888.8a8 8 0 008 8.2h59.9c4.3 0 7.9-3.5 8-7.8 2-77.2 32.9-149.5 87.6-204.3C357 628.2 432.2 597 512.2 597c56.7 0 111.1 15.7 158 45.1a8.1 8.1 0 008.1.3zM512.2 521c-45.8 0-88.9-17.9-121.4-50.4A171.2 171.2 0 01340.5 349c0-45.9 17.9-89.1 50.3-121.6S466.3 177 512.2 177s88.9 17.9 121.4 50.4A171.2 171.2 0 01683.9 349c0 45.9-17.9 89.1-50.3 121.6C601.1 503.1 558 521 512.2 521zM880 759h-84v-84c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v84h-84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h84v84c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-84h84c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z"}}]},name:"user-add",theme:"outlined"},dZ=H_.default=uZ;function D0(){return D0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,D0({},e,{ref:t,icon:dZ})),mZ=a.forwardRef(fZ);var V_={};Object.defineProperty(V_,"__esModule",{value:!0});var pZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M858.5 763.6a374 374 0 00-80.6-119.5 375.63 375.63 0 00-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 00-80.6 119.5A371.7 371.7 0 00136 901.8a8 8 0 008 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 008-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"}}]},name:"user",theme:"outlined"},gZ=V_.default=pZ;function F0(){return F0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,F0({},e,{ref:t,icon:gZ})),yZ=a.forwardRef(hZ);function vZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState([]),[f,p]=a.useState([]),[h,b]=a.useState([]),[x,v]=a.useState(!1),[g,y]=a.useState(!1),[$,w]=a.useState(null),[I]=De.useForm(),C=De.useWatch("role_id",I),N=a.useMemo(()=>d.find(M=>M.role_id===C),[d,C]);async function E(){v(!0);try{const[M,O,k,B]=await Promise.all([d_(t),f_(t),m_(t).catch(()=>({items:[]})),p_(t).catch(()=>({items:[]}))]);u(M.items||[]),m(O.items||[]),p(k.items||[]),b(B.items||[])}catch(M){const O=M.message||String(M);o(O),i.error(O)}finally{v(!1)}}a.useEffect(()=>{E()},[t.accessToken]);function R(){w(null);const M=d.find(O=>O.code==="生成发布"||O.code==="publisher")||d.find(O=>O.code==="运维"||O.code==="operator")||d[0];I.resetFields(),I.setFieldsValue({name:"",role_id:M==null?void 0:M.role_id,app_slugs:[],channel_id:void 0,online_db_id:void 0,database_name:void 0}),y(!0)}function P(M){w(M),I.setFieldsValue({name:M.name||"",role_id:M.role_id||void 0,app_slugs:M.app_slugs||[],channel_id:M.channel_id||void 0,online_db_id:M.online_db_id||void 0,database_name:M.database_name||void 0}),y(!0)}async function T(M=!1){const O=await I.validateFields();r(!0);try{const k={channel_id:O.channel_id||"",online_db_id:O.online_db_id||"",database_name:(O.database_name||"").trim()||""};if($)await gE(t,$.agent_id,{name:O.name.trim(),role_id:O.role_id,app_slugs:O.app_slugs||[],...k,...M?{status:"active"}:{}}),i.success(M?"已保存并启用":"已保存"),s(M?`已保存并启用「${O.name.trim()}」`:`已保存「${O.name.trim()}」`);else{const B=await WY(t,{name:O.name.trim(),role_id:O.role_id,app_slugs:O.app_slugs||[],...k});l.success({title:"用户已创建",content:S.jsxs("div",{children:[S.jsx("p",{children:"请立即保存 client_secret(只显示一次):"}),S.jsx(Oe.Paragraph,{copyable:!0,code:!0,children:B.client_secret})]})}),s(`已创建用户「${O.name.trim()}」`)}y(!1),await E()}catch(k){const B=k.message||String(k);o(B),i.error(B)}finally{r(!1)}}const _=(M,O)=>{if(M==="active"){const k=!!(O!=null&&O.channel_id&&(O!=null&&O.online_db_id));return S.jsxs(Mt,{size:4,children:[S.jsx(Dt,{color:"success",children:"active"}),k?S.jsx(Dt,{color:"blue",children:"同步已绑"}):null]})}return M==="pending"?S.jsx(Dt,{color:"warning",children:"pending · 仅登记"}):S.jsx(Dt,{children:M})};return S.jsxs(rr,{title:"用户管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:E,loading:x,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:R,disabled:!d.length,children:"新建用户"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["当前租户 #",t.tenantId,"。用户挂在本租户下;同角色跨公司靠租户隔离,不靠再拆一套角色。 角色请在「角色管理」中维护。可绑定",S.jsx("strong",{children:"同步通道 / 线上库"}),":该智能体发布的模块与松离线数据进同一目标库(Z8)。"]}),S.jsx($n,{rowKey:"agent_id",loading:x||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"用户名称",dataIndex:"name",render:(M,O)=>S.jsxs("div",{children:[S.jsx("strong",{children:M||"—"}),O.host_key?S.jsx("div",{children:S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:12},children:["host: ",O.host_key]})}):null]})},{title:"client_id",dataIndex:"client_id",render:M=>S.jsx(Oe.Text,{code:!0,children:M})},{title:"状态",dataIndex:"status",width:160,render:(M,O)=>_(M,O)},{title:"角色",render:(M,O)=>O.role_name||O.role_code||"—"},{title:"权限",dataIndex:"permissions",width:260,render:M=>(M||[]).length?S.jsx(Mt,{size:[4,4],wrap:!0,children:(M||[]).map(O=>S.jsx(Dt,{color:["读取模块","发布模块","数据同步"].includes(Ma(O))?"blue":void 0,children:Ma(O)},O))}):S.jsx(Oe.Text,{type:"secondary",children:"未授权"})},{title:"可访问模块",dataIndex:"app_slugs",render:M=>(M||[]).length?S.jsx(Mt,{size:[4,4],wrap:!0,children:(M||[]).map(O=>S.jsx(Dt,{children:O},O))}):"—"},{title:"同步绑定",render:(M,O)=>{if(!O.channel_id&&!O.online_db_id&&!O.database_name)return"—";const k=f.find(B=>B.id===O.channel_id);return S.jsxs("span",{style:{fontSize:12},children:[(k==null?void 0:k.name)||O.channel_id||"无通道",S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",children:[O.online_db_id||"—",O.database_name?` · ${O.database_name}`:""]})]})}},{title:"操作",width:320,render:(M,O)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>P(O),children:"编辑"}),S.jsx(Ke,{size:"small",icon:O.status==="active"?S.jsx(k_,{}):S.jsx(zx,{}),onClick:async()=>{const k=O.status==="active"?"disabled":"active";if(k==="active"&&!O.role_id&&!(O.permissions||[]).length){i.warning("请先编辑并分配角色后再启用");return}r(!0);try{await gE(t,O.agent_id,{status:k}),i.success(`已设为 ${k}`),s(`已将「${O.name}」设为 ${k}`),await E()}catch(B){i.error(B.message||String(B)),o(B.message||String(B))}finally{r(!1)}},children:O.status==="active"?"停用":"启用"}),S.jsx(Ke,{size:"small",icon:S.jsx(jf,{}),onClick:async()=>{r(!0);try{const k=await KY(t,O.agent_id);l.success({title:"密钥已轮换",content:S.jsx(Oe.Paragraph,{copyable:!0,code:!0,children:k.client_secret})}),s(`已轮换「${O.name}」的 secret`)}catch(k){i.error(k.message||String(k)),o(k.message||String(k))}finally{r(!1)}},children:"轮换密钥"}),S.jsx(du,{title:`删除用户「${O.name}」?`,onConfirm:async()=>{r(!0);try{await UY(t,O.agent_id),i.success("已删除"),s(`已删除「${O.name}」`),await E()}catch(k){i.error(k.message||String(k)),o(k.message||String(k))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:$?`编辑用户 #${$.agent_id}`:"新建用户",open:g,onCancel:()=>y(!1),confirmLoading:n,width:640,destroyOnClose:!0,footer:[S.jsx(Ke,{onClick:()=>y(!1),children:"取消"},"cancel"),$?S.jsx(Ke,{onClick:()=>T(!0),loading:n,children:"保存并启用"},"activate"):null,S.jsx(Ke,{type:"primary",onClick:()=>T(!1),loading:n,children:$?"保存修改":"创建用户"},"ok")],children:S.jsxs(De,{form:I,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"用户名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"例如:产线宿主 A"})}),S.jsx(De.Item,{label:"角色",name:"role_id",rules:[{required:!0,message:"请选择角色"}],children:S.jsx(Qt,{placeholder:"请选择角色",options:d.map(M=>({value:M.role_id,label:`${M.name}(${M.code})`}))})}),N&&S.jsx(rr,{size:"small",title:"角色权限预览",style:{marginBottom:16},children:S.jsx(Mt,{size:[4,4],wrap:!0,children:(N.permissions||[]).map(M=>S.jsx(Dt,{children:Ma(M)},M))})}),S.jsx(De.Item,{label:"可访问模块(可选)",name:"app_slugs",extra:"留空=可自由发布任意自建模块,无需再逐个授权。仅当需要限制范围时再填写白名单(或 * 表示全部)。",children:S.jsx(Qt,{mode:"tags",placeholder:"可选限制:输入 slug 后回车;留空表示不限制",tokenSeparators:[","],allowClear:!0})}),S.jsx(Oe.Text,{strong:!0,children:"松离线 / 模块落库(Z8)"}),S.jsx(De.Item,{name:"channel_id",label:"同步通道",style:{marginTop:8},extra:"该智能体的模块与本机 sync 应对准同一通道线上库",children:S.jsx(Qt,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:"可选",options:f.map(M=>({value:M.id,label:`${M.name} (${M.id.slice(0,8)}…)`})),onChange:M=>{if(!M)return;const O=h.find(k=>k.channel_id===M);O&&I.setFieldsValue({online_db_id:O.online_db_id,database_name:O.display_name||O.database_name||I.getFieldValue("database_name")})}})}),S.jsx(De.Item,{name:"online_db_id",label:"线上库 ID",extra:"与 Binding.online_db_id 对齐;宇恒 push 须带此 id。可选从 Binding 带出。",children:S.jsx(Pt,{placeholder:"online_db_id",allowClear:!0,list:"agent-online-db-options"})}),S.jsx("datalist",{id:"agent-online-db-options",children:[...new Set(h.map(M=>M.online_db_id).filter(Boolean))].map(M=>S.jsx("option",{value:M},M))}),S.jsx(De.Item,{name:"database_name",label:"模块落库名",extra:"智能体新建发布时优先写入此 Postgres 库(database_per_app);与通道 remote 对齐为佳",children:S.jsx(Pt,{placeholder:"例如 appdb_t1_aisite",allowClear:!0})})]})})]})}function bZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState([]),[m,f]=a.useState(!1),[p,h]=a.useState(!1),[b]=De.useForm();async function x(){f(!0);try{const[g,y]=await Promise.all([JY(t),x$(t).catch(()=>({items:[]}))]);c(g.items||[]),d(y.items||[])}catch(g){const y=g.message||String(g);o(y),i.error(y)}finally{f(!1)}}a.useEffect(()=>{x()},[t.accessToken]);async function v(){const g=await b.validateFields();r(!0);try{const y=await ZY(t,{role:g.role,org_unit_id:g.org_unit_id||0,max_uses:g.max_uses,expires_in_hours:g.expires_in_hours||0});i.success(`邀请码已创建:${y.code}`),s(`邀请码 ${y.code}(角色 ${y.role})`),h(!1),await x()}catch(y){i.error(y.message||String(y)),o(y.message||String(y))}finally{r(!1)}}return S.jsxs(rr,{title:"邀请加入",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:x,loading:m,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>{b.setFieldsValue({role:"编辑",max_uses:1,expires_in_hours:72,org_unit_id:void 0}),h(!0)},children:"生成邀请码"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["把邀请码发给新用户。对方注册后处于「待加入」,输入邀请码即可成为本司成员。 成员角色:",S.jsx("strong",{children:"管理员"}),"(顶级,含数据同步)、",S.jsx("strong",{children:"编辑"}),"(读写数据)、",S.jsx("strong",{children:"只读"}),"(仅查看导出)。详见 docs/角色说明.md。"]}),S.jsx($n,{rowKey:"invite_id",loading:m||n,dataSource:l,pagination:{pageSize:10},columns:[{title:"邀请码",dataIndex:"code",render:g=>S.jsx(Oe.Text,{copyable:!0,code:!0,children:g})},{title:"加入角色",dataIndex:"role",width:100,render:g=>S.jsx(Dt,{children:rc(g)})},{title:"组织",width:140,render:(g,y)=>{if(!y.org_unit_id)return"全公司";const $=u.find(w=>w.org_unit_id===y.org_unit_id);return($==null?void 0:$.name)||`#${y.org_unit_id}`}},{title:"使用",width:100,render:(g,y)=>`${y.used_count}/${y.max_uses}`},{title:"状态",dataIndex:"status",width:110,render:g=>g==="active"?S.jsx(Dt,{color:"success",children:"有效"}):g==="revoked"?S.jsx(Dt,{children:"已撤销"}):g==="exhausted"?S.jsx(Dt,{color:"warning",children:"已用尽"}):S.jsx(Dt,{children:g})},{title:"过期",dataIndex:"expires_at",render:g=>g?new Date(g).toLocaleString():"不过期"},{title:"操作",width:120,render:(g,y)=>y.status==="active"?S.jsx(du,{title:"撤销该邀请码?",onConfirm:async()=>{r(!0);try{await eQ(t,y.invite_id),i.success("已撤销"),await x()}catch($){i.error($.message||String($))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(k_,{}),children:"撤销"})}):"—"}]}),S.jsx(tn,{title:"生成邀请码",open:p,onCancel:()=>h(!1),onOk:v,confirmLoading:n,okText:"生成",destroyOnClose:!0,children:S.jsxs(De,{form:b,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"加入后角色",name:"role",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"编辑",label:"编辑 — 可读写业务数据,不可发布/管组织"},{value:"只读",label:"只读 — 仅查看与导出"},{value:"管理员",label:"管理员 — 公司顶级(含数据同步)"}]})}),S.jsx(De.Item,{label:"绑定组织(可选)",name:"org_unit_id",children:S.jsx(Qt,{allowClear:!0,placeholder:"空=不绑组织(可见全公司数据)",options:u.map(g=>({value:g.org_unit_id,label:`${"— ".repeat(Math.max(0,g.depth-1))}${g.name}`}))})}),S.jsx(De.Item,{label:"可用次数",name:"max_uses",rules:[{required:!0}],children:S.jsx(Pf,{min:1,max:1e3,style:{width:"100%"}})}),S.jsx(De.Item,{label:"有效小时数(0=不过期)",name:"expires_in_hours",children:S.jsx(Pf,{min:0,max:8760,style:{width:"100%"}})})]})})]})}function xZ(e){const{session:t,onOpenPublished:n,onContinueDraft:r}=e,{modal:o}=wo.useApp(),[s,i]=a.useState([]),[l,c]=a.useState(""),[u,d]=a.useState(!1),[m,f]=a.useState(!1);async function p(){d(!0);try{const x=await oc(t);i(x.items||[]),c(x.scope||"")}catch(x){_d.error(x.message||String(x))}finally{d(!1)}}function h(){o.confirm({title:"一键开启全部业务表导入?",content:"将为本公司所有已发布模块补齐蓝图 import/export(无需逐个再发布)。只读表不会改动。",okText:"开启",onOk:async()=>{f(!0);try{const x=await OY(t,!1);_d.success(x.message||`已更新 ${x.updated} 个模块`),await p()}catch(x){throw _d.error(x.message||String(x)),x}finally{f(!1)}}})}a.useEffect(()=>{p()},[t.accessToken]);const b=x=>{const v=x.status_label||x.status;return x.status==="published"?S.jsx(Dt,{color:"success",children:v}):x.status==="failed"?S.jsx(Dt,{color:"error",children:v}):S.jsx(Dt,{color:"processing",children:v||"在建"})};return S.jsxs(rr,{title:"模块管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(dJ,{}),loading:m,onClick:()=>h(),children:"一键开启导入"}),S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:p,loading:u,children:"刷新"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["管理账号(如 owner)可查看本租户",S.jsx("strong",{children:"全部模块"}),",含",S.jsx("strong",{children:"在建"}),"与已发布。 智能体默认不限制模块(可自由发布自建 slug);仅当配置了白名单时才受限。 「一键开启导入」修复旧模块因蓝图缺 import 导致的导入 400(Z9e)。",l==="all"?" 当前范围:管理全部。":l==="open"?" 当前范围:智能体开放。":l==="granted"?" 当前范围:白名单。":null]}),S.jsx($n,{rowKey:"app_id",loading:u,dataSource:s,pagination:{pageSize:20},columns:[{title:"模块名称",dataIndex:"name"},{title:"slug",dataIndex:"slug",render:x=>S.jsx(Oe.Text,{code:!0,children:x})},{title:"状态",width:110,render:(x,v)=>b(v)},{title:"页面数",dataIndex:"page_count",width:80},{title:"实体数",dataIndex:"entity_count",width:80},{title:"更新时间",dataIndex:"updated_at",width:200},{title:"操作",width:200,render:(x,v)=>S.jsx(Mt,{children:v.status==="published"?S.jsx(Ke,{type:"link",onClick:()=>n(v.slug),children:"打开"}):S.jsx(Ke,{type:"link",onClick:()=>r(v.slug),children:"继续编辑"})})}],locale:{emptyText:"暂无模块。生成蓝图后会登记为「在建」,发布成功后变为「已发布」。"}})]})}function $Z(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState(5),[m,f]=a.useState(!1),[p,h]=a.useState(!1),[b,x]=a.useState(null),[v]=De.useForm();async function g(){f(!0);try{const C=await x$(t);c(C.items||[]),C.max_depth&&d(C.max_depth)}catch(C){const N=C.message||String(C);o(N),i.error(N)}finally{f(!1)}}a.useEffect(()=>{g()},[t.accessToken]);const y=a.useMemo(()=>(l||[]).filter(C=>C.depth({value:C.org_unit_id,label:`${"— ".repeat(Math.max(0,C.depth-1))}${C.name}(L${C.depth})`})),[l,u]);function $(C){x(null),v.resetFields(),v.setFieldsValue({parent_id:C||void 0,name:"",code:""}),h(!0)}function w(C){x(C),v.setFieldsValue({name:C.name,code:C.code||"",parent_id:C.parent_id||void 0}),h(!0)}async function I(){const C=await v.validateFields();r(!0);try{if(b)await nQ(t,b.org_unit_id,{name:C.name.trim(),code:(C.code||"").trim()}),i.success("已保存"),s(`已保存组织「${C.name.trim()}」`);else{const N=await tQ(t,{parent_id:C.parent_id||0,name:C.name.trim(),code:(C.code||"").trim()});i.success(`已创建「${N.name}」`),s(`已创建组织「${N.name}」(深度 ${N.depth}/${u})`)}h(!1),await g()}catch(N){i.error(N.message||String(N)),o(N.message||String(N))}finally{r(!1)}}return S.jsxs(rr,{title:"组织管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:g,loading:m,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>$(),children:"新建顶级组织"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["公司(租户)下可建多级组织,最多 ",u," 级。成员通过邀请码绑定组织后,只能访问本组织及下级数据;公司管理员(owner)可看全公司。"]}),S.jsx($n,{rowKey:"org_unit_id",loading:m||n,dataSource:l,pagination:{pageSize:20},columns:[{title:"名称",dataIndex:"name",render:(C,N)=>S.jsxs("span",{style:{paddingLeft:(N.depth-1)*16},children:[N.depth>1?"└ ":"",C]})},{title:"编码",dataIndex:"code",width:140,render:C=>C||"—"},{title:"层级",dataIndex:"depth",width:90,render:C=>S.jsxs(Dt,{children:["L",C,"/",u]})},{title:"路径",dataIndex:"path",ellipsis:!0},{title:"操作",width:260,render:(C,N)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(Bo,{}),disabled:N.depth>=u,onClick:()=>$(N.org_unit_id),children:"下级"}),S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>w(N),children:"编辑"}),S.jsx(du,{title:`删除「${N.name}」?需先删下级`,onConfirm:async()=>{r(!0);try{await rQ(t,N.org_unit_id),i.success("已删除"),await g()}catch(E){i.error(E.message||String(E)),o(E.message||String(E))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:b?`编辑组织 #${b.org_unit_id}`:"新建组织",open:p,onCancel:()=>h(!1),onOk:I,confirmLoading:n,destroyOnClose:!0,okText:"保存",children:S.jsxs(De,{form:v,layout:"vertical",style:{marginTop:12},children:[!b&&S.jsx(De.Item,{label:"上级组织",name:"parent_id",children:S.jsx(Qt,{allowClear:!0,placeholder:"空=顶级组织",options:y})}),S.jsx(De.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"如:华东事业部 / 项目一组"})}),S.jsx(De.Item,{label:"编码(可选,租户内唯一)",name:"code",children:S.jsx(Pt,{placeholder:"如 east / proj_a",disabled:!!b&&!!b.code})})]})})]})}async function sc(e,t,n,r){return Nr(t.role)?await new Promise(s=>{e.confirm({title:"超管写操作确认(1/2)",content:S.jsxs("div",{children:[S.jsxs("p",{children:["你正在以",S.jsx("strong",{children:"平台超级管理员"}),"身份修改某公司内部数据(不是该公司管理员账号)。"]}),S.jsxs("p",{children:["操作:",S.jsx("strong",{children:n})]}),r?S.jsx("p",{style:{color:"#666"},children:r}):null,S.jsx("p",{children:"日常应由该公司管理员处理。是否继续?"})]}),okText:"继续",cancelText:"取消",onOk:()=>s(!0),onCancel:()=>s(!1)})})?new Promise(s=>{e.confirm({title:"超管写操作确认(2/2)",content:S.jsxs("div",{children:[S.jsxs("p",{children:["请再次确认:将执行「",n,"」。"]}),S.jsx("p",{style:{color:"#b42318"},children:"此操作会影响该公司业务配置或成员权限,请确认无误。"})]}),okText:"确认执行",okButtonProps:{danger:!0},cancelText:"取消",onOk:()=>s(!0),onCancel:()=>s(!1)})}):!1:!0}async function SZ(e,t,n){return new Promise(r=>{e.confirm({title:"打开公司管理视图",content:S.jsxs("div",{children:[S.jsxs("p",{children:["以",S.jsx("strong",{children:"平台超级管理员"}),"身份打开「",S.jsx("strong",{children:t}),"」(#",n,")。"]}),S.jsx("p",{children:"这是你的平台管理能力,不是登录成该公司账号。写操作仍会再次确认。"})]}),okText:"打开",cancelText:"取消",onOk:()=>r(!0),onCancel:()=>r(!1)})})}function CZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState(!1),[f,p]=a.useState(!1),[h,b]=a.useState(null),[x,v]=a.useState([]),[g,y]=a.useState([]),[$]=De.useForm();async function w(){m(!0);try{const[E,R]=await Promise.all([f_(t),h_(t)]);u(E.items||[]),y(R.modules||[])}catch(E){const R=E.message||String(E);o(R),i.error(R)}finally{m(!1)}}a.useEffect(()=>{w()},[t.accessToken,t.tenantId]);function I(){b(null),v([]),$.resetFields(),$.setFieldsValue({permissions:[]}),p(!0)}function C(E){b(E),v([...E.permissions||[]]),$.setFieldsValue({code:E.code,name:E.name,description:E.description,permissions:E.permissions||[]}),p(!0)}async function N(){const E=await $.validateFields();if(!x.length){i.warning("请至少勾选一项权限");return}const R=h?`保存智能体角色「${E.name.trim()}」及其权限`:`创建智能体角色「${E.name.trim()}」`;if(await sc(l,t,R)){r(!0);try{h?(await GY(t,h.role_id,{name:E.name.trim(),description:(E.description||"").trim(),permissions:x}),i.success(`已保存角色「${E.name.trim()}」`),s(`已保存角色「${E.name.trim()}」`)):(await qY(t,{code:(E.code||"").trim(),name:E.name.trim(),description:(E.description||"").trim(),permissions:x}),i.success(`已创建角色「${E.name.trim()}」`),s(`已创建角色「${E.name.trim()}」`)),p(!1),await w()}catch(T){const _=T.message||String(T);o(_),i.error(_)}finally{r(!1)}}}return S.jsxs(rr,{title:"角色管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:w,loading:d,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:I,children:"新建角色"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["此处配置",S.jsx("strong",{children:"智能体角色"}),"。可选权限以平台超级管理员授予本公司的额度为准,无法勾选未授权项。 默认角色:生成发布 / 只读 / 读写 / 运维。"]}),S.jsx($n,{rowKey:"role_id",loading:d||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"名称",dataIndex:"name",width:140},{title:"编码",dataIndex:"code",width:140,render:E=>S.jsx(Dt,{children:E})},{title:"说明",dataIndex:"description",ellipsis:!0},{title:"权限",dataIndex:"permissions",render:E=>(E||[]).length?S.jsxs(Mt,{size:[4,4],wrap:!0,children:[(E||[]).slice(0,8).map(R=>S.jsx(Dt,{children:Ma(R)},R)),(E||[]).length>8?S.jsxs(Dt,{children:["+",(E||[]).length-8]}):null]}):"—"},{title:"操作",width:180,render:(E,R)=>S.jsxs(Mt,{children:[S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>C(R),children:"编辑"}),S.jsx(du,{title:`删除角色「${R.name}」?`,onConfirm:async()=>{if(await sc(l,t,`删除智能体角色「${R.name}」`)){r(!0);try{await XY(t,R.role_id),i.success("已删除"),s(`已删除角色「${R.name}」`),await w()}catch(T){i.error(T.message||String(T)),o(T.message||String(T))}finally{r(!1)}}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:h?`编辑角色 #${h.role_id}`:"新建角色",open:f,onCancel:()=>p(!1),onOk:N,confirmLoading:n,width:720,destroyOnClose:!0,okText:"保存",children:S.jsxs(De,{form:$,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"角色编码",name:"code",rules:h?[]:[{required:!0,message:"请填写中文编码,如 只读"}],children:S.jsx(Pt,{placeholder:"如 只读 / 读写 / 自定义运维",disabled:!!h})}),S.jsx(De.Item,{label:"角色名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"与编码可相同,如:只读"})}),S.jsx(De.Item,{label:"说明",name:"description",children:S.jsx(Pt.TextArea,{rows:2,placeholder:"可选"})}),S.jsx(De.Item,{label:"权限分配",required:!0,extra:"仅显示本公司权限额度内的选项",children:S.jsx(wY,{value:x,onChange:v,allowedModules:g})})]})})]})}function wZ(e){const t={};for(const n of(e||"").split(",")){const[r,o]=n.split(":").map(s=>s.trim());r&&o&&(t[r]=o)}return t}function EZ(e){const t=(e||"").replace(/:[^:@/]+@/,":***@"),n=t.match(/(?:^|[\\/])([^\\/?#]+\.db)(?:\?|$)/i);return n?n[1]:t.length>56?`${t.slice(0,56)}…`:t}function xE(e){return(e.database_name||"").trim()||e.local_database_id}function $E(e){return(e.display_name||"").trim()||e.online_db_id}function IZ(e){const t=(e.note||"").toLowerCase();if(t.includes("smoke")||t.includes("user-jwt"))return!0;const n=(e.local_database_id||"").toLowerCase(),r=(e.online_db_id||"").toLowerCase();return n.startsWith("local_")||r.startsWith("online_")}function SE(e,t){var s;const n=t.filter(i=>i.channel_id===e.id),r=n.map(i=>(i.database_name||"").trim()).filter(Boolean);if(r.length)return r[0];const o=n.map(i=>(i.display_name||"").trim()).filter(Boolean);return o.length?o[0]:(e.name||"").trim()?e.name.trim():((s=e.remote)==null?void 0:s.driver)||"线上库"}function PZ(e,t){var i;const n=t.filter(l=>l.channel_id===e.id),r=n.map(l=>l.online_db_id).filter(Boolean),o=[...new Set(r)];return o.length?n.map(l=>(l.database_name||"").trim()).find(Boolean)&&((i=n[0])!=null&&i.local_database_id)?`${n[0].local_database_id} ↔ ${o.join(" · ")}`:o.join(" · "):""}function CE(e,t){return{id:t,name:e.name,direction:e.direction,conflict_policy:e.conflict_policy,poll_interval_ms:e.poll_interval_ms||500,agent_id:e.agent_id||void 0,app_slug:(e.app_slug||"").trim()||void 0,local:{driver:e.local.driver,dsn:e.local.dsn,tables:(e.local.tables||"").split(",").map(n=>n.trim()).filter(Boolean)},remote:{driver:e.remote.driver,dsn:e.remote.dsn,tables:(e.remote.tables||"").split(",").map(n=>n.trim()).filter(Boolean)},pk_columns:wZ(e.pk_columns)}}function NZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState([]),[m,f]=a.useState([]),[p,h]=a.useState([]),[b,x]=a.useState([]),[v,g]=a.useState(!1),[y,$]=a.useState(!1),[w,I]=a.useState(null),[C,N]=a.useState(!1),[E,R]=a.useState(void 0),[P,T]=a.useState(!1),[_,M]=a.useState(null),[O,k]=a.useState("remote"),[B,j]=a.useState(null),[z,A]=a.useState(!1),[D,L]=a.useState(!1),[H,K]=a.useState(null),[V,W]=a.useState(!1),[q]=De.useForm(),ee=C?u:u.filter(te=>!IZ(te)),se=u.length-ee.length,le=E?l.filter(te=>{var Y;return te.agent_id===E||((Y=p.find(de=>de.agent_id===E))==null?void 0:Y.channel_id)===te.id}):l;async function ce(){g(!0);try{const[te,Y,de,ue,ge]=await Promise.all([m_(t),p_(t).catch(()=>({items:[]})),d_(t).catch(()=>({items:[]})),oc(t).catch(()=>({items:[]})),gQ(t).catch(()=>({items:[]}))]);c(te.items||[]),d(Y.items||[]),h(de.items||[]),f(ge.items||[]),x((ue.items||[]).filter(we=>we.status==="published"||!we.status).map(we=>({value:we.slug,label:`${we.name||we.slug} (${we.slug})`})))}catch(te){const Y=te.message||String(te);o(Y),i.error(Y)}finally{g(!1)}}a.useEffect(()=>{ce()},[t.accessToken]);function G(){I(null),q.setFieldsValue({name:"本地 B ↔ 线上 A",direction:"local_to_remote",conflict_policy:"lww_source",poll_interval_ms:500,agent_id:void 0,app_slug:void 0,local:{driver:"sqlite",dsn:"file:./data/local.db",tables:"article"},remote:{driver:"postgres",dsn:"postgres://user:pass@127.0.0.1:5432/app?sslmode=disable",tables:"article"},pk_columns:"article:id"}),$(!0)}function ne(te){I(te),q.setFieldsValue({name:te.name,direction:te.direction,conflict_policy:te.conflict_policy,poll_interval_ms:te.poll_interval_ms,agent_id:te.agent_id||void 0,app_slug:te.app_slug||void 0,local:{driver:te.local.driver,dsn:te.local.dsn,tables:(te.local.tables||[]).join(",")},remote:{driver:te.remote.driver,dsn:te.remote.dsn,tables:(te.remote.tables||[]).join(",")},pk_columns:Object.entries(te.pk_columns||{}).map(([Y,de])=>`${Y}:${de}`).join(",")}),$(!0)}async function re(te,Y="remote"){M(te),k(Y),T(!0),j(null),A(!0);try{const de=await fQ(t,te.id,{side:Y,include_sync_meta:!0});j(de)}catch(de){i.error(de.message||String(de)),T(!1)}finally{A(!1)}}async function U(te){if(_){W(!0),L(!0),K(null);try{const Y=await mQ(t,_.id,{table:te,side:O,limit:50});K(Y)}catch(Y){i.error(Y.message||String(Y)),L(!1)}finally{W(!1)}}}function J(te){if(!te)return"—";const Y=new Date(te);return Number.isNaN(Y.getTime())?te:Y.toLocaleString()}async function oe(te){r(!0);try{const Y=await uQ(t,te.id);if(!Y.latest&&!Y.previous){i.warning("尚无成功同步快照。请先完成一次同步(含自动推送),约 30 秒后生成。");return}let de=Y.latest?"latest":"previous";const ue=[];Y.latest&&ue.push({value:"latest",label:`最近一次 · ${J(Y.latest.synced_at)}(${Y.latest.row_count??0} 行 / ${Y.latest.table_count??0} 表)`}),Y.previous&&ue.push({value:"previous",label:`上一代 · ${J(Y.previous.synced_at)}(${Y.previous.row_count??0} 行 / ${Y.previous.table_count??0} 表)`}),tn.confirm({title:`数据恢复 · ${te.name||te.id}`,width:560,content:S.jsxs("div",{children:[S.jsxs("p",{style:{marginTop:0},children:["将",S.jsx("strong",{children:"线上库"}),"恢复为所选同步快照(upsert 并删除快照中不存在的行)。本机数据需宇恒下次同步/pull 从线上补回。"]}),S.jsx("p",{style:{color:"rgba(0,0,0,0.45)",fontSize:13},children:"若误删后又发生成功自动同步,最新快照可能已含删除后状态,请改选「上一代」。"}),S.jsxs("div",{style:{marginTop:12},children:[S.jsx(Oe.Text,{type:"secondary",children:"恢复到"}),S.jsx(Qt,{style:{width:"100%",marginTop:6},defaultValue:de,options:ue,onChange:ge=>{de=ge}})]})]}),okText:"确认恢复",okType:"danger",cancelText:"取消",onOk:async()=>{try{const ge=await dQ(t,te.id,{which:de,confirm:!0});i.success(`已恢复:写入 ${ge.upserted??0} 行,清理多余 ${ge.deleted??0} 行(快照 ${J(ge.synced_at)})`),s("线上库已按同步快照恢复"),await ce()}catch(ge){throw i.error(ge.message||String(ge)),ge}}})}catch(Y){i.error(Y.message||String(Y))}finally{r(!1)}}function Z(te){if(!_)return;const Y=O==="remote"?"线上库":"本机端(通道 local)";tn.confirm({title:`删除表「${te}」?`,content:S.jsxs("div",{children:[S.jsxs("p",{children:["将从",S.jsx("strong",{children:Y}),"删除该表及同步元数据残留。此操作不可恢复。"]}),S.jsxs("p",{style:{marginBottom:0},children:["松离线",S.jsx("strong",{children:"不会"}),"把删表同步到另一侧。若本机仍有同名表,下次 push/ensure 可能再次出现在线上。"]})]}),okText:"确认删除",okType:"danger",cancelText:"取消",onOk:async()=>{try{const de=await pQ(t,_.id,{table:te,side:O});i.success(de.message||(de.dropped?"已删除":"表不存在")),(H==null?void 0:H.table)===te&&L(!1),await re(_,O)}catch(de){throw i.error(de.message||String(de)),de}}})}async function Q(){const te=await q.validateFields();r(!0);try{const Y=CE(te,w==null?void 0:w.id),de=w?await sQ(t,w.id,Y):await oQ(t,Y),ue=(de==null?void 0:de.id)||(w==null?void 0:w.id);if(ue)try{await hE(t,ue),s("同步通道已保存并启动")}catch{s("同步通道已保存(启动失败时可手动点「启动」)")}else s("同步通道已保存");$(!1),await ce()}catch(Y){i.error(Y.message||String(Y))}finally{r(!1)}}async function ae(){var Y,de;const te=await q.validateFields();r(!0);try{const ue=CE(te),ge=await aQ(t,{local:ue.local,remote:ue.remote,side:"both"}),we=(Y=ge.local)==null?void 0:Y.ok,he=(de=ge.remote)==null?void 0:de.ok;we&&he?i.success("本地与线上数据库均可连接"):i.warning(JSON.stringify(ge))}catch(ue){i.error(ue.message||String(ue))}finally{r(!1)}}return S.jsxs("div",{className:"panel",children:[S.jsx(Oe.Title,{level:4,style:{marginTop:0},children:"数据同步"}),S.jsxs(Oe.Paragraph,{type:"secondary",children:["仅本",S.jsx("strong",{children:"公司顶级权限(管理员)"}),"可配置通道 DSN / 线上库落点;通道按公司隔离。 终端用户以 ",S.jsx(Oe.Text,{code:!0,children:"Binding"})," + 登录 JWT 为同步权限; 库级选「同步」后该库",S.jsx("strong",{children:"全部表"}),"可上云,管理员",S.jsx("strong",{children:"不必"}),"按业务表维护通道白名单。 通道可绑定",S.jsx("strong",{children:"智能体 + 模块"}),":在「用户管理」为智能体填写同步通道/线上库/落库名后,可按智能体筛通道; 模块发布(智能体 Token)优先写入绑定库。本机库管理模块表见宇恒侧(Z8f)。 仅线上/首启可用 pull·bootstrap 从线上灌回本机。默认客户",S.jsx("strong",{children:"无感"}),":未开通不走松离线。 线上库 A 推荐 ",S.jsx(Oe.Text,{code:!0,children:"postgres"}),";多服务器每库一条通道。"]}),S.jsx(po,{type:"info",showIcon:!0,style:{marginBottom:12},message:"冲突已自动按 LWW 处理;覆盖审计请到「平台超管 · 租户/公司 · LWW 覆盖日志」查看。公司侧无冲突台。"}),S.jsxs(Mt,{style:{marginBottom:12},wrap:!0,children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:G,children:"新建通道"}),S.jsx(Ke,{icon:S.jsx(ls,{}),loading:v,onClick:()=>void ce(),children:"刷新"}),S.jsx(Qt,{allowClear:!0,placeholder:"按智能体筛选通道",style:{minWidth:220},value:E,onChange:te=>R(te),options:p.map(te=>({value:te.agent_id,label:`${te.name}${te.channel_id?" · 已绑通道":""}`}))})]}),S.jsx($n,{rowKey:"id",loading:v,dataSource:le,pagination:!1,locale:{emptyText:E?"该智能体暂无同步通道":"该公司暂无同步通道(未绑定智能体或尚未创建通道)"},columns:[{title:"通道 ID",dataIndex:"id",width:280,render:te=>S.jsx(Oe.Text,{copyable:{text:te},style:{fontSize:12},children:te})},{title:"名称",dataIndex:"name"},{title:"方向",dataIndex:"direction",render:te=>S.jsx(Dt,{children:te})},{title:"本地",render:(te,Y)=>`${Y.local.driver}`},{title:"线上",render:(te,Y)=>{var we,he;const de=SE(Y,u),ue=PZ(Y,u),ge=EZ(((we=Y.remote)==null?void 0:we.dsn)||"");return S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:de}),S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:12},children:[(he=Y.remote)==null?void 0:he.driver,ue?` · ${ue}`:"",ge?` · ${ge}`:""]})]})}},{title:"智能体/模块",render:(te,Y)=>{const de=p.find(we=>we.agent_id===Y.agent_id),ue=b.find(we=>we.value===Y.app_slug),ge=Y.app_slug?ue?`${(ue.label.split(" (")[0]||ue.label).trim()}`:Y.app_slug:"未绑模块";return S.jsxs("span",{children:[de?de.name:Y.agent_id?`#${Y.agent_id}`:"—",S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:11},children:[ge,Y.app_slug&&ue?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx("span",{style:{opacity:.75},children:Y.app_slug})]}):null]})]})}},{title:"状态",render:(te,Y)=>Y.enabled?S.jsx(Dt,{color:"green",children:"运行中"}):S.jsx(Dt,{children:"已停止"})},{title:"推送次数",render:(te,Y)=>{var de,ue;return S.jsxs("span",{children:["↑",((de=Y.stats)==null?void 0:de.pushed_ok)||0,(ue=Y.stats)!=null&&ue.pushed_skipped?`(跳过 ${Y.stats.pushed_skipped})`:"",S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:11},children:"push 成功次数,非表数"})]})}},{title:"操作",render:(te,Y)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(tZ,{}),onClick:()=>void re(Y,"remote"),children:"查看线上表"}),S.jsx(Ke,{size:"small",onClick:()=>ne(Y),children:"配置"}),Y.enabled?S.jsx(Ke,{size:"small",icon:S.jsx(BJ,{}),onClick:async()=>{await lQ(t,Y.id),await ce()},children:"停止"}):S.jsx(Ke,{size:"small",type:"primary",icon:S.jsx(DJ,{}),onClick:async()=>{try{await hE(t,Y.id),s("同步已启动"),await ce()}catch(de){i.error(de.message||String(de))}},children:"启动"}),S.jsx(Ke,{size:"small",onClick:async()=>{r(!0);try{const ue=((await cQ(t,Y.id)).reports||[]).map(ge=>`${ge.table}: 补推${ge.patched_push} 补拉${ge.patched_pull}(仅本地${(ge.only_local||[]).length} 仅线上${(ge.only_remote||[]).length})`);i.success(ue.length?ue.join(";"):"同步修复完成,无差异"),s("同步修复完成"),await ce()}catch(de){const ue=de.message||String(de);/过于频繁|429|Too Many/i.test(ue)?i.warning(ue||"对账过于频繁,请稍后再试"):i.error(ue)}finally{r(!1)}},children:"同步修复"}),S.jsx(Ke,{size:"small",onClick:()=>void oe(Y),children:"数据恢复"}),S.jsx(Ke,{size:"small",danger:!0,onClick:()=>{tn.confirm({title:`删除通道「${Y.name||Y.id}」?`,content:Y.is_system_default?"这是公司默认同步通道。删除后将自动重建并重挂库绑定,账号落点不会丢失。":"删除后,仍挂在此通道上的绑定会自动改挂公司默认同步通道。",okText:"确认删除",okType:"danger",cancelText:"取消",onOk:async()=>{r(!0);try{const de=await iQ(t,Y.id);de.heal_error?i.warning(`通道已删,自愈未完成:${de.heal_error}`):de.recreated_default?i.success("已删除;公司默认同步通道已自动重建并重挂绑定"):i.success("已删除"),await ce()}catch(de){throw i.error(de.message||String(de)),de}finally{r(!1)}}})},children:"删除"})]})}]}),S.jsx(Oe.Title,{level:5,style:{marginTop:28},children:"绑定码(发给终端开通)"}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["关联本公司默认同步落点;终端用 ",S.jsx(Oe.Text,{code:!0,children:"POST /auth/bind-code/redeem"})," ","兑换。生产联调成员手机请用 ",S.jsx(Oe.Text,{code:!0,children:"13531041944"}),",勿用超管号。"]}),S.jsx(Mt,{style:{marginBottom:12},children:S.jsx(Ke,{type:"primary",disabled:n,onClick:async()=>{r(!0);try{const te=await hQ(t,{max_uses:1,expires_hours:168});i.success(`已生成绑定码 ${te.code}`),s(`绑定码 ${te.code}(可复制发给用户)`),await ce()}catch(te){i.error(te.message||String(te))}finally{r(!1)}},children:"生成绑定码"})}),S.jsx($n,{rowKey:"code",loading:v,dataSource:m,pagination:!1,locale:{emptyText:"暂无绑定码"},columns:[{title:"绑定码",dataIndex:"code",render:te=>S.jsx(Oe.Text,{copyable:!0,code:!0,children:te})},{title:"通道",dataIndex:"channel_id",render:te=>te?S.jsxs(Oe.Text,{copyable:{text:te},children:[te.slice(0,8),"…"]}):"—"},{title:"次数",render:(te,Y)=>`${Y.used_count}/${Y.max_uses}`,width:80},{title:"过期",dataIndex:"expires_at",render:te=>te?new Date(te).toLocaleString():"—"},{title:"状态",width:90,render:(te,Y)=>Y.revoked?S.jsx(Dt,{color:"default",children:"已撤销"}):Y.used_count>=Y.max_uses?S.jsx(Dt,{children:"已用尽"}):Y.expires_at&&new Date(Y.expires_at).getTime()S.jsx(Ke,{size:"small",danger:!0,disabled:!!Y.revoked||n,onClick:async()=>{r(!0);try{await yQ(t,Y.code),s(`已撤销 ${Y.code}`),await ce()}catch(de){i.error(de.message||String(de))}finally{r(!1)}},children:"撤销"})}]}),S.jsx(Oe.Title,{level:5,style:{marginTop:28},children:"库绑定(本地 ↔ 线上)"}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:[S.jsx(Oe.Text,{code:!0,children:"local_database_id"})," 与"," ",S.jsx(Oe.Text,{code:!0,children:"online_db_id"})," ",S.jsx("strong",{children:"本就可以不同"}),"(映射关系,不是要求同名)。 可读名靠宇恒 ensure 时带 ",S.jsx(Oe.Text,{code:!0,children:"database_name"})," /"," ",S.jsx(Oe.Text,{code:!0,children:"display_name"}),";通道「线上」列优先用本地可读名。默认隐藏联调烟雾 Binding(",S.jsx(Oe.Text,{code:!0,children:"local_*"})," / note=smoke)。"]}),S.jsx(Mt,{style:{marginBottom:8},children:S.jsxs(go,{checked:C,onChange:te=>N(te.target.checked),children:["显示联调烟雾 Binding",se>0?`(已隐藏 ${se} 条)`:""]})}),S.jsx($n,{rowKey:"id",loading:v,dataSource:ee,pagination:!1,locale:{emptyText:"暂无 Binding(客户端选「同步」并登记后出现)"},columns:[{title:"本地库名",render:(te,Y)=>S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:xE(Y)}),Y.database_name?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:Y.local_database_id})]}):null]})},{title:"线上库名",render:(te,Y)=>S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:$E(Y)}),Y.display_name?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:Y.online_db_id})]}):null]})},{title:"映射",render:(te,Y)=>S.jsxs(Oe.Text,{style:{fontSize:13},children:[xE(Y)," ↔ ",$E(Y)]})},{title:"通道",dataIndex:"channel_id",render:te=>{var ue;if(!te)return"—";const Y=l.find(ge=>ge.id===te);if(!Y)return S.jsxs(Oe.Text,{type:"danger",style:{fontSize:12},children:["通道已删除 · ",te.slice(0,8),"…"]});const de=(((ue=Y.remote)==null?void 0:ue.tables)||[]).join(", ");return S.jsxs("span",{children:[Y.name||te,S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:11},children:de?`策略表(参考,非整库限制):${de}`:"整库同步中(Binding 任意表可 push)"})]})}},{title:"备注",dataIndex:"note",ellipsis:!0},{title:"共享",width:70,render:(te,Y)=>Y.shared?S.jsx(Dt,{color:"blue",children:"共享"}):S.jsx(Oe.Text,{type:"secondary",children:"个人"})}]}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:16},children:["「同步修复」有最小间隔限流(默认 5 分钟)。 ↑ 推送次数 = agent push 成功次数,不是业务表数量。 本地有、线上没有的表(如尚未 push 的业务表)属正常,不是 Binding 映射错了。 Binding 标 ",S.jsx(Oe.Text,{code:!0,children:"shared=true"})," 为公司共享库(仅管理员可设)。"]}),S.jsxs(tn,{title:_?`线上库表 · ${SE(_,u)}${O==="local"?"(本机端)":""}`:"库表",open:P,onCancel:()=>T(!1),width:820,footer:S.jsxs(Mt,{children:[S.jsxs(Ke,{loading:z,onClick:()=>_&&void re(_,O==="remote"?"local":"remote"),children:["切换到",O==="remote"?"本机端":"线上"]}),S.jsx(Ke,{loading:z,onClick:()=>_&&void re(_,O),children:"刷新"}),S.jsx(Ke,{type:"primary",onClick:()=>T(!1),children:"关闭"})]}),children:[B!=null&&B.dsn_hint?S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:[B.driver," · ",B.dsn_hint,B.message?` · ${B.message}`:""]}):null,S.jsx($n,{rowKey:"name",loading:z,dataSource:((B==null?void 0:B.tables)||[]).filter(te=>!String(te.name||"").startsWith("_ajz_")),pagination:!1,size:"small",locale:{emptyText:"暂无业务表(尚未 push 或连不上库)"},columns:[{title:"表名",dataIndex:"name"},{title:"行数",dataIndex:"row_count",width:90,render:te=>S.jsx(Oe.Text,{strong:!0,children:te})},{title:"字段数",dataIndex:"column_count",width:90},{title:"字段",dataIndex:"columns",ellipsis:!0,render:te=>(te||[]).join(", ")},{title:"操作",width:168,render:(te,Y)=>S.jsxs(Mt,{size:4,children:[S.jsx(Ke,{size:"small",icon:S.jsx(Q4,{}),onClick:()=>void U(Y.name),children:"预览"}),S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),onClick:()=>Z(Y.name),children:"删表"})]})}]}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:12,marginBottom:0},children:[((B==null?void 0:B.tables)||[]).some(te=>String(te.name||"").startsWith("_ajz_"))?S.jsxs(S.Fragment,{children:["已隐藏同步系统表 ",S.jsx(Oe.Text,{code:!0,children:"_ajz_*"}),"(版本/outbox,不是业务模块表)。"]}):null,"本机有、这里没有的表 = 尚未 push/ensure。「删表」只删当前查看侧,不会同步到另一侧。"]})]}),S.jsx(tn,{title:H?`预览 · ${H.table}(共 ${H.total} 行,显示前 ${H.limit})`:"预览",open:D,onCancel:()=>L(!1),width:960,footer:S.jsx(Ke,{type:"primary",onClick:()=>L(!1),children:"关闭"}),children:S.jsx($n,{loading:V,dataSource:((H==null?void 0:H.rows)||[]).map((te,Y)=>({...te,__k:Y})),rowKey:"__k",size:"small",scroll:{x:!0},pagination:!1,columns:((H==null?void 0:H.columns)||[]).map(te=>({title:te,dataIndex:te,ellipsis:!0,render:Y=>Y==null?S.jsx(Oe.Text,{type:"secondary",children:"null"}):String(Y)}))})}),S.jsx(tn,{title:w?"编辑同步通道":"新建同步通道",open:y,onCancel:()=>$(!1),width:720,footer:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(b_,{}),loading:n,onClick:()=>void ae(),children:"测试连接"}),S.jsx(Ke,{onClick:()=>$(!1),children:"取消"}),S.jsx(Ke,{type:"primary",loading:n,onClick:()=>void Q(),children:"保存"})]}),children:S.jsxs(De,{form:q,layout:"vertical",children:[S.jsx(De.Item,{name:"name",label:"名称",rules:[{required:!0}],children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"agent_id",label:"所属智能体",extra:"哪个智能体的库就选哪个;模块数据应落在该智能体对应线上库",children:S.jsx(Qt,{allowClear:!0,placeholder:"可选",options:p.map(te=>({value:te.agent_id,label:`${te.name} (#${te.agent_id})`}))})}),S.jsx(De.Item,{name:"app_slug",label:"关联模块",extra:"已发布模块;本地上传/智能体管理的模块数据与此对照",children:S.jsx(Qt,{allowClear:!0,showSearch:!0,placeholder:"可选",options:b})}),S.jsx(De.Item,{name:"direction",label:"方向",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"local_to_remote",label:"本地 → 线上"},{value:"remote_to_local",label:"线上 → 本地"},{value:"bidirectional",label:"双向"}]})}),S.jsx(De.Item,{name:"conflict_policy",label:"冲突策略",extra:"自动 LWW;覆盖日志仅平台超级管理员可查,公司侧无冲突台",children:S.jsx(Qt,{options:[{value:"lww_source",label:"源端覆盖(推荐,B→A)"},{value:"lww_target",label:"保留目标"},{value:"queue",label:"入队(调试用,租户不可见)"}]})}),S.jsx(De.Item,{name:"poll_interval_ms",label:"轮询间隔(ms)",children:S.jsx(Pf,{min:100,max:6e4,style:{width:"100%"}})}),S.jsx(Oe.Text,{strong:!0,children:"本地库"}),S.jsx(De.Item,{name:["local","driver"],label:"驱动",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"sqlite"},{value:"mysql"},{value:"postgres"}]})}),S.jsx(De.Item,{name:["local","dsn"],label:"DSN",rules:[{required:!0}],extra:"SQLite 例:file:./data/local.db",children:S.jsx(Pt.TextArea,{rows:2})}),S.jsx(De.Item,{name:["local","tables"],label:"策略表(参考)",rules:[{required:!0}],extra:"Z4:不按此名单拒收;用户 JWT + Binding 下任意表可 push。此处仅运维提示。",children:S.jsx(Pt,{placeholder:"article,order"})}),S.jsx(Oe.Text,{strong:!0,children:"线上库 A(生产统一 Postgres)"}),S.jsx(De.Item,{name:["remote","driver"],label:"驱动",rules:[{required:!0}],extra:"生产推荐 postgres;mysql 兼容存量;sqlite 仅联调临时 A,不宜多 writer",children:S.jsx(Qt,{options:[{value:"postgres",label:"postgres(推荐)"},{value:"mysql",label:"mysql"},{value:"sqlite",label:"sqlite(仅联调)"}]})}),S.jsx(De.Item,{name:["remote","dsn"],label:"线上 DSN",rules:[{required:!0}],extra:"Postgres 例:postgres://user:pass@127.0.0.1:5432/dbname?sslmode=disable",children:S.jsx(Pt.TextArea,{rows:2})}),S.jsx(De.Item,{name:["remote","tables"],label:"策略表(参考)",rules:[{required:!0}],extra:"非整库限制;与本地提示一致即可。验同步请用「查看线上表」",children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"pk_columns",label:"主键映射",extra:"格式 table:pk,多个用逗号。默认每表 id",children:S.jsx(Pt,{placeholder:"article:id"})})]})})]})}function RZ(e){var re;const{session:t,busy:n,setBusy:r,setError:o,setInfo:s,onSession:i,onEnteredCompany:l}=e,{message:c,modal:u}=wo.useApp(),d=(t.tenantId||0)>0,[m,f]=a.useState([]),[p,h]=a.useState(!1),[b,x]=a.useState(!1),[v,g]=a.useState(!1),[y,$]=a.useState(!1),[w,I]=a.useState(!1),[C,N]=a.useState(null),[E,R]=a.useState([]),[P,T]=a.useState(null),[_,M]=a.useState([]),[O,k]=a.useState(0),[B,j]=a.useState([]),[z,A]=a.useState(""),[D,L]=a.useState(null),[H,K]=a.useState([]),[V,W]=a.useState(!1),[q]=De.useForm(),[ee]=De.useForm(),[se]=De.useForm();async function le(){h(!0);try{const U=await xQ(t);f(U.items||[])}catch(U){const J=U.message||String(U);o(J),c.error(J)}finally{h(!1)}}async function ce(){W(!0);try{const U=await vQ(t,{limit:100});K(U.items||[])}catch(U){c.error(U.message||String(U))}finally{W(!1)}}async function G(U){N(U),r(!0);try{const oe=(await NQ(t,U.tenant_id)).items||[];if(R(oe),oe.length===0){const ae=(await PQ(t,U.tenant_id,"")).admin_account;L({username:ae.username,password:ae.password,phone:ae.phone,company:U.name}),u.info({title:`「${U.name}」管理员账号已生成`,content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.username})]}),S.jsxs("p",{children:["密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.password})]}),S.jsx(Oe.Text,{type:"danger",children:"密码仅此一次展示;之后可在此改密码/绑手机。"})]}),okText:"已保存"}),await le();return}const Z=oe[0];T(Z.user_id),se.setFieldsValue({user_id:Z.user_id,phone:Z.phone||"",reset_password:!1,password:""}),I(!0)}catch(J){c.error(J.message||String(J))}finally{r(!1)}}a.useEffect(()=>{le(),ce(),$Q(t).then(U=>{M(U.modules||[]),k((U.catalog||[]).length)}).catch(()=>{})},[t.accessToken]);async function ne(U){N(U),r(!0);try{const J=await SQ(t,U.tenant_id);j(J.permissions||[]),J.total&&k(J.total),$(!0)}catch(J){c.error(J.message||String(J))}finally{r(!1)}}return S.jsxs("div",{className:"panel",children:[S.jsx(Oe.Title,{level:4,style:{marginTop:0},children:"平台工作台 · 公司总览"}),S.jsxs(Oe.Paragraph,{type:"secondary",children:["这是",S.jsx("strong",{children:"平台超级管理员自己的功能"}),":新建/改名公司、路径 slug、权限额度;新建时同步生成该公司管理员账号(随机唯一)。 路径约定:基础域名下 ",S.jsxs(Oe.Text,{code:!0,children:["/","{slug}","/..."]}),"(例如 www.yuxinda.com/aaa/)。点「管理该公司」打开内部视图;身份始终是超管。"]}),d&&S.jsxs(Oe.Paragraph,{children:[S.jsxs(Dt,{color:"orange",children:["正在管理:",t.tenantName||`公司 #${t.tenantId}`]}),S.jsx(Ke,{size:"small",icon:S.jsx(R_,{}),style:{marginLeft:8},loading:n,onClick:async()=>{r(!0);try{const U=await g_(t);i==null||i(U),s("已回到平台工作台"),c.success("已回到平台工作台")}catch(U){c.error(U.message||String(U))}finally{r(!1)}},children:"返回平台工作台"})]}),D&&S.jsxs(Oe.Paragraph,{className:"flash ok",children:["「",D.company,"」管理员(用户名唯一不可改): 用户名 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.username}),D.password?S.jsxs(S.Fragment,{children:[" · ","密码 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.password})]}):null,D.phone?S.jsxs(S.Fragment,{children:[" · ","手机 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.phone})]}):null]}),z&&S.jsxs(Oe.Paragraph,{className:"flash ok",children:["管理员邀请码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:z}),"(可选,发给客户自行注册)"]}),S.jsxs(Mt,{style:{marginBottom:12},children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>x(!0),children:"新建公司"}),S.jsx(Ke,{icon:S.jsx(ls,{}),loading:p,onClick:()=>void le(),children:"刷新"})]}),S.jsx($n,{rowKey:"tenant_id",loading:p,dataSource:m,pagination:!1,columns:[{title:"ID",dataIndex:"tenant_id",width:70},{title:"公司名称",dataIndex:"name"},{title:"路径 slug",dataIndex:"slug",width:140,render:U=>U?S.jsxs(Oe.Text,{code:!0,children:["/",U,"/"]}):S.jsx(Dt,{children:"未设置"})},{title:"成员",dataIndex:"user_count",width:70},{title:"模块",dataIndex:"app_count",width:70},{title:"创建时间",dataIndex:"created_at",render:U=>U?new Date(U).toLocaleString():"—"},{title:"操作",width:420,render:(U,J)=>S.jsxs(Mt,{wrap:!0,size:4,children:[S.jsx(Ke,{type:"primary",size:"small",icon:S.jsx(vJ,{}),loading:n,onClick:async()=>{if(await SZ(u,J.name,J.tenant_id)){r(!0);try{const Z=await TQ(t,J.tenant_id);Z.tenantName=J.name,i==null||i(Z),s(`已打开「${J.name}」管理视图(身份仍是平台超管)`),c.success(`已打开「${J.name}」管理视图(身份仍是平台超管)`),l==null||l()}catch(Z){c.error(Z.message||String(Z))}finally{r(!1)}}},children:"管理该公司"}),S.jsx(Ke,{size:"small",icon:S.jsx(jf,{}),loading:n,onClick:()=>void G(J),children:"管理员凭据"}),S.jsx(Ke,{size:"small",icon:S.jsx(GJ,{}),onClick:()=>void ne(J),children:"权限额度"}),S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>{N(J),ee.setFieldsValue({name:J.name,slug:J.slug||""}),g(!0)},children:"改名/slug"}),S.jsx(Ke,{size:"small",type:"link",loading:n,onClick:async()=>{r(!0);try{const oe=await IQ(t,J.tenant_id);A(oe.code),s(`已为「${J.name}」生成管理员邀请码`),c.success("邀请码已生成")}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}},children:"邀请码"})]})}]}),S.jsx(tn,{title:"新建公司",open:b,onCancel:()=>x(!1),onOk:async()=>{var J;const U=await q.validateFields();r(!0);try{const oe=await wQ(t,U.name.trim(),!!U.with_invite,(U.slug||"").trim(),(U.admin_phone||"").trim()),Z=oe.admin_account;if(!(Z!=null&&Z.username)||!(Z!=null&&Z.password)){c.error("公司已创建,但未返回管理员账号,请点「管理员凭据」补发"),x(!1),q.resetFields(),await le();return}L({username:Z.username,password:Z.password,phone:Z.phone,company:oe.tenant.name}),u.info({title:"公司与管理员账号已就绪",content:S.jsxs("div",{children:[S.jsxs("p",{children:["公司 ",S.jsx(Oe.Text,{strong:!0,children:oe.tenant.name}),"(路径 ",S.jsxs(Oe.Text,{code:!0,children:["/",oe.tenant.slug,"/"]}),")"]}),S.jsxs("p",{children:["管理员用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.username})]}),S.jsxs("p",{children:["管理员密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.password})]}),Z.phone||U.admin_phone?S.jsxs("p",{children:["手机:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.phone||U.admin_phone})]}):null,S.jsx(Oe.Text,{type:"danger",children:"创建公司即附带此账号;密码仅展示一次,请立即保存。"})]}),okText:"已保存"});const Q=(J=oe.admin_invite)==null?void 0:J.code;Q&&A(Q),c.success(`已创建「${oe.tenant.name}」并生成管理员账号`),s(`已创建「${oe.tenant.name}」管理员 ${Z.username}`),x(!1),q.resetFields(),await le()}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}},confirmLoading:n,children:S.jsxs(De,{form:q,layout:"vertical",initialValues:{with_invite:!1},children:[S.jsx(De.Item,{name:"name",label:"公司名称",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"例如:某某科技"})}),S.jsx(De.Item,{name:"slug",label:"路径 slug",extra:"访问前缀,如 aaa → www.yuxinda.com/aaa/。小写字母开头,仅 a-z/0-9/-",rules:[{required:!0,message:"请填写 slug"},{pattern:/^[a-z][a-z0-9-]{1,31}$/,message:"格式:2–32 位,小写字母开头"}],children:S.jsx(Pt,{placeholder:"例如:aaa"})}),S.jsx(De.Item,{name:"admin_phone",label:"管理员手机号(可选)",extra:"填写则绑定,可用手机登录;有 License 期限控制时不必强制",rules:[{validator:async(U,J)=>{const oe=String(J||"").trim();if(oe&&!/^1[3-9]\d{9}$/.test(oe))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",maxLength:20,allowClear:!0})}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginBottom:8},children:[S.jsx("strong",{children:"创建后立即生成"}),"管理员账号(随机用户名 + 初始密码);密码弹窗展示一次。"]}),S.jsx(De.Item,{name:"with_invite",valuePropName:"checked",children:S.jsx(go,{children:"额外生成邀请码(可选,一般不需要)"})})]})}),S.jsx(tn,{title:"修改公司名称 / 路径",open:v,onCancel:()=>g(!1),onOk:async()=>{if(!C)return;const U=await ee.validateFields();r(!0);try{await EQ(t,C.tenant_id,U.name.trim(),(U.slug||"").trim()),c.success("已保存"),g(!1),await le()}catch(J){c.error(J.message||String(J))}finally{r(!1)}},confirmLoading:n,children:S.jsxs(De,{form:ee,layout:"vertical",children:[S.jsx(De.Item,{name:"name",label:"公司名称",rules:[{required:!0}],children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"slug",label:"路径 slug",extra:"修改后,对外路径变为 /{slug}/(路由层后续阶段启用)",rules:[{required:!0,message:"请填写 slug"},{pattern:/^[a-z][a-z0-9-]{1,31}$/,message:"格式:2–32 位,小写字母开头"}],children:S.jsx(Pt,{})})]})}),S.jsx(tn,{title:C?`管理员凭据 · ${C.name}`:"管理员凭据",open:w,onCancel:()=>I(!1),confirmLoading:n,okText:"保存",onOk:async()=>{var oe;if(!C||!P)return;const U=await se.validateFields(),J=(U.phone||"").trim()!==(((oe=E.find(Z=>Z.user_id===P))==null?void 0:oe.phone)||"");if(!U.reset_password&&!J){c.info("未修改密码或手机号");return}r(!0);try{const Z={};U.reset_password&&(Z.reset_password=!0,Z.password=(U.password||"").trim()),J&&(Z.phone=(U.phone||"").trim());const ae=(await RQ(t,C.tenant_id,P,Z)).admin_account;L({username:ae.username,password:ae.password,phone:ae.phone,company:C.name}),ae.password?u.info({title:"密码已重置 — 请保存",content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.username})]}),S.jsxs("p",{children:["新密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.password})]}),ae.phone?S.jsxs("p",{children:["手机:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.phone})]}):null,S.jsx(Oe.Text,{type:"danger",children:"新密码仅此一次展示。"})]}),okText:"已保存"}):c.success(ae.phone?`已绑定手机 ${ae.phone}`:"已更新"),s(`已更新「${C.name}」管理员 ${ae.username}`),I(!1),await le()}catch(Z){c.error(Z.message||String(Z))}finally{r(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:se,layout:"vertical",children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"用户名不可改。可重置密码、绑定/更换手机号(手机登录可选)。"}),E.length>1?S.jsx(De.Item,{name:"user_id",label:"选择管理员",rules:[{required:!0}],children:S.jsx(Qt,{options:E.map(U=>({value:U.user_id,label:`${U.username}${U.phone?` · ${U.phone}`:""}`})),onChange:U=>{T(U);const J=E.find(oe=>oe.user_id===U);se.setFieldsValue({phone:(J==null?void 0:J.phone)||"",reset_password:!1,password:""})}})}):S.jsx(De.Item,{label:"内部用户名",children:S.jsx(Oe.Text,{code:!0,copyable:!0,children:((re=E[0])==null?void 0:re.username)||"—"})}),S.jsx(De.Item,{name:"phone",label:"绑定手机号",extra:"可选;留空保存即解除绑定。有期限控制时可用用户名登录",rules:[{validator:async(U,J)=>{const oe=String(J||"").trim();if(oe&&!/^1[3-9]\d{9}$/.test(oe))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",allowClear:!0,maxLength:20})}),S.jsx(De.Item,{name:"reset_password",valuePropName:"checked",children:S.jsx(go,{children:"重置密码"})}),S.jsx(De.Item,{noStyle:!0,shouldUpdate:(U,J)=>U.reset_password!==J.reset_password,children:()=>se.getFieldValue("reset_password")?S.jsx(De.Item,{name:"password",label:"新密码",extra:"留空则随机生成,保存后仅展示一次",children:S.jsx(Pt.Password,{placeholder:"至少 6 位,可留空自动生成"})}):null})]})}),S.jsxs(tn,{title:C?`公司权限额度 · ${C.name}`:"公司权限额度",open:y,width:720,onCancel:()=>$(!1),onOk:()=>{if(!C)return;const U=async()=>{r(!0);try{const J=await CQ(t,C.tenant_id,B);j(J.permissions||[]),c.success(`已保存(${(J.permissions||[]).length}/${J.total||O})`),$(!1)}catch(J){c.error(J.message||String(J))}finally{r(!1)}};if(B.length===0){u.confirm({title:"确认清空该公司全部权限?",content:"保存后该公司将无法使用任何业务接口,直到重新授予。",onOk:()=>void U()});return}U()},confirmLoading:n,okText:"保存额度",children:[S.jsxs(Mt,{style:{marginBottom:12},children:[S.jsxs(Dt,{children:["已选 ",B.length,"/",O||"?"]}),S.jsx(Ke,{size:"small",onClick:()=>j(_.flatMap(U=>(U.items||[]).map(J=>J.perm))),children:"全选"}),S.jsx(Ke,{size:"small",onClick:()=>j([]),children:"全不选"})]}),S.jsx(Mt,{direction:"vertical",size:"middle",style:{width:"100%"},children:_.map(U=>{const J=(U.items||[]).map(oe=>oe.perm);return S.jsxs("div",{children:[S.jsx(Oe.Text,{strong:!0,children:U.title}),S.jsx("div",{style:{marginTop:8},children:S.jsx(go.Group,{style:{width:"100%",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},options:(U.items||[]).map(oe=>({label:S.jsxs("span",{children:[oe.perm,S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:oe.desc})]}),value:oe.perm})),value:B.filter(oe=>J.includes(oe)),onChange:oe=>{const Z=new Set(J),Q=B.filter(ae=>!Z.has(ae));j([...Q,...oe])}})})]},U.title)})})]}),S.jsx(Oe.Title,{level:5,style:{marginTop:32},children:"LWW 覆盖日志(仅超管)"}),S.jsx(Oe.Paragraph,{type:"secondary",children:"同步自动覆盖时的落败/胜出记录;公司管理员不可见。默认保留 90 天。 对「源端覆盖」记录可按落败快照回滚线上单行(需通道 remote 仍可达)。"}),S.jsx(Mt,{style:{marginBottom:8},children:S.jsx(Ke,{icon:S.jsx(ls,{}),loading:V,onClick:()=>void ce(),children:"刷新日志"})}),S.jsx($n,{rowKey:"id",size:"small",loading:V,dataSource:H,pagination:{pageSize:10},columns:[{title:"公司",dataIndex:"tenant_id",width:80},{title:"入口",dataIndex:"entry",width:100},{title:"表",dataIndex:"table",width:120},{title:"主键",dataIndex:"row_pk",ellipsis:!0},{title:"策略",dataIndex:"policy",width:110},{title:"结果",dataIndex:"outcome",width:120},{title:"时间",dataIndex:"created_at",width:180,render:U=>U?new Date(U).toLocaleString():""},{title:"操作",width:100,render:(U,J)=>J.outcome==="applied_source"?S.jsx(Ke,{size:"small",danger:!0,loading:n,onClick:()=>{u.confirm({title:"按落败快照回滚线上单行?",content:`${J.table} / ${J.row_pk}`,onOk:async()=>{r(!0);try{await bQ(t,J.id),c.success("已回滚并记入审计"),await ce()}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}}})},children:"回滚"}):null}]})]})}function TZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState([]),[f,p]=a.useState(!1),[h,b]=a.useState(!1),[x,v]=a.useState(!1),[g,y]=a.useState(null),[$,w]=a.useState(""),[I]=De.useForm();async function C(){p(!0);try{const[E,R]=await Promise.all([_Q(t),x$(t).catch(()=>({items:[]}))]);u(E.items||[]),m(R.items||[])}catch(E){const R=E.message||String(E);o(R),i.error(R)}finally{p(!1)}}a.useEffect(()=>{C()},[t.accessToken,t.tenantId]);async function N(E,R,P){if(await sc(l,t,R,`成员:${E.display_name||E.username}(#${E.user_id})`)){r(!0);try{await yE(t,E.user_id,P),s(`${R}成功`),await C()}catch(_){i.error(_.message||String(_))}finally{r(!1)}}}return S.jsxs(rr,{title:"成员管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>{I.setFieldsValue({role:"编辑",password:void 0,display_name:void 0,org_unit_id:void 0}),b(!0)},children:"新建成员"}),S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:()=>void C(),loading:f,children:"刷新"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["用户名由系统随机生成且全局唯一;初始密码可留空自动生成,登录后可自行「修改密码」。也可走「邀请加入」。 管理员可为成员「绑定手机」(登录/同号同步联调用);顶栏「更换手机」只改当前登录账号。",t.role==="超级管理员"||t.role==="platform_admin"?" 超管代管修改时会要求两次确认。":""]}),S.jsx($n,{rowKey:"user_id",loading:f||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"用户名",dataIndex:"username",width:140},{title:"手机号",dataIndex:"phone",width:200,render:(E,R)=>S.jsxs(Mt,{size:4,children:[E?S.jsx(Oe.Text,{copyable:!0,children:E}):S.jsx(Oe.Text,{type:"secondary",children:"未绑定"}),S.jsx(Ke,{type:"link",size:"small",style:{padding:0},onClick:()=>{y(R),w(E||""),v(!0)},children:E?"更换":"绑定"})]})},{title:"显示名",dataIndex:"display_name",width:120},{title:"角色",dataIndex:"role",width:160,render:(E,R)=>S.jsx(Qt,{size:"small",style:{width:120},value:E,disabled:R.user_id===t.userId,options:[{value:"管理员",label:"管理员"},{value:"编辑",label:"编辑"},{value:"只读",label:"只读"}],onChange:P=>void N(R,`将 ${R.username} 设为${rc(P)}`,{role:P})})},{title:"组织",width:160,render:(E,R)=>S.jsx(Qt,{size:"small",allowClear:!0,style:{width:140},placeholder:"全公司",value:R.org_unit_id||void 0,options:d.map(P=>({value:P.org_unit_id,label:P.name})),onChange:P=>void N(R,`调整 ${R.username} 的组织`,{org_unit_id:P||0})})},{title:"状态",dataIndex:"status",width:120,render:(E,R)=>S.jsx(Qt,{size:"small",style:{width:100},value:E||"active",disabled:R.user_id===t.userId,options:[{value:"active",label:"正常"},{value:"disabled",label:"停用"}],onChange:P=>void N(R,`${P==="disabled"?"停用":"启用"}成员 ${R.username}`,{status:P})})},{title:"角色标签",width:90,render:(E,R)=>S.jsx(Dt,{children:rc(R.role)})}]}),S.jsxs(tn,{title:g!=null&&g.phone?"更换手机号":"绑定手机号",open:x,onCancel:()=>{v(!1),y(null)},onOk:async()=>{if(!g)return;const E=$.trim();if(await sc(l,t,E?"绑定/更换成员手机号":"解绑成员手机号",`成员:${g.display_name||g.username}(#${g.user_id})→ ${E||"(空)"}`)){r(!0);try{await yE(t,g.user_id,{phone:E}),s(E?`已绑定 ${E}`:"已解绑手机号"),v(!1),y(null),await C()}catch(P){i.error(P.message||String(P))}finally{r(!1)}}},confirmLoading:n,destroyOnHidden:!0,okText:"保存",children:[S.jsxs(Oe.Paragraph,{type:"secondary",children:["用于手机号登录与松离线同号绑定联调。生产宇信达请绑"," ",S.jsx(Oe.Text,{code:!0,children:"13531041944"}),";勿绑超管号 13531041945。清空并保存即解绑。"]}),S.jsx(Pt,{value:$,onChange:E=>w(E.target.value),placeholder:"例:13531041944",maxLength:20,allowClear:!0})]}),S.jsx(tn,{title:"新建成员",open:h,onCancel:()=>b(!1),onOk:async()=>{const E=await I.validateFields();if(await sc(l,t,"新建成员","将随机生成唯一用户名;初始密码可稍后由本人修改")){r(!0);try{const P=await MQ(t,{password:(E.password||"").trim(),display_name:(E.display_name||"").trim(),role:E.role,org_unit_id:E.org_unit_id||0});l.info({title:"成员已创建 — 请保存账号",content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:P.username})]}),S.jsxs("p",{children:["初始密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:P.password})]}),S.jsxs("p",{children:["角色:",rc(P.role)]}),S.jsx(Oe.Text,{type:"secondary",children:"用户名随机唯一不可改;密码请交给本人后由其登录并自行修改。"})]}),okText:"已保存"}),s(`已创建成员 ${P.username}`),b(!1),I.resetFields(),await C()}catch(P){i.error(P.message||String(P))}finally{r(!1)}}},confirmLoading:n,destroyOnHidden:!0,children:S.jsxs(De,{form:I,layout:"vertical",initialValues:{role:"编辑"},children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"用户名由系统随机生成(全局唯一)。初始密码可指定,留空则随机生成;登录后可自行修改。"}),S.jsx(De.Item,{name:"password",label:"初始密码",extra:"留空则随机生成",children:S.jsx(Pt.Password,{placeholder:"至少 6 位,可留空"})}),S.jsx(De.Item,{name:"display_name",label:"显示名",children:S.jsx(Pt,{placeholder:"可选"})}),S.jsx(De.Item,{name:"role",label:"角色",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"管理员",label:"管理员(公司顶级)"},{value:"编辑",label:"编辑"},{value:"只读",label:"只读"}]})}),S.jsx(De.Item,{name:"org_unit_id",label:"组织",children:S.jsx(Qt,{allowClear:!0,placeholder:"全公司(不限组织)",options:d.map(E=>({value:E.org_unit_id,label:E.name}))})})]})})]})}const Is=["#1d4f91","#7c3aed","#c2410c","#0f766e","#b42318","#854d0e"];function _Z({title:e,value:t}){return S.jsxs("div",{className:"kpi",children:[S.jsx("div",{className:"kpi-title",children:e}),S.jsx("div",{className:"kpi-value",children:t})]})}function wE({title:e,buckets:t}){const n=Math.max(1,...t.map(r=>r.count));return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:e}),S.jsx("div",{className:"bars",children:t.map((r,o)=>S.jsxs("div",{className:"bar-row",children:[S.jsx("span",{className:"bar-label",children:r.key}),S.jsx("div",{className:"bar-track",children:S.jsx("div",{className:"bar-fill",style:{width:`${r.count/n*100}%`,background:Is[o%Is.length]}})}),S.jsx("span",{className:"bar-num",children:r.count})]},r.key))})]})}function MZ({title:e,buckets:t}){const n=t.reduce((s,i)=>s+i.count,0)||1;let r=0;const o=t.map((s,i)=>{const l=r/n*100;r+=s.count;const c=r/n*100;return`${Is[i%Is.length]} ${l}% ${c}%`});return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:e}),S.jsxs("div",{className:"pie-wrap",children:[S.jsx("div",{className:"pie",style:{background:`conic-gradient(${o.join(",")})`}}),S.jsx("ul",{className:"pie-legend",children:t.map((s,i)=>S.jsxs("li",{children:[S.jsx("i",{style:{background:Is[i%Is.length]}}),s.key," · ",s.count]},s.key))})]})]})}function W_({title:e,points:t,series:n,yUnit:r=""}){if(!t.length||!n.length)return S.jsxs("div",{className:"chart-card line-chart",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"empty",children:"暂无曲线数据"})]});const o=t.flatMap(E=>n.map(R=>E.values[R.key]).filter(R=>Number.isFinite(R))),s=[...o].sort((E,R)=>E-R),i=E=>{if(!s.length)return 0;const R=Math.min(s.length-1,Math.max(0,Math.floor((s.length-1)*E)));return s[R]};let l=s.length?Math.min(0,i(.05)):0,c=s.length?Math.max(1,i(.95)):1;c-l<1&&(l=Math.min(0,...o,-1),c=Math.max(1,...o,1));const u=(c-l)*.12||1,d=l-u,m=c+u,f=920,p=280,h=48,b=16,x=20,v=36,g=f-h-b,y=p-x-v,$=E=>h+(t.length<=1?g/2:E/(t.length-1)*g),w=E=>x+(m-E)/(m-d)*y,I=n.map((E,R)=>{const P=t.map((T,_)=>{var k;const M=T.values[E.key];return Number.isFinite(M)?`${_===0||!Number.isFinite((k=t[_-1])==null?void 0:k.values[E.key])?"M":"L"}${$(_).toFixed(1)},${w(M).toFixed(1)}`:null}).filter(Boolean).join(" ");return{...E,d:P,color:Is[R%Is.length]}}),C=5,N=Array.from({length:C},(E,R)=>d+(m-d)*R/(C-1));return S.jsxs("div",{className:"chart-card line-chart",children:[S.jsxs("div",{className:"line-chart-head",children:[e?S.jsx("h4",{children:e}):null,S.jsx("ul",{className:"line-legend",children:I.map(E=>S.jsxs("li",{children:[S.jsx("i",{style:{background:E.color}}),E.label]},E.key))})]}),S.jsx("div",{className:"line-chart-scroll",children:S.jsxs("svg",{viewBox:`0 0 ${f} ${p}`,width:"100%",height:p,preserveAspectRatio:"none",role:"img",children:[N.map(E=>S.jsxs("g",{children:[S.jsx("line",{x1:h,x2:f-b,y1:w(E),y2:w(E),className:"line-grid"}),S.jsx("text",{x:h-6,y:w(E)+4,className:"line-axis",textAnchor:"end",children:E.toFixed(0)})]},E)),S.jsx("text",{x:8,y:14,className:"line-axis",children:r}),I.map(E=>S.jsx("path",{d:E.d,fill:"none",stroke:E.color,strokeWidth:2.2},E.key)),t.map((E,R)=>S.jsx("text",{x:$(R),y:p-10,className:"line-axis",textAnchor:"middle",children:R%Math.ceil(t.length/8)===0?E.x:""},`${E.x}-${R}`))]})})]})}function OZ({points:e,yUnit:t="",yAxisLabel:n="",designColor:r="#e8590c",invertY:o=!1}){if(!e.length)return S.jsx("div",{className:"chart-card line-chart",children:S.jsx("div",{className:"empty",children:"暂无曲线数据"})});const s=e.map(E=>E.value).filter(E=>Number.isFinite(E)),i=e.map(E=>E.design).filter(E=>Number.isFinite(E)),l=[...s,...i];let c=l.length?Math.min(...l):0,u=l.length?Math.max(...l):1;u-c<1e-6&&(c-=1,u+=1);const d=(u-c)*.08||1;c-=d,u+=d;const m=Math.max(920,e.length*22),f=260,p=52,h=12,b=16,x=34,v=m-p-h,g=f-b-x,y=E=>p+(e.length<=1?v/2:E/(e.length-1)*v),$=E=>o?b+(E-c)/(u-c)*g:b+(u-E)/(u-c)*g,w=6,I=Array.from({length:w},(E,R)=>c+(u-c)*R/(w-1)),C=t?String(t):"",N=e.map((E,R)=>{var _;const P=E.design;return Number.isFinite(P)?`${R===0||!Number.isFinite((_=e[R-1])==null?void 0:_.design)?"M":"L"}${y(R).toFixed(1)},${$(P).toFixed(1)}`:null}).filter(Boolean).join(" ");return S.jsx("div",{className:"chart-card line-chart section-mark-chart",children:S.jsx("div",{className:"line-chart-scroll",children:S.jsxs("svg",{viewBox:`0 0 ${m} ${f}`,width:"100%",height:f,preserveAspectRatio:"none",role:"img",children:[I.map(E=>S.jsxs("g",{children:[S.jsx("line",{x1:p,x2:m-h,y1:$(E),y2:$(E),className:"line-grid"}),S.jsxs("text",{x:p-6,y:$(E)+4,className:"line-axis",textAnchor:"end",children:[Number.isInteger(E)?String(E):E.toFixed(1),C]})]},E)),n?S.jsx("text",{x:6,y:14,className:"line-axis",children:n}):null,N?S.jsx("path",{d:N,fill:"none",stroke:r,strokeWidth:2}):null,e.map((E,R)=>{const P=E.value;if(!Number.isFinite(P))return null;const T=y(R),_=$(P),M=$(0),O=Math.min(_,M),k=Math.max(3,Math.abs(_-M));return S.jsx("rect",{x:T-3,y:O,width:6,height:k,fill:E.color||"#214080",opacity:.9},`${E.x}-${R}`)}),e.map((E,R)=>S.jsx("text",{x:y(R),y:f-8,className:"line-axis",textAnchor:"middle",children:R%Math.ceil(e.length/8)===0?E.x:""},`lb-${R}`))]})})})}function K_({title:e,items:t,variant:n="cells"}){return n==="stacked"?S.jsxs("div",{className:"chart-card status-strip status-strip-stacked",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"status-strip-row stacked-row",children:t.map((r,o)=>{if(r.stop)return S.jsx("div",{className:"status-stack stop",title:r.label,children:S.jsx("span",{className:"stack-stop",children:"停"})},`${r.label}-${o}`);const s=Math.max(0,Number(r.value)||0),i=Math.max(0,Number(r.secondary)||0),l=s+i||1;if(i<=0&&s>0)return S.jsx("div",{className:"status-stack all-grey",title:r.label,children:S.jsx("span",{className:"stack-solo",children:s})},`${r.label}-${o}`);if(s<=0&&i>0)return S.jsx("div",{className:"status-stack all-green",title:r.label,children:S.jsx("span",{className:"stack-solo",children:i})},`${r.label}-${o}`);const c=s/l*100,u=i/l*100;return S.jsxs("div",{className:"status-stack",title:r.label,children:[S.jsx("div",{className:"stack-top",style:{flex:`${Math.max(c,8)} 1 0`},children:S.jsx("span",{children:s})}),S.jsx("div",{className:"stack-bot",style:{flex:`${Math.max(u,8)} 1 0`},children:S.jsx("span",{children:i})})]},`${r.label}-${o}`)})})]}):S.jsxs("div",{className:"chart-card status-strip",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"status-strip-row",children:t.map((r,o)=>S.jsxs("div",{className:`status-cell tone-${r.tone||"ok"}`,title:r.label,children:[S.jsx("span",{className:"status-top",children:r.label}),S.jsx("span",{className:"status-val",children:r.value})]},`${r.label}-${o}`))})]})}const zZ="AJZP1",U_="application/x-ajz-machine",jZ="aijianzhan-page-machine-v1";function BZ(e,t){const n=new Uint8Array(e.length),r=new TextEncoder().encode(t);for(let o=0;og.entity===n.entity)||(((p=o==null?void 0:o.apis)==null?void 0:p.resources)||[]).find(g=>String(g.path||"").replace(/^\//,"")===r),c=(l==null?void 0:l.operations)||["list","get","create","update","delete","import","export"],u={};c.includes("list")&&(u.list={method:"GET",path:i}),c.includes("get")&&(u.get={method:"GET",path:`${i}/{id}`}),c.includes("create")&&(u.create={method:"POST",path:i}),c.includes("update")&&(u.update={method:"PUT",path:`${i}/{id}`}),c.includes("delete")&&(u.delete={method:"DELETE",path:`${i}/{id}`}),c.includes("import")&&(u.import={method:"POST",path:`${i}/import`}),c.includes("export")&&(u.export={method:"GET",path:`${i}/export`}),u.aggregate={method:"GET",path:`${i}/aggregate`},u.blueprint={method:"GET",path:`${s}/blueprint`};const d=((o==null?void 0:o.entities)||[]).find(g=>g.name===n.entity),m=((d==null?void 0:d.fields)||[]).filter(g=>g==null?void 0:g.name).slice(0,80).map(g=>({name:String(g.name),type:String(g.type||"string"),label:g.label?String(g.label):void 0}));return{v:1,kind:"ajz-page",slug:t,base_path:s,page:{id:n.id,type:n.type,route:n.route||"",title:n.title||""},entity:n.entity,resource:r,auth:{type:"bearer_jwt",header:"Authorization"},endpoints:u,filters:((h=n.layout)==null?void 0:h.filters)||((b=l==null?void 0:l.list)==null?void 0:b.allowed_filters)||[],fields:m,actions:((x=n.layout)==null?void 0:x.actions)||[],widgets:(((v=n.layout)==null?void 0:v.widgets)||[]).map(g=>({type:g.type,title:g.title,entity:g.entity})),notes:"list 支持 filter.=value;需 Authorization: Bearer "}}function AZ(e){var n,r,o;const t=a.useMemo(()=>{try{const s=kZ(e);return q_(s)}catch{return""}},[e.slug,e.resource,(n=e.page)==null?void 0:n.id,(r=e.page)==null?void 0:r.type,(o=e.page)==null?void 0:o.entity,e.blueprint]);return t?S.jsx("div",{className:"ajz-machine-tag",hidden:!0,"aria-hidden":"true","data-ajz-machine":t,"data-ajz-mime":U_,"data-ajz-codec":"AJZP1","data-ajz-kind":"page","data-ajz-slug":e.slug,"data-ajz-page":e.page.id,"data-ajz-entity":e.page.entity,"data-ajz-resource":e.resource}):null}function G_(e){const t=a.useMemo(()=>{try{return q_({v:1,kind:"ajz-block",slug:e.slug,resource:e.resource,block_id:e.blockId,endpoint:e.endpoint||{method:"GET",path:`/api/v1/apps/${e.slug}/${e.resource}`},...e.extra||{}})}catch{return""}},[e.slug,e.resource,e.blockId,e.endpoint,e.extra]);return t?S.jsx("div",{className:"ajz-machine-tag",hidden:!0,"aria-hidden":"true","data-ajz-machine":t,"data-ajz-mime":U_,"data-ajz-codec":"AJZP1","data-ajz-kind":"block","data-ajz-block":e.blockId,"data-ajz-slug":e.slug,"data-ajz-resource":e.resource}):null}function DZ(e,t){return t==null||t===""?"—":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function FZ(e,t){if(!t.filter_field)return!0;const n=e[t.filter_field],r=Number(n),o=t.filter_op||"gt",s=Number(t.filter_value??0);return o==="gt"?Number.isFinite(r)&&r>s:o==="gte"?Number.isFinite(r)&&r>=s:o==="lt"?Number.isFinite(r)&&rye&&ye!=="全部"),C=g.select_field||g.filter_select_field||["worksite","site","store","warehouse","dept"].find(ye=>s[ye])||"",N=!!(w&&I.length>0),E=!!C;a.useEffect(()=>{(async()=>{try{const ye={};if(w&&f){const Re=g.filter_value_aliases||{};ye[w]=Re[f]||f}C&&h&&(ye[C]=h);const Ne=await np(t,n,r,ye,1,2e3);u(Ne.items||[]),m(Ne.total||(Ne.items||[]).length)}catch(ye){l(ye.message||String(ye))}})()},[t,n,r,w,f,C,h,l,g.filter_value_aliases]);const R=ye=>{var Ve;const Ne=g.table_headers||[],Re=o.find(at=>at.type==="table"),Ye=((Re==null?void 0:Re.columns)||[]).indexOf(ye);return Ye>=0&&Ne[Ye]?Ne[0]==="序号"&&Ne[Ye+1]?Ne[Ye+1]:Ne[Ye]:((Ve=s[ye])==null?void 0:Ve.label)||ye},P=o.find(ye=>ye.type==="line_chart"||ye.type==="bar_chart"),T=o.find(ye=>ye.type==="status_strip"),_=o.find(ye=>ye.type==="table"),M=g.chart_side_label||(P==null?void 0:P.title)||"主图",O=g.strip_side_label||(T==null?void 0:T.title)||"状态",k=g.table_side_label||"明细",B=g.table_title||(_==null?void 0:_.title)||"明细表",j=g.stats_left_label||"",z=g.stats_right_label||"",A=a.useMemo(()=>{const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||Object.keys(s)[0]||"id";return[...c].sort((Ne,Re)=>String(Ne[ye]??"").localeCompare(String(Re[ye]??""),"zh"))},[c,P,s]),D=g.value_field||(P==null?void 0:P.metric)||((Ce=P==null?void 0:P.metrics)==null?void 0:Ce[0])||["value","cjl_value","cum_value","cum_settlement_mm","amount","qty"].find(ye=>s[ye])||"",L=g.color_field||["color","cjl_color","mark_color"].find(ye=>s[ye])||"",H=g.design_field||["design_value","design_settlement_mm","target","design"].find(ye=>s[ye])||"",K=g.category_colors||{},V=g.category_field||w||"",W=String(g.chart_style||"").toLowerCase(),q=W==="line"||W==="multi_series"||W==="line_chart",ee=W==="section_marks"||W==="colored_marks",se=!!P&&!!D&&!!(P!=null&&P.x_field||P!=null&&P.group_by||Object.keys(s)[0]),le=ee||!q&&se,ce=a.useMemo(()=>{if(!le)return[];const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||Object.keys(s)[0]||"",Ne=["#1d4f91","#7c3aed","#868e96","#0f766e","#c2410c"],Re=new Map;return A.map(Xe=>{const Ye=El(D?Xe[D]:void 0),Ve=H?El(Xe[H]):NaN;let at=L?String(Xe[L]||"").trim():"";if(!at&&V){const xe=String(Xe[V]??"");K[xe]?at=K[xe]:xe&&(Re.has(xe)||Re.set(xe,Re.size),at=Ne[Re.get(xe)%Ne.length])}return at||(at=Ne[0]),{x:String(Xe[ye]??""),value:Number.isFinite(Ye)?Ye:0,design:Number.isFinite(Ve)?Ve:void 0,color:at}})},[le,A,P,D,L,H,V,K,s]),G=a.useMemo(()=>{var Ye;if(!P||le)return null;const ye=P.x_field||P.group_by||"";let Ne=((Ye=P.metrics)!=null&&Ye.length?P.metrics:P.metric&&P.metric!=="count"?[P.metric]:[]).filter(Boolean);if((!Ne.length||!Ne.some(Ve=>s[Ve]))&&(Ne=Object.values(s).filter(Ve=>["int","bigint","decimal","number","float"].includes(String(Ve.type))).map(Ve=>Ve.name).filter(Ve=>!["id","tenant_id"].includes(Ve)).slice(0,4)),!ye||!Ne.length)return null;const Re=A.map(Ve=>{const at={};for(const xe of Ne){const Le=El(Ve[xe]);Number.isFinite(Le)&&(at[xe]=Le)}return{x:String(Ve[ye]??""),values:at}}),Xe=g.series_labels||{};return{title:P.title||"图表",points:Re,series:Ne.map(Ve=>({key:Ve,label:Xe[Ve]||R(Ve)})),yUnit:P.y_unit||g.y_unit||""}},[P,A,le,g.series_labels,g.y_unit,s]),ne=(qe=g.legend_items)!=null&&qe.length?g.legend_items:le&&Object.keys(K).length?Object.entries(K).map(([ye,Ne])=>({label:ye,color:Ne})):((G==null?void 0:G.series)||[]).map((ye,Ne)=>({label:ye.label,color:["#1d4f91","#7c3aed","#6b7280","#c2410c"][Ne%4]})),re=a.useMemo(()=>{if(!T)return[];const ye=T.label_field||"",Ne=T.value_field||"",Re=T.secondary_field||"";if(!ye||!Ne)return[];const Xe=Number(T.cycle_days)||Number(g.cycle_days)||30,Ye=T.variant==="stacked"||T.variant==="stacked_days"||!!Re;return A.map(Ve=>{const at=String(Ve[ye]??"");let xe=El(Ve[Ne]),Le=Re?El(Ve[Re]):NaN;if(Number.isFinite(xe)||(xe=0),Number.isFinite(Le)||(Le=0),Ye&&xe+Le>50&&xe+Le<120){const Pe=Math.round(xe/100*Xe),ve=Math.max(0,Xe-Pe);xe=Pe,Le=ve}const me=!!Ve.stop_flag||String(Ve.status||"").includes("停")||Ye&&xe===0&&Le===0;return{label:at,value:xe,secondary:Ye?Le:void 0,stop:me}})},[T,A,g.cycle_days]),U=(T==null?void 0:T.variant)==="stacked"||(T==null?void 0:T.variant)==="stacked_days"||T!=null&&T.secondary_field?"stacked":"cells",J=(Qe=_==null?void 0:_.columns)!=null&&Qe.length?_.columns:Object.keys(s).filter(ye=>!["id","tenant_id"].includes(ye)).slice(0,6),oe=_?A.filter(ye=>FZ(ye,_)):[],Z=a.useMemo(()=>{var Ne,Re;if(!C)return[];if((Re=(Ne=s[C])==null?void 0:Ne.enum_values)!=null&&Re.length)return s[C].enum_values;const ye=new Set;for(const Xe of c){const Ye=String(Xe[C]??"");Ye&&ye.add(Ye)}return Array.from(ye).sort()},[C,s,c]),Q=a.useMemo(()=>{const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||"";return ye&&new Set(c.map(Ne=>String(Ne[ye]??""))).size||d},[c,d,P]),ae=Number(g.chart_page_size)||28,te=le?ce.length:(G==null?void 0:G.points.length)||re.length,Y=Math.max(0,te-ae),de=ce.slice(x,x+ae),ue=(G==null?void 0:G.points.slice(x,x+ae))||[],ge=re.slice(x,x+ae),we=(()=>{if(y&&(j||z)&&y.includes(j||"\0"))return y;const ye=[];return y&&ye.push(y),j&&ye.push(`${j}:${Q}个`),z&&ye.push(`${z}: ${d}个`),ye.join(" ")||(d?`共 ${d} 条`:"")})(),he=g.select_label||(C?R(C):"")||"",Be=(P==null?void 0:P.y_unit)||g.y_unit||"",be=g.y_axis_label||Be||"",Fe=!!g.invert_y,_e=g.design_series_color||"#e8590c",Ee=g.empty_table_text||"暂无数据",Te=[w,C].filter(Boolean);return S.jsxs("div",{className:"sf-root",children:[S.jsx(G_,{slug:n,resource:r,blockId:"sf-dashboard",endpoint:{method:"GET",path:`/api/v1/apps/${n}/${r}`},extra:{page_type:"dashboard",filters:Te,list_query:"filter.=value&page=1&page_size=2000"}}),S.jsxs("div",{className:"sf-filterbar",children:[S.jsx("div",{className:"sf-context",children:S.jsx("strong",{children:we})}),N&&S.jsx("div",{className:"sf-radios",children:["",...I].map(ye=>S.jsxs("label",{className:`sf-radio ${(f||"")===ye?"on":""}`,children:[S.jsx("input",{type:"radio",name:"sf-radio",checked:(f||"")===ye,onChange:()=>p(ye)}),ye||g.radio_all_label||"全部"]},ye||"all"))}),E&&S.jsxs("label",{className:"sf-select",children:[he?`${he}:`:null,S.jsxs("select",{value:h,onChange:ye=>b(ye.target.value),children:[S.jsx("option",{value:"",children:"--请选择--"}),Z.map(ye=>S.jsx("option",{value:ye,children:ye},ye))]})]}),$?S.jsx("span",{className:"sf-hint",children:$}):null]}),ne.length>0&&P&&S.jsx("div",{className:"sf-legend",children:ne.map((ye,Ne)=>S.jsx("span",{className:`sf-leg-item${/曲线|折线|line/i.test(ye.label)?" leg-line":""}`,style:{"--leg":ye.color},children:ye.label},`${ye.label}-${Ne}`))}),S.jsxs("div",{className:"sf-body",children:[S.jsxs("div",{className:"sf-rail",children:[P?S.jsx("div",{className:"sf-rail-seg chart",children:M}):null,T?S.jsx("div",{className:"sf-rail-seg strip",children:O}):null,_?S.jsx("div",{className:"sf-rail-seg table",children:k}):null]}),S.jsxs("div",{className:"sf-main",children:[P&&S.jsxs("div",{className:"sf-line-wrap",children:[le?S.jsx(OZ,{points:de.length?de:ce,yUnit:Be,yAxisLabel:be,invertY:Fe,designColor:_e}):G?S.jsx(W_,{title:"",points:ue.length?ue:G.points,series:G.series,yUnit:G.yUnit}):S.jsx("div",{className:"empty",style:{padding:"2rem",textAlign:"center"},children:"暂无曲线数据(请检查蓝图 x_field / metrics 与已导入数据)"}),Y>0&&S.jsx("input",{className:"sf-scroll",type:"range",min:0,max:Y,value:x,onChange:ye=>v(Number(ye.target.value))})]}),T&&S.jsx("div",{className:"sf-strip-wrap",children:S.jsx(K_,{title:"",variant:U,items:ge})}),_&&S.jsxs("div",{className:"sf-table-panel",children:[S.jsx("div",{className:"sf-table-title",children:B}),S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{className:"sf-table",children:[S.jsx("thead",{children:S.jsxs("tr",{children:[S.jsx("th",{children:"序号"}),J.map(ye=>S.jsx("th",{children:R(ye)},ye))]})}),S.jsxs("tbody",{children:[oe.map((ye,Ne)=>S.jsxs("tr",{children:[S.jsx("td",{children:Ne+1}),J.map(Re=>S.jsx("td",{children:DZ(Re,ye[Re])},Re))]},Ne)),!oe.length&&S.jsx("tr",{children:S.jsx("td",{colSpan:J.length+1,className:"empty",children:Ee})})]})]})})]})]})]})]})}function X_(e){if(typeof e=="string")return e.trim();if(e&&typeof e=="object"){const t=e;for(const n of["label","title","name","text"])if(typeof t[n]=="string"&&String(t[n]).trim())return String(t[n]).trim()}return""}function VZ(e){if(!e||typeof e!="object")return"";const t=e;for(const n of["route","path","href","url"])if(typeof t[n]=="string"&&String(t[n]).trim())return String(t[n]).trim();return""}function EE(e,t=[]){return(Array.isArray(e)?e:t).map(X_).filter(Boolean)}function nd(e,t){return e.title||e.id}function WZ(e,t){var r,o,s;const n=(((r=e==null?void 0:e.apis)==null?void 0:r.resources)||[]).find(i=>i.entity===t)||((s=(o=e==null?void 0:e.apis)==null?void 0:o.resources)==null?void 0:s[0]);return String((n==null?void 0:n.path)||`/${t}`).replace(/^\//,"")}function IE(e,t){var r;const n=((e==null?void 0:e.entities)||[]).find(o=>o.name===t)||((r=e==null?void 0:e.entities)==null?void 0:r[0]);return((n==null?void 0:n.fields)||[]).map(o=>{var s;return{name:o.name,label:o.label||o.name,type:o.type||"string",enum_values:o.enum_values||o.enumValues,widget:(s=o.ui)==null?void 0:s.widget}})}const KZ=new Set(["id","tenant_id","org_unit_id","created_by","created_at","updated_at"]),PE=/(status|type|category|state|分类|类型|状态)$/i;function Bf(e){return e.type==="enum"||e.widget==="select"||e.enum_values&&e.enum_values.length>0?!0:PE.test(e.name)||PE.test(e.label)}function H0(e){return e.type==="datetime"||Lf(e)?!1:e.type==="date"||e.widget==="datepicker"?!0:/日期/.test(e.label)||/(^|_)date$/i.test(e.name)}function Lf(e){return e.type==="datetime"||e.widget==="datetime"||/(_at$|时间|datetime)/i.test(e.name)}function V0(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return t==="date"?e.slice(0,10):e.length>=16?e.slice(0,16):e;const r=l=>String(l).padStart(2,"0"),o=n.getFullYear(),s=r(n.getMonth()+1),i=r(n.getDate());return t==="date"?`${o}-${s}-${i}`:`${o}-${s}-${i}T${r(n.getHours())}:${r(n.getMinutes())}`}function UZ(e,t){if(!e)return"";const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toISOString()}function qZ(e){return/status_check|_status_check/i.test(e)?"状态值不合法:请从下拉框选择蓝图允许的枚举值。":/violates check constraint/i.test(e)||/检查约束/.test(e)?`字段值不符合约束:${e}`:/null value|非空|not-null/i.test(e)?`必填字段为空:${e}`:e}function GZ({meta:e,value:t,options:n,onChange:r}){if(Bf(e)||n.length>0){const o=n.length?n:e.enum_values||[];return S.jsxs("select",{value:t,onChange:s=>r(s.target.value),children:[S.jsx("option",{value:"",children:"请选择"}),o.map(s=>S.jsx("option",{value:s,children:s},s))]})}return e.type==="boolean"||e.widget==="checkbox"?S.jsxs("select",{value:t,onChange:o=>r(o.target.value),children:[S.jsx("option",{value:"",children:"请选择"}),S.jsx("option",{value:"true",children:"是"}),S.jsx("option",{value:"false",children:"否"})]}):Lf(e)?S.jsx("input",{type:"datetime-local",value:V0(t,"datetime"),onChange:o=>r(UZ(o.target.value))}):H0(e)?S.jsx("input",{type:"date",value:V0(t,"date"),onChange:o=>r(o.target.value)}):e.type==="int"||e.type==="bigint"||e.type==="decimal"||e.widget==="number"?S.jsx("input",{type:"number",step:e.type==="decimal"?"0.01":"1",value:t,onChange:o=>r(o.target.value)}):e.type==="text"||e.widget==="textarea"?S.jsx("textarea",{rows:3,value:t,onChange:o=>r(o.target.value)}):S.jsx("input",{type:"text",value:t,onChange:o=>r(o.target.value)})}function Y_(e,t){if(t==null||t==="")return"—";if(String(e).endsWith("_at")){const n=new Date(String(t));if(!Number.isNaN(n.getTime()))return n.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}return String(t)}function XZ(e){return/在售|正常|启用|合格/.test(e)?"ok":/停售|禁用|缺货|超限|异常|逾期/.test(e)?"bad":"warn"}function YZ({session:e,blueprint:t,onBack:n}){var M,O,k,B,j,z,A,D,L,H,K,V,W,q,ee,se,le,ce,G,ne,re,U,J,oe,Z,Q,ae,te,Y,de;const r=(M=t==null?void 0:t.meta)==null?void 0:M.slug,o=(t==null?void 0:t.pages)||[],s=o.find(ue=>ue.type==="list")||o[0],[i,l]=a.useState((s==null?void 0:s.id)||""),[c,u]=a.useState(null),[d,m]=a.useState(""),[f,p]=a.useState(""),[h,b]=a.useState(!1),x=a.useMemo(()=>{var ue,ge;if(i.startsWith("__edit__")){const we=i.replace("__edit__",""),he=o.find(be=>be.type==="list"&&be.entity===we),Be=IE(t,we);return{id:i,title:"编辑",route:`/${we}/edit`,type:"form_edit",entity:we,layout:{form_fields:((ge=(ue=he==null?void 0:he.layout)==null?void 0:ue.columns)==null?void 0:ge.filter(be=>be!=="id"))||Be.map(be=>be.name).filter(be=>be!=="id"),actions:["edit"]}}}return o.find(we=>we.id===i)||s},[i,o,s,t]),v=x?WZ(t,x.entity):"",g=a.useMemo(()=>x?IE(t,x.entity):[],[x,t]),y=a.useMemo(()=>Object.fromEntries(g.map(ue=>[ue.name,ue])),[g]),$=a.useMemo(()=>{const ue=/^(欢迎您|退出|帮助|登录|注册|返回|系统首页|修改密码)$/,ge=o.filter(he=>he.type!=="form_edit"&&he.type!=="detail"&&!ue.test(String(he.title||""))),we=he=>he.type==="list"?0:he.type==="form_create"?1:he.type==="dashboard"?2:3;return[...ge].sort((he,Be)=>we(he)-we(Be))},[o]),w=a.useMemo(()=>{var he,Be;const ue=Array.isArray((Be=(he=t==null?void 0:t.meta)==null?void 0:he.ui)==null?void 0:Be.nav_items)?t.meta.ui.nav_items:[];if(!ue.length)return[];const ge=$.find(be=>be.type==="dashboard"),we=be=>be.replace(/\/+$/,"").toLowerCase();return ue.map(be=>{const Fe=X_(be),_e=VZ(be);if(!Fe&&!_e)return null;let Ee=(_e?$.find(Te=>we(String(Te.route||""))===we(_e)):void 0)||$.find(Te=>Te.title===Fe||String(Te.title||"").includes(Fe)||Fe&&Fe.includes(String(Te.title||"")));return!Ee&&ge&&Fe&&(ge.title===Fe||String(ge.title||"").includes(Fe))&&(Ee=ge),{label:Fe||(Ee==null?void 0:Ee.title)||_e,pageId:Ee==null?void 0:Ee.id}}).filter(Boolean)},[(k=(O=t==null?void 0:t.meta)==null?void 0:O.ui)==null?void 0:k.nav_items,$]),I=a.useMemo(()=>{var ue,ge;return EE((ge=(ue=t==null?void 0:t.meta)==null?void 0:ue.ui)==null?void 0:ge.shell_links,["欢迎您","退出","帮助"])},[(j=(B=t==null?void 0:t.meta)==null?void 0:B.ui)==null?void 0:j.shell_links]),C=((A=(z=t==null?void 0:t.meta)==null?void 0:z.ui)==null?void 0:A.platform_subtitle)||((D=t==null?void 0:t.meta)==null?void 0:D.platform_subtitle)||"",N=a.useMemo(()=>{var ue,ge;return EE((ge=(ue=t==null?void 0:t.meta)==null?void 0:ue.ui)==null?void 0:ge.float_actions,["客服","电话","点击隐藏"])},[(H=(L=t==null?void 0:t.meta)==null?void 0:L.ui)==null?void 0:H.float_actions]),E=((K=t==null?void 0:t.meta)==null?void 0:K.ui_preset)||((W=(V=o.find(ue=>{var ge;return(ge=ue.layout)==null?void 0:ge.preset}))==null?void 0:V.layout)==null?void 0:W.preset)||"default",R=((q=t==null?void 0:t.meta)==null?void 0:q.project_context)||"",P=ue=>{var he,Be,be;if(!ue||ue.type!=="dashboard")return!1;if(((he=ue.layout)==null?void 0:he.preset)==="screenshot_faithful"||((Be=ue.layout)==null?void 0:Be.preset)==="ops_monitor")return!0;const ge=((be=ue.layout)==null?void 0:be.widgets)||[],we=new Set(ge.map(Fe=>Fe.type));return(we.has("line_chart")||we.has("bar_chart"))&&(we.has("status_strip")||we.has("table"))},T=E==="screenshot_faithful"||E==="ops_monitor"||!!((se=(ee=t==null?void 0:t.meta)==null?void 0:ee.source)!=null&&se.screenshot_faithful)||!!((G=(ce=(le=t==null?void 0:t.meta)==null?void 0:le.source)==null?void 0:ce.image_refs)!=null&&G.length)||!!((U=(re=(ne=t==null?void 0:t.meta)==null?void 0:ne.source)==null?void 0:re.layout_refs)!=null&&U.length)||P(o.find(ue=>ue.type==="dashboard")),_=((oe=(J=t==null?void 0:t.meta)==null?void 0:J.ui)==null?void 0:oe.platform_title)||((Z=t==null?void 0:t.meta)==null?void 0:Z.platform_title)||"";return a.useEffect(()=>{if(!T)return;const ue=o.find(ge=>ge.type==="dashboard");ue&&(!i||i===(s==null?void 0:s.id))&&(s==null?void 0:s.type)!=="dashboard"&&l(ue.id)},[T,(Q=t==null?void 0:t.meta)==null?void 0:Q.slug]),S.jsxs("div",{className:`gen-app ${T?"gen-app-ops":""}`,children:[T?S.jsxs("header",{className:"sf-shell-bar",children:[S.jsxs("div",{className:"sf-shell-left",children:[_||"业务管理平台",C?S.jsx("span",{className:"sf-shell-en",children:C}):null]}),S.jsx("div",{className:"sf-shell-center",children:((ae=t==null?void 0:t.meta)==null?void 0:ae.name)||r}),S.jsxs("div",{className:"sf-shell-right",children:[I.map(ue=>S.jsx("span",{className:"sf-shell-link",children:ue},ue)),S.jsx("button",{type:"button",className:"sf-shell-back",onClick:n,children:"返回控制台"})]})]}):S.jsxs("header",{className:"gen-header",children:[S.jsxs("div",{children:[S.jsx("p",{className:"gen-eyebrow",children:"业务模块"}),S.jsx("h1",{className:"gen-title",children:((te=t==null?void 0:t.meta)==null?void 0:te.name)||r}),S.jsx("p",{className:"gen-desc",children:((Y=t==null?void 0:t.meta)==null?void 0:Y.description)||"由蓝图自动生成的业务页面"})]}),S.jsx("button",{type:"button",className:"btn secondary",onClick:n,children:"返回控制台"})]}),S.jsxs("nav",{className:`gen-nav ${T?"gen-nav-ops":""}`,children:[(T&&w.length>0?w:$.map(ue=>({label:nd(ue),pageId:ue.id}))).map((ue,ge)=>{const we=ue.pageId?(x==null?void 0:x.id)===ue.pageId&&!c:!1;return S.jsx("button",{type:"button",className:`gen-nav-item ${we?"active":""} ${ue.pageId?"":"is-chrome"}`,onClick:()=>{ue.pageId&&(u(null),l(ue.pageId),m(""),p(""))},children:ue.label},`${ue.label}-${ge}`)}),T&&w.length>0?$.filter(ue=>ue.type==="list"||ue.type==="dashboard").filter(ue=>!w.some(ge=>ge.pageId===ue.id||ge.label===ue.title)).map(ue=>S.jsx("button",{type:"button",className:`gen-nav-item ${(x==null?void 0:x.id)===ue.id&&!c?"active":""}`,onClick:()=>{u(null),l(ue.id),m(""),p("")},children:nd(ue)},ue.id)):null]}),T&&R&&(x==null?void 0:x.type)!=="dashboard"&&S.jsx("div",{className:"sf-mini-context",children:R}),d&&S.jsx("p",{className:"flash err",children:d}),f&&S.jsx("p",{className:"flash ok",children:f}),x&&v&&S.jsx(AZ,{slug:r,resource:v,page:x,blueprint:t}),(x==null?void 0:x.type)==="list"&&!c&&S.jsx(QZ,{session:e,slug:r,resource:v,page:x,fieldMap:y,busy:h,setBusy:b,setError:m,setInfo:p,onCreate:()=>{const ue=o.find(ge=>ge.type==="form_create"&&ge.entity===x.entity);ue&&l(ue.id)},onEdit:ue=>{u(ue);const ge=o.find(we=>we.type==="form_edit"&&we.entity===x.entity);l(ge?ge.id:`__edit__${x.entity}`)}}),((x==null?void 0:x.type)==="form_create"||(x==null?void 0:x.type)==="form_edit")&&S.jsx(JZ,{session:e,slug:r,resource:v,page:x,title:nd(x),fields:g,editId:x.type==="form_edit"?c:null,busy:h,setBusy:b,setError:m,setInfo:p,onDone:()=>{u(null);const ue=o.find(ge=>ge.type==="list"&&ge.entity===x.entity);ue&&l(ue.id)}}),(x==null?void 0:x.type)==="dashboard"&&!c&&(T||P(x)?S.jsx(HZ,{session:e,slug:r,resource:v,title:nd(x),widgets:(((de=x.layout)==null?void 0:de.widgets)||[]).filter(ue=>ue.type!=="kpi"),fieldMap:y,meta:(t==null?void 0:t.meta)||{},setError:m}):S.jsx(ZZ,{session:e,slug:r,resource:v,page:x,fieldMap:y,setError:m})),T&&N.length>0?S.jsx("aside",{className:"sf-float-dock","aria-label":"快捷操作",children:N.map(ue=>S.jsx("button",{type:"button",tabIndex:-1,children:ue},ue))}):null]})}function QZ(e){var T,_,M,O,k,B,j;const{session:t,slug:n,resource:r,page:o,fieldMap:s,busy:i,setBusy:l,setError:c,setInfo:u,onCreate:d,onEdit:m}=e,f=(_=(T=o.layout)==null?void 0:T.columns)!=null&&_.length?o.layout.columns:Object.keys(s).filter(z=>!["id","tenant_id"].includes(z)).slice(0,8),p=a.useMemo(()=>{var z;return((z=o.layout)==null?void 0:z.filters)||[]},[(M=o.layout)==null?void 0:M.filters]),h=((O=o.layout)==null?void 0:O.actions)||["refresh"],b=((k=o.layout)==null?void 0:k.action_labels)||{},x=(z,A)=>b[z]||A,v=h.filter(z=>!["edit","delete"].includes(z)),[g,y]=a.useState({}),[$,w]=a.useState({}),[I,C]=a.useState([]),[N,E]=a.useState(0),R=a.useCallback(async()=>{var z;l(!0),c("");try{const A=await np(t,n,r,g);C(A.items||[]),E(A.total||0);const D={};for(const L of p){const H=s[L];if((z=H==null?void 0:H.enum_values)!=null&&z.length){D[L]=H.enum_values;continue}const K=new Set;for(const V of A.items||[]){const W=V[L];W!=null&&String(W).trim()!==""&&K.add(String(W))}D[L]=Array.from(K).sort()}w(L=>{let H=!1;const K={...L};for(const[V,W]of Object.entries(D)){const q=L[V]||[];(q.length!==W.length||q.some((ee,se)=>ee!==W[se]))&&(K[V]=W,H=!0)}return H?K:L})}catch(A){c(A.message||String(A))}finally{l(!1)}},[t,n,r,g,l,c,p,s]);a.useEffect(()=>{R()},[R]);async function P(z){if(confirm("确认删除该行?")){l(!0);try{await kY(t,n,r,z),u("已删除"),await R()}catch(A){c(A.message||String(A))}finally{l(!1)}}}return S.jsxs("section",{className:"panel gen-panel",children:[S.jsx(G_,{slug:n,resource:r,blockId:`list:${o.id}`,endpoint:{method:"GET",path:`/api/v1/apps/${n}/${r}`},extra:{page_type:"list",filters:p,columns:f}}),S.jsxs("div",{className:"gen-toolbar",children:[S.jsx("h2",{className:"section-title",style:{margin:0},children:o.title}),S.jsx("div",{className:"actions",style:{margin:0},children:v.map(z=>{if(z==="create")return S.jsx("button",{type:"button",className:"btn",disabled:i,onClick:d,children:x("create","新增")},z);if(z==="refresh")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:x("refresh","刷新")},z);if(z==="import")return S.jsxs("label",{className:"file-field btn secondary",style:{margin:0,padding:"8px 12px",cursor:"pointer"},children:[x("import","导入 Excel"),S.jsx("input",{type:"file",accept:".xlsx,.xlsm,.csv",hidden:!0,onChange:async D=>{var H,K;const L=(H=D.target.files)==null?void 0:H[0];if(L){l(!0);try{const V=await FY(t,n,r,L),W=V.inserted||0,q=V.skipped||0,ee=(V.errors||[]).length;u(`导入完成:成功 ${W} 行`+(q?`,跳过 ${q}`:"")+(ee?`,错误 ${ee} 条(仅展示部分)`:"")),ee&&((K=V.errors)!=null&&K[0])&&c(String(V.errors[0])),await R()}catch(V){c(V.message||String(V))}finally{l(!1),D.target.value=""}}}})]},z);if(z==="export")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:async()=>{l(!0);try{await HY(t,n,r,"xlsx"),u("已导出 Excel")}catch(D){c(D.message||String(D))}finally{l(!1)}},children:x("export","导出 Excel")},z);if(z==="search")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:x("search","查询")},z);const A=x(z,z.replace(/^custom_/,""));return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>u(`按键「${A}」已按说明展示(业务逻辑可后续绑定)`),children:A},z)})})]}),p.length>0&&(((B=o.layout)==null?void 0:B.filter_style)==="section_radios"||((j=o.layout)==null?void 0:j.filter_style)==="radios")?S.jsx("div",{className:"ops-section-radios",children:(()=>{const z=p.find(L=>{var H;return(((H=s[L])==null?void 0:H.enum_values)||[]).length>0})||p[0],A=s[z]||{label:z},D=$[z]||A.enum_values||[];return S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"ops-radio-label",children:A.label||"类型"}),["",...D].map(L=>S.jsx("button",{type:"button",className:`ops-radio ${(g[z]||"")===L?"active":""}`,onClick:()=>{y(H=>({...H,[z]:L})),setTimeout(()=>void R(),0)},children:L||"全部"},L||"all")),p.filter(L=>L!==z).map(L=>{const H=s[L]||{label:L};return S.jsxs("label",{className:"ops-extra-filter",children:[H.label||L,S.jsx("input",{value:g[L]||"",placeholder:"筛选…",onChange:K=>y(V=>({...V,[L]:K.target.value}))})]},L)}),S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:"应用筛选"})]})})()}):p.length>0?S.jsxs("div",{className:"row compact gen-filters",children:[p.map(z=>{const A=s[z]||{name:z,label:z,type:"string"},D=$[z]||A.enum_values||[],L=Bf(A)||D.length>0;return S.jsxs("label",{children:[A.label||z,L?S.jsxs("select",{value:g[z]||"",onChange:H=>y(K=>({...K,[z]:H.target.value})),children:[S.jsx("option",{value:"",children:"全部"}),D.map(H=>S.jsx("option",{value:H,children:H},H))]}):S.jsx("input",{value:g[z]||"",placeholder:"筛选…",onChange:H=>y(K=>({...K,[z]:H.target.value}))})]},z)}),S.jsx("div",{className:"actions",style:{marginTop:0},children:S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:"应用筛选"})})]}):null,S.jsxs("p",{className:"pages-line",children:["共 ",N," 条"]}),I.length===0?S.jsx("div",{className:"empty",children:"暂无数据,可点「新增」或导入 Excel"}):S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{children:[S.jsx("thead",{children:S.jsxs("tr",{children:[f.map(z=>{var A;return S.jsx("th",{children:((A=s[z])==null?void 0:A.label)||z},z)}),(h.includes("edit")||h.includes("delete"))&&S.jsx("th",{children:"操作"})]})}),S.jsx("tbody",{children:I.map((z,A)=>S.jsxs("tr",{children:[f.map(D=>{const L=Y_(D,z[D]);return D==="status"?S.jsx("td",{className:"cell-status",children:S.jsx("span",{className:`badge ${XZ(L)}`,children:L})},D):S.jsx("td",{className:D.endsWith("_at")?"cell-muted":void 0,children:L},D)}),(h.includes("edit")||h.includes("delete"))&&S.jsx("td",{children:S.jsxs("div",{className:"actions",style:{margin:0,gap:6},children:[h.includes("edit")&&S.jsx("button",{type:"button",className:"btn secondary",style:{padding:"6px 10px"},onClick:()=>m(String(z.id)),children:x("edit","编辑")}),h.includes("delete")&&S.jsx("button",{type:"button",className:"btn secondary",style:{padding:"6px 10px"},onClick:()=>void P(String(z.id)),children:x("delete","删除")})]})})]},String(z.id??A)))})]})})]})}function JZ(e){var w,I;const{session:t,slug:n,resource:r,page:o,title:s,fields:i,editId:l,busy:c,setBusy:u,setError:d,setInfo:m,onDone:f}=e,p=(((w=o.layout)==null?void 0:w.form_fields)||i.map(C=>C.name)).filter(C=>!KZ.has(C)),h=((I=o.layout)==null?void 0:I.action_labels)||{},b=(C,N)=>h[C]||N,[x,v]=a.useState({}),[g,y]=a.useState({});a.useEffect(()=>{const C={};for(const N of p)C[N]="";v(C),(async()=>{var E,R;const N={};for(const P of p){const T=i.find(_=>_.name===P);T&&(E=T.enum_values)!=null&&E.length&&(N[P]=T.enum_values)}try{const T=(await np(t,n,r)).items||[];for(const _ of p){const M=i.find(k=>k.name===_);if(!M||!Bf(M)||(R=N[_])!=null&&R.length)continue;const O=new Set;for(const k of T){const B=k[_];B!=null&&String(B).trim()!==""&&O.add(String(B))}O.size>0&&O.size<=50&&(N[_]=Array.from(O).sort())}if(l){const _=T.find(M=>String(M.id)===l);if(_){const M={};for(const O of p){const k=i.find(j=>j.name===O),B=_[O]==null?"":String(_[O]);k&&Lf(k)?M[O]=B:k&&H0(k)?M[O]=V0(B,"date"):M[O]=B}v(M)}}}catch(P){l&&d(P.message||String(P))}y(N)})()},[l,n,r]);async function $(){u(!0),d("");try{const C={};for(const N of p){const E=i.find(P=>P.name===N),R=x[N];if((E==null?void 0:E.type)==="int"||(E==null?void 0:E.type)==="bigint"||(E==null?void 0:E.type)==="decimal"?C[N]=R===""?null:Number(R):(E==null?void 0:E.type)==="boolean"?C[N]=R==="true":E&&Lf(E)||E&&H0(E)?C[N]=R===""?null:R:C[N]=R,Bf(E||{name:N,label:N,type:"string"})&&!R)throw new Error(`请选择「${(E==null?void 0:E.label)||N}」`)}l?(await LY(t,n,r,l,C),m("已更新")):(await BY(t,n,r,C),m("已创建")),f()}catch(C){d(qZ(C.message||String(C)))}finally{u(!1)}}return S.jsxs("section",{className:"panel gen-panel",style:{maxWidth:560},children:[S.jsx("h2",{className:"section-title",children:s}),S.jsx("div",{className:"row",children:p.map(C=>{const N=i.find(R=>R.name===C)||{name:C,label:C,type:"string"},E=g[C]||N.enum_values||[];return S.jsxs("label",{children:[N.label||C,S.jsx(GZ,{meta:N,value:x[C]||"",options:E,onChange:R=>v(P=>({...P,[C]:R}))})]},C)})}),S.jsxs("div",{className:"actions",children:[S.jsx("button",{type:"button",className:"btn",disabled:c,onClick:()=>void $(),children:l?b("save","保存"):b("create","创建")}),S.jsx("button",{type:"button",className:"btn secondary",disabled:c,onClick:f,children:b("cancel","取消")})]})]})}function ZZ(e){var g,y,$,w,I,C,N,E,R,P;const{session:t,slug:n,resource:r,page:o,fieldMap:s={},setError:i}=e,l=((g=o.layout)==null?void 0:g.widgets)||[],[c,u]=a.useState(null),[d,m]=a.useState([]),f=((y=l.find(T=>T.type==="bar_chart"||T.type==="pie_chart"))==null?void 0:y.group_by)||(($=l.find(T=>T.group_by))==null?void 0:$.group_by)||"",p=((w=l.find(T=>T.metric&&T.metric!=="count"))==null?void 0:w.metric)||((C=(I=l.find(T=>{var _;return(_=T.metrics)==null?void 0:_.length}))==null?void 0:I.metrics)==null?void 0:C[0])||"",h=a.useMemo(()=>JSON.stringify(l),[(N=o.layout)==null?void 0:N.widgets]);if(a.useEffect(()=>{(async()=>{try{if(f){const _=await AY(t,n,r,f,p||void 0);u(_)}if(l.some(_=>["line_chart","table","status_strip"].includes(_.type))||!f){const _=await np(t,n,r);m(_.items||[]),f||u({total:_.total||(_.items||[]).length})}}catch(T){i(T.message||String(T))}})()},[t,n,r,f,p,i,h]),!c)return S.jsx("div",{className:"panel gen-panel",children:S.jsx("div",{className:"empty",children:"加载看板…"})});function b(T){var _;return((_=s[T])==null?void 0:_.label)||T}function x(T){const _=T.x_field||T.group_by||"",M=(T.metrics&&T.metrics.length?T.metrics:T.metric&&T.metric!=="count"?[T.metric]:[]).filter(Boolean);if(!_||!M.length||!d.length)return null;const k=[...d].sort((j,z)=>String(j[_]??"").localeCompare(String(z[_]??""),"zh")).slice(0,100).map(j=>{const z={};for(const A of M){const D=Number(j[A]);Number.isFinite(D)&&(z[A]=D)}return{x:String(j[_]??""),values:z}}),B=M.map(j=>({key:j,label:b(j)}));return S.jsx(W_,{title:T.title||"趋势图",points:k,series:B,yUnit:T.y_unit||""},`line-${T.title}-${_}`)}function v(T,_){if(!_.filter_field)return!0;const M=T[_.filter_field],O=Number(M),k=_.filter_op||"gt",B=Number(_.filter_value??0);return k==="gt"?Number.isFinite(O)&&O>B:k==="gte"?Number.isFinite(O)&&O>=B:k==="lt"?Number.isFinite(O)&&OT.type==="kpi").length?l.filter(T=>T.type==="kpi"):[{type:"kpi",title:"记录数",metric:"count"}]).map((T,_)=>S.jsx(_Z,{title:T.title||"KPI",value:T.metric==="count"||!T.metric?c.total:Number(c.sum||0).toFixed(2)},`${T.title}-${_}`))}),l.filter(T=>T.type==="line_chart").map(T=>x(T)),l.filter(T=>T.type==="status_strip").map((T,_)=>{const M=T.label_field||"",O=T.value_field||"",k=T.secondary_field||"",B=T.warn_field||"",j=Number(T.cycle_days)||30,z=T.variant==="stacked"||T.variant==="stacked_days"||!!k;if(!M||!O)return null;const A=d.slice(0,48).map(D=>{let L=Number(D[O]??0),H=k?Number(D[k]??0):0;if(z&&L+H>50&&L+H<120){const K=Math.round(L/100*j);H=Math.max(0,j-K),L=K}return{label:String(D[M]??""),value:L,secondary:z?H:void 0,tone:B&&Number(D[B]??0)>0?"warn":"ok",stop:String(D.status||"").includes("停")||z&&L===0&&H===0}});return S.jsx(K_,{title:T.title||"状态条",variant:z?"stacked":"cells",items:A},`strip-${_}`)}),l.filter(T=>T.type==="table").map((T,_)=>{var k;const M=(k=T.columns)!=null&&k.length?T.columns:Object.keys(d[0]||{}).slice(0,6),O=d.filter(B=>v(B,T)).slice(0,50);return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:T.title||"明细表"}),S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{children:[S.jsx("thead",{children:S.jsx("tr",{children:M.map(B=>S.jsx("th",{children:b(B)},B))})}),S.jsxs("tbody",{children:[O.map((B,j)=>S.jsx("tr",{children:M.map(z=>S.jsx("td",{children:Y_(z,B[z])},z))},j)),!O.length&&S.jsx("tr",{children:S.jsx("td",{colSpan:M.length,className:"empty",children:"暂无数据"})})]})]})})]},`tbl-${_}`)}),S.jsxs("div",{className:"chart-grid",children:[l.filter(T=>T.type==="bar_chart").map((T,_)=>S.jsx(wE,{title:T.title||"分布",buckets:c.buckets||[]},`bar-${_}`)),l.filter(T=>T.type==="pie_chart").map((T,_)=>S.jsx(MZ,{title:T.title||"占比",buckets:c.buckets||[]},`pie-${_}`)),!l.some(T=>T.type==="bar_chart"||T.type==="pie_chart")&&(((P=c.buckets)==null?void 0:P.length)||0)>0&&S.jsx(wE,{title:"分布",buckets:c.buckets||[]})]})]})}async function jg(e){const t=`${Dc}/api/v1/demo/file/${e.split("/").map(encodeURIComponent).join("/")}`,n=await fetch(t);if(!n.ok)return null;const r=await n.blob(),o=e.split("/").pop()||"file";return{blob:r,name:o}}function Bg(e,t,n){return new File([e],t,{type:n||e.type||"application/octet-stream"})}async function eee(){var d,m,f,p,h,b;const e=[],t=await fetch(`${Dc}/api/v1/demo/fixtures`);if(!t.ok)throw new Error(`无法读取测试素材清单 HTTP ${t.status}`);const n=await t.json();if(!n.available)throw new Error(`测试目录不可用:${n.root||"test/"}`);const o=await(await fetch(`${Dc}/api/v1/demo/prompt`)).json(),s=String(o.prompt||"");s||e.push(n.prompt||"prompt");const i=n.data||((m=(d=n.files)==null?void 0:d.data)==null?void 0:m.path);let l=null;if(i){const x=await jg(i);x?l=Bg(x.blob,x.name,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"):e.push(i)}const c=[];for(const x of n.images||((p=(f=n.files)==null?void 0:f.images)==null?void 0:p.map(v=>v.path))||[]){const v=await jg(x);v?c.push(Bg(v.blob,v.name,"image/png")):e.push(x)}const u=[];for(const x of n.layouts||((b=(h=n.files)==null?void 0:h.layouts)==null?void 0:b.map(v=>v.path))||[]){const v=await jg(x);v?u.push(Bg(v.blob,v.name,"text/html")):e.push(x)}return{prompt:s,slug:n.slug||"settlement_observation_system",excel:l,images:c,layouts:u,label:n.label||"演示包",missing:e}}const{Header:tee,Sider:nee,Content:ree}=Fs,oee={platform:"平台管理",generate:"生成与发布",modules:"模块管理",sync:"数据同步",agent:"智能体胶囊",roles:"角色管理",agents:"智能体账号",orgs:"组织管理",invites:"邀请加入",members:"成员管理",audit:"审计"};function see({session:e,entitlements:t,tab:n,onTabChange:r,onOpenApp:o,onLogout:s,onSession:i,busy:l,banner:c,children:u}){const[d,m]=a.useState(!1),[f,p]=a.useState(!1),[h,b]=a.useState(!1),[x,v]=a.useState(!1),[g,y]=a.useState(!1),[$,w]=a.useState(!1),[I]=De.useForm(),[C]=De.useForm(),{token:N}=gX.useToken(),{message:E}=wo.useApp(),R=a.useMemo(()=>{const P=[],T=Nr(e.role),_=(e.tenantId||0)>0;if(T&&!_)return P.push({key:"platform",icon:S.jsx(vE,{}),label:"平台管理"}),P;if(!_)return P;T&&P.push({key:"platform",icon:S.jsx(vE,{}),label:"平台管理"});const M=k=>EY(t,k),O=jl(e.role)||T;return(M("发布模块")||M("写入模块")||M("读取模块"))&&P.push({key:"generate",icon:S.jsx(cZ,{}),label:"生成与发布"}),M("读取模块")&&P.push({key:"modules",icon:S.jsx(UQ,{}),label:"模块管理"}),O&&M("数据同步")&&P.push({key:"sync",icon:S.jsx(aJ,{}),label:"数据同步"}),M("读取模块")&&P.push({key:"agent",icon:S.jsx(b_,{}),label:"智能体胶囊"}),M("管理智能体")&&(P.push({key:"roles",icon:S.jsx(jf,{}),label:"角色管理"}),P.push({key:"agents",icon:S.jsx(WJ,{}),label:"智能体账号"})),O&&M("管理组织")&&P.push({key:"orgs",icon:S.jsx(AQ,{}),label:"组织管理"}),O&&M("邀请成员")&&(P.push({key:"invites",icon:S.jsx(mZ,{}),label:"邀请加入"}),P.push({key:"members",icon:S.jsx(sZ,{}),label:"成员管理"})),M("查看审计")&&P.push({key:"audit",icon:S.jsx(eJ,{}),label:"审计"}),P},[e,t]);return S.jsxs(Fs,{className:"console-root",style:{minHeight:"100vh"},children:[S.jsxs(nee,{collapsible:!0,collapsed:d,trigger:null,width:232,className:"console-sider",theme:"light",children:[S.jsxs("div",{className:`console-brand ${d?"is-collapsed":""}`,children:[S.jsx("span",{className:"console-brand-mark",children:"宇"}),!d&&S.jsxs("div",{className:"console-brand-text",children:[S.jsx("strong",{children:"宇信达智建"}),S.jsx("span",{children:Nr(e.role)?"平台超管工作台":"AI 建站控制台"})]})]}),S.jsx(Fi,{mode:"inline",selectedKeys:[n],items:R,onClick:({key:P})=>r(P),style:{borderInlineEnd:0,padding:"8px 8px 24px"}})]}),S.jsxs(Fs,{children:[S.jsxs(tee,{className:"console-header",style:{background:N.colorBgContainer},children:[S.jsxs(Mt,{size:"middle",children:[S.jsx(Ke,{type:"text",icon:d?S.jsx(RJ,{}):S.jsx(EJ,{}),onClick:()=>m(P=>!P)}),S.jsx(Oe.Title,{level:4,style:{margin:0},children:oee[n]||"控制台"})]}),S.jsxs(Mt,{size:"middle",wrap:!0,children:[S.jsxs(Mt,{size:8,children:[S.jsx($T,{size:"small",icon:S.jsx(yZ,{}),style:{background:N.colorPrimary}}),S.jsx("span",{className:"console-user",children:e.displayName||e.username}),e.username?S.jsx(Oe.Text,{type:"secondary",code:!0,style:{fontSize:12},children:e.username}):null,e.phone?S.jsx(Dt,{icon:S.jsx(bE,{}),children:e.phone}):S.jsx(Dt,{children:"未绑手机"}),S.jsx(Dt,{color:"green",children:rc(e.role||"管理员")}),Nr(e.role)&&e.tenantId>0?S.jsxs(S.Fragment,{children:[S.jsxs(Dt,{color:"orange",children:["管理:",e.tenantName||`公司 #${e.tenantId}`]}),S.jsx(Ke,{size:"small",icon:S.jsx(YQ,{}),loading:$,onClick:async()=>{w(!0);try{const P=await g_(e);y0(P),i==null||i(P),r("platform"),E.success("已回到平台工作台")}catch(P){E.error(P.message||String(P))}finally{w(!1)}},children:"返回平台工作台"})]}):e.tenantId>0?S.jsxs(Dt,{children:["公司 #",e.tenantId]}):null]}),S.jsx(Ke,{icon:S.jsx(bE,{}),onClick:()=>{C.setFieldsValue({phone:e.phone||""}),v(!0)},children:e.phone?"更换手机":"绑定手机"}),S.jsx(Ke,{icon:S.jsx(jf,{}),onClick:()=>{I.resetFields(),p(!0)},children:"修改密码"}),S.jsx(Ke,{onClick:o,disabled:l,children:"打开模块"}),S.jsx(Ke,{icon:S.jsx(R_,{}),onClick:s,children:"退出"})]})]}),S.jsxs(ree,{className:"console-content",children:[c,S.jsx("div",{className:"console-panel",children:u})]})]}),S.jsx(tn,{title:"修改密码",open:f,onCancel:()=>p(!1),confirmLoading:h,onOk:async()=>{const P=await I.validateFields();b(!0);try{await OQ(e,P.old_password,P.new_password),E.success("密码已更新"),p(!1),I.resetFields()}catch(T){E.error(T.message||String(T))}finally{b(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:I,layout:"vertical",children:[S.jsxs(Oe.Paragraph,{type:"secondary",children:["账号 ",S.jsx(Oe.Text,{code:!0,children:e.username})," 为系统分配、不可更改;仅可修改密码。 绑定手机后也可用手机号 + 密码登录。"]}),S.jsx(De.Item,{name:"old_password",label:"当前密码",rules:[{required:!0,message:"请输入当前密码"}],children:S.jsx(Pt.Password,{autoComplete:"current-password"})}),S.jsx(De.Item,{name:"new_password",label:"新密码",rules:[{required:!0,message:"请输入新密码"},{min:6,message:"至少 6 位"}],children:S.jsx(Pt.Password,{autoComplete:"new-password"})}),S.jsx(De.Item,{name:"confirm",label:"确认新密码",dependencies:["new_password"],rules:[{required:!0,message:"请再次输入"},({getFieldValue:P})=>({validator(T,_){return!_||P("new_password")===_?Promise.resolve():Promise.reject(new Error("两次输入不一致"))}})],children:S.jsx(Pt.Password,{autoComplete:"new-password"})})]})}),S.jsx(tn,{title:e.phone?"更换手机号":"绑定手机号",open:x,onCancel:()=>v(!1),confirmLoading:g,onOk:async()=>{const P=await C.validateFields();y(!0);try{const T=(P.phone||"").trim(),_=await zQ(e,T),M={...e,phone:_.phone||void 0,usernameLoginDisabled:!!_.username_login_disabled};y0(M),i==null||i(M),E.success(_.phone?`已绑定 ${_.phone}`:"已更新"),v(!1)}catch(T){E.error(T.message||String(T))}finally{y(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:C,layout:"vertical",children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"绑定后可用手机号+密码或短信登录。有 License 期限控制时也可用用户名登录。"}),S.jsx(De.Item,{name:"phone",label:"手机号",rules:[{validator:async(P,T)=>{const _=String(T||"").trim();if(_&&!/^1[3-9]\d{9}$/.test(_)&&!/^\+?86\s*1[3-9]\d{9}$/.test(_.replace(/\s/g,"")))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",maxLength:20,allowClear:!0})})]})})]})}function $$({children:e,subtitle:t}){return S.jsxs("div",{className:"auth-shell",children:[S.jsx("div",{className:"auth-backdrop","aria-hidden":!0}),S.jsxs(rr,{className:"auth-card",bordered:!1,children:[S.jsx(Oe.Title,{level:2,className:"auth-brand",children:"宇信达智建"}),S.jsx(Oe.Paragraph,{type:"secondary",style:{marginTop:-8},children:t}),e]})]})}function ro(e,t){var r;const n=(r=e.current)==null?void 0:r.input;return n&&typeof n.value=="string"?n.value:t}function iee(e){const[t,n]=a.useState("account_password"),[r,o]=a.useState(""),[s,i]=a.useState(""),[l,c]=a.useState(0),[u,d]=a.useState(!1),m=a.useRef(null),f=a.useRef(null),p=a.useRef(null),h=a.useRef(null),b=a.useRef(null);a.useEffect(()=>{if(l<=0)return;const y=window.setTimeout(()=>c($=>$-1),1e3);return()=>window.clearTimeout(y)},[l]);const x=()=>{if(t==="phone_sms"){const w=ro(h,e.username).trim(),I=ro(b,r).trim();e.onUsername(w),e.onLogin({mode:t,phone:w,sms_code:I});return}if(t==="phone_password"){const w=ro(h,e.username).trim(),I=ro(f,e.password);e.onUsername(w),e.onPassword(I),e.onLogin({mode:t,phone:w,password:I});return}const y=ro(m,e.username).trim(),$=ro(f,e.password);e.onUsername(y),e.onPassword($),e.onLogin({mode:t,username:y,password:$})},v=()=>{const y=ro(m,e.username).trim()||ro(h,e.username).trim(),$=ro(f,e.password),w=ro(p,e.displayName).trim();e.onUsername(y),e.onPassword($),e.onDisplayName(w),e.onRegister(y,$,w)};async function g(){const y=ro(h,e.username).trim();if(!/^1[3-9]\d{9}$/.test(y)){i("请先填写正确的 11 位手机号");return}d(!0),i("");try{const $=await RY(y);c($.retry_after&&$.retry_after>0?$.retry_after:60),$.debug_code?(o($.debug_code),i(`开发模式验证码:${$.debug_code}(正式环境将发短信)`)):i($.message||"验证码已发送")}catch($){i($.message||String($))}finally{d(!1)}}return S.jsxs($$,{subtitle:"描述 + Excel/CSV/JSON → 自动建库建 API → 生成可操作的前端页面",children:[S.jsx(hV,{block:!0,style:{marginBottom:16},value:t,onChange:y=>n(y),options:[{label:"账号密码",value:"account_password"},{label:"手机密码",value:"phone_password"},{label:"短信登录",value:"phone_sms"}]}),S.jsxs(De,{layout:"vertical",requiredMark:!1,onFinish:x,children:[t==="account_password"?S.jsx(De.Item,{label:"用户名",children:S.jsx(Pt,{ref:m,size:"large",value:e.username,onChange:y=>e.onUsername(y.target.value),autoComplete:"username",placeholder:"系统分配的用户名",allowClear:!0})}):S.jsx(De.Item,{label:"手机号",children:S.jsx(Pt,{ref:h,size:"large",value:e.username,onChange:y=>e.onUsername(y.target.value),autoComplete:"tel",placeholder:"已绑定的 11 位手机号",allowClear:!0})}),t==="phone_sms"?S.jsx(De.Item,{label:"短信验证码",children:S.jsxs(Mt.Compact,{style:{width:"100%"},children:[S.jsx(Pt,{ref:b,size:"large",value:r,onChange:y=>o(y.target.value),placeholder:"6 位验证码",maxLength:8}),S.jsx(Ke,{size:"large",loading:u,disabled:l>0||e.busy,onClick:()=>void g(),children:l>0?`${l}s`:"获取验证码"})]})}):S.jsx(De.Item,{label:"密码",children:S.jsx(Pt.Password,{ref:f,size:"large",value:e.password,onChange:y=>e.onPassword(y.target.value),autoComplete:"current-password"})}),t==="account_password"?S.jsx(De.Item,{label:"显示名(仅注册用,登录可忽略)",children:S.jsx(Pt,{ref:p,size:"large",value:e.displayName,onChange:y=>e.onDisplayName(y.target.value)})}):null,e.error?S.jsx(po,{type:"error",showIcon:!0,message:e.error,style:{marginBottom:16}}):null,s?S.jsx(po,{type:"info",showIcon:!0,message:s,style:{marginBottom:16}}):null,e.info&&!e.info.startsWith("已填入测试默认")?S.jsx(po,{type:"success",showIcon:!0,message:e.info,style:{marginBottom:16}}):null,t==="account_password"?S.jsxs(Mt,{wrap:!0,style:{marginBottom:12},children:[S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("demo"),e.onPassword("demo123"),e.onDisplayName("演示用户")},children:"填入 demo"}),S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("ljk_admin"),e.onPassword("ljk_admin"),e.onDisplayName("平台超级管理员")},children:"填入 ljk_admin"})]}):S.jsxs(Mt,{wrap:!0,style:{marginBottom:12},children:[S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("13800000001"),e.onPassword("demo123")},children:"填入 demo 手机"}),S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("13531041945"),e.onPassword("ljk_admin")},children:"填入超管手机"})]}),S.jsxs("div",{className:"auth-actions",children:[S.jsx(Ke,{type:"primary",htmlType:"submit",size:"large",block:!0,loading:e.busy,children:"登录"}),t==="account_password"?S.jsx(Ke,{htmlType:"button",size:"large",block:!0,disabled:e.busy,onClick:v,children:"注册"}):null]}),S.jsx(Oe.Paragraph,{type:"secondary",style:{marginTop:20,marginBottom:0,fontSize:13},children:"支持用户名+密码、手机号+密码、手机号+短信。外公司部署用 License 控期限时,不必强制手机登录。"})]})]})}function aee(e){return S.jsxs($$,{subtitle:"账号已注册,但尚未加入任何公司。未入驻前不能查看未公布数据与业务页面。",children:[S.jsxs(Oe.Text,{type:"secondary",children:[e.displayLabel," · pending"]}),e.error&&S.jsx(po,{type:"error",showIcon:!0,message:e.error,style:{margin:"16px 0"}}),e.info&&S.jsx(po,{type:"success",showIcon:!0,message:e.info,style:{margin:"16px 0"}}),S.jsxs(De,{layout:"vertical",style:{marginTop:16},requiredMark:!1,children:[S.jsx(De.Item,{label:"邀请码",children:S.jsx(Pt,{size:"large",value:e.inviteCode,onChange:t=>e.onInviteCode(t.target.value),placeholder:"粘贴公司管理员发来的邀请码"})}),S.jsx(Ke,{type:"primary",size:"large",block:!0,loading:e.busy,disabled:!e.inviteCode.trim(),onClick:e.onAcceptInvite,children:"加入已有公司"}),S.jsx(rV,{children:"或"}),S.jsx(De.Item,{label:"公司名称",children:S.jsx(Pt,{size:"large",value:e.companyName,onChange:t=>e.onCompanyName(t.target.value),placeholder:"创建自己的公司(成为管理员)"})}),S.jsxs(Mt,{direction:"vertical",style:{width:"100%"},children:[S.jsx(Ke,{size:"large",block:!0,loading:e.busy,onClick:e.onCreateCompany,children:"创建公司"}),S.jsx(Ke,{size:"large",block:!0,onClick:e.onLogout,children:"退出"})]})]})]})}function lee(e){return S.jsx($$,{subtitle:e.message,children:e.error?S.jsx(po,{type:"error",showIcon:!0,message:e.error}):null})}function Lg(){const t=(window.location.hash||"").replace(/^#/,"").match(/^\/?app\/([a-zA-Z][a-zA-Z0-9_]{0,63})\/?$/);return t?t[1]:null}function cee(e){const t=`#/app/${encodeURIComponent(e)}`;window.location.hash===t?window.dispatchEvent(new Event("hashchange")):window.location.hash=t}function rd(){!window.location.hash||window.location.hash==="#/"||window.location.hash==="#"||(window.location.hash="#/")}function ia(e,t){if(e)try{const n=new DataTransfer;for(const r of t)n.items.add(r);e.files=n.files}catch{}}function uee(){var ke,je,We;const[e,t]=a.useState("generate"),[n,r]=a.useState("console"),[o,s]=a.useState(null),[i,l]=a.useState(""),[c,u]=a.useState(""),[d,m]=a.useState("demo"),[f,p]=a.useState("demo123"),[h,b]=a.useState("演示用户"),[x,v]=a.useState(""),[g,y]=a.useState(""),[$,w]=a.useState(""),[I,C]=a.useState(null),[N,E]=a.useState([]),[R,P]=a.useState([]),T=a.useRef(null),_=a.useRef(null),M=a.useRef(null),O=a.useRef(0),[k,B]=a.useState("schema_per_app"),[j,z]=a.useState("deepseek"),[A,D]=a.useState("deepseek-chat"),[L,H]=a.useState([]),[K,V]=a.useState(null),[W,q]=a.useState([]),[ee,se]=a.useState(null),[le,ce]=a.useState(null),[G,ne]=a.useState("myapp"),[re,U]=a.useState("__new__"),[J,oe]=a.useState([]),[Z,Q]=a.useState(null),[ae,te]=a.useState("records"),[Y,de]=a.useState(""),[ue,ge]=a.useState(!0),[we,he]=a.useState(!1),[Be,be]=a.useState(!1),[Fe,_e]=a.useState([]),[Ee,Te]=a.useState(null),[$e,Ce]=a.useState(!1),[qe,Qe]=a.useState("");async function ye(fe=!1){if(!zg()&&!o){fe||l("请先登录后再填入测试默认");return}he(!0),fe||l("");try{const ze=await eee();w(ze.prompt),C(ze.excel),E(ze.images),P(ze.layouts),ne(ze.slug),Ce(!0),ia(T.current,ze.excel?[ze.excel]:[]),ia(_.current,ze.images),ia(M.current,ze.layouts);const lt=[ze.excel?ze.excel.name:null,ze.images.length?`${ze.images.length} 张截图`:null,ze.layouts.length?`${ze.layouts.length} 个 HTML`:null].filter(Boolean);Qe(lt.join(" · ")||"仅需求文本");const Ze=ze.missing.length?`(缺:${ze.missing.join(", ")})`:"";u(`已填入测试默认:${ze.label}${Ze}`)}catch(ze){fe||l(ze.message||String(ze))}finally{he(!1)}}a.useEffect(()=>{const fe=zg();fe&&s(fe);const ze=()=>{s(null),!(td()||Lg())&&(l("登录已失效,请重新登录"),rd(),r("console"),Q(null))};return window.addEventListener("ajz:session-expired",ze),_Y().then(lt=>{var gt,kt,rt;H(lt.providers||[]);const Ze=lt.default||"deepseek",wt=(lt.providers||[]).find(Ge=>Ge.id===Ze)||((gt=lt.providers)==null?void 0:gt[0]);wt&&(z(wt.id),D(wt.default_model||((rt=(kt=wt.models)==null?void 0:kt[0])==null?void 0:rt.id)||""))}).catch(()=>{}),()=>window.removeEventListener("ajz:session-expired",ze)},[]),a.useEffect(()=>{!(o!=null&&o.accessToken)||Og(o)||Nr(o.role)&&!(o.tenantId>0)||localStorage.getItem("ajz_skip_demo_autoload")==="1"||$e||ye(!0).catch(()=>{})},[o==null?void 0:o.accessToken,o==null?void 0:o.tenantId]),a.useEffect(()=>{if(!(o!=null&&o.accessToken)||Og(o)){oe([]),Te(null);return}if(Nr(o.role)&&!(o.tenantId>0)){t("platform"),oe([]),Te(null);return}oc(o).then(fe=>oe(fe.items||[])).catch(()=>oe([])),o.tenantId>0?h_(o).then(fe=>Te(fe.permissions||[])).catch(()=>Te(Nr(o.role)?null:[])):Te(null)},[o]),a.useEffect(()=>{let fe=!1;async function ze(){var kt,rt,Ge,He,Ae,dt,vt,ct;const lt=++O.current,Ze=()=>fe||lt!==O.current,wt=td();if(wt){Ze()||(he(!0),l(""),Q(null));try{const yt=await SY(wt);if(Ze())return;Q(yt.blueprint),V(yt.blueprint),ne(((rt=(kt=yt.blueprint)==null?void 0:kt.meta)==null?void 0:rt.slug)||"preview"),te(yt.resource||"records"),r("app")}catch(yt){Ze()||(Mg(),l(yt.message||String(yt)),r("console"),Q(null),rd())}finally{Ze()||he(!1)}return}Mg();const gt=Lg();if(!gt){Ze()||(r("console"),Q(null));return}Ze()||(he(!0),l(""),ne(gt),Q(null));try{const yt=o||zg(),St=await pE(yt,gt);if(Ze())return;if(String(((Ge=St==null?void 0:St.meta)==null?void 0:Ge.slug)||"")!==gt)throw new Error(`模块路由不匹配:请求 ${gt},返回 ${String(((He=St==null?void 0:St.meta)==null?void 0:He.slug)||"空")}`);Q(St),V(St);const Tt=((ct=(vt=(dt=(Ae=St==null?void 0:St.apis)==null?void 0:Ae.resources)==null?void 0:dt[0])==null?void 0:vt.path)==null?void 0:ct.replace(/^\//,""))||ae;te(Tt),r("app")}catch(yt){Ze()||(l(yt.message||String(yt)),r("console"),Q(null),rd())}finally{Ze()||he(!1)}}return ze(),window.addEventListener("hashchange",ze),()=>{fe=!0,O.current++,window.removeEventListener("hashchange",ze)}},[o]),a.useEffect(()=>{!$e&&!I&&!N.length&&!R.length||(ia(T.current,I?[I]:[]),ia(_.current,N),ia(M.current,R))},[$e,I,N,R,e,o,n]);function Ne(fe){s(fe),y0(fe)}async function Re(fe){be(!0),l(""),u("");try{const ze=fe.mode==="phone_sms"?{phone:String(fe.phone||"").trim(),sms_code:String(fe.sms_code||"").trim()}:fe.mode==="phone_password"?{phone:String(fe.phone||"").trim(),password:String(fe.password||"")}:{username:String(fe.username||"").trim(),password:String(fe.password||"")},lt=await NY(ze);(Nr(lt.role)||lt.username==="ljk_admin")&&t("platform"),Ne(lt),u(`已登录 ${lt.displayName||lt.phone||lt.username}(${lt.role||"用户"})`)}catch(ze){l(ze.message||String(ze))}finally{be(!1)}}async function Xe(fe=d,ze=f,lt=h){be(!0),l(""),u("");try{const Ze=await TY(String(fe||"").trim(),String(ze||""),String(lt||"").trim());Ne(Ze),u("注册成功:待加入公司(pending)。请输入邀请码,或创建自己的公司。")}catch(Ze){l(Ze.message||String(Ze))}finally{be(!1)}}async function Ye(){if(o){be(!0),l("");try{const fe=await YY(o,x.trim());Ne(fe),u(fe.displayName?`已加入租户 #${fe.tenantId}`:`已加入租户 #${fe.tenantId}`),v("")}catch(fe){l(fe.message||String(fe))}finally{be(!1)}}}async function Ve(){if(o){be(!0),l("");try{const fe=await QY(o,g.trim()||h||d);Ne(fe),u(`已创建公司(租户 #${fe.tenantId}),你是管理员`),y("")}catch(fe){l(fe.message||String(fe))}finally{be(!1)}}}async function at(){var fe,ze,lt,Ze,wt,gt,kt,rt,Ge,He;he(!0),l(""),se(null),ce(null);try{const Ae=await MY($,I,N,k,j,A,R);V(Ae.draft),q(Ae.warnings||[]),se(Ae.fidelity||null),ce(Ae.generate_log||null),(ze=(fe=Ae.draft)==null?void 0:fe.meta)!=null&&ze.slug&&ne(Ae.draft.meta.slug);const dt=(kt=(gt=(wt=(Ze=(lt=Ae.draft)==null?void 0:lt.apis)==null?void 0:Ze.resources)==null?void 0:wt[0])==null?void 0:gt.path)==null?void 0:kt.replace(/^\//,"");dt&&te(dt);const vt=Ae.fidelity;let ct="";vt&&!vt.skipped&&(ct=vt.passed?`还原度达标 ${vt.final_score}%(目标 ${vt.target}%)。`:`还原度 ${vt.final_score??"—"}%(目标 ${vt.target}%),请查看差异后继续微调或再生成。`);const yt=(rt=Ae.generate_log)!=null&&rt.run_id?` run=${Ae.generate_log.run_id}`:"";let St="";if(o&&((He=(Ge=Ae.draft)==null?void 0:Ge.meta)!=null&&He.slug))try{const Tt=String(Ae.draft.meta.slug).trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").slice(0,48);if(Tt){await zY(o,Tt,Ae.draft);const fn=await oc(o);oe(fn.items||[]),U("__new__"),St=`已登记为在建模块「${Tt}」。`}}catch(Tt){St=`(在建登记未成功:${Tt.message||Tt})`}u(`草稿置信度 ${Ae.confidence}。${ct}${St}确认发布后将打开模块页。${yt}`)}catch(Ae){l(Ae.message||String(Ae))}finally{he(!1)}}function xe(fe){ne(fe),cee(fe)}async function Le(){var fe,ze,lt,Ze,wt,gt,kt,rt;if(!(!o||!K)){he(!0),l("");try{const Ge=JSON.parse(JSON.stringify(K)),He=re!=="__new__";let Ae=He?re:String(((fe=Ge==null?void 0:Ge.meta)==null?void 0:fe.slug)||"app").trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");He||((!Ae||!/^[a-z]/.test(Ae))&&(Ae=`app_${Ae||"draft"}`.replace(/_+/g,"_")),Ae=Ae.slice(0,48).replace(/_+$/g,"")||"app");const dt=He?J.find(_t=>_t.slug===Ae):null;Ge.meta={...Ge.meta||{},slug:Ae,name:(dt==null?void 0:dt.name)||((ze=Ge.meta)==null?void 0:ze.name)||Ae},Ge.meta.name||(Ge.meta.name=Ae),Ge.version||(Ge.version="1.0"),Ge.storage||(Ge.storage={mode:"schema_per_app",engine:"postgres"}),Ge.security||(Ge.security={visibility:"private",roles:[],row_policies:[]}),Ge.apis&&(Ge.apis={...Ge.apis,base_path:`/api/v1/apps/${Ae}`});const vt=_t=>String(_t||"").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),ct={};for(const _t of Ge.entities||[]){const Zt=String(_t.name||"");_t.name&&(_t.name=vt(_t.name)||"record"),_t.table&&(_t.table=vt(_t.table)||_t.name),Zt&&(ct[Zt]=_t.name,ct[vt(Zt)]=_t.name);for(const gn of _t.fields||[]){gn.name&&(gn.name=vt(String(gn.name).replace(/\./g,"_"))||"field");const In=String(gn.type||"string").toLowerCase();["float","float64","double","number","numeric"].includes(In)?gn.type="decimal":["integer","int32"].includes(In)?gn.type="int":["int64","long"].includes(In)?gn.type="bigint":In==="bool"?gn.type="boolean":["varchar","str"].includes(In)&&(gn.type="string")}}for(const _t of((lt=Ge.apis)==null?void 0:lt.resources)||[]){const Zt=String(_t.entity||"");_t.entity=ct[Zt]||ct[vt(Zt)]||vt(Zt)||_t.entity,_t.path&&(_t.path="/"+(vt(String(_t.path).replace(/^\//,""))||"items"))}for(const _t of Ge.pages||[]){const Zt=String(_t.entity||"");_t.entity=ct[Zt]||ct[vt(Zt)]||vt(Zt)||_t.entity}const yt=((kt=(gt=(wt=(Ze=Ge==null?void 0:Ge.apis)==null?void 0:Ze.resources)==null?void 0:wt[0])==null?void 0:gt.path)==null?void 0:kt.replace(/^\//,""))||ae;te(yt);const Tt=await jY(o,Ae,Ge,He?"add_pages":"create");V(Ge),ne(Ae);try{const _t=await oc(o);oe(_t.items||[])}catch{}const fn=Tt.publish_mode==="pages_added"||Tt.publish_mode==="merged"?`已发布新页面${(rt=Tt.added_pages)!=null&&rt.length?`(${Tt.added_pages.join(", ")})`:""}`:"已新建模块";u(`${fn} ${Ae} → ${Tt.schema_name}。正在跳转模块页…`),xe(Ae)}catch(Ge){l(Ge.message||String(Ge))}finally{he(!1)}}}function me(){if(!o)return;if(l(""),!G.trim()){l("请填写已发布模块 slug");return}const fe=J.find(ze=>ze.slug===G.trim());if(fe&&fe.status!=="published"){l(`模块「${G}」状态为${fe.status_label||fe.status},请先发布后再打开;可在「模块管理」继续编辑`);return}u(`正在跳转模块:/#/app/${G}`),xe(G.trim())}async function Pe(){if(o){he(!0),l("");try{const fe=await DY(o,G);de(fe.capsule),u(fe.hint),t("agent")}catch(fe){l(fe.message||String(fe))}finally{he(!1)}}}if(n==="app"&&Z)return S.jsx(YZ,{session:o,blueprint:Z,onBack:()=>{Mg(),rd()}},String(((ke=Z==null?void 0:Z.meta)==null?void 0:ke.slug)||G));const ve=async fe=>{if(t(fe),l(""),fe==="audit"&&o)try{const ze=await VY(o);_e(ze.items||[])}catch(ze){l(ze.message||String(ze))}};if((td()||Lg())&&!Z)return S.jsx(lee,{message:`正在打开${td()?"草稿预览":"模块"}…`,error:i||void 0});if(!o)return S.jsx(iee,{username:d,password:f,displayName:h,busy:Be,error:i,info:c,onUsername:m,onPassword:p,onDisplayName:b,onLogin:Re,onRegister:Xe});if(Og(o))return S.jsx(aee,{displayLabel:o.displayName||o.username||"",inviteCode:x,companyName:g,busy:Be,error:i,info:c,onInviteCode:v,onCompanyName:y,onAcceptInvite:Ye,onCreateCompany:Ve,onLogout:()=>{Oa(),s(null)}});const Me=(L.length?L:[{id:"deepseek",label:"DeepSeek",configured:!0,default_model:"",models:[]},{id:"minimax",label:"MiniMax",configured:!0,default_model:"",models:[]},{id:"heuristic",label:"本地启发式",configured:!0,default_model:"",models:[]}]).map(fe=>({value:fe.id,label:`${fe.label}${fe.configured===!1?"(未配置 Key)":""}`})),Ie=(((je=L.find(fe=>fe.id===j))==null?void 0:je.models)||[]).map(fe=>({value:fe.id,label:fe.label}));return!Ie.length&&A&&Ie.push({value:A,label:A||"默认"}),S.jsxs(see,{session:o,entitlements:Ee,tab:e,busy:we,onTabChange:ve,onOpenApp:me,onSession:Ne,onLogout:()=>{Oa(),s(null)},banner:S.jsxs(S.Fragment,{children:[i?S.jsx(po,{type:"error",showIcon:!0,closable:!0,message:i,onClose:()=>l(""),style:{marginBottom:12}}):null,c?S.jsx(po,{type:"success",showIcon:!0,closable:!0,message:c,onClose:()=>u(""),style:{marginBottom:12}}):null]}),children:[e==="generate"&&S.jsxs(Tv,{gutter:[16,16],children:[S.jsx(si,{xs:24,lg:14,children:S.jsx(rr,{title:"需求与素材",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{disabled:we,onClick:()=>ye(!1),children:"填入测试默认"}),$e&&S.jsxs(Oe.Text,{type:"secondary",children:["已加载:",qe]})]}),children:S.jsxs(De,{layout:"vertical",requiredMark:!1,children:[S.jsx(De.Item,{label:"需求描述",extra:"可写业务要求、按键,以及截图关系。上传截图后,未点名修改的部分按原图还原。",children:S.jsx(Pt.TextArea,{rows:6,placeholder:`示例: + `]:{marginInlineStart:0,marginInlineEnd:e.marginXXS}},...TX(e),..._X(e),...MX(),"&-rtl":{direction:"rtl"}}}},zX=()=>({titleMarginTop:"1.2em",titleMarginBottom:"0.5em"}),t_=zt("Typography",OX,zX),jX=e=>{const{prefixCls:t,"aria-label":n,className:r,style:o,classNames:s,styles:i,direction:l,maxLength:c,autoSize:u=!0,value:d,onSave:m,onCancel:f,onEnd:p,component:h,enterIcon:b=a.createElement(EX,null)}=e,x=a.useRef(null),v=a.useRef(!1),g=a.useRef(null),[y,$]=a.useState(d);a.useEffect(()=>{$(d)},[d]),a.useEffect(()=>{var O;if((O=x.current)!=null&&O.resizableTextArea){const{textArea:k}=x.current.resizableTextArea;k.focus();const{length:B}=k.value;k.setSelectionRange(B,B)}},[]);const w=({target:O})=>{$(O.value.replace(/[\n\r]/g,""))},I=()=>{v.current=!0},C=()=>{v.current=!1},N=({keyCode:O})=>{v.current||(g.current=O)},E=()=>{m(y.trim())},R=({keyCode:O,ctrlKey:k,altKey:B,metaKey:j,shiftKey:z})=>{g.current!==O||v.current||k||B||j||z||(O===it.ENTER?(E(),p==null||p()):O===it.ESC&&f())},P=()=>{E()},[T,_]=t_(t),M=F(t,`${t}-edit-content`,{[`${t}-rtl`]:l==="rtl",[`${t}-${h}`]:!!h},r,s.root,T,_);return a.createElement("div",{className:M,style:{...i.root,...o}},a.createElement(J4,{ref:x,maxLength:c,value:y,onChange:w,onKeyDown:N,onKeyUp:R,onCompositionStart:I,onCompositionEnd:C,onBlur:P,"aria-label":n,rows:1,autoSize:u,className:s.textarea,style:i.textarea}),b!==null?Wn(b,{className:`${t}-edit-content-confirm`}):null)},BX=(e,t)=>{let n=!1;const r=o=>{var s,i,l;o.stopPropagation(),o.preventDefault(),(s=o.clipboardData)==null||s.clearData(),(i=o.clipboardData)==null||i.setData("text/plain",e),t&&((l=o.clipboardData)==null||l.setData("text/html",e)),n=!0};try{return document.addEventListener("copy",r,{capture:!0}),document.execCommand("copy"),n}catch{return!1}finally{document.removeEventListener("copy",r,{capture:!0})}},LX=async(e,t)=>{try{return t?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})})]):await navigator.clipboard.writeText(e),!0}catch{return!1}};async function kX(e,t){if(typeof e!="string")return!1;const n=(t==null?void 0:t.format)==="text/html";return!!(await LX(e,n)||BX(e,n))}const AX=({copyConfig:e,children:t})=>{const[n,r]=a.useState(!1),[o,s]=a.useState(!1),i=a.useRef(null),l=()=>{i.current&&clearTimeout(i.current)},c={};e.format&&(c.format=e.format),a.useEffect(()=>l,[]);const u=bt(async d=>{var m;d==null||d.preventDefault(),d==null||d.stopPropagation(),s(!0);try{const f=xt(e.text)?await e.text():e.text;await kX(f||a6(t,{skipEmpty:!0}).join("")||"",c),s(!1),r(!0),l(),i.current=setTimeout(()=>{r(!1)},3e3),(m=e.onCopy)==null||m.call(e,d)}catch(f){throw s(!1),f}});return{copied:n,copyLoading:o,onClick:u}},Ig=(e,t)=>{const n=!!e;return a.useMemo(()=>{const r={...t,...n&&pt(e)?e:null};return[n,r]},[n,e,t])},DX=e=>{const t=a.useRef(void 0);return a.useEffect(()=>{t.current=e}),t.current},FX=(e,t,n)=>a.useMemo(()=>e===!0?{title:t??n}:a.isValidElement(e)?{title:e}:pt(e)?{title:t??n,...e}:{title:e},[e,t,n]),n_=(e,t,n,r,o)=>{const{getPrefixCls:s,direction:i,className:l,style:c,classNames:u,styles:d}=Rt("typography"),m=r??i,f=s("typography",e),p={...o,prefixCls:f,direction:m},h=a.useMemo(()=>({root:l}),[l]),b=a.useMemo(()=>({root:c}),[c]),[x,v]=Bt([h,u,t],[b,d,n],{props:p});return[x,v,f,m]},r_=a.forwardRef((e,t)=>{const{component:n="article",className:r,rootClassName:o,children:s,direction:i,style:l,classNames:c,styles:u,prefixCls:d,...m}=e,[f,p]=t_(d),h=F(d,{[`${d}-rtl`]:i==="rtl"},r,o,f,p,c==null?void 0:c.root),b={...u==null?void 0:u.root,...l};return a.createElement(n,{...m,className:h,style:b,ref:t},s)}),HX=a.forwardRef((e,t)=>{const{prefixCls:n,className:r,rootClassName:o,direction:s,classNames:i,styles:l,...c}=e,[u,d,m,f]=n_(n,i,l,s,e);return a.createElement(r_,{ref:t,className:F(r,o),direction:f,classNames:u,styles:d,prefixCls:m,...c})});var o_={};Object.defineProperty(o_,"__esModule",{value:!0});var VX={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"}}]},name:"copy",theme:"outlined"},WX=o_.default=VX;function h0(){return h0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,h0({},e,{ref:t,icon:WX})),UX=a.forwardRef(KX),cE=e=>e===!1?[!1,!1]:a6(e);function Pg(e,t,n){return e===!0||e===void 0?t:e||n&&t}function qX(e){const t=document.createElement("em");e.appendChild(t);const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.removeChild(t),n.left>r.left||r.right>n.right||n.top>r.top||r.bottom>n.bottom}const h$=e=>["string","number"].includes(typeof e),GX=e=>{const{prefixCls:t,copied:n,locale:r,iconOnly:o,tooltips:s,icon:i,tabIndex:l,onCopy:c,loading:u,className:d,style:m}=e,f=cE(s),p=cE(i),{copied:h,copy:b}=r??{},x=n?h:b,v=Pg(f[n?1:0],x),g=typeof v=="string"?v:x;return a.createElement($o,{title:v},a.createElement("button",{type:"button",className:F(`${t}-copy`,d,{[`${t}-copy-success`]:n,[`${t}-copy-icon-only`]:o}),style:m,onClick:c,"aria-label":g,tabIndex:l},n?Pg(p[1],a.createElement(zx,null),!0):Pg(p[0],u?a.createElement(ki,null):a.createElement(UX,null),!0)))},Zu=a.forwardRef(({style:e,children:t},n)=>{const r=a.useRef(null);return a.useImperativeHandle(n,()=>({isExceed:()=>{const o=r.current;return o.scrollHeight>o.clientHeight},getHeight:()=>r.current.clientHeight})),a.createElement("span",{"aria-hidden":!0,ref:r,style:{position:"fixed",display:"block",left:0,top:0,pointerEvents:"none",backgroundColor:"rgba(255, 0, 0, 0.65)",...e}},t)}),XX=e=>e.reduce((t,n)=>t+(h$(n)?String(n).length:1),0);function uE(e,t){let n=0;const r=[];for(let o=0;ot){const u=t-n;return r.push(String(s).slice(0,u)),r}r.push(s),n=c}return e}const Ng=0,Rg=1,Tg=2,_g=3,dE=4,ed={display:"-webkit-box",overflow:"hidden",WebkitBoxOrient:"vertical"};function YX(e){const{enableMeasure:t,width:n,text:r,children:o,rows:s,expanded:i,measureDeps:l,miscDeps:c,onEllipsis:u}=e,d=a.useMemo(()=>Ln(r),[r]),m=a.useMemo(()=>XX(d),[r]),f=a.useMemo(()=>o(d,!1),[r].concat($t(l))),[p,h]=a.useState(null),b=a.useRef(null),x=a.useRef(null),v=a.useRef(null),g=a.useRef(null),y=a.useRef(null),[$,w]=a.useState(!1),[I,C]=a.useState(Ng),[N,E]=a.useState(0),[R,P]=a.useState(null);Nt(()=>{C(t&&n&&m?Rg:Ng)},[n,r,s,t,d].concat($t(l))),Nt(()=>{var O,k,B,j;if(I===Rg){C(Tg);const z=x.current&&getComputedStyle(x.current).whiteSpace;P(z)}else if(I===Tg){const z=!!((O=v.current)!=null&&O.isExceed());C(z?_g:dE),h(z?[0,m]:null),w(z);const A=((k=v.current)==null?void 0:k.getHeight())||0,D=s===1?0:((B=g.current)==null?void 0:B.getHeight())||0,L=((j=y.current)==null?void 0:j.getHeight())||0,H=Math.max(A,D+L);E(H+1),u(z)}},[I]);const T=p?Math.ceil((p[0]+p[1])/2):0;Nt(()=>{var B;const[O,k]=p||[0,0];if(O!==k){const z=(((B=b.current)==null?void 0:B.getHeight())||0)>N;let A=T;k-O===1&&(A=z?O:k),h(z?[O,A]:[A,k])}},[p,T]);const _=a.useMemo(()=>{if(!t)return o(d,!1);if(I!==_g||!p||p[0]!==p[1]){const O=o(d,!1);return[dE,Ng].includes(I)?O:a.createElement("span",{style:{...ed,WebkitLineClamp:s}},O)}return o(i?d:uE(d,p[0]),$)},[i,I,p,d].concat($t(c))),M={width:n,margin:0,padding:0,whiteSpace:R==="nowrap"?"normal":"inherit"};return a.createElement(a.Fragment,null,_,I===Tg&&a.createElement(a.Fragment,null,a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:s},ref:v},f),a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:s-1},ref:g},f),a.createElement(Zu,{style:{...M,...ed,WebkitLineClamp:1},ref:y},o([],!0))),I===_g&&p&&p[0]!==p[1]&&a.createElement(Zu,{style:{...M,top:400},ref:b},o(uE(d,T),!0)),I===Rg&&a.createElement("span",{style:{whiteSpace:"inherit"},ref:x}))}const QX=({enableEllipsis:e,isEllipsis:t,open:n,children:r,tooltipProps:o})=>{if(!(o!=null&&o.title)||!e)return r;const s=n&&t;return a.createElement($o,{open:s,...o},r)};function JX({mark:e,code:t,underline:n,delete:r,strong:o,keyboard:s,italic:i},l){let c=l;function u(d,m){m&&(c=a.createElement(d,{},c))}return u("strong",o),u("u",n),u("del",r),u("code",t),u("mark",e),u("kbd",s),u("i",i),c}const ZX="...",fE=["delete","mark","code","underline","strong","keyboard","italic"],Gm=a.forwardRef((e,t)=>{const{prefixCls:n,className:r,style:o,classNames:s,styles:i,direction:l,type:c,disabled:u,children:d,ellipsis:m,editable:f,copyable:p,actions:h,component:b,title:x,onMouseEnter:v,onMouseLeave:g,...y}=e,[$]=Ar("Text"),w=a.useRef(null),I=a.useRef(null),[C,N,E,R]=n_(n,s,i,l,e),P=Vt(y,fE),[T,_]=Ig(f),[M,O]=sn(!1,_.editing),{triggerType:k=["icon"]}=_,B=Pe=>{var ve;Pe&&((ve=_.onStart)==null||ve.call(_)),O(Pe)},j=DX(M);Nt(()=>{var Pe;!M&&j&&((Pe=I.current)==null||Pe.focus())},[M]);const z=Pe=>{Pe==null||Pe.preventDefault(),B(!0)},A=Pe=>{var ve;(ve=_.onChange)==null||ve.call(_,Pe),B(!1)},D=()=>{var Pe;(Pe=_.onCancel)==null||Pe.call(_),B(!1)},[L,H]=Ig(p),{placement:K="end"}=h??{},{copied:V,copyLoading:W,onClick:q}=AX({copyConfig:H,children:d}),[ee,se]=a.useState(!1),[le,ce]=a.useState(!1),[G,ne]=a.useState(!1),[re,U]=a.useState(!1),[J,oe]=a.useState(!0),[Z,Q]=Ig(m,{expandable:!1,symbol:Pe=>Pe?$==null?void 0:$.collapse:$==null?void 0:$.expand}),[ae,te]=sn(Q.defaultExpanded||!1,Q.expanded),Y=Z&&(!ae||Q.expandable==="collapsible"),{rows:de=1}=Q,ue=a.useMemo(()=>Y&&(Q.suffix!==void 0||Q.onEllipsis||Q.expandable||T||L),[Y,Q,T,L]);Nt(()=>{Z&&!ue&&(se(FS("webkitLineClamp")),ce(FS("textOverflow")))},[ue,Z]);const[ge,we]=a.useState(Y),he=a.useMemo(()=>ue?!1:de===1?le:ee,[ue,de,ee,le]);Nt(()=>{we(he&&Y)},[he,Y]);const Be=FX(Q.tooltip,_.text,d),be=ge&&!!Be.title,Fe=Y&&(ge?be&&re:G),_e=Y&&de===1&&ge,Ee=Y&&de>1&&ge,Te=(Pe,ve)=>{var Se;te(ve.expanded),(Se=Q.onExpand)==null||Se.call(Q,Pe,ve)},[$e,Ce]=a.useState(0),[qe,Qe]=a.useState(!1),[ye,Ne]=a.useState(!1),Re=({offsetWidth:Pe})=>{Ce(Pe)},Xe=Pe=>{var ve;ne(Pe),G!==Pe&&((ve=Q.onEllipsis)==null||ve.call(Q,Pe))};a.useEffect(()=>{const Pe=w.current;if(Z&&be&&Pe){const ve=qX(Pe);re!==ve&&U(ve)}},[Z,be,d,Ee,J,$e]),a.useEffect(()=>{const Pe=w.current;if(typeof IntersectionObserver>"u"||!Pe||!be||!Y)return;const ve=new IntersectionObserver(()=>{oe(!!Pe.offsetParent)});return ve.observe(Pe),()=>{ve.disconnect()}},[be,Y]);const Ye=a.useMemo(()=>{if(!(!Z||ge))return[_.text,d,x,Be.title].find(h$)},[Z,ge,x,Be.title,Fe,_.text]);if(M)return a.createElement(jX,{value:_.text??(typeof d=="string"?d:""),onSave:A,onCancel:D,onEnd:_.onEnd,prefixCls:E,className:r,style:o,direction:R,component:b,maxLength:_.maxLength,autoSize:_.autoSize,enterIcon:_.enterIcon,classNames:C,styles:N});const Ve=()=>{const{expandable:Pe,symbol:ve}=Q;return Pe?a.createElement("button",{type:"button",key:"expand",className:F(`${E}-${ae?"collapse":"expand"}`,C.action),style:N.action,onClick:Se=>Te(Se,{expanded:!ae}),"aria-label":ae?$.collapse:$==null?void 0:$.expand},xt(ve)?ve(ae):ve):null},at=()=>{if(!T)return;const{icon:Pe,tooltip:ve,tabIndex:Se}=_,Me=Ln(ve)[0]||($==null?void 0:$.edit),Ie=typeof Me=="string"?Me:"";return k.includes("icon")?a.createElement($o,{key:"edit",title:ve===!1?"":Me},a.createElement("button",{type:"button",ref:I,className:F(`${E}-edit`,C.action),style:N.action,onClick:z,"aria-label":Ie,tabIndex:Se},Pe||a.createElement(mu,{role:"button"}))):null},xe=()=>L?a.createElement(GX,{key:"copy",...H,prefixCls:E,copied:V,locale:$,onCopy:q,loading:W,iconOnly:!wn(d),className:C.action,style:N.action}):null,Le=Pe=>{const ve=Pe&&Ve(),Se=at(),Me=xe();return!ve&&!Se&&!Me?null:a.createElement("span",{key:"operations",className:F(`${E}-actions`,C.actions,{[`${E}-actions-start`]:K==="start"}),style:N.actions,onMouseEnter:()=>Qe(!0),onMouseLeave:()=>Qe(!1)},ve,Se,Me)},me=Pe=>[Pe&&!ae&&a.createElement("span",{"aria-hidden":!0,key:"ellipsis"},ZX),Q.suffix];return a.createElement(lr,{onResize:Re,disabled:!Y},Pe=>a.createElement(QX,{tooltipProps:Be,enableEllipsis:Y,isEllipsis:Fe,open:ye&&!qe},a.createElement(r_,{onMouseEnter:ve=>{Ne(!0),v==null||v(ve)},onMouseLeave:ve=>{Ne(!1),g==null||g(ve)},className:F({[`${E}-${c}`]:c,[`${E}-disabled`]:u,[`${E}-ellipsis`]:Z,[`${E}-ellipsis-single-line`]:_e,[`${E}-ellipsis-multiple-line`]:Ee,[`${E}-link`]:b==="a"},r),classNames:C,styles:N,prefixCls:E,style:{...o,WebkitLineClamp:Ee?de:void 0},component:b,ref:On(Pe,w,t),direction:R,onClick:k.includes("text")?z:void 0,"aria-label":Ye==null?void 0:Ye.toString(),title:x,...P},a.createElement(YX,{enableMeasure:Y&&!ge,text:d,rows:de,width:$e,onEllipsis:Xe,expanded:ae,measureDeps:[K],miscDeps:[V,ae,W,T,L,K,$].concat($t(fE.map(ve=>e[ve])))},(ve,Se)=>JX(e,a.createElement(a.Fragment,null,K==="start"?Le(Se):null,ve.length>0&&Se&&!ae&&Ye?a.createElement("span",{key:"show-content","aria-hidden":!0},ve):ve,me(Se),K==="start"?null:Le(Se)))))))}),eY=a.forwardRef((e,t)=>{const{ellipsis:n,rel:r,children:o,navigate:s,...i}=e,l={...i,rel:r===void 0&&i.target==="_blank"?"noopener noreferrer":r};return a.createElement(Gm,{...l,ref:t,ellipsis:!!n,component:"a"},o)}),tY=a.forwardRef((e,t)=>{const{children:n,...r}=e;return a.createElement(Gm,{ref:t,...r,component:"div"},n)}),nY=a.forwardRef((e,t)=>{const{ellipsis:n,children:r,...o}=e,s=a.useMemo(()=>pt(n)?Vt(n,["expandable","rows"]):n,[n]);return a.createElement(Gm,{ref:t,...o,ellipsis:s,component:"span"},r)}),rY=[1,2,3,4,5],oY=a.forwardRef((e,t)=>{const{level:n=1,children:r,...o}=e,s=rY.includes(n)?`h${n}`:"h1";return a.createElement(Gm,{ref:t,...o,component:s},r)}),Oe=HX;Oe.Text=nY;Oe.Link=eY;Oe.Title=oY;Oe.Paragraph=tY;var Xm={},s_={exports:{}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(s_);var y$=s_.exports,Ym={};Object.defineProperty(Ym,"__esModule",{value:!0});Ym.default=void 0;const sY={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:"页码"};Ym.default=sY;var Qm={},pu={},Jm={},Zm={};Object.defineProperty(Zm,"__esModule",{value:!0});Zm.commonLocale=void 0;Zm.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0};Object.defineProperty(Jm,"__esModule",{value:!0});Jm.default=void 0;var iY=Zm;const aY={...iY.commonLocale,locale:"zh_CN",today:"今天",now:"此刻",backToToday:"返回今天",ok:"确定",timeSelect:"选择时间",dateSelect:"选择日期",weekSelect:"选择周",clear:"清除",week:"周",month:"月",year:"年",previousMonth:"上个月 (翻页上键)",nextMonth:"下个月 (翻页下键)",monthSelect:"选择月份",yearSelect:"选择年份",decadeSelect:"选择年代",previousYear:"上一年 (Control键加左方向键)",nextYear:"下一年 (Control键加右方向键)",previousDecade:"上一年代",nextDecade:"下一年代",previousCentury:"上一世纪",nextCentury:"下一世纪",yearFormat:"YYYY年",cellDateFormat:"D",monthBeforeYear:!1};Jm.default=aY;var gu={};Object.defineProperty(gu,"__esModule",{value:!0});gu.default=void 0;const lY={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]};gu.default=lY;var i_=y$.default;Object.defineProperty(pu,"__esModule",{value:!0});pu.default=void 0;var cY=i_(Jm),uY=i_(gu);const a_={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...cY.default},timePickerLocale:{...uY.default}};a_.lang.ok="确定";pu.default=a_;var dY=y$.default;Object.defineProperty(Qm,"__esModule",{value:!0});Qm.default=void 0;var fY=dY(pu);Qm.default=fY.default;var ep=y$.default;Object.defineProperty(Xm,"__esModule",{value:!0});Xm.default=void 0;var mY=ep(Ym),pY=ep(Qm),gY=ep(pu),hY=ep(gu);const Pr="${label}不是一个有效的${type}",yY={locale:"zh-cn",Pagination:mY.default,DatePicker:gY.default,TimePicker:hY.default,Calendar:pY.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:"收起"},Form:{optional:"(可选)",defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:Pr,method:Pr,array:Pr,object:Pr,number:Pr,date:Pr,boolean:Pr,integer:Pr,float:Pr,regexp:Pr,email:Pr,url:Pr,hex:Pr},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:"渐变色"}};Xm.default=yY;var vY=Xm;const bY=W0(vY);let v$=null;function xY(){return v$}function Mg(){v$=null}function mE(e){v$=e}function $Y(e){const t=typeof window<"u"?window.__AJZ_PREVIEW__:void 0;return!(t!=null&&t.blueprint)||t.id&&t.id!==e?null:{id:String(t.id||e),blueprint:t.blueprint,rows:Array.isArray(t.rows)?t.rows:[],resource:String(t.resource||"records")}}async function SY(e){const t=$Y(e);if(t)return mE(t),t;const n=await fetch(`/ai/api/v1/preview/${encodeURIComponent(e)}`),r=await n.json();if(!n.ok||!(r!=null&&r.ok))throw new Error((r==null?void 0:r.error)||`预览不存在或已过期 (${n.status})`);const o={id:String(r.id||e),blueprint:r.blueprint,rows:Array.isArray(r.rows)?r.rows:[],resource:String(r.resource||"records")};return mE(o),o}function td(){const t=(window.location.hash||"").replace(/^#/,"").match(/^\/?preview\/([a-zA-Z0-9_-]{6,32})\/?$/);return t?t[1]:null}const l_=[{title:"模块",items:[{id:"读取模块",label:"读取模块"},{id:"写入模块",label:"写入模块"},{id:"发布模块",label:"发布模块"}]},{title:"数据",items:[{id:"查询数据",label:"查询数据"},{id:"新增数据",label:"新增数据"},{id:"更新数据",label:"更新数据"},{id:"删除数据",label:"删除数据"},{id:"导入数据",label:"导入数据"},{id:"导出数据",label:"导出数据"}]},{title:"其他",items:[{id:"下载文件",label:"下载文件"},{id:"上传文件",label:"上传文件"},{id:"查看审计",label:"查看审计"}]}],c_={"app.read":"读取模块","app.write":"写入模块","app.admin":"发布模块","row.create":"新增数据","row.read":"查询数据","row.update":"更新数据","row.delete":"删除数据","row.export":"导出数据","row.import":"导入数据","audit.read":"查看审计","storage.write":"上传文件","storage.read":"下载文件","agent.admin":"管理智能体","tenant.invite":"邀请成员","org.admin":"管理组织","sync.admin":"数据同步"},CY={...Object.fromEntries(l_.flatMap(e=>e.items.map(t=>[t.id,t.label]))),管理智能体:"管理智能体",邀请成员:"邀请成员",管理组织:"管理组织",数据同步:"数据同步"};function Ma(e){const t=c_[e]||e;return CY[t]||t}function tp(e){switch(e){case"platform_admin":case"super_admin":case"超级管理员":return"超级管理员";case"owner":case"管理员":return"管理员";case"editor":case"编辑":return"编辑";case"viewer":case"只读":return"只读";case"pending":case"待加入":return"待加入";case"agent":case"智能体":return"智能体";default:return e}}function rc(e){return tp(e)}function Nr(e){return tp(e||"")==="超级管理员"}function jl(e){return tp(e||"")==="管理员"}function wY(e){var r;const t=((r=e.allowedModules)!=null&&r.length?e.allowedModules:l_.map(o=>({title:o.title,items:o.items.map(s=>({perm:s.id,desc:s.label}))}))).map(o=>({title:o.title,items:o.items||(o.perms||[]).map(s=>({perm:s,desc:Ma(s)}))})),n=e.value.map(o=>c_[o]||o);return S.jsx(Mt,{direction:"vertical",size:"middle",style:{width:"100%"},children:t.map(o=>{const s=o.items.map(i=>i.perm);return S.jsxs("div",{children:[S.jsx(Oe.Text,{type:"secondary",strong:!0,children:o.title}),S.jsx("div",{style:{marginTop:8},children:S.jsx(go.Group,{style:{width:"100%",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8},value:n.filter(i=>s.includes(i)),onChange:i=>{const l=new Set(s),c=n.filter(u=>!l.has(u));e.onChange([...c,...i])},options:o.items.map(i=>({label:S.jsxs("span",{children:[Ma(i.perm),i.desc?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:i.desc})]}):null]}),value:i.perm}))})})]},o.title)})})}function EY(e,t){return e==null?!0:e.includes(t)}const Un="",Dc="/ai",b$="ajz_session";function Og(e){if(!e)return!1;const t=tp(e.role||"");return t==="超级管理员"||e.username==="ljk_admin"?!1:t==="待加入"||e.status==="pending"||!e.tenantId}function u_(e){if(!e||e.split(".").length<2)return"";try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),r=atob(n),o=Uint8Array.from(r,i=>i.charCodeAt(0)),s=JSON.parse(new TextDecoder().decode(o));return typeof(s==null?void 0:s.role)=="string"?s.role:""}catch{return""}}function Oa(e){try{localStorage.removeItem(b$)}catch{}(e==null?void 0:e.emit)!==!1&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("ajz:session-expired"))}function zg(){try{const e=localStorage.getItem(b$);if(!e)return null;const t=JSON.parse(e);return!(t!=null&&t.accessToken)||typeof t.accessToken!="string"||t.accessToken.split(".").length!==3?(Oa({emit:!1}),null):t.expiresAt&&t.expiresAt*1e3Object.entries(r).every(([y,$])=>!$||String(g[y]??"")===String($))));const v=Math.max(0,(o-1)*s);return{items:x.slice(v,v+s),total:x.length}}const m={};e!=null&&e.accessToken&&(m.Authorization=`Bearer ${e.accessToken}`);const f=await tt(c,{headers:m,cache:"no-store"}),p=await nt(f);return ot(f,p,"list failed"),p}async function BY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"create failed"),s}async function LY(e,t,n,r,o){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const s=await tt(`${Un}/api/v1/apps/${t}/${n}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(o)}),i=await nt(s);return ot(s,i,"update failed"),i}async function kY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}/${r}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}});if(!o.ok&&o.status!==204){const s=await nt(o).catch(()=>({}));ot(o,s,"delete failed")}}async function AY(e,t,n,r,o){const s=new URLSearchParams;r&&s.set("group_by",r),o&&s.set("sum",o);const i={};e!=null&&e.accessToken&&(i.Authorization=`Bearer ${e.accessToken}`);const l=await tt(`${Un}/api/v1/apps/${t}/${n}/aggregate?${s}`,{headers:i}),c=await nt(l);return ot(l,c,"aggregate failed"),c}async function DY(e,t){const n=await tt(`${Un}/api/v1/apps/${t}/agent-capsule`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"capsule failed"),r}async function FY(e,t,n,r){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=new FormData;o.append("file",r);const s=await tt(`${Un}/api/v1/apps/${t}/${n}/import`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:o}),i=await nt(s);return ot(s,i,"import failed"),i}async function HY(e,t,n,r="xlsx"){if(!(e!=null&&e.accessToken))throw new Error("预览模式为只读,写操作请先登录控制台");const o=await tt(`${Un}/api/v1/apps/${t}/${n}/export?format=${r}`,{headers:{Authorization:`Bearer ${e.accessToken}`}});if(!o.ok){const c=await nt(o).catch(()=>({}));ot(o,c,"export failed")}const s=await o.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=`${n}.${r==="csv"?"csv":"xlsx"}`,l.click(),URL.revokeObjectURL(i)}async function VY(e,t=1){const n=await tt(`/api/v1/audit/logs?page=${t}&page_size=50`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"audit failed"),r}async function d_(e){const t=await tt("/api/v1/admin/agents",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list agents failed"),n}async function WY(e,t){const n=await tt("/api/v1/admin/agents",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create agent failed"),r}async function gE(e,t,n){const r=await tt(`/api/v1/admin/agents/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update agent failed"),o}async function KY(e,t){const n=await tt(`/api/v1/admin/agents/${t}/rotate-secret`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"rotate secret failed"),r}async function UY(e,t){const n=await tt(`/api/v1/admin/agents/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete agent failed")}async function f_(e){const t=await tt("/api/v1/admin/roles",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list roles failed"),n}async function qY(e,t){const n=await tt("/api/v1/admin/roles",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create role failed"),r}async function GY(e,t,n){const r=await tt(`/api/v1/admin/roles/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update role failed"),o}async function XY(e,t){const n=await tt(`/api/v1/admin/roles/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete role failed")}async function YY(e,t){const n=await tt("/api/v1/auth/invites/accept",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({code:t})}),r=await nt(n);return ot(n,r,"accept invite failed"),cl(r)}async function QY(e,t){const n=await tt("/api/v1/tenants",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:t})}),r=await nt(n);return ot(n,r,"create tenant failed"),cl(r)}async function JY(e){const t=await tt("/api/v1/admin/invites",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list invites failed"),n}async function ZY(e,t){const n=await tt("/api/v1/admin/invites",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create invite failed"),r}async function eQ(e,t){const n=await tt(`/api/v1/admin/invites/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"revoke invite failed")}async function x$(e){const t=await tt("/api/v1/admin/org-units",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list org units failed"),n}async function tQ(e,t){const n=await tt("/api/v1/admin/org-units",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create org unit failed"),r}async function nQ(e,t,n){const r=await tt(`/api/v1/admin/org-units/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update org unit failed"),o}async function rQ(e,t){const n=await tt(`/api/v1/admin/org-units/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);ot(n,r,"delete org unit failed")}async function m_(e){const t=await tt("/api/v1/admin/sync/channels",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list sync channels failed"),n}async function oQ(e,t){const n=await tt("/api/v1/admin/sync/channels",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create sync channel failed"),r}async function sQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update sync channel failed"),o}async function iQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"delete sync channel failed"),r}async function aQ(e,t){const n=await tt("/api/v1/admin/sync/test",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"test sync failed"),r}async function hE(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/start`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"start sync failed"),r}async function lQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/stop`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"stop sync failed"),r}async function cQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/reconcile`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"reconcile failed"),r}async function uQ(e,t){const n=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/checkpoint`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"get checkpoint failed"),r}async function dQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/restore`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"restore failed"),o}async function fQ(e,t,n){const r=(n==null?void 0:n.side)||"remote",o=new URLSearchParams({side:r});o.set("include_sync_meta","1");const s=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/inspect?${o}`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),i=await nt(s);return ot(s,i,"inspect failed"),i}async function mQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/preview`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"preview failed"),o}async function pQ(e,t,n){const r=await tt(`/api/v1/admin/sync/channels/${encodeURIComponent(t)}/drop-table`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"drop table failed"),o}async function gQ(e){const t=await tt("/api/v1/admin/bind-codes",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list bind codes failed"),n}async function hQ(e,t){const n=await tt("/api/v1/admin/bind-codes",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t||{})}),r=await nt(n);return ot(n,r,"create bind code failed"),r}async function yQ(e,t){const n=await tt(`/api/v1/admin/bind-codes/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"revoke bind code failed"),r}async function p_(e,t){const r=await tt("/api/v1/admin/sync/bindings",{headers:{Authorization:`Bearer ${e.accessToken}`}}),o=await nt(r);return ot(r,o,"list bindings failed"),o}async function vQ(e,t){const n=new URLSearchParams;t!=null&&t.tenant_id&&n.set("tenant_id",String(t.tenant_id)),t!=null&&t.channel_id&&n.set("channel_id",t.channel_id),n.set("limit",String(t.limit));const r=n.toString(),o=await tt(`/api/v1/platform/dbsync/lww-overrides${r?`?${r}`:""}`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),s=await nt(o);return ot(o,s,"list lww overrides failed"),s}async function bQ(e,t){const n=await tt(`/api/v1/platform/dbsync/lww-overrides/${encodeURIComponent(t)}/rollback`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"lww rollback failed"),r}async function xQ(e){const t=await tt("/api/v1/platform/tenants",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list tenants failed"),n}async function $Q(e){const t=await tt("/api/v1/platform/perm-modules",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list perm modules failed"),n}async function SQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/permissions`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"get tenant perms failed"),r}async function CQ(e,t,n){const r=await tt(`/api/v1/platform/tenants/${t}/permissions`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({permissions:n})}),o=await nt(r);return ot(r,o,"set tenant perms failed"),o}async function wQ(e,t,n=!1,r="",o=""){const s=await tt("/api/v1/platform/tenants",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:t,slug:r||void 0,with_admin_invite:n,admin_phone:o.trim()||void 0})}),i=await nt(s);return ot(s,i,"create tenant failed"),i}async function EQ(e,t,n,r=""){const o=await tt(`/api/v1/platform/tenants/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:n,slug:r||void 0})}),s=await nt(o);return ot(o,s,"update tenant failed"),s}async function IQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/admin-invite`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"admin invite failed"),r}async function PQ(e,t,n){const r=await tt(`/api/v1/platform/tenants/${t}/admin-account`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({phone:n.trim()})}),o=await nt(r);return ot(r,o,"admin account failed"),o}async function NQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/admins`,{headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"list admins failed"),r}async function RQ(e,t,n,r){const o=await tt(`/api/v1/platform/tenants/${t}/admins/${n}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"update admin failed"),s}async function TQ(e,t){const n=await tt(`/api/v1/platform/tenants/${t}/enter`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),r=await nt(n);return ot(n,r,"enter tenant failed"),cl(r)}async function g_(e){const t=await tt("/api/v1/platform/exit",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"exit tenant failed"),cl(n)}async function h_(e){const t=await tt("/api/v1/admin/entitlements",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"get entitlements failed"),n}async function _Q(e){const t=await tt("/api/v1/admin/members",{headers:{Authorization:`Bearer ${e.accessToken}`}}),n=await nt(t);return ot(t,n,"list members failed"),n}async function MQ(e,t){const n=await tt("/api/v1/admin/members",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await nt(n);return ot(n,r,"create member failed"),r}async function OQ(e,t,n){const r=await tt("/api/v1/auth/password",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({old_password:t,new_password:n})}),o=await nt(r);return ot(r,o,"change password failed"),o}async function zQ(e,t,n){const r={phone:t},o=await tt("/api/v1/auth/phone",{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await nt(o);return ot(o,s,"bind phone failed"),s}async function yE(e,t,n){const r=await tt(`/api/v1/admin/members/${t}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await nt(r);return ot(r,o,"update member failed"),o}async function jQ(e,t){const n=new FormData;n.append("file",t);const r=await tt("/api/v1/storage",{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:n}),o=await nt(r);return ot(r,o,"upload failed"),o}var y_={};Object.defineProperty(y_,"__esModule",{value:!0});var BQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M908 640H804V488c0-4.4-3.6-8-8-8H548v-96h108c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16H368c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h108v96H228c-4.4 0-8 3.6-8 8v152H116c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16H292v-88h440v88H620c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16zm-564 76v168H176V716h168zm84-408V140h168v168H428zm420 576H680V716h168v168z"}}]},name:"apartment",theme:"outlined"},LQ=y_.default=BQ;function v0(){return v0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,v0({},e,{ref:t,icon:LQ})),AQ=a.forwardRef(kQ);var v_={};Object.defineProperty(v_,"__esModule",{value:!0});var DQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 00-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 000 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3 2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4-186.8-186.8 59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7 35.3 0 68.4 13.7 93.4 38.7 24.9 24.9 38.7 58.1 38.7 93.4 0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 00-11.3 0L501 613.3 410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 00-11.3 0L363 475.3l-43-43a7.85 7.85 0 00-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 000 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3 51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43 66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 01-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 01-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4 186.8 186.8-59.4 59.4z"}}]},name:"api",theme:"outlined"},FQ=v_.default=DQ;function b0(){return b0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,b0({},e,{ref:t,icon:FQ})),b_=a.forwardRef(HQ);var x_={};Object.defineProperty(x_,"__esModule",{value:!0});var VQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"}}]},name:"appstore",theme:"outlined"},WQ=x_.default=VQ;function x0(){return x0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,x0({},e,{ref:t,icon:WQ})),UQ=a.forwardRef(KQ);var $_={};Object.defineProperty($_,"__esModule",{value:!0});var qQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M872 474H286.9l350.2-304c5.6-4.9 2.2-14-5.2-14h-88.5c-3.9 0-7.6 1.4-10.5 3.9L155 487.8a31.96 31.96 0 000 48.3L535.1 866c1.5 1.3 3.3 2 5.2 2h91.5c7.4 0 10.8-9.2 5.2-14L286.9 550H872c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"arrow-left",theme:"outlined"},GQ=$_.default=qQ;function $0(){return $0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,$0({},e,{ref:t,icon:GQ})),YQ=a.forwardRef(XQ);var S_={};Object.defineProperty(S_,"__esModule",{value:!0});var QQ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M296 250c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H296zm184 144H296c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zm-48 458H208V148h560v320c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V108c0-17.7-14.3-32-32-32H168c-17.7 0-32 14.3-32 32v784c0 17.7 14.3 32 32 32h264c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm440-88H728v-36.6c46.3-13.8 80-56.6 80-107.4 0-61.9-50.1-112-112-112s-112 50.1-112 112c0 50.7 33.7 93.6 80 107.4V764H520c-8.8 0-16 7.2-16 16v152c0 8.8 7.2 16 16 16h352c8.8 0 16-7.2 16-16V780c0-8.8-7.2-16-16-16zM646 620c0-27.6 22.4-50 50-50s50 22.4 50 50-22.4 50-50 50-50-22.4-50-50zm180 266H566v-60h260v60z"}}]},name:"audit",theme:"outlined"},JQ=S_.default=QQ;function S0(){return S0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,S0({},e,{ref:t,icon:JQ})),eJ=a.forwardRef(ZQ);var C_={};Object.defineProperty(C_,"__esModule",{value:!0});var tJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M894 462c30.9 0 43.8-39.7 18.7-58L530.8 126.2a31.81 31.81 0 00-37.6 0L111.3 404c-25.1 18.2-12.2 58 18.8 58H192v374h-72c-4.4 0-8 3.6-8 8v52c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-52c0-4.4-3.6-8-8-8h-72V462h62zM512 196.7l271.1 197.2H240.9L512 196.7zM264 462h117v374H264V462zm189 0h117v374H453V462zm307 374H642V462h118v374z"}}]},name:"bank",theme:"outlined"},nJ=C_.default=tJ;function C0(){return C0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,C0({},e,{ref:t,icon:nJ})),vE=a.forwardRef(rJ);var w_={};Object.defineProperty(w_,"__esModule",{value:!0});var oJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M811.4 368.9C765.6 248 648.9 162 512.2 162S258.8 247.9 213 368.8C126.9 391.5 63.5 470.2 64 563.6 64.6 668 145.6 752.9 247.6 762c4.7.4 8.7-3.3 8.7-8v-60.4c0-4-3-7.4-7-7.9-27-3.4-52.5-15.2-72.1-34.5-24-23.5-37.2-55.1-37.2-88.6 0-28 9.1-54.4 26.2-76.4 16.7-21.4 40.2-36.9 66.1-43.7l37.9-10 13.9-36.7c8.6-22.8 20.6-44.2 35.7-63.5 14.9-19.2 32.6-36 52.4-50 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.3c19.9 14 37.5 30.8 52.4 50 15.1 19.3 27.1 40.7 35.7 63.5l13.8 36.6 37.8 10c54.2 14.4 92.1 63.7 92.1 120 0 33.6-13.2 65.1-37.2 88.6-19.5 19.2-44.9 31.1-71.9 34.5-4 .5-6.9 3.9-6.9 7.9V754c0 4.7 4.1 8.4 8.8 8 101.7-9.2 182.5-94 183.2-198.2.6-93.4-62.7-172.1-148.6-194.9z"}},{tag:"path",attrs:{d:"M376.9 656.4c1.8-33.5 15.7-64.7 39.5-88.6 25.4-25.5 60-39.8 96-39.8 36.2 0 70.3 14.1 96 39.8 1.4 1.4 2.7 2.8 4.1 4.3l-25 19.6a8 8 0 003 14.1l98.2 24c5 1.2 9.9-2.6 9.9-7.7l.5-101.3c0-6.7-7.6-10.5-12.9-6.3L663 532.7c-36.6-42-90.4-68.6-150.5-68.6-107.4 0-195 85.1-199.4 191.7-.2 4.5 3.4 8.3 8 8.3H369c4.2-.1 7.7-3.4 7.9-7.7zM703 664h-47.9c-4.2 0-7.7 3.3-8 7.6-1.8 33.5-15.7 64.7-39.5 88.6-25.4 25.5-60 39.8-96 39.8-36.2 0-70.3-14.1-96-39.8-1.4-1.4-2.7-2.8-4.1-4.3l25-19.6a8 8 0 00-3-14.1l-98.2-24c-5-1.2-9.9 2.6-9.9 7.7l-.4 101.4c0 6.7 7.6 10.5 12.9 6.3l23.2-18.2c36.6 42 90.4 68.6 150.5 68.6 107.4 0 195-85.1 199.4-191.7.2-4.5-3.4-8.3-8-8.3z"}}]},name:"cloud-sync",theme:"outlined"},sJ=w_.default=oJ;function w0(){return w0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,w0({},e,{ref:t,icon:sJ})),aJ=a.forwardRef(iJ);var E_={};Object.defineProperty(E_,"__esModule",{value:!0});var lJ={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM653.3 424.6l52.2 52.2a8.01 8.01 0 01-4.7 13.6l-179.4 21c-5.1.6-9.5-3.7-8.9-8.9l21-179.4c.8-6.6 8.9-9.4 13.6-4.7l52.4 52.4 256.2-256.2c3.1-3.1 8.2-3.1 11.3 0l42.4 42.4c3.1 3.1 3.1 8.2 0 11.3L653.3 424.6z"}}]},name:"import",theme:"outlined"},cJ=E_.default=lJ;function E0(){return E0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,E0({},e,{ref:t,icon:cJ})),dJ=a.forwardRef(uJ);var I_={};Object.defineProperty(I_,"__esModule",{value:!0});var fJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5L255.8 713.6l-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l110.3 111.2c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.1 304.1 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112m161.2 465.2C726.2 620.3 668.9 644 608 644s-118.2-23.7-161.2-66.8C403.7 534.2 380 476.9 380 416s23.7-118.2 66.8-161.2c43-43.1 100.3-66.8 161.2-66.8s118.2 23.7 161.2 66.8c43.1 43 66.8 100.3 66.8 161.2s-23.7 118.2-66.8 161.2"}}]},name:"key",theme:"outlined"},mJ=I_.default=fJ;function I0(){return I0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,I0({},e,{ref:t,icon:mJ})),jf=a.forwardRef(pJ);var P_={};Object.defineProperty(P_,"__esModule",{value:!0});var gJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M521.7 82c-152.5-.4-286.7 78.5-363.4 197.7-3.4 5.3.4 12.3 6.7 12.3h70.3c4.8 0 9.3-2.1 12.3-5.8 7-8.5 14.5-16.7 22.4-24.5 32.6-32.5 70.5-58.1 112.7-75.9 43.6-18.4 90-27.8 137.9-27.8 47.9 0 94.3 9.3 137.9 27.8 42.2 17.8 80.1 43.4 112.7 75.9 32.6 32.5 58.1 70.4 76 112.5C865.7 417.8 875 464.1 875 512c0 47.9-9.4 94.2-27.8 137.8-17.8 42.1-43.4 80-76 112.5s-70.5 58.1-112.7 75.9A352.8 352.8 0 01520.6 866c-47.9 0-94.3-9.4-137.9-27.8A353.84 353.84 0 01270 762.3c-7.9-7.9-15.3-16.1-22.4-24.5-3-3.7-7.6-5.8-12.3-5.8H165c-6.3 0-10.2 7-6.7 12.3C234.9 863.2 368.5 942 520.6 942c236.2 0 428-190.1 430.4-425.6C953.4 277.1 761.3 82.6 521.7 82zM395.02 624v-76h-314c-4.4 0-8-3.6-8-8v-56c0-4.4 3.6-8 8-8h314v-76c0-6.7 7.8-10.5 13-6.3l141.9 112a8 8 0 010 12.6l-141.9 112c-5.2 4.1-13 .4-13-6.3z"}}]},name:"login",theme:"outlined"},hJ=P_.default=gJ;function P0(){return P0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,P0({},e,{ref:t,icon:hJ})),vJ=a.forwardRef(yJ);var N_={};Object.defineProperty(N_,"__esModule",{value:!0});var bJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M868 732h-70.3c-4.8 0-9.3 2.1-12.3 5.8-7 8.5-14.5 16.7-22.4 24.5a353.84 353.84 0 01-112.7 75.9A352.8 352.8 0 01512.4 866c-47.9 0-94.3-9.4-137.9-27.8a353.84 353.84 0 01-112.7-75.9 353.28 353.28 0 01-76-112.5C167.3 606.2 158 559.9 158 512s9.4-94.2 27.8-137.8c17.8-42.1 43.4-80 76-112.5s70.5-58.1 112.7-75.9c43.6-18.4 90-27.8 137.9-27.8 47.9 0 94.3 9.3 137.9 27.8 42.2 17.8 80.1 43.4 112.7 75.9 7.9 7.9 15.3 16.1 22.4 24.5 3 3.7 7.6 5.8 12.3 5.8H868c6.3 0 10.2-7 6.7-12.3C798 160.5 663.8 81.6 511.3 82 271.7 82.6 79.6 277.1 82 516.4 84.4 751.9 276.2 942 512.4 942c152.1 0 285.7-78.8 362.3-197.7 3.4-5.3-.4-12.3-6.7-12.3zm88.9-226.3L815 393.7c-5.3-4.2-13-.4-13 6.3v76H488c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h314v76c0 6.7 7.8 10.5 13 6.3l141.9-112a8 8 0 000-12.6z"}}]},name:"logout",theme:"outlined"},xJ=N_.default=bJ;function N0(){return N0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,N0({},e,{ref:t,icon:xJ})),R_=a.forwardRef($J);var T_={};Object.defineProperty(T_,"__esModule",{value:!0});var SJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 000 13.8z"}}]},name:"menu-fold",theme:"outlined"},CJ=T_.default=SJ;function R0(){return R0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,R0({},e,{ref:t,icon:CJ})),EJ=a.forwardRef(wJ);var __={};Object.defineProperty(__,"__esModule",{value:!0});var IJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 000-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0014.4 7z"}}]},name:"menu-unfold",theme:"outlined"},PJ=__.default=IJ;function T0(){return T0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,T0({},e,{ref:t,icon:PJ})),RJ=a.forwardRef(NJ);var M_={};Object.defineProperty(M_,"__esModule",{value:!0});var TJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M744 62H280c-35.3 0-64 28.7-64 64v768c0 35.3 28.7 64 64 64h464c35.3 0 64-28.7 64-64V126c0-35.3-28.7-64-64-64zm-8 824H288V134h448v752zM472 784a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"mobile",theme:"outlined"},_J=M_.default=TJ;function _0(){return _0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,_0({},e,{ref:t,icon:_J})),bE=a.forwardRef(MJ);var O_={};Object.defineProperty(O_,"__esModule",{value:!0});var OJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm-88-532h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8zm224 0h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8z"}}]},name:"pause-circle",theme:"outlined"},zJ=O_.default=OJ;function M0(){return M0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,M0({},e,{ref:t,icon:zJ})),BJ=a.forwardRef(jJ);var z_={};Object.defineProperty(z_,"__esModule",{value:!0});var LJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"},kJ=z_.default=LJ;function O0(){return O0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,O0({},e,{ref:t,icon:kJ})),DJ=a.forwardRef(AJ);var j_={};Object.defineProperty(j_,"__esModule",{value:!0});var FJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"},HJ=j_.default=FJ;function z0(){return z0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,z0({},e,{ref:t,icon:HJ})),WJ=a.forwardRef(VJ);var B_={};Object.defineProperty(B_,"__esModule",{value:!0});var KJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M866.9 169.9L527.1 54.1C523 52.7 517.5 52 512 52s-11 .7-15.1 2.1L157.1 169.9c-8.3 2.8-15.1 12.4-15.1 21.2v482.4c0 8.8 5.7 20.4 12.6 25.9L499.3 968c3.5 2.7 8 4.1 12.6 4.1s9.2-1.4 12.6-4.1l344.7-268.6c6.9-5.4 12.6-17 12.6-25.9V191.1c.2-8.8-6.6-18.3-14.9-21.2zM810 654.3L512 886.5 214 654.3V226.7l298-101.6 298 101.6v427.6zm-405.8-201c-3-4.1-7.8-6.6-13-6.6H336c-6.5 0-10.3 7.4-6.5 12.7l126.4 174a16.1 16.1 0 0026 0l212.6-292.7c3.8-5.3 0-12.7-6.5-12.7h-55.2c-5.1 0-10 2.5-13 6.6L468.9 542.4l-64.7-89.1z"}}]},name:"safety-certificate",theme:"outlined"},UJ=B_.default=KJ;function j0(){return j0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,j0({},e,{ref:t,icon:UJ})),GJ=a.forwardRef(qJ);var L_={};Object.defineProperty(L_,"__esModule",{value:!0});var XJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372 0-89 31.3-170.8 83.5-234.8l523.3 523.3C682.8 852.7 601 884 512 884zm288.5-137.2L277.2 223.5C341.2 171.3 423 140 512 140c205.4 0 372 166.6 372 372 0 89-31.3 170.8-83.5 234.8z"}}]},name:"stop",theme:"outlined"},YJ=L_.default=XJ;function B0(){return B0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,B0({},e,{ref:t,icon:YJ})),k_=a.forwardRef(QJ);var A_={};Object.defineProperty(A_,"__esModule",{value:!0});var JJ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 208H676V232h212v136zm0 224H676V432h212v160zM412 432h200v160H412V432zm200-64H412V232h200v136zm-476 64h212v160H136V432zm0-200h212v136H136V232zm0 424h212v136H136V656zm276 0h200v136H412V656zm476 136H676V656h212v136z"}}]},name:"table",theme:"outlined"},ZJ=A_.default=JJ;function L0(){return L0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,L0({},e,{ref:t,icon:ZJ})),tZ=a.forwardRef(eZ);var D_={};Object.defineProperty(D_,"__esModule",{value:!0});var nZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"}}]},name:"team",theme:"outlined"},rZ=D_.default=nZ;function k0(){return k0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,k0({},e,{ref:t,icon:rZ})),sZ=a.forwardRef(oZ);var F_={};Object.defineProperty(F_,"__esModule",{value:!0});var iZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M848 359.3H627.7L825.8 109c4.1-5.3.4-13-6.3-13H436c-2.8 0-5.5 1.5-6.9 4L170 547.5c-3.1 5.3.7 12 6.9 12h174.4l-89.4 357.6c-1.9 7.8 7.5 13.3 13.3 7.7L853.5 373c5.2-4.9 1.7-13.7-5.5-13.7zM378.2 732.5l60.3-241H281.1l189.6-327.4h224.6L487 427.4h211L378.2 732.5z"}}]},name:"thunderbolt",theme:"outlined"},aZ=F_.default=iZ;function A0(){return A0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,A0({},e,{ref:t,icon:aZ})),cZ=a.forwardRef(lZ);var H_={};Object.defineProperty(H_,"__esModule",{value:!0});var uZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M678.3 642.4c24.2-13 51.9-20.4 81.4-20.4h.1c3 0 4.4-3.6 2.2-5.6a371.67 371.67 0 00-103.7-65.8c-.4-.2-.8-.3-1.2-.5C719.2 505 759.6 431.7 759.6 349c0-137-110.8-248-247.5-248S264.7 212 264.7 349c0 82.7 40.4 156 102.6 201.1-.4.2-.8.3-1.2.5-44.7 18.9-84.8 46-119.3 80.6a373.42 373.42 0 00-80.4 119.5A373.6 373.6 0 00137 888.8a8 8 0 008 8.2h59.9c4.3 0 7.9-3.5 8-7.8 2-77.2 32.9-149.5 87.6-204.3C357 628.2 432.2 597 512.2 597c56.7 0 111.1 15.7 158 45.1a8.1 8.1 0 008.1.3zM512.2 521c-45.8 0-88.9-17.9-121.4-50.4A171.2 171.2 0 01340.5 349c0-45.9 17.9-89.1 50.3-121.6S466.3 177 512.2 177s88.9 17.9 121.4 50.4A171.2 171.2 0 01683.9 349c0 45.9-17.9 89.1-50.3 121.6C601.1 503.1 558 521 512.2 521zM880 759h-84v-84c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v84h-84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h84v84c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-84h84c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z"}}]},name:"user-add",theme:"outlined"},dZ=H_.default=uZ;function D0(){return D0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,D0({},e,{ref:t,icon:dZ})),mZ=a.forwardRef(fZ);var V_={};Object.defineProperty(V_,"__esModule",{value:!0});var pZ={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M858.5 763.6a374 374 0 00-80.6-119.5 375.63 375.63 0 00-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 00-80.6 119.5A371.7 371.7 0 00136 901.8a8 8 0 008 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 008-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"}}]},name:"user",theme:"outlined"},gZ=V_.default=pZ;function F0(){return F0=Object.assign?Object.assign.bind():function(e){for(var t=1;ta.createElement(mt,F0({},e,{ref:t,icon:gZ})),yZ=a.forwardRef(hZ);function vZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState([]),[f,p]=a.useState([]),[h,b]=a.useState([]),[x,v]=a.useState(!1),[g,y]=a.useState(!1),[$,w]=a.useState(null),[I]=De.useForm(),C=De.useWatch("role_id",I),N=a.useMemo(()=>d.find(M=>M.role_id===C),[d,C]);async function E(){v(!0);try{const[M,O,k,B]=await Promise.all([d_(t),f_(t),m_(t).catch(()=>({items:[]})),p_(t).catch(()=>({items:[]}))]);u(M.items||[]),m(O.items||[]),p(k.items||[]),b(B.items||[])}catch(M){const O=M.message||String(M);o(O),i.error(O)}finally{v(!1)}}a.useEffect(()=>{E()},[t.accessToken]);function R(){w(null);const M=d.find(O=>O.code==="生成发布"||O.code==="publisher")||d.find(O=>O.code==="运维"||O.code==="operator")||d[0];I.resetFields(),I.setFieldsValue({name:"",role_id:M==null?void 0:M.role_id,app_slugs:[],channel_id:void 0,online_db_id:void 0,database_name:void 0}),y(!0)}function P(M){w(M),I.setFieldsValue({name:M.name||"",role_id:M.role_id||void 0,app_slugs:M.app_slugs||[],channel_id:M.channel_id||void 0,online_db_id:M.online_db_id||void 0,database_name:M.database_name||void 0}),y(!0)}async function T(M=!1){const O=await I.validateFields();r(!0);try{const k={channel_id:O.channel_id||"",online_db_id:O.online_db_id||"",database_name:(O.database_name||"").trim()||""};if($)await gE(t,$.agent_id,{name:O.name.trim(),role_id:O.role_id,app_slugs:O.app_slugs||[],...k,...M?{status:"active"}:{}}),i.success(M?"已保存并启用":"已保存"),s(M?`已保存并启用「${O.name.trim()}」`:`已保存「${O.name.trim()}」`);else{const B=await WY(t,{name:O.name.trim(),role_id:O.role_id,app_slugs:O.app_slugs||[],...k});l.success({title:"用户已创建",content:S.jsxs("div",{children:[S.jsx("p",{children:"请立即保存 client_secret(只显示一次):"}),S.jsx(Oe.Paragraph,{copyable:!0,code:!0,children:B.client_secret})]})}),s(`已创建用户「${O.name.trim()}」`)}y(!1),await E()}catch(k){const B=k.message||String(k);o(B),i.error(B)}finally{r(!1)}}const _=(M,O)=>{if(M==="active"){const k=!!(O!=null&&O.channel_id&&(O!=null&&O.online_db_id));return S.jsxs(Mt,{size:4,children:[S.jsx(Dt,{color:"success",children:"active"}),k?S.jsx(Dt,{color:"blue",children:"同步已绑"}):null]})}return M==="pending"?S.jsx(Dt,{color:"warning",children:"pending · 仅登记"}):S.jsx(Dt,{children:M})};return S.jsxs(rr,{title:"用户管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:E,loading:x,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:R,disabled:!d.length,children:"新建用户"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["当前租户 #",t.tenantId,"。用户挂在本租户下;同角色跨公司靠租户隔离,不靠再拆一套角色。 角色请在「角色管理」中维护。可绑定",S.jsx("strong",{children:"同步通道 / 线上库"}),":该智能体发布的模块与松离线数据进同一目标库(Z8)。"]}),S.jsx($n,{rowKey:"agent_id",loading:x||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"用户名称",dataIndex:"name",render:(M,O)=>S.jsxs("div",{children:[S.jsx("strong",{children:M||"—"}),O.host_key?S.jsx("div",{children:S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:12},children:["host: ",O.host_key]})}):null]})},{title:"client_id",dataIndex:"client_id",render:M=>S.jsx(Oe.Text,{code:!0,children:M})},{title:"状态",dataIndex:"status",width:160,render:(M,O)=>_(M,O)},{title:"角色",render:(M,O)=>O.role_name||O.role_code||"—"},{title:"权限",dataIndex:"permissions",width:260,render:M=>(M||[]).length?S.jsx(Mt,{size:[4,4],wrap:!0,children:(M||[]).map(O=>S.jsx(Dt,{color:["读取模块","发布模块","数据同步"].includes(Ma(O))?"blue":void 0,children:Ma(O)},O))}):S.jsx(Oe.Text,{type:"secondary",children:"未授权"})},{title:"可访问模块",dataIndex:"app_slugs",render:M=>(M||[]).length?S.jsx(Mt,{size:[4,4],wrap:!0,children:(M||[]).map(O=>S.jsx(Dt,{children:O},O))}):"—"},{title:"同步绑定",render:(M,O)=>{if(!O.channel_id&&!O.online_db_id&&!O.database_name)return"—";const k=f.find(B=>B.id===O.channel_id);return S.jsxs("span",{style:{fontSize:12},children:[(k==null?void 0:k.name)||O.channel_id||"无通道",S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",children:[O.online_db_id||"—",O.database_name?` · ${O.database_name}`:""]})]})}},{title:"操作",width:320,render:(M,O)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>P(O),children:"编辑"}),S.jsx(Ke,{size:"small",icon:O.status==="active"?S.jsx(k_,{}):S.jsx(zx,{}),onClick:async()=>{const k=O.status==="active"?"disabled":"active";if(k==="active"&&!O.role_id&&!(O.permissions||[]).length){i.warning("请先编辑并分配角色后再启用");return}r(!0);try{await gE(t,O.agent_id,{status:k}),i.success(`已设为 ${k}`),s(`已将「${O.name}」设为 ${k}`),await E()}catch(B){i.error(B.message||String(B)),o(B.message||String(B))}finally{r(!1)}},children:O.status==="active"?"停用":"启用"}),S.jsx(Ke,{size:"small",icon:S.jsx(jf,{}),onClick:async()=>{r(!0);try{const k=await KY(t,O.agent_id);l.success({title:"密钥已轮换",content:S.jsx(Oe.Paragraph,{copyable:!0,code:!0,children:k.client_secret})}),s(`已轮换「${O.name}」的 secret`)}catch(k){i.error(k.message||String(k)),o(k.message||String(k))}finally{r(!1)}},children:"轮换密钥"}),S.jsx(du,{title:`删除用户「${O.name}」?`,onConfirm:async()=>{r(!0);try{await UY(t,O.agent_id),i.success("已删除"),s(`已删除「${O.name}」`),await E()}catch(k){i.error(k.message||String(k)),o(k.message||String(k))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:$?`编辑用户 #${$.agent_id}`:"新建用户",open:g,onCancel:()=>y(!1),confirmLoading:n,width:640,destroyOnClose:!0,footer:[S.jsx(Ke,{onClick:()=>y(!1),children:"取消"},"cancel"),$?S.jsx(Ke,{onClick:()=>T(!0),loading:n,children:"保存并启用"},"activate"):null,S.jsx(Ke,{type:"primary",onClick:()=>T(!1),loading:n,children:$?"保存修改":"创建用户"},"ok")],children:S.jsxs(De,{form:I,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"用户名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"例如:产线宿主 A"})}),S.jsx(De.Item,{label:"角色",name:"role_id",rules:[{required:!0,message:"请选择角色"}],children:S.jsx(Qt,{placeholder:"请选择角色",options:d.map(M=>({value:M.role_id,label:`${M.name}(${M.code})`}))})}),N&&S.jsx(rr,{size:"small",title:"角色权限预览",style:{marginBottom:16},children:S.jsx(Mt,{size:[4,4],wrap:!0,children:(N.permissions||[]).map(M=>S.jsx(Dt,{children:Ma(M)},M))})}),S.jsx(De.Item,{label:"可访问模块(可选)",name:"app_slugs",extra:"留空=可自由发布任意自建模块,无需再逐个授权。仅当需要限制范围时再填写白名单(或 * 表示全部)。",children:S.jsx(Qt,{mode:"tags",placeholder:"可选限制:输入 slug 后回车;留空表示不限制",tokenSeparators:[","],allowClear:!0})}),S.jsx(Oe.Text,{strong:!0,children:"松离线 / 模块落库(Z8)"}),S.jsx(De.Item,{name:"channel_id",label:"同步通道",style:{marginTop:8},extra:"该智能体的模块与本机 sync 应对准同一通道线上库",children:S.jsx(Qt,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:"可选",options:f.map(M=>({value:M.id,label:`${M.name} (${M.id.slice(0,8)}…)`})),onChange:M=>{if(!M)return;const O=h.find(k=>k.channel_id===M);O&&I.setFieldsValue({online_db_id:O.online_db_id,database_name:O.display_name||O.database_name||I.getFieldValue("database_name")})}})}),S.jsx(De.Item,{name:"online_db_id",label:"线上库 ID",extra:"与 Binding.online_db_id 对齐;宇恒 push 须带此 id。可选从 Binding 带出。",children:S.jsx(Pt,{placeholder:"online_db_id",allowClear:!0,list:"agent-online-db-options"})}),S.jsx("datalist",{id:"agent-online-db-options",children:[...new Set(h.map(M=>M.online_db_id).filter(Boolean))].map(M=>S.jsx("option",{value:M},M))}),S.jsx(De.Item,{name:"database_name",label:"模块落库名",extra:"智能体新建发布时优先写入此 Postgres 库(database_per_app);与通道 remote 对齐为佳",children:S.jsx(Pt,{placeholder:"例如 appdb_t1_aisite",allowClear:!0})})]})})]})}function bZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState([]),[m,f]=a.useState(!1),[p,h]=a.useState(!1),[b]=De.useForm();async function x(){f(!0);try{const[g,y]=await Promise.all([JY(t),x$(t).catch(()=>({items:[]}))]);c(g.items||[]),d(y.items||[])}catch(g){const y=g.message||String(g);o(y),i.error(y)}finally{f(!1)}}a.useEffect(()=>{x()},[t.accessToken]);async function v(){const g=await b.validateFields();r(!0);try{const y=await ZY(t,{role:g.role,org_unit_id:g.org_unit_id||0,max_uses:g.max_uses,expires_in_hours:g.expires_in_hours||0});i.success(`邀请码已创建:${y.code}`),s(`邀请码 ${y.code}(角色 ${y.role})`),h(!1),await x()}catch(y){i.error(y.message||String(y)),o(y.message||String(y))}finally{r(!1)}}return S.jsxs(rr,{title:"邀请加入",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:x,loading:m,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>{b.setFieldsValue({role:"编辑",max_uses:1,expires_in_hours:72,org_unit_id:void 0}),h(!0)},children:"生成邀请码"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["把邀请码发给新用户。对方注册后处于「待加入」,输入邀请码即可成为本司成员。 成员角色:",S.jsx("strong",{children:"管理员"}),"(顶级,含数据同步)、",S.jsx("strong",{children:"编辑"}),"(读写数据)、",S.jsx("strong",{children:"只读"}),"(仅查看导出)。详见 docs/角色说明.md。"]}),S.jsx($n,{rowKey:"invite_id",loading:m||n,dataSource:l,pagination:{pageSize:10},columns:[{title:"邀请码",dataIndex:"code",render:g=>S.jsx(Oe.Text,{copyable:!0,code:!0,children:g})},{title:"加入角色",dataIndex:"role",width:100,render:g=>S.jsx(Dt,{children:rc(g)})},{title:"组织",width:140,render:(g,y)=>{if(!y.org_unit_id)return"全公司";const $=u.find(w=>w.org_unit_id===y.org_unit_id);return($==null?void 0:$.name)||`#${y.org_unit_id}`}},{title:"使用",width:100,render:(g,y)=>`${y.used_count}/${y.max_uses}`},{title:"状态",dataIndex:"status",width:110,render:g=>g==="active"?S.jsx(Dt,{color:"success",children:"有效"}):g==="revoked"?S.jsx(Dt,{children:"已撤销"}):g==="exhausted"?S.jsx(Dt,{color:"warning",children:"已用尽"}):S.jsx(Dt,{children:g})},{title:"过期",dataIndex:"expires_at",render:g=>g?new Date(g).toLocaleString():"不过期"},{title:"操作",width:120,render:(g,y)=>y.status==="active"?S.jsx(du,{title:"撤销该邀请码?",onConfirm:async()=>{r(!0);try{await eQ(t,y.invite_id),i.success("已撤销"),await x()}catch($){i.error($.message||String($))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(k_,{}),children:"撤销"})}):"—"}]}),S.jsx(tn,{title:"生成邀请码",open:p,onCancel:()=>h(!1),onOk:v,confirmLoading:n,okText:"生成",destroyOnClose:!0,children:S.jsxs(De,{form:b,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"加入后角色",name:"role",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"编辑",label:"编辑 — 可读写业务数据,不可发布/管组织"},{value:"只读",label:"只读 — 仅查看与导出"},{value:"管理员",label:"管理员 — 公司顶级(含数据同步)"}]})}),S.jsx(De.Item,{label:"绑定组织(可选)",name:"org_unit_id",children:S.jsx(Qt,{allowClear:!0,placeholder:"空=不绑组织(可见全公司数据)",options:u.map(g=>({value:g.org_unit_id,label:`${"— ".repeat(Math.max(0,g.depth-1))}${g.name}`}))})}),S.jsx(De.Item,{label:"可用次数",name:"max_uses",rules:[{required:!0}],children:S.jsx(Pf,{min:1,max:1e3,style:{width:"100%"}})}),S.jsx(De.Item,{label:"有效小时数(0=不过期)",name:"expires_in_hours",children:S.jsx(Pf,{min:0,max:8760,style:{width:"100%"}})})]})})]})}function xZ(e){const{session:t,onOpenPublished:n,onContinueDraft:r}=e,{modal:o}=wo.useApp(),[s,i]=a.useState([]),[l,c]=a.useState(""),[u,d]=a.useState(!1),[m,f]=a.useState(!1);async function p(){d(!0);try{const x=await oc(t);i(x.items||[]),c(x.scope||"")}catch(x){_d.error(x.message||String(x))}finally{d(!1)}}function h(){o.confirm({title:"一键开启全部业务表导入?",content:"将为本公司所有已发布模块补齐蓝图 import/export(无需逐个再发布)。只读表不会改动。",okText:"开启",onOk:async()=>{f(!0);try{const x=await OY(t,!1);_d.success(x.message||`已更新 ${x.updated} 个模块`),await p()}catch(x){throw _d.error(x.message||String(x)),x}finally{f(!1)}}})}a.useEffect(()=>{p()},[t.accessToken]);const b=x=>{const v=x.status_label||x.status;return x.status==="published"?S.jsx(Dt,{color:"success",children:v}):x.status==="failed"?S.jsx(Dt,{color:"error",children:v}):S.jsx(Dt,{color:"processing",children:v||"在建"})};return S.jsxs(rr,{title:"模块管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(dJ,{}),loading:m,onClick:()=>h(),children:"一键开启导入"}),S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:p,loading:u,children:"刷新"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["管理账号(如 owner)可查看本租户",S.jsx("strong",{children:"全部模块"}),",含",S.jsx("strong",{children:"在建"}),"与已发布。 智能体默认不限制模块(可自由发布自建 slug);仅当配置了白名单时才受限。 「一键开启导入」修复旧模块因蓝图缺 import 导致的导入 400(Z9e)。",l==="all"?" 当前范围:管理全部。":l==="open"?" 当前范围:智能体开放。":l==="granted"?" 当前范围:白名单。":null]}),S.jsx($n,{rowKey:"app_id",loading:u,dataSource:s,pagination:{pageSize:20},columns:[{title:"模块名称",dataIndex:"name"},{title:"slug",dataIndex:"slug",render:x=>S.jsx(Oe.Text,{code:!0,children:x})},{title:"状态",width:110,render:(x,v)=>b(v)},{title:"页面数",dataIndex:"page_count",width:80},{title:"实体数",dataIndex:"entity_count",width:80},{title:"更新时间",dataIndex:"updated_at",width:200},{title:"操作",width:200,render:(x,v)=>S.jsx(Mt,{children:v.status==="published"?S.jsx(Ke,{type:"link",onClick:()=>n(v.slug),children:"打开"}):S.jsx(Ke,{type:"link",onClick:()=>r(v.slug),children:"继续编辑"})})}],locale:{emptyText:"暂无模块。生成蓝图后会登记为「在建」,发布成功后变为「已发布」。"}})]})}function $Z(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState(5),[m,f]=a.useState(!1),[p,h]=a.useState(!1),[b,x]=a.useState(null),[v]=De.useForm();async function g(){f(!0);try{const C=await x$(t);c(C.items||[]),C.max_depth&&d(C.max_depth)}catch(C){const N=C.message||String(C);o(N),i.error(N)}finally{f(!1)}}a.useEffect(()=>{g()},[t.accessToken]);const y=a.useMemo(()=>(l||[]).filter(C=>C.depth({value:C.org_unit_id,label:`${"— ".repeat(Math.max(0,C.depth-1))}${C.name}(L${C.depth})`})),[l,u]);function $(C){x(null),v.resetFields(),v.setFieldsValue({parent_id:C||void 0,name:"",code:""}),h(!0)}function w(C){x(C),v.setFieldsValue({name:C.name,code:C.code||"",parent_id:C.parent_id||void 0}),h(!0)}async function I(){const C=await v.validateFields();r(!0);try{if(b)await nQ(t,b.org_unit_id,{name:C.name.trim(),code:(C.code||"").trim()}),i.success("已保存"),s(`已保存组织「${C.name.trim()}」`);else{const N=await tQ(t,{parent_id:C.parent_id||0,name:C.name.trim(),code:(C.code||"").trim()});i.success(`已创建「${N.name}」`),s(`已创建组织「${N.name}」(深度 ${N.depth}/${u})`)}h(!1),await g()}catch(N){i.error(N.message||String(N)),o(N.message||String(N))}finally{r(!1)}}return S.jsxs(rr,{title:"组织管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:g,loading:m,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>$(),children:"新建顶级组织"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["公司(租户)下可建多级组织,最多 ",u," 级。成员通过邀请码绑定组织后,只能访问本组织及下级数据;公司管理员(owner)可看全公司。"]}),S.jsx($n,{rowKey:"org_unit_id",loading:m||n,dataSource:l,pagination:{pageSize:20},columns:[{title:"名称",dataIndex:"name",render:(C,N)=>S.jsxs("span",{style:{paddingLeft:(N.depth-1)*16},children:[N.depth>1?"└ ":"",C]})},{title:"编码",dataIndex:"code",width:140,render:C=>C||"—"},{title:"层级",dataIndex:"depth",width:90,render:C=>S.jsxs(Dt,{children:["L",C,"/",u]})},{title:"路径",dataIndex:"path",ellipsis:!0},{title:"操作",width:260,render:(C,N)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(Bo,{}),disabled:N.depth>=u,onClick:()=>$(N.org_unit_id),children:"下级"}),S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>w(N),children:"编辑"}),S.jsx(du,{title:`删除「${N.name}」?需先删下级`,onConfirm:async()=>{r(!0);try{await rQ(t,N.org_unit_id),i.success("已删除"),await g()}catch(E){i.error(E.message||String(E)),o(E.message||String(E))}finally{r(!1)}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:b?`编辑组织 #${b.org_unit_id}`:"新建组织",open:p,onCancel:()=>h(!1),onOk:I,confirmLoading:n,destroyOnClose:!0,okText:"保存",children:S.jsxs(De,{form:v,layout:"vertical",style:{marginTop:12},children:[!b&&S.jsx(De.Item,{label:"上级组织",name:"parent_id",children:S.jsx(Qt,{allowClear:!0,placeholder:"空=顶级组织",options:y})}),S.jsx(De.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"如:华东事业部 / 项目一组"})}),S.jsx(De.Item,{label:"编码(可选,租户内唯一)",name:"code",children:S.jsx(Pt,{placeholder:"如 east / proj_a",disabled:!!b&&!!b.code})})]})})]})}async function sc(e,t,n,r){return Nr(t.role)?await new Promise(s=>{e.confirm({title:"超管写操作确认(1/2)",content:S.jsxs("div",{children:[S.jsxs("p",{children:["你正在以",S.jsx("strong",{children:"平台超级管理员"}),"身份修改某公司内部数据(不是该公司管理员账号)。"]}),S.jsxs("p",{children:["操作:",S.jsx("strong",{children:n})]}),r?S.jsx("p",{style:{color:"#666"},children:r}):null,S.jsx("p",{children:"日常应由该公司管理员处理。是否继续?"})]}),okText:"继续",cancelText:"取消",onOk:()=>s(!0),onCancel:()=>s(!1)})})?new Promise(s=>{e.confirm({title:"超管写操作确认(2/2)",content:S.jsxs("div",{children:[S.jsxs("p",{children:["请再次确认:将执行「",n,"」。"]}),S.jsx("p",{style:{color:"#b42318"},children:"此操作会影响该公司业务配置或成员权限,请确认无误。"})]}),okText:"确认执行",okButtonProps:{danger:!0},cancelText:"取消",onOk:()=>s(!0),onCancel:()=>s(!1)})}):!1:!0}async function SZ(e,t,n){return new Promise(r=>{e.confirm({title:"打开公司管理视图",content:S.jsxs("div",{children:[S.jsxs("p",{children:["以",S.jsx("strong",{children:"平台超级管理员"}),"身份打开「",S.jsx("strong",{children:t}),"」(#",n,")。"]}),S.jsx("p",{children:"这是你的平台管理能力,不是登录成该公司账号。写操作仍会再次确认。"})]}),okText:"打开",cancelText:"取消",onOk:()=>r(!0),onCancel:()=>r(!1)})})}function CZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState(!1),[f,p]=a.useState(!1),[h,b]=a.useState(null),[x,v]=a.useState([]),[g,y]=a.useState([]),[$]=De.useForm();async function w(){m(!0);try{const[E,R]=await Promise.all([f_(t),h_(t)]);u(E.items||[]),y(R.modules||[])}catch(E){const R=E.message||String(E);o(R),i.error(R)}finally{m(!1)}}a.useEffect(()=>{w()},[t.accessToken,t.tenantId]);function I(){b(null),v([]),$.resetFields(),$.setFieldsValue({permissions:[]}),p(!0)}function C(E){b(E),v([...E.permissions||[]]),$.setFieldsValue({code:E.code,name:E.name,description:E.description,permissions:E.permissions||[]}),p(!0)}async function N(){const E=await $.validateFields();if(!x.length){i.warning("请至少勾选一项权限");return}const R=h?`保存智能体角色「${E.name.trim()}」及其权限`:`创建智能体角色「${E.name.trim()}」`;if(await sc(l,t,R)){r(!0);try{h?(await GY(t,h.role_id,{name:E.name.trim(),description:(E.description||"").trim(),permissions:x}),i.success(`已保存角色「${E.name.trim()}」`),s(`已保存角色「${E.name.trim()}」`)):(await qY(t,{code:(E.code||"").trim(),name:E.name.trim(),description:(E.description||"").trim(),permissions:x}),i.success(`已创建角色「${E.name.trim()}」`),s(`已创建角色「${E.name.trim()}」`)),p(!1),await w()}catch(T){const _=T.message||String(T);o(_),i.error(_)}finally{r(!1)}}}return S.jsxs(rr,{title:"角色管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:w,loading:d,children:"刷新"}),S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:I,children:"新建角色"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["此处配置",S.jsx("strong",{children:"智能体角色"}),"。可选权限以平台超级管理员授予本公司的额度为准,无法勾选未授权项。 默认角色:生成发布 / 只读 / 读写 / 运维。"]}),S.jsx($n,{rowKey:"role_id",loading:d||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"名称",dataIndex:"name",width:140},{title:"编码",dataIndex:"code",width:140,render:E=>S.jsx(Dt,{children:E})},{title:"说明",dataIndex:"description",ellipsis:!0},{title:"权限",dataIndex:"permissions",render:E=>(E||[]).length?S.jsxs(Mt,{size:[4,4],wrap:!0,children:[(E||[]).slice(0,8).map(R=>S.jsx(Dt,{children:Ma(R)},R)),(E||[]).length>8?S.jsxs(Dt,{children:["+",(E||[]).length-8]}):null]}):"—"},{title:"操作",width:180,render:(E,R)=>S.jsxs(Mt,{children:[S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>C(R),children:"编辑"}),S.jsx(du,{title:`删除角色「${R.name}」?`,onConfirm:async()=>{if(await sc(l,t,`删除智能体角色「${R.name}」`)){r(!0);try{await XY(t,R.role_id),i.success("已删除"),s(`已删除角色「${R.name}」`),await w()}catch(T){i.error(T.message||String(T)),o(T.message||String(T))}finally{r(!1)}}},children:S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),children:"删除"})})]})}]}),S.jsx(tn,{title:h?`编辑角色 #${h.role_id}`:"新建角色",open:f,onCancel:()=>p(!1),onOk:N,confirmLoading:n,width:720,destroyOnClose:!0,okText:"保存",children:S.jsxs(De,{form:$,layout:"vertical",style:{marginTop:12},children:[S.jsx(De.Item,{label:"角色编码",name:"code",rules:h?[]:[{required:!0,message:"请填写中文编码,如 只读"}],children:S.jsx(Pt,{placeholder:"如 只读 / 读写 / 自定义运维",disabled:!!h})}),S.jsx(De.Item,{label:"角色名称",name:"name",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"与编码可相同,如:只读"})}),S.jsx(De.Item,{label:"说明",name:"description",children:S.jsx(Pt.TextArea,{rows:2,placeholder:"可选"})}),S.jsx(De.Item,{label:"权限分配",required:!0,extra:"仅显示本公司权限额度内的选项",children:S.jsx(wY,{value:x,onChange:v,allowedModules:g})})]})})]})}function wZ(e){const t={};for(const n of(e||"").split(",")){const[r,o]=n.split(":").map(s=>s.trim());r&&o&&(t[r]=o)}return t}function EZ(e){const t=(e||"").replace(/:[^:@/]+@/,":***@"),n=t.match(/(?:^|[\\/])([^\\/?#]+\.db)(?:\?|$)/i);return n?n[1]:t.length>56?`${t.slice(0,56)}…`:t}function xE(e){return(e.database_name||"").trim()||e.local_database_id}function $E(e){return(e.display_name||"").trim()||e.online_db_id}function IZ(e){const t=(e.note||"").toLowerCase();if(t.includes("smoke")||t.includes("user-jwt"))return!0;const n=(e.local_database_id||"").toLowerCase(),r=(e.online_db_id||"").toLowerCase();return n.startsWith("local_")||r.startsWith("online_")}function SE(e,t){var s;const n=t.filter(i=>i.channel_id===e.id),r=n.map(i=>(i.database_name||"").trim()).filter(Boolean);if(r.length)return r[0];const o=n.map(i=>(i.display_name||"").trim()).filter(Boolean);return o.length?o[0]:(e.name||"").trim()?e.name.trim():((s=e.remote)==null?void 0:s.driver)||"线上库"}function PZ(e,t){var i;const n=t.filter(l=>l.channel_id===e.id),r=n.map(l=>l.online_db_id).filter(Boolean),o=[...new Set(r)];return o.length?n.map(l=>(l.database_name||"").trim()).find(Boolean)&&((i=n[0])!=null&&i.local_database_id)?`${n[0].local_database_id} ↔ ${o.join(" · ")}`:o.join(" · "):""}function CE(e,t){return{id:t,name:e.name,direction:e.direction,conflict_policy:e.conflict_policy,poll_interval_ms:e.poll_interval_ms||500,agent_id:e.agent_id||void 0,app_slug:(e.app_slug||"").trim()||void 0,local:{driver:e.local.driver,dsn:e.local.dsn,tables:(e.local.tables||"").split(",").map(n=>n.trim()).filter(Boolean)},remote:{driver:e.remote.driver,dsn:e.remote.dsn,tables:(e.remote.tables||"").split(",").map(n=>n.trim()).filter(Boolean)},pk_columns:wZ(e.pk_columns)}}function NZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i}=wo.useApp(),[l,c]=a.useState([]),[u,d]=a.useState([]),[m,f]=a.useState([]),[p,h]=a.useState([]),[b,x]=a.useState([]),[v,g]=a.useState(!1),[y,$]=a.useState(!1),[w,I]=a.useState(null),[C,N]=a.useState(!1),[E,R]=a.useState(void 0),[P,T]=a.useState(!1),[_,M]=a.useState(null),[O,k]=a.useState("remote"),[B,j]=a.useState(null),[z,A]=a.useState(!1),[D,L]=a.useState(!1),[H,K]=a.useState(null),[V,W]=a.useState(!1),[q]=De.useForm(),ee=C?u:u.filter(te=>!IZ(te)),se=u.length-ee.length,le=E?l.filter(te=>{var Y;return te.agent_id===E||((Y=p.find(de=>de.agent_id===E))==null?void 0:Y.channel_id)===te.id}):l;async function ce(){g(!0);try{const[te,Y,de,ue,ge]=await Promise.all([m_(t),p_(t).catch(()=>({items:[]})),d_(t).catch(()=>({items:[]})),oc(t).catch(()=>({items:[]})),gQ(t).catch(()=>({items:[]}))]);c(te.items||[]),d(Y.items||[]),h(de.items||[]),f(ge.items||[]),x((ue.items||[]).filter(we=>we.status==="published"||!we.status).map(we=>({value:we.slug,label:`${we.name||we.slug} (${we.slug})`})))}catch(te){const Y=te.message||String(te);o(Y),i.error(Y)}finally{g(!1)}}a.useEffect(()=>{ce()},[t.accessToken]);function G(){I(null),q.setFieldsValue({name:"本地 B ↔ 线上 A",direction:"local_to_remote",conflict_policy:"lww_source",poll_interval_ms:500,agent_id:void 0,app_slug:void 0,local:{driver:"sqlite",dsn:"file:./data/local.db",tables:"article"},remote:{driver:"postgres",dsn:"postgres://user:pass@127.0.0.1:5432/app?sslmode=disable",tables:"article"},pk_columns:"article:id"}),$(!0)}function ne(te){I(te),q.setFieldsValue({name:te.name,direction:te.direction,conflict_policy:te.conflict_policy,poll_interval_ms:te.poll_interval_ms,agent_id:te.agent_id||void 0,app_slug:te.app_slug||void 0,local:{driver:te.local.driver,dsn:te.local.dsn,tables:(te.local.tables||[]).join(",")},remote:{driver:te.remote.driver,dsn:te.remote.dsn,tables:(te.remote.tables||[]).join(",")},pk_columns:Object.entries(te.pk_columns||{}).map(([Y,de])=>`${Y}:${de}`).join(",")}),$(!0)}async function re(te,Y="remote"){M(te),k(Y),T(!0),j(null),A(!0);try{const de=await fQ(t,te.id,{side:Y,include_sync_meta:!0});j(de)}catch(de){i.error(de.message||String(de)),T(!1)}finally{A(!1)}}async function U(te){if(_){W(!0),L(!0),K(null);try{const Y=await mQ(t,_.id,{table:te,side:O,limit:50});K(Y)}catch(Y){i.error(Y.message||String(Y)),L(!1)}finally{W(!1)}}}function J(te){if(!te)return"—";const Y=new Date(te);return Number.isNaN(Y.getTime())?te:Y.toLocaleString()}async function oe(te){r(!0);try{const Y=await uQ(t,te.id);if(!Y.latest&&!Y.previous){i.warning("尚无成功同步快照。请先完成一次同步(含自动推送),约 30 秒后生成。");return}let de=Y.latest?"latest":"previous";const ue=[];Y.latest&&ue.push({value:"latest",label:`最近一次 · ${J(Y.latest.synced_at)}(${Y.latest.row_count??0} 行 / ${Y.latest.table_count??0} 表)`}),Y.previous&&ue.push({value:"previous",label:`上一代 · ${J(Y.previous.synced_at)}(${Y.previous.row_count??0} 行 / ${Y.previous.table_count??0} 表)`}),tn.confirm({title:`数据恢复 · ${te.name||te.id}`,width:560,content:S.jsxs("div",{children:[S.jsxs("p",{style:{marginTop:0},children:["将",S.jsx("strong",{children:"线上库"}),"恢复为所选同步快照(upsert 并删除快照中不存在的行)。本机数据需宇恒下次同步/pull 从线上补回。"]}),S.jsx("p",{style:{color:"rgba(0,0,0,0.45)",fontSize:13},children:"若误删后又发生成功自动同步,最新快照可能已含删除后状态,请改选「上一代」。"}),S.jsxs("div",{style:{marginTop:12},children:[S.jsx(Oe.Text,{type:"secondary",children:"恢复到"}),S.jsx(Qt,{style:{width:"100%",marginTop:6},defaultValue:de,options:ue,onChange:ge=>{de=ge}})]})]}),okText:"确认恢复",okType:"danger",cancelText:"取消",onOk:async()=>{try{const ge=await dQ(t,te.id,{which:de,confirm:!0});i.success(`已恢复:写入 ${ge.upserted??0} 行,清理多余 ${ge.deleted??0} 行(快照 ${J(ge.synced_at)})`),s("线上库已按同步快照恢复"),await ce()}catch(ge){throw i.error(ge.message||String(ge)),ge}}})}catch(Y){i.error(Y.message||String(Y))}finally{r(!1)}}function Z(te){if(!_)return;const Y=O==="remote"?"线上库":"本机端(通道 local)";tn.confirm({title:`删除表「${te}」?`,content:S.jsxs("div",{children:[S.jsxs("p",{children:["将从",S.jsx("strong",{children:Y}),"删除该表及同步元数据残留。此操作不可恢复。"]}),S.jsxs("p",{style:{marginBottom:0},children:["松离线",S.jsx("strong",{children:"不会"}),"把删表同步到另一侧。若本机仍有同名表,下次 push/ensure 可能再次出现在线上。"]})]}),okText:"确认删除",okType:"danger",cancelText:"取消",onOk:async()=>{try{const de=await pQ(t,_.id,{table:te,side:O});i.success(de.message||(de.dropped?"已删除":"表不存在")),(H==null?void 0:H.table)===te&&L(!1),await re(_,O)}catch(de){throw i.error(de.message||String(de)),de}}})}async function Q(){const te=await q.validateFields();r(!0);try{const Y=CE(te,w==null?void 0:w.id),de=w?await sQ(t,w.id,Y):await oQ(t,Y),ue=(de==null?void 0:de.id)||(w==null?void 0:w.id);if(ue)try{await hE(t,ue),s("同步通道已保存并启动")}catch{s("同步通道已保存(启动失败时可手动点「启动」)")}else s("同步通道已保存");$(!1),await ce()}catch(Y){i.error(Y.message||String(Y))}finally{r(!1)}}async function ae(){var Y,de;const te=await q.validateFields();r(!0);try{const ue=CE(te),ge=await aQ(t,{local:ue.local,remote:ue.remote,side:"both"}),we=(Y=ge.local)==null?void 0:Y.ok,he=(de=ge.remote)==null?void 0:de.ok;we&&he?i.success("本地与线上数据库均可连接"):i.warning(JSON.stringify(ge))}catch(ue){i.error(ue.message||String(ue))}finally{r(!1)}}return S.jsxs("div",{className:"panel",children:[S.jsx(Oe.Title,{level:4,style:{marginTop:0},children:"数据同步"}),S.jsxs(Oe.Paragraph,{type:"secondary",children:["仅本",S.jsx("strong",{children:"公司顶级权限(管理员)"}),"可配置通道 DSN / 线上库落点;通道按公司隔离。 终端用户以 ",S.jsx(Oe.Text,{code:!0,children:"Binding"})," + 登录 JWT 为同步权限; 库级选「同步」后该库",S.jsx("strong",{children:"全部表"}),"可上云,管理员",S.jsx("strong",{children:"不必"}),"按业务表维护通道白名单。 通道可绑定",S.jsx("strong",{children:"智能体 + 模块"}),":在「用户管理」为智能体填写同步通道/线上库/落库名后,可按智能体筛通道; 模块发布(智能体 Token)优先写入绑定库。本机库管理模块表见宇恒侧(Z8f)。 仅线上/首启可用 pull·bootstrap 从线上灌回本机。默认客户",S.jsx("strong",{children:"无感"}),":未开通不走松离线。 线上库 A 推荐 ",S.jsx(Oe.Text,{code:!0,children:"postgres"}),";多服务器每库一条通道。"]}),S.jsx(po,{type:"info",showIcon:!0,style:{marginBottom:12},message:"冲突已自动按 LWW 处理;覆盖审计请到「平台超管 · 租户/公司 · LWW 覆盖日志」查看。公司侧无冲突台。"}),S.jsxs(Mt,{style:{marginBottom:12},wrap:!0,children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:G,children:"新建通道"}),S.jsx(Ke,{icon:S.jsx(ls,{}),loading:v,onClick:()=>void ce(),children:"刷新"}),S.jsx(Qt,{allowClear:!0,placeholder:"按智能体筛选通道",style:{minWidth:220},value:E,onChange:te=>R(te),options:p.map(te=>({value:te.agent_id,label:`${te.name}${te.channel_id?" · 已绑通道":""}`}))})]}),S.jsx($n,{rowKey:"id",loading:v,dataSource:le,pagination:!1,locale:{emptyText:E?"该智能体暂无同步通道":"该公司暂无同步通道(未绑定智能体或尚未创建通道)"},columns:[{title:"通道 ID",dataIndex:"id",width:280,render:te=>S.jsx(Oe.Text,{copyable:{text:te},style:{fontSize:12},children:te})},{title:"名称",dataIndex:"name"},{title:"方向",dataIndex:"direction",render:te=>S.jsx(Dt,{children:te})},{title:"本地",render:(te,Y)=>`${Y.local.driver}`},{title:"线上",render:(te,Y)=>{var we,he;const de=SE(Y,u),ue=PZ(Y,u),ge=EZ(((we=Y.remote)==null?void 0:we.dsn)||"");return S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:de}),S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:12},children:[(he=Y.remote)==null?void 0:he.driver,ue?` · ${ue}`:"",ge?` · ${ge}`:""]})]})}},{title:"智能体/模块",render:(te,Y)=>{const de=p.find(we=>we.agent_id===Y.agent_id),ue=b.find(we=>we.value===Y.app_slug),ge=Y.app_slug?ue?`${(ue.label.split(" (")[0]||ue.label).trim()}`:Y.app_slug:"未绑模块";return S.jsxs("span",{children:[de?de.name:Y.agent_id?`#${Y.agent_id}`:"—",S.jsx("br",{}),S.jsxs(Oe.Text,{type:"secondary",style:{fontSize:11},children:[ge,Y.app_slug&&ue?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx("span",{style:{opacity:.75},children:Y.app_slug})]}):null]})]})}},{title:"状态",render:(te,Y)=>Y.enabled?S.jsx(Dt,{color:"green",children:"运行中"}):S.jsx(Dt,{children:"已停止"})},{title:"推送次数",render:(te,Y)=>{var de,ue;return S.jsxs("span",{children:["↑",((de=Y.stats)==null?void 0:de.pushed_ok)||0,(ue=Y.stats)!=null&&ue.pushed_skipped?`(跳过 ${Y.stats.pushed_skipped})`:"",S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:11},children:"push 成功次数,非表数"})]})}},{title:"操作",render:(te,Y)=>S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{size:"small",icon:S.jsx(tZ,{}),onClick:()=>void re(Y,"remote"),children:"查看线上表"}),S.jsx(Ke,{size:"small",onClick:()=>ne(Y),children:"配置"}),Y.enabled?S.jsx(Ke,{size:"small",icon:S.jsx(BJ,{}),onClick:async()=>{await lQ(t,Y.id),await ce()},children:"停止"}):S.jsx(Ke,{size:"small",type:"primary",icon:S.jsx(DJ,{}),onClick:async()=>{try{await hE(t,Y.id),s("同步已启动"),await ce()}catch(de){i.error(de.message||String(de))}},children:"启动"}),S.jsx(Ke,{size:"small",onClick:async()=>{r(!0);try{const ue=((await cQ(t,Y.id)).reports||[]).map(ge=>`${ge.table}: 补推${ge.patched_push} 补拉${ge.patched_pull}(仅本地${(ge.only_local||[]).length} 仅线上${(ge.only_remote||[]).length})`);i.success(ue.length?ue.join(";"):"同步修复完成,无差异"),s("同步修复完成"),await ce()}catch(de){const ue=de.message||String(de);/过于频繁|429|Too Many/i.test(ue)?i.warning(ue||"对账过于频繁,请稍后再试"):i.error(ue)}finally{r(!1)}},children:"同步修复"}),S.jsx(Ke,{size:"small",onClick:()=>void oe(Y),children:"数据恢复"}),S.jsx(Ke,{size:"small",danger:!0,onClick:()=>{tn.confirm({title:`删除通道「${Y.name||Y.id}」?`,content:Y.is_system_default?"这是公司默认同步通道。删除后将自动重建并重挂库绑定,账号落点不会丢失。":"删除后,仍挂在此通道上的绑定会自动改挂公司默认同步通道。",okText:"确认删除",okType:"danger",cancelText:"取消",onOk:async()=>{r(!0);try{const de=await iQ(t,Y.id);de.heal_error?i.warning(`通道已删,自愈未完成:${de.heal_error}`):de.recreated_default?i.success("已删除;公司默认同步通道已自动重建并重挂绑定"):i.success("已删除"),await ce()}catch(de){throw i.error(de.message||String(de)),de}finally{r(!1)}}})},children:"删除"})]})}]}),S.jsx(Oe.Title,{level:5,style:{marginTop:28},children:"绑定码(发给终端开通)"}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["关联本公司默认同步落点;终端用 ",S.jsx(Oe.Text,{code:!0,children:"POST /auth/bind-code/redeem"})," ","兑换。生产联调成员手机请用 ",S.jsx(Oe.Text,{code:!0,children:"13531041944"}),",勿用超管号。"]}),S.jsx(Mt,{style:{marginBottom:12},children:S.jsx(Ke,{type:"primary",disabled:n,onClick:async()=>{r(!0);try{const te=await hQ(t,{max_uses:1,expires_hours:168});i.success(`已生成绑定码 ${te.code}`),s(`绑定码 ${te.code}(可复制发给用户)`),await ce()}catch(te){i.error(te.message||String(te))}finally{r(!1)}},children:"生成绑定码"})}),S.jsx($n,{rowKey:"code",loading:v,dataSource:m,pagination:!1,locale:{emptyText:"暂无绑定码"},columns:[{title:"绑定码",dataIndex:"code",render:te=>S.jsx(Oe.Text,{copyable:!0,code:!0,children:te})},{title:"通道",dataIndex:"channel_id",render:te=>te?S.jsxs(Oe.Text,{copyable:{text:te},children:[te.slice(0,8),"…"]}):"—"},{title:"次数",render:(te,Y)=>`${Y.used_count}/${Y.max_uses}`,width:80},{title:"过期",dataIndex:"expires_at",render:te=>te?new Date(te).toLocaleString():"—"},{title:"状态",width:90,render:(te,Y)=>Y.revoked?S.jsx(Dt,{color:"default",children:"已撤销"}):Y.used_count>=Y.max_uses?S.jsx(Dt,{children:"已用尽"}):Y.expires_at&&new Date(Y.expires_at).getTime()S.jsx(Ke,{size:"small",danger:!0,disabled:!!Y.revoked||n,onClick:async()=>{r(!0);try{await yQ(t,Y.code),s(`已撤销 ${Y.code}`),await ce()}catch(de){i.error(de.message||String(de))}finally{r(!1)}},children:"撤销"})}]}),S.jsx(Oe.Title,{level:5,style:{marginTop:28},children:"库绑定(本地 ↔ 线上)"}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:[S.jsx(Oe.Text,{code:!0,children:"local_database_id"})," 与"," ",S.jsx(Oe.Text,{code:!0,children:"online_db_id"})," ",S.jsx("strong",{children:"本就可以不同"}),"(映射关系,不是要求同名)。 可读名靠宇恒 ensure 时带 ",S.jsx(Oe.Text,{code:!0,children:"database_name"})," /"," ",S.jsx(Oe.Text,{code:!0,children:"display_name"}),";通道「线上」列优先用本地可读名。默认隐藏联调烟雾 Binding(",S.jsx(Oe.Text,{code:!0,children:"local_*"})," / note=smoke)。"]}),S.jsx(Mt,{style:{marginBottom:8},children:S.jsxs(go,{checked:C,onChange:te=>N(te.target.checked),children:["显示联调烟雾 Binding",se>0?`(已隐藏 ${se} 条)`:""]})}),S.jsx($n,{rowKey:"id",loading:v,dataSource:ee,pagination:!1,locale:{emptyText:"暂无 Binding(客户端选「同步」并登记后出现)"},columns:[{title:"本地库名",render:(te,Y)=>S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:xE(Y)}),Y.database_name?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:Y.local_database_id})]}):null]})},{title:"线上库名",render:(te,Y)=>S.jsxs("span",{children:[S.jsx(Oe.Text,{strong:!0,children:$E(Y)}),Y.display_name?S.jsxs(S.Fragment,{children:[S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:Y.online_db_id})]}):null]})},{title:"映射",render:(te,Y)=>S.jsxs(Oe.Text,{style:{fontSize:13},children:[xE(Y)," ↔ ",$E(Y)]})},{title:"通道",dataIndex:"channel_id",render:te=>{var ue;if(!te)return"—";const Y=l.find(ge=>ge.id===te);if(!Y)return S.jsxs(Oe.Text,{type:"danger",style:{fontSize:12},children:["通道已删除 · ",te.slice(0,8),"…"]});const de=(((ue=Y.remote)==null?void 0:ue.tables)||[]).join(", ");return S.jsxs("span",{children:[Y.name||te,S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:11},children:de?`策略表(参考,非整库限制):${de}`:"整库同步中(Binding 任意表可 push)"})]})}},{title:"备注",dataIndex:"note",ellipsis:!0},{title:"共享",width:70,render:(te,Y)=>Y.shared?S.jsx(Dt,{color:"blue",children:"共享"}):S.jsx(Oe.Text,{type:"secondary",children:"个人"})}]}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:16},children:["「同步修复」有最小间隔限流(默认 5 分钟)。 ↑ 推送次数 = agent push 成功次数,不是业务表数量。 本地有、线上没有的表(如尚未 push 的业务表)属正常,不是 Binding 映射错了。 Binding 标 ",S.jsx(Oe.Text,{code:!0,children:"shared=true"})," 为公司共享库(仅管理员可设)。"]}),S.jsxs(tn,{title:_?`线上库表 · ${SE(_,u)}${O==="local"?"(本机端)":""}`:"库表",open:P,onCancel:()=>T(!1),width:820,footer:S.jsxs(Mt,{children:[S.jsxs(Ke,{loading:z,onClick:()=>_&&void re(_,O==="remote"?"local":"remote"),children:["切换到",O==="remote"?"本机端":"线上"]}),S.jsx(Ke,{loading:z,onClick:()=>_&&void re(_,O),children:"刷新"}),S.jsx(Ke,{type:"primary",onClick:()=>T(!1),children:"关闭"})]}),children:[B!=null&&B.dsn_hint?S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:[B.driver," · ",B.dsn_hint,B.message?` · ${B.message}`:""]}):null,S.jsx($n,{rowKey:"name",loading:z,dataSource:((B==null?void 0:B.tables)||[]).filter(te=>!String(te.name||"").startsWith("_ajz_")),pagination:!1,size:"small",locale:{emptyText:"暂无业务表(尚未 push 或连不上库)"},columns:[{title:"表名",dataIndex:"name"},{title:"行数",dataIndex:"row_count",width:90,render:te=>S.jsx(Oe.Text,{strong:!0,children:te})},{title:"字段数",dataIndex:"column_count",width:90},{title:"字段",dataIndex:"columns",ellipsis:!0,render:te=>(te||[]).join(", ")},{title:"操作",width:168,render:(te,Y)=>S.jsxs(Mt,{size:4,children:[S.jsx(Ke,{size:"small",icon:S.jsx(Q4,{}),onClick:()=>void U(Y.name),children:"预览"}),S.jsx(Ke,{size:"small",danger:!0,icon:S.jsx(qm,{}),onClick:()=>Z(Y.name),children:"删表"})]})}]}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:12,marginBottom:0},children:[((B==null?void 0:B.tables)||[]).some(te=>String(te.name||"").startsWith("_ajz_"))?S.jsxs(S.Fragment,{children:["已隐藏同步系统表 ",S.jsx(Oe.Text,{code:!0,children:"_ajz_*"}),"(版本/outbox,不是业务模块表)。"]}):null,"本机有、这里没有的表 = 尚未 push/ensure。「删表」只删当前查看侧,不会同步到另一侧。"]})]}),S.jsx(tn,{title:H?`预览 · ${H.table}(共 ${H.total} 行,显示前 ${H.limit})`:"预览",open:D,onCancel:()=>L(!1),width:960,footer:S.jsx(Ke,{type:"primary",onClick:()=>L(!1),children:"关闭"}),children:S.jsx($n,{loading:V,dataSource:((H==null?void 0:H.rows)||[]).map((te,Y)=>({...te,__k:Y})),rowKey:"__k",size:"small",scroll:{x:!0},pagination:!1,columns:((H==null?void 0:H.columns)||[]).map(te=>({title:te,dataIndex:te,ellipsis:!0,render:Y=>Y==null?S.jsx(Oe.Text,{type:"secondary",children:"null"}):String(Y)}))})}),S.jsx(tn,{title:w?"编辑同步通道":"新建同步通道",open:y,onCancel:()=>$(!1),width:720,footer:S.jsxs(Mt,{children:[S.jsx(Ke,{icon:S.jsx(b_,{}),loading:n,onClick:()=>void ae(),children:"测试连接"}),S.jsx(Ke,{onClick:()=>$(!1),children:"取消"}),S.jsx(Ke,{type:"primary",loading:n,onClick:()=>void Q(),children:"保存"})]}),children:S.jsxs(De,{form:q,layout:"vertical",children:[S.jsx(De.Item,{name:"name",label:"名称",rules:[{required:!0}],children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"agent_id",label:"所属智能体",extra:"哪个智能体的库就选哪个;模块数据应落在该智能体对应线上库",children:S.jsx(Qt,{allowClear:!0,placeholder:"可选",options:p.map(te=>({value:te.agent_id,label:`${te.name} (#${te.agent_id})`}))})}),S.jsx(De.Item,{name:"app_slug",label:"关联模块",extra:"已发布模块;本地上传/智能体管理的模块数据与此对照",children:S.jsx(Qt,{allowClear:!0,showSearch:!0,placeholder:"可选",options:b})}),S.jsx(De.Item,{name:"direction",label:"方向",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"local_to_remote",label:"本地 → 线上"},{value:"remote_to_local",label:"线上 → 本地"},{value:"bidirectional",label:"双向"}]})}),S.jsx(De.Item,{name:"conflict_policy",label:"冲突策略",extra:"自动 LWW;覆盖日志仅平台超级管理员可查,公司侧无冲突台",children:S.jsx(Qt,{options:[{value:"lww_source",label:"源端覆盖(推荐,B→A)"},{value:"lww_target",label:"保留目标"},{value:"queue",label:"入队(调试用,租户不可见)"}]})}),S.jsx(De.Item,{name:"poll_interval_ms",label:"轮询间隔(ms)",children:S.jsx(Pf,{min:100,max:6e4,style:{width:"100%"}})}),S.jsx(Oe.Text,{strong:!0,children:"本地库"}),S.jsx(De.Item,{name:["local","driver"],label:"驱动",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"sqlite"},{value:"mysql"},{value:"postgres"}]})}),S.jsx(De.Item,{name:["local","dsn"],label:"DSN",rules:[{required:!0}],extra:"SQLite 例:file:./data/local.db",children:S.jsx(Pt.TextArea,{rows:2})}),S.jsx(De.Item,{name:["local","tables"],label:"策略表(参考)",rules:[{required:!0}],extra:"Z4:不按此名单拒收;用户 JWT + Binding 下任意表可 push。此处仅运维提示。",children:S.jsx(Pt,{placeholder:"article,order"})}),S.jsx(Oe.Text,{strong:!0,children:"线上库 A(生产统一 Postgres)"}),S.jsx(De.Item,{name:["remote","driver"],label:"驱动",rules:[{required:!0}],extra:"生产推荐 postgres;mysql 兼容存量;sqlite 仅联调临时 A,不宜多 writer",children:S.jsx(Qt,{options:[{value:"postgres",label:"postgres(推荐)"},{value:"mysql",label:"mysql"},{value:"sqlite",label:"sqlite(仅联调)"}]})}),S.jsx(De.Item,{name:["remote","dsn"],label:"线上 DSN",rules:[{required:!0}],extra:"Postgres 例:postgres://user:pass@127.0.0.1:5432/dbname?sslmode=disable",children:S.jsx(Pt.TextArea,{rows:2})}),S.jsx(De.Item,{name:["remote","tables"],label:"策略表(参考)",rules:[{required:!0}],extra:"非整库限制;与本地提示一致即可。验同步请用「查看线上表」",children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"pk_columns",label:"主键映射",extra:"格式 table:pk,多个用逗号。默认每表 id",children:S.jsx(Pt,{placeholder:"article:id"})})]})})]})}function RZ(e){var re;const{session:t,busy:n,setBusy:r,setError:o,setInfo:s,onSession:i,onEnteredCompany:l}=e,{message:c,modal:u}=wo.useApp(),d=(t.tenantId||0)>0,[m,f]=a.useState([]),[p,h]=a.useState(!1),[b,x]=a.useState(!1),[v,g]=a.useState(!1),[y,$]=a.useState(!1),[w,I]=a.useState(!1),[C,N]=a.useState(null),[E,R]=a.useState([]),[P,T]=a.useState(null),[_,M]=a.useState([]),[O,k]=a.useState(0),[B,j]=a.useState([]),[z,A]=a.useState(""),[D,L]=a.useState(null),[H,K]=a.useState([]),[V,W]=a.useState(!1),[q]=De.useForm(),[ee]=De.useForm(),[se]=De.useForm();async function le(){h(!0);try{const U=await xQ(t);f(U.items||[])}catch(U){const J=U.message||String(U);o(J),c.error(J)}finally{h(!1)}}async function ce(){W(!0);try{const U=await vQ(t,{limit:100});K(U.items||[])}catch(U){c.error(U.message||String(U))}finally{W(!1)}}async function G(U){N(U),r(!0);try{const oe=(await NQ(t,U.tenant_id)).items||[];if(R(oe),oe.length===0){const ae=(await PQ(t,U.tenant_id,"")).admin_account;L({username:ae.username,password:ae.password,phone:ae.phone,company:U.name}),u.info({title:`「${U.name}」管理员账号已生成`,content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.username})]}),S.jsxs("p",{children:["密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.password})]}),S.jsx(Oe.Text,{type:"danger",children:"密码仅此一次展示;之后可在此改密码/绑手机。"})]}),okText:"已保存"}),await le();return}const Z=oe[0];T(Z.user_id),se.setFieldsValue({user_id:Z.user_id,phone:Z.phone||"",reset_password:!1,password:""}),I(!0)}catch(J){c.error(J.message||String(J))}finally{r(!1)}}a.useEffect(()=>{le(),ce(),$Q(t).then(U=>{M(U.modules||[]),k((U.catalog||[]).length)}).catch(()=>{})},[t.accessToken]);async function ne(U){N(U),r(!0);try{const J=await SQ(t,U.tenant_id);j(J.permissions||[]),J.total&&k(J.total),$(!0)}catch(J){c.error(J.message||String(J))}finally{r(!1)}}return S.jsxs("div",{className:"panel",children:[S.jsx(Oe.Title,{level:4,style:{marginTop:0},children:"平台工作台 · 公司总览"}),S.jsxs(Oe.Paragraph,{type:"secondary",children:["这是",S.jsx("strong",{children:"平台超级管理员自己的功能"}),":新建/改名公司、路径 slug、权限额度;新建时同步生成该公司管理员账号(随机唯一)。 路径约定:基础域名下 ",S.jsxs(Oe.Text,{code:!0,children:["/","{slug}","/..."]}),"(例如 www.yuxinda.com/aaa/)。点「管理该公司」打开内部视图;身份始终是超管。"]}),d&&S.jsxs(Oe.Paragraph,{children:[S.jsxs(Dt,{color:"orange",children:["正在管理:",t.tenantName||`公司 #${t.tenantId}`]}),S.jsx(Ke,{size:"small",icon:S.jsx(R_,{}),style:{marginLeft:8},loading:n,onClick:async()=>{r(!0);try{const U=await g_(t);i==null||i(U),s("已回到平台工作台"),c.success("已回到平台工作台")}catch(U){c.error(U.message||String(U))}finally{r(!1)}},children:"返回平台工作台"})]}),D&&S.jsxs(Oe.Paragraph,{className:"flash ok",children:["「",D.company,"」管理员(用户名唯一不可改): 用户名 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.username}),D.password?S.jsxs(S.Fragment,{children:[" · ","密码 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.password})]}):null,D.phone?S.jsxs(S.Fragment,{children:[" · ","手机 ",S.jsx(Oe.Text,{copyable:!0,code:!0,children:D.phone})]}):null]}),z&&S.jsxs(Oe.Paragraph,{className:"flash ok",children:["管理员邀请码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:z}),"(可选,发给客户自行注册)"]}),S.jsxs(Mt,{style:{marginBottom:12},children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>x(!0),children:"新建公司"}),S.jsx(Ke,{icon:S.jsx(ls,{}),loading:p,onClick:()=>void le(),children:"刷新"})]}),S.jsx($n,{rowKey:"tenant_id",loading:p,dataSource:m,pagination:!1,columns:[{title:"ID",dataIndex:"tenant_id",width:70},{title:"公司名称",dataIndex:"name"},{title:"路径 slug",dataIndex:"slug",width:140,render:U=>U?S.jsxs(Oe.Text,{code:!0,children:["/",U,"/"]}):S.jsx(Dt,{children:"未设置"})},{title:"成员",dataIndex:"user_count",width:70},{title:"模块",dataIndex:"app_count",width:70},{title:"创建时间",dataIndex:"created_at",render:U=>U?new Date(U).toLocaleString():"—"},{title:"操作",width:420,render:(U,J)=>S.jsxs(Mt,{wrap:!0,size:4,children:[S.jsx(Ke,{type:"primary",size:"small",icon:S.jsx(vJ,{}),loading:n,onClick:async()=>{if(await SZ(u,J.name,J.tenant_id)){r(!0);try{const Z=await TQ(t,J.tenant_id);Z.tenantName=J.name,i==null||i(Z),s(`已打开「${J.name}」管理视图(身份仍是平台超管)`),c.success(`已打开「${J.name}」管理视图(身份仍是平台超管)`),l==null||l()}catch(Z){c.error(Z.message||String(Z))}finally{r(!1)}}},children:"管理该公司"}),S.jsx(Ke,{size:"small",icon:S.jsx(jf,{}),loading:n,onClick:()=>void G(J),children:"管理员凭据"}),S.jsx(Ke,{size:"small",icon:S.jsx(GJ,{}),onClick:()=>void ne(J),children:"权限额度"}),S.jsx(Ke,{size:"small",icon:S.jsx(mu,{}),onClick:()=>{N(J),ee.setFieldsValue({name:J.name,slug:J.slug||""}),g(!0)},children:"改名/slug"}),S.jsx(Ke,{size:"small",type:"link",loading:n,onClick:async()=>{r(!0);try{const oe=await IQ(t,J.tenant_id);A(oe.code),s(`已为「${J.name}」生成管理员邀请码`),c.success("邀请码已生成")}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}},children:"邀请码"})]})}]}),S.jsx(tn,{title:"新建公司",open:b,onCancel:()=>x(!1),onOk:async()=>{var J;const U=await q.validateFields();r(!0);try{const oe=await wQ(t,U.name.trim(),!!U.with_invite,(U.slug||"").trim(),(U.admin_phone||"").trim()),Z=oe.admin_account;if(!(Z!=null&&Z.username)||!(Z!=null&&Z.password)){c.error("公司已创建,但未返回管理员账号,请点「管理员凭据」补发"),x(!1),q.resetFields(),await le();return}L({username:Z.username,password:Z.password,phone:Z.phone,company:oe.tenant.name}),u.info({title:"公司与管理员账号已就绪",content:S.jsxs("div",{children:[S.jsxs("p",{children:["公司 ",S.jsx(Oe.Text,{strong:!0,children:oe.tenant.name}),"(路径 ",S.jsxs(Oe.Text,{code:!0,children:["/",oe.tenant.slug,"/"]}),")"]}),S.jsxs("p",{children:["管理员用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.username})]}),S.jsxs("p",{children:["管理员密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.password})]}),Z.phone||U.admin_phone?S.jsxs("p",{children:["手机:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:Z.phone||U.admin_phone})]}):null,S.jsx(Oe.Text,{type:"danger",children:"创建公司即附带此账号;密码仅展示一次,请立即保存。"})]}),okText:"已保存"});const Q=(J=oe.admin_invite)==null?void 0:J.code;Q&&A(Q),c.success(`已创建「${oe.tenant.name}」并生成管理员账号`),s(`已创建「${oe.tenant.name}」管理员 ${Z.username}`),x(!1),q.resetFields(),await le()}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}},confirmLoading:n,children:S.jsxs(De,{form:q,layout:"vertical",initialValues:{with_invite:!1},children:[S.jsx(De.Item,{name:"name",label:"公司名称",rules:[{required:!0,message:"请填写名称"}],children:S.jsx(Pt,{placeholder:"例如:某某科技"})}),S.jsx(De.Item,{name:"slug",label:"路径 slug",extra:"访问前缀,如 aaa → www.yuxinda.com/aaa/。小写字母开头,仅 a-z/0-9/-",rules:[{required:!0,message:"请填写 slug"},{pattern:/^[a-z][a-z0-9-]{1,31}$/,message:"格式:2–32 位,小写字母开头"}],children:S.jsx(Pt,{placeholder:"例如:aaa"})}),S.jsx(De.Item,{name:"admin_phone",label:"管理员手机号(可选)",extra:"填写则绑定,可用手机登录;有 License 期限控制时不必强制",rules:[{validator:async(U,J)=>{const oe=String(J||"").trim();if(oe&&!/^1[3-9]\d{9}$/.test(oe))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",maxLength:20,allowClear:!0})}),S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginBottom:8},children:[S.jsx("strong",{children:"创建后立即生成"}),"管理员账号(随机用户名 + 初始密码);密码弹窗展示一次。"]}),S.jsx(De.Item,{name:"with_invite",valuePropName:"checked",children:S.jsx(go,{children:"额外生成邀请码(可选,一般不需要)"})})]})}),S.jsx(tn,{title:"修改公司名称 / 路径",open:v,onCancel:()=>g(!1),onOk:async()=>{if(!C)return;const U=await ee.validateFields();r(!0);try{await EQ(t,C.tenant_id,U.name.trim(),(U.slug||"").trim()),c.success("已保存"),g(!1),await le()}catch(J){c.error(J.message||String(J))}finally{r(!1)}},confirmLoading:n,children:S.jsxs(De,{form:ee,layout:"vertical",children:[S.jsx(De.Item,{name:"name",label:"公司名称",rules:[{required:!0}],children:S.jsx(Pt,{})}),S.jsx(De.Item,{name:"slug",label:"路径 slug",extra:"修改后,对外路径变为 /{slug}/(路由层后续阶段启用)",rules:[{required:!0,message:"请填写 slug"},{pattern:/^[a-z][a-z0-9-]{1,31}$/,message:"格式:2–32 位,小写字母开头"}],children:S.jsx(Pt,{})})]})}),S.jsx(tn,{title:C?`管理员凭据 · ${C.name}`:"管理员凭据",open:w,onCancel:()=>I(!1),confirmLoading:n,okText:"保存",onOk:async()=>{var oe;if(!C||!P)return;const U=await se.validateFields(),J=(U.phone||"").trim()!==(((oe=E.find(Z=>Z.user_id===P))==null?void 0:oe.phone)||"");if(!U.reset_password&&!J){c.info("未修改密码或手机号");return}r(!0);try{const Z={};U.reset_password&&(Z.reset_password=!0,Z.password=(U.password||"").trim()),J&&(Z.phone=(U.phone||"").trim());const ae=(await RQ(t,C.tenant_id,P,Z)).admin_account;L({username:ae.username,password:ae.password,phone:ae.phone,company:C.name}),ae.password?u.info({title:"密码已重置 — 请保存",content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.username})]}),S.jsxs("p",{children:["新密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.password})]}),ae.phone?S.jsxs("p",{children:["手机:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:ae.phone})]}):null,S.jsx(Oe.Text,{type:"danger",children:"新密码仅此一次展示。"})]}),okText:"已保存"}):c.success(ae.phone?`已绑定手机 ${ae.phone}`:"已更新"),s(`已更新「${C.name}」管理员 ${ae.username}`),I(!1),await le()}catch(Z){c.error(Z.message||String(Z))}finally{r(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:se,layout:"vertical",children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"用户名不可改。可重置密码、绑定/更换手机号(手机登录可选)。"}),E.length>1?S.jsx(De.Item,{name:"user_id",label:"选择管理员",rules:[{required:!0}],children:S.jsx(Qt,{options:E.map(U=>({value:U.user_id,label:`${U.username}${U.phone?` · ${U.phone}`:""}`})),onChange:U=>{T(U);const J=E.find(oe=>oe.user_id===U);se.setFieldsValue({phone:(J==null?void 0:J.phone)||"",reset_password:!1,password:""})}})}):S.jsx(De.Item,{label:"内部用户名",children:S.jsx(Oe.Text,{code:!0,copyable:!0,children:((re=E[0])==null?void 0:re.username)||"—"})}),S.jsx(De.Item,{name:"phone",label:"绑定手机号",extra:"可选;留空保存即解除绑定。有期限控制时可用用户名登录",rules:[{validator:async(U,J)=>{const oe=String(J||"").trim();if(oe&&!/^1[3-9]\d{9}$/.test(oe))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",allowClear:!0,maxLength:20})}),S.jsx(De.Item,{name:"reset_password",valuePropName:"checked",children:S.jsx(go,{children:"重置密码"})}),S.jsx(De.Item,{noStyle:!0,shouldUpdate:(U,J)=>U.reset_password!==J.reset_password,children:()=>se.getFieldValue("reset_password")?S.jsx(De.Item,{name:"password",label:"新密码",extra:"留空则随机生成,保存后仅展示一次",children:S.jsx(Pt.Password,{placeholder:"至少 6 位,可留空自动生成"})}):null})]})}),S.jsxs(tn,{title:C?`公司权限额度 · ${C.name}`:"公司权限额度",open:y,width:720,onCancel:()=>$(!1),onOk:()=>{if(!C)return;const U=async()=>{r(!0);try{const J=await CQ(t,C.tenant_id,B);j(J.permissions||[]),c.success(`已保存(${(J.permissions||[]).length}/${J.total||O})`),$(!1)}catch(J){c.error(J.message||String(J))}finally{r(!1)}};if(B.length===0){u.confirm({title:"确认清空该公司全部权限?",content:"保存后该公司将无法使用任何业务接口,直到重新授予。",onOk:()=>void U()});return}U()},confirmLoading:n,okText:"保存额度",children:[S.jsxs(Mt,{style:{marginBottom:12},children:[S.jsxs(Dt,{children:["已选 ",B.length,"/",O||"?"]}),S.jsx(Ke,{size:"small",onClick:()=>j(_.flatMap(U=>(U.items||[]).map(J=>J.perm))),children:"全选"}),S.jsx(Ke,{size:"small",onClick:()=>j([]),children:"全不选"})]}),S.jsx(Mt,{direction:"vertical",size:"middle",style:{width:"100%"},children:_.map(U=>{const J=(U.items||[]).map(oe=>oe.perm);return S.jsxs("div",{children:[S.jsx(Oe.Text,{strong:!0,children:U.title}),S.jsx("div",{style:{marginTop:8},children:S.jsx(go.Group,{style:{width:"100%",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:8},options:(U.items||[]).map(oe=>({label:S.jsxs("span",{children:[oe.perm,S.jsx("br",{}),S.jsx(Oe.Text,{type:"secondary",style:{fontSize:12},children:oe.desc})]}),value:oe.perm})),value:B.filter(oe=>J.includes(oe)),onChange:oe=>{const Z=new Set(J),Q=B.filter(ae=>!Z.has(ae));j([...Q,...oe])}})})]},U.title)})})]}),S.jsx(Oe.Title,{level:5,style:{marginTop:32},children:"LWW 覆盖日志(仅超管)"}),S.jsx(Oe.Paragraph,{type:"secondary",children:"同步自动覆盖时的落败/胜出记录;公司管理员不可见。默认保留 90 天。 对「源端覆盖」记录可按落败快照回滚线上单行(需通道 remote 仍可达)。"}),S.jsx(Mt,{style:{marginBottom:8},children:S.jsx(Ke,{icon:S.jsx(ls,{}),loading:V,onClick:()=>void ce(),children:"刷新日志"})}),S.jsx($n,{rowKey:"id",size:"small",loading:V,dataSource:H,pagination:{pageSize:10},columns:[{title:"公司",dataIndex:"tenant_id",width:80},{title:"入口",dataIndex:"entry",width:100},{title:"表",dataIndex:"table",width:120},{title:"主键",dataIndex:"row_pk",ellipsis:!0},{title:"策略",dataIndex:"policy",width:110},{title:"结果",dataIndex:"outcome",width:120},{title:"时间",dataIndex:"created_at",width:180,render:U=>U?new Date(U).toLocaleString():""},{title:"操作",width:100,render:(U,J)=>J.outcome==="applied_source"?S.jsx(Ke,{size:"small",danger:!0,loading:n,onClick:()=>{u.confirm({title:"按落败快照回滚线上单行?",content:`${J.table} / ${J.row_pk}`,onOk:async()=>{r(!0);try{await bQ(t,J.id),c.success("已回滚并记入审计"),await ce()}catch(oe){c.error(oe.message||String(oe))}finally{r(!1)}}})},children:"回滚"}):null}]})]})}function TZ(e){const{session:t,busy:n,setBusy:r,setError:o,setInfo:s}=e,{message:i,modal:l}=wo.useApp(),[c,u]=a.useState([]),[d,m]=a.useState([]),[f,p]=a.useState(!1),[h,b]=a.useState(!1),[x,v]=a.useState(!1),[g,y]=a.useState(null),[$,w]=a.useState(""),[I]=De.useForm();async function C(){p(!0);try{const[E,R]=await Promise.all([_Q(t),x$(t).catch(()=>({items:[]}))]);u(E.items||[]),m(R.items||[])}catch(E){const R=E.message||String(E);o(R),i.error(R)}finally{p(!1)}}a.useEffect(()=>{C()},[t.accessToken,t.tenantId]);async function N(E,R,P){if(await sc(l,t,R,`成员:${E.display_name||E.username}(#${E.user_id})`)){r(!0);try{await yE(t,E.user_id,P),s(`${R}成功`),await C()}catch(_){i.error(_.message||String(_))}finally{r(!1)}}}return S.jsxs(rr,{title:"成员管理",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{type:"primary",icon:S.jsx(Bo,{}),onClick:()=>{I.setFieldsValue({role:"编辑",password:void 0,display_name:void 0,org_unit_id:void 0}),b(!0)},children:"新建成员"}),S.jsx(Ke,{icon:S.jsx(ls,{}),onClick:()=>void C(),loading:f,children:"刷新"})]}),children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginTop:0},children:["用户名由系统随机生成且全局唯一;初始密码可留空自动生成,登录后可自行「修改密码」。也可走「邀请加入」。 管理员可为成员「绑定手机」(登录/同号同步联调用);顶栏「更换手机」只改当前登录账号。",t.role==="超级管理员"||t.role==="platform_admin"?" 超管代管修改时会要求两次确认。":""]}),S.jsx($n,{rowKey:"user_id",loading:f||n,dataSource:c,pagination:{pageSize:10},columns:[{title:"用户名",dataIndex:"username",width:140},{title:"手机号",dataIndex:"phone",width:200,render:(E,R)=>S.jsxs(Mt,{size:4,children:[E?S.jsx(Oe.Text,{copyable:!0,children:E}):S.jsx(Oe.Text,{type:"secondary",children:"未绑定"}),S.jsx(Ke,{type:"link",size:"small",style:{padding:0},onClick:()=>{y(R),w(E||""),v(!0)},children:E?"更换":"绑定"})]})},{title:"显示名",dataIndex:"display_name",width:120},{title:"角色",dataIndex:"role",width:160,render:(E,R)=>S.jsx(Qt,{size:"small",style:{width:120},value:E,disabled:R.user_id===t.userId,options:[{value:"管理员",label:"管理员"},{value:"编辑",label:"编辑"},{value:"只读",label:"只读"}],onChange:P=>void N(R,`将 ${R.username} 设为${rc(P)}`,{role:P})})},{title:"组织",width:160,render:(E,R)=>S.jsx(Qt,{size:"small",allowClear:!0,style:{width:140},placeholder:"全公司",value:R.org_unit_id||void 0,options:d.map(P=>({value:P.org_unit_id,label:P.name})),onChange:P=>void N(R,`调整 ${R.username} 的组织`,{org_unit_id:P||0})})},{title:"状态",dataIndex:"status",width:120,render:(E,R)=>S.jsx(Qt,{size:"small",style:{width:100},value:E||"active",disabled:R.user_id===t.userId,options:[{value:"active",label:"正常"},{value:"disabled",label:"停用"}],onChange:P=>void N(R,`${P==="disabled"?"停用":"启用"}成员 ${R.username}`,{status:P})})},{title:"角色标签",width:90,render:(E,R)=>S.jsx(Dt,{children:rc(R.role)})}]}),S.jsxs(tn,{title:g!=null&&g.phone?"更换手机号":"绑定手机号",open:x,onCancel:()=>{v(!1),y(null)},onOk:async()=>{if(!g)return;const E=$.trim();if(await sc(l,t,E?"绑定/更换成员手机号":"解绑成员手机号",`成员:${g.display_name||g.username}(#${g.user_id})→ ${E||"(空)"}`)){r(!0);try{await yE(t,g.user_id,{phone:E}),s(E?`已绑定 ${E}`:"已解绑手机号"),v(!1),y(null),await C()}catch(P){i.error(P.message||String(P))}finally{r(!1)}}},confirmLoading:n,destroyOnHidden:!0,okText:"保存",children:[S.jsxs(Oe.Paragraph,{type:"secondary",children:["用于手机号登录与松离线同号绑定联调。生产宇信达请绑"," ",S.jsx(Oe.Text,{code:!0,children:"13531041944"}),";勿绑超管号 13531041945。清空并保存即解绑。"]}),S.jsx(Pt,{value:$,onChange:E=>w(E.target.value),placeholder:"例:13531041944",maxLength:20,allowClear:!0})]}),S.jsx(tn,{title:"新建成员",open:h,onCancel:()=>b(!1),onOk:async()=>{const E=await I.validateFields();if(await sc(l,t,"新建成员","将随机生成唯一用户名;初始密码可稍后由本人修改")){r(!0);try{const P=await MQ(t,{password:(E.password||"").trim(),display_name:(E.display_name||"").trim(),role:E.role,org_unit_id:E.org_unit_id||0});l.info({title:"成员已创建 — 请保存账号",content:S.jsxs("div",{children:[S.jsxs("p",{children:["用户名:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:P.username})]}),S.jsxs("p",{children:["初始密码:",S.jsx(Oe.Text,{copyable:!0,code:!0,children:P.password})]}),S.jsxs("p",{children:["角色:",rc(P.role)]}),S.jsx(Oe.Text,{type:"secondary",children:"用户名随机唯一不可改;密码请交给本人后由其登录并自行修改。"})]}),okText:"已保存"}),s(`已创建成员 ${P.username}`),b(!1),I.resetFields(),await C()}catch(P){i.error(P.message||String(P))}finally{r(!1)}}},confirmLoading:n,destroyOnHidden:!0,children:S.jsxs(De,{form:I,layout:"vertical",initialValues:{role:"编辑"},children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"用户名由系统随机生成(全局唯一)。初始密码可指定,留空则随机生成;登录后可自行修改。"}),S.jsx(De.Item,{name:"password",label:"初始密码",extra:"留空则随机生成",children:S.jsx(Pt.Password,{placeholder:"至少 6 位,可留空"})}),S.jsx(De.Item,{name:"display_name",label:"显示名",children:S.jsx(Pt,{placeholder:"可选"})}),S.jsx(De.Item,{name:"role",label:"角色",rules:[{required:!0}],children:S.jsx(Qt,{options:[{value:"管理员",label:"管理员(公司顶级)"},{value:"编辑",label:"编辑"},{value:"只读",label:"只读"}]})}),S.jsx(De.Item,{name:"org_unit_id",label:"组织",children:S.jsx(Qt,{allowClear:!0,placeholder:"全公司(不限组织)",options:d.map(E=>({value:E.org_unit_id,label:E.name}))})})]})})]})}const Is=["#1d4f91","#7c3aed","#c2410c","#0f766e","#b42318","#854d0e"];function _Z({title:e,value:t}){return S.jsxs("div",{className:"kpi",children:[S.jsx("div",{className:"kpi-title",children:e}),S.jsx("div",{className:"kpi-value",children:t})]})}function wE({title:e,buckets:t}){const n=Math.max(1,...t.map(r=>r.count));return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:e}),S.jsx("div",{className:"bars",children:t.map((r,o)=>S.jsxs("div",{className:"bar-row",children:[S.jsx("span",{className:"bar-label",children:r.key}),S.jsx("div",{className:"bar-track",children:S.jsx("div",{className:"bar-fill",style:{width:`${r.count/n*100}%`,background:Is[o%Is.length]}})}),S.jsx("span",{className:"bar-num",children:r.count})]},r.key))})]})}function MZ({title:e,buckets:t}){const n=t.reduce((s,i)=>s+i.count,0)||1;let r=0;const o=t.map((s,i)=>{const l=r/n*100;r+=s.count;const c=r/n*100;return`${Is[i%Is.length]} ${l}% ${c}%`});return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:e}),S.jsxs("div",{className:"pie-wrap",children:[S.jsx("div",{className:"pie",style:{background:`conic-gradient(${o.join(",")})`}}),S.jsx("ul",{className:"pie-legend",children:t.map((s,i)=>S.jsxs("li",{children:[S.jsx("i",{style:{background:Is[i%Is.length]}}),s.key," · ",s.count]},s.key))})]})]})}function W_({title:e,points:t,series:n,yUnit:r=""}){if(!t.length||!n.length)return S.jsxs("div",{className:"chart-card line-chart",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"empty",children:"暂无曲线数据"})]});const o=t.flatMap(E=>n.map(R=>E.values[R.key]).filter(R=>Number.isFinite(R))),s=[...o].sort((E,R)=>E-R),i=E=>{if(!s.length)return 0;const R=Math.min(s.length-1,Math.max(0,Math.floor((s.length-1)*E)));return s[R]};let l=s.length?Math.min(0,i(.05)):0,c=s.length?Math.max(1,i(.95)):1;c-l<1&&(l=Math.min(0,...o,-1),c=Math.max(1,...o,1));const u=(c-l)*.12||1,d=l-u,m=c+u,f=920,p=280,h=48,b=16,x=20,v=36,g=f-h-b,y=p-x-v,$=E=>h+(t.length<=1?g/2:E/(t.length-1)*g),w=E=>x+(m-E)/(m-d)*y,I=n.map((E,R)=>{const P=t.map((T,_)=>{var k;const M=T.values[E.key];return Number.isFinite(M)?`${_===0||!Number.isFinite((k=t[_-1])==null?void 0:k.values[E.key])?"M":"L"}${$(_).toFixed(1)},${w(M).toFixed(1)}`:null}).filter(Boolean).join(" ");return{...E,d:P,color:Is[R%Is.length]}}),C=5,N=Array.from({length:C},(E,R)=>d+(m-d)*R/(C-1));return S.jsxs("div",{className:"chart-card line-chart",children:[S.jsxs("div",{className:"line-chart-head",children:[e?S.jsx("h4",{children:e}):null,S.jsx("ul",{className:"line-legend",children:I.map(E=>S.jsxs("li",{children:[S.jsx("i",{style:{background:E.color}}),E.label]},E.key))})]}),S.jsx("div",{className:"line-chart-scroll",children:S.jsxs("svg",{viewBox:`0 0 ${f} ${p}`,width:"100%",height:p,preserveAspectRatio:"none",role:"img",children:[N.map(E=>S.jsxs("g",{children:[S.jsx("line",{x1:h,x2:f-b,y1:w(E),y2:w(E),className:"line-grid"}),S.jsx("text",{x:h-6,y:w(E)+4,className:"line-axis",textAnchor:"end",children:E.toFixed(0)})]},E)),S.jsx("text",{x:8,y:14,className:"line-axis",children:r}),I.map(E=>S.jsx("path",{d:E.d,fill:"none",stroke:E.color,strokeWidth:2.2},E.key)),t.map((E,R)=>S.jsx("text",{x:$(R),y:p-10,className:"line-axis",textAnchor:"middle",children:R%Math.ceil(t.length/8)===0?E.x:""},`${E.x}-${R}`))]})})]})}function OZ({points:e,yUnit:t="",yAxisLabel:n="",designColor:r="#e8590c",invertY:o=!1}){if(!e.length)return S.jsx("div",{className:"chart-card line-chart",children:S.jsx("div",{className:"empty",children:"暂无曲线数据"})});const s=e.map(E=>E.value).filter(E=>Number.isFinite(E)),i=e.map(E=>E.design).filter(E=>Number.isFinite(E)),l=[...s,...i];let c=l.length?Math.min(...l):0,u=l.length?Math.max(...l):1;u-c<1e-6&&(c-=1,u+=1);const d=(u-c)*.08||1;c-=d,u+=d;const m=Math.max(920,e.length*22),f=260,p=52,h=12,b=16,x=34,v=m-p-h,g=f-b-x,y=E=>p+(e.length<=1?v/2:E/(e.length-1)*v),$=E=>o?b+(E-c)/(u-c)*g:b+(u-E)/(u-c)*g,w=6,I=Array.from({length:w},(E,R)=>c+(u-c)*R/(w-1)),C=t?String(t):"",N=e.map((E,R)=>{var _;const P=E.design;return Number.isFinite(P)?`${R===0||!Number.isFinite((_=e[R-1])==null?void 0:_.design)?"M":"L"}${y(R).toFixed(1)},${$(P).toFixed(1)}`:null}).filter(Boolean).join(" ");return S.jsx("div",{className:"chart-card line-chart section-mark-chart",children:S.jsx("div",{className:"line-chart-scroll",children:S.jsxs("svg",{viewBox:`0 0 ${m} ${f}`,width:"100%",height:f,preserveAspectRatio:"none",role:"img",children:[I.map(E=>S.jsxs("g",{children:[S.jsx("line",{x1:p,x2:m-h,y1:$(E),y2:$(E),className:"line-grid"}),S.jsxs("text",{x:p-6,y:$(E)+4,className:"line-axis",textAnchor:"end",children:[Number.isInteger(E)?String(E):E.toFixed(1),C]})]},E)),n?S.jsx("text",{x:6,y:14,className:"line-axis",children:n}):null,N?S.jsx("path",{d:N,fill:"none",stroke:r,strokeWidth:2}):null,e.map((E,R)=>{const P=E.value;if(!Number.isFinite(P))return null;const T=y(R),_=$(P),M=$(0),O=Math.min(_,M),k=Math.max(3,Math.abs(_-M));return S.jsx("rect",{x:T-3,y:O,width:6,height:k,fill:E.color||"#214080",opacity:.9},`${E.x}-${R}`)}),e.map((E,R)=>S.jsx("text",{x:y(R),y:f-8,className:"line-axis",textAnchor:"middle",children:R%Math.ceil(e.length/8)===0?E.x:""},`lb-${R}`))]})})})}function K_({title:e,items:t,variant:n="cells"}){return n==="stacked"?S.jsxs("div",{className:"chart-card status-strip status-strip-stacked",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"status-strip-row stacked-row",children:t.map((r,o)=>{if(r.stop)return S.jsx("div",{className:"status-stack stop",title:r.label,children:S.jsx("span",{className:"stack-stop",children:"停"})},`${r.label}-${o}`);const s=Math.max(0,Number(r.value)||0),i=Math.max(0,Number(r.secondary)||0),l=s+i||1;if(i<=0&&s>0)return S.jsx("div",{className:"status-stack all-grey",title:r.label,children:S.jsx("span",{className:"stack-solo",children:s})},`${r.label}-${o}`);if(s<=0&&i>0)return S.jsx("div",{className:"status-stack all-green",title:r.label,children:S.jsx("span",{className:"stack-solo",children:i})},`${r.label}-${o}`);const c=s/l*100,u=i/l*100;return S.jsxs("div",{className:"status-stack",title:r.label,children:[S.jsx("div",{className:"stack-top",style:{flex:`${Math.max(c,8)} 1 0`},children:S.jsx("span",{children:s})}),S.jsx("div",{className:"stack-bot",style:{flex:`${Math.max(u,8)} 1 0`},children:S.jsx("span",{children:i})})]},`${r.label}-${o}`)})})]}):S.jsxs("div",{className:"chart-card status-strip",children:[e?S.jsx("h4",{children:e}):null,S.jsx("div",{className:"status-strip-row",children:t.map((r,o)=>S.jsxs("div",{className:`status-cell tone-${r.tone||"ok"}`,title:r.label,children:[S.jsx("span",{className:"status-top",children:r.label}),S.jsx("span",{className:"status-val",children:r.value})]},`${r.label}-${o}`))})]})}const zZ="AJZP1",U_="application/x-ajz-machine",jZ="aijianzhan-page-machine-v1";function BZ(e,t){const n=new Uint8Array(e.length),r=new TextEncoder().encode(t);for(let o=0;og.entity===n.entity)||(((p=o==null?void 0:o.apis)==null?void 0:p.resources)||[]).find(g=>String(g.path||"").replace(/^\//,"")===r),c=(l==null?void 0:l.operations)||["list","get","create","update","delete","import","export"],u={};c.includes("list")&&(u.list={method:"GET",path:i}),c.includes("get")&&(u.get={method:"GET",path:`${i}/{id}`}),c.includes("create")&&(u.create={method:"POST",path:i}),c.includes("update")&&(u.update={method:"PUT",path:`${i}/{id}`}),c.includes("delete")&&(u.delete={method:"DELETE",path:`${i}/{id}`}),c.includes("import")&&(u.import={method:"POST",path:`${i}/import`}),c.includes("export")&&(u.export={method:"GET",path:`${i}/export`}),u.aggregate={method:"GET",path:`${i}/aggregate`},u.blueprint={method:"GET",path:`${s}/blueprint`};const d=((o==null?void 0:o.entities)||[]).find(g=>g.name===n.entity),m=((d==null?void 0:d.fields)||[]).filter(g=>g==null?void 0:g.name).slice(0,80).map(g=>({name:String(g.name),type:String(g.type||"string"),label:g.label?String(g.label):void 0}));return{v:1,kind:"ajz-page",slug:t,base_path:s,page:{id:n.id,type:n.type,route:n.route||"",title:n.title||""},entity:n.entity,resource:r,auth:{type:"bearer_jwt",header:"Authorization"},endpoints:u,filters:((h=n.layout)==null?void 0:h.filters)||((b=l==null?void 0:l.list)==null?void 0:b.allowed_filters)||[],fields:m,actions:((x=n.layout)==null?void 0:x.actions)||[],widgets:(((v=n.layout)==null?void 0:v.widgets)||[]).map(g=>({type:g.type,title:g.title,entity:g.entity})),notes:"list 支持 filter.=value;需 Authorization: Bearer "}}function AZ(e){var n,r,o;const t=a.useMemo(()=>{try{const s=kZ(e);return q_(s)}catch{return""}},[e.slug,e.resource,(n=e.page)==null?void 0:n.id,(r=e.page)==null?void 0:r.type,(o=e.page)==null?void 0:o.entity,e.blueprint]);return t?S.jsx("div",{className:"ajz-machine-tag",hidden:!0,"aria-hidden":"true","data-ajz-machine":t,"data-ajz-mime":U_,"data-ajz-codec":"AJZP1","data-ajz-kind":"page","data-ajz-slug":e.slug,"data-ajz-page":e.page.id,"data-ajz-entity":e.page.entity,"data-ajz-resource":e.resource}):null}function G_(e){const t=a.useMemo(()=>{try{return q_({v:1,kind:"ajz-block",slug:e.slug,resource:e.resource,block_id:e.blockId,endpoint:e.endpoint||{method:"GET",path:`/api/v1/apps/${e.slug}/${e.resource}`},...e.extra||{}})}catch{return""}},[e.slug,e.resource,e.blockId,e.endpoint,e.extra]);return t?S.jsx("div",{className:"ajz-machine-tag",hidden:!0,"aria-hidden":"true","data-ajz-machine":t,"data-ajz-mime":U_,"data-ajz-codec":"AJZP1","data-ajz-kind":"block","data-ajz-block":e.blockId,"data-ajz-slug":e.slug,"data-ajz-resource":e.resource}):null}function DZ(e,t){return t==null||t===""?"—":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function FZ(e,t){if(!t.filter_field)return!0;const n=e[t.filter_field],r=Number(n),o=t.filter_op||"gt",s=Number(t.filter_value??0);return o==="gt"?Number.isFinite(r)&&r>s:o==="gte"?Number.isFinite(r)&&r>=s:o==="lt"?Number.isFinite(r)&&rye&&ye!=="全部"),C=g.select_field||g.filter_select_field||["worksite","site","store","warehouse","dept"].find(ye=>s[ye])||"",N=!!(w&&I.length>0),E=!!C;a.useEffect(()=>{(async()=>{try{const ye={};if(w&&f){const Re=g.filter_value_aliases||{};ye[w]=Re[f]||f}C&&h&&(ye[C]=h);const Ne=await np(t,n,r,ye,1,2e3);u(Ne.items||[]),m(Ne.total||(Ne.items||[]).length)}catch(ye){l(ye.message||String(ye))}})()},[t,n,r,w,f,C,h,l,g.filter_value_aliases]);const R=ye=>{var Ve;const Ne=g.table_headers||[],Re=o.find(at=>at.type==="table"),Ye=((Re==null?void 0:Re.columns)||[]).indexOf(ye);return Ye>=0&&Ne[Ye]?Ne[0]==="序号"&&Ne[Ye+1]?Ne[Ye+1]:Ne[Ye]:((Ve=s[ye])==null?void 0:Ve.label)||ye},P=o.find(ye=>ye.type==="line_chart"||ye.type==="bar_chart"),T=o.find(ye=>ye.type==="status_strip"),_=o.find(ye=>ye.type==="table"),M=g.chart_side_label||(P==null?void 0:P.title)||"主图",O=g.strip_side_label||(T==null?void 0:T.title)||"状态",k=g.table_side_label||"明细",B=g.table_title||(_==null?void 0:_.title)||"明细表",j=g.stats_left_label||"",z=g.stats_right_label||"",A=a.useMemo(()=>{const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||Object.keys(s)[0]||"id";return[...c].sort((Ne,Re)=>String(Ne[ye]??"").localeCompare(String(Re[ye]??""),"zh"))},[c,P,s]),D=g.value_field||(P==null?void 0:P.metric)||((Ce=P==null?void 0:P.metrics)==null?void 0:Ce[0])||["value","cjl_value","cum_value","cum_settlement_mm","amount","qty"].find(ye=>s[ye])||"",L=g.color_field||["color","cjl_color","mark_color"].find(ye=>s[ye])||"",H=g.design_field||["design_value","design_settlement_mm","target","design"].find(ye=>s[ye])||"",K=g.category_colors||{},V=g.category_field||w||"",W=String(g.chart_style||"").toLowerCase(),q=W==="line"||W==="multi_series"||W==="line_chart",ee=W==="section_marks"||W==="colored_marks",se=!!P&&!!D&&!!(P!=null&&P.x_field||P!=null&&P.group_by||Object.keys(s)[0]),le=ee||!q&&se,ce=a.useMemo(()=>{if(!le)return[];const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||Object.keys(s)[0]||"",Ne=["#1d4f91","#7c3aed","#868e96","#0f766e","#c2410c"],Re=new Map;return A.map(Xe=>{const Ye=El(D?Xe[D]:void 0),Ve=H?El(Xe[H]):NaN;let at=L?String(Xe[L]||"").trim():"";if(!at&&V){const xe=String(Xe[V]??"");K[xe]?at=K[xe]:xe&&(Re.has(xe)||Re.set(xe,Re.size),at=Ne[Re.get(xe)%Ne.length])}return at||(at=Ne[0]),{x:String(Xe[ye]??""),value:Number.isFinite(Ye)?Ye:0,design:Number.isFinite(Ve)?Ve:void 0,color:at}})},[le,A,P,D,L,H,V,K,s]),G=a.useMemo(()=>{var Ye;if(!P||le)return null;const ye=P.x_field||P.group_by||"";let Ne=((Ye=P.metrics)!=null&&Ye.length?P.metrics:P.metric&&P.metric!=="count"?[P.metric]:[]).filter(Boolean);if((!Ne.length||!Ne.some(Ve=>s[Ve]))&&(Ne=Object.values(s).filter(Ve=>["int","bigint","decimal","number","float"].includes(String(Ve.type))).map(Ve=>Ve.name).filter(Ve=>!["id","tenant_id"].includes(Ve)).slice(0,4)),!ye||!Ne.length)return null;const Re=A.map(Ve=>{const at={};for(const xe of Ne){const Le=El(Ve[xe]);Number.isFinite(Le)&&(at[xe]=Le)}return{x:String(Ve[ye]??""),values:at}}),Xe=g.series_labels||{};return{title:P.title||"图表",points:Re,series:Ne.map(Ve=>({key:Ve,label:Xe[Ve]||R(Ve)})),yUnit:P.y_unit||g.y_unit||""}},[P,A,le,g.series_labels,g.y_unit,s]),ne=(qe=g.legend_items)!=null&&qe.length?g.legend_items:le&&Object.keys(K).length?Object.entries(K).map(([ye,Ne])=>({label:ye,color:Ne})):((G==null?void 0:G.series)||[]).map((ye,Ne)=>({label:ye.label,color:["#1d4f91","#7c3aed","#6b7280","#c2410c"][Ne%4]})),re=a.useMemo(()=>{if(!T)return[];const ye=T.label_field||"",Ne=T.value_field||"",Re=T.secondary_field||"";if(!ye||!Ne)return[];const Xe=Number(T.cycle_days)||Number(g.cycle_days)||30,Ye=T.variant==="stacked"||T.variant==="stacked_days"||!!Re;return A.map(Ve=>{const at=String(Ve[ye]??"");let xe=El(Ve[Ne]),Le=Re?El(Ve[Re]):NaN;if(Number.isFinite(xe)||(xe=0),Number.isFinite(Le)||(Le=0),Ye&&xe+Le>50&&xe+Le<120){const Pe=Math.round(xe/100*Xe),ve=Math.max(0,Xe-Pe);xe=Pe,Le=ve}const me=!!Ve.stop_flag||String(Ve.status||"").includes("停")||Ye&&xe===0&&Le===0;return{label:at,value:xe,secondary:Ye?Le:void 0,stop:me}})},[T,A,g.cycle_days]),U=(T==null?void 0:T.variant)==="stacked"||(T==null?void 0:T.variant)==="stacked_days"||T!=null&&T.secondary_field?"stacked":"cells",J=(Qe=_==null?void 0:_.columns)!=null&&Qe.length?_.columns:Object.keys(s).filter(ye=>!["id","tenant_id"].includes(ye)).slice(0,6),oe=_?A.filter(ye=>FZ(ye,_)):[],Z=a.useMemo(()=>{var Ne,Re;if(!C)return[];if((Re=(Ne=s[C])==null?void 0:Ne.enum_values)!=null&&Re.length)return s[C].enum_values;const ye=new Set;for(const Xe of c){const Ye=String(Xe[C]??"");Ye&&ye.add(Ye)}return Array.from(ye).sort()},[C,s,c]),Q=a.useMemo(()=>{const ye=(P==null?void 0:P.x_field)||(P==null?void 0:P.group_by)||"";return ye&&new Set(c.map(Ne=>String(Ne[ye]??""))).size||d},[c,d,P]),ae=Number(g.chart_page_size)||28,te=le?ce.length:(G==null?void 0:G.points.length)||re.length,Y=Math.max(0,te-ae),de=ce.slice(x,x+ae),ue=(G==null?void 0:G.points.slice(x,x+ae))||[],ge=re.slice(x,x+ae),we=(()=>{if(y&&(j||z)&&y.includes(j||"\0"))return y;const ye=[];return y&&ye.push(y),j&&ye.push(`${j}:${Q}个`),z&&ye.push(`${z}: ${d}个`),ye.join(" ")||(d?`共 ${d} 条`:"")})(),he=g.select_label||(C?R(C):"")||"",Be=(P==null?void 0:P.y_unit)||g.y_unit||"",be=g.y_axis_label||Be||"",Fe=!!g.invert_y,_e=g.design_series_color||"#e8590c",Ee=g.empty_table_text||"暂无数据",Te=[w,C].filter(Boolean);return S.jsxs("div",{className:"sf-root",children:[S.jsx(G_,{slug:n,resource:r,blockId:"sf-dashboard",endpoint:{method:"GET",path:`/api/v1/apps/${n}/${r}`},extra:{page_type:"dashboard",filters:Te,list_query:"filter.=value&page=1&page_size=2000"}}),S.jsxs("div",{className:"sf-filterbar",children:[S.jsx("div",{className:"sf-context",children:S.jsx("strong",{children:we})}),N&&S.jsx("div",{className:"sf-radios",children:["",...I].map(ye=>S.jsxs("label",{className:`sf-radio ${(f||"")===ye?"on":""}`,children:[S.jsx("input",{type:"radio",name:"sf-radio",checked:(f||"")===ye,onChange:()=>p(ye)}),ye||g.radio_all_label||"全部"]},ye||"all"))}),E&&S.jsxs("label",{className:"sf-select",children:[he?`${he}:`:null,S.jsxs("select",{value:h,onChange:ye=>b(ye.target.value),children:[S.jsx("option",{value:"",children:"--请选择--"}),Z.map(ye=>S.jsx("option",{value:ye,children:ye},ye))]})]}),$?S.jsx("span",{className:"sf-hint",children:$}):null]}),ne.length>0&&P&&S.jsx("div",{className:"sf-legend",children:ne.map((ye,Ne)=>S.jsx("span",{className:`sf-leg-item${/曲线|折线|line/i.test(ye.label)?" leg-line":""}`,style:{"--leg":ye.color},children:ye.label},`${ye.label}-${Ne}`))}),S.jsxs("div",{className:"sf-body",children:[S.jsxs("div",{className:"sf-rail",children:[P?S.jsx("div",{className:"sf-rail-seg chart",children:M}):null,T?S.jsx("div",{className:"sf-rail-seg strip",children:O}):null,_?S.jsx("div",{className:"sf-rail-seg table",children:k}):null]}),S.jsxs("div",{className:"sf-main",children:[P&&S.jsxs("div",{className:"sf-line-wrap",children:[le?S.jsx(OZ,{points:de.length?de:ce,yUnit:Be,yAxisLabel:be,invertY:Fe,designColor:_e}):G?S.jsx(W_,{title:"",points:ue.length?ue:G.points,series:G.series,yUnit:G.yUnit}):S.jsx("div",{className:"empty",style:{padding:"2rem",textAlign:"center"},children:"暂无曲线数据(请检查蓝图 x_field / metrics 与已导入数据)"}),Y>0&&S.jsx("input",{className:"sf-scroll",type:"range",min:0,max:Y,value:x,onChange:ye=>v(Number(ye.target.value))})]}),T&&S.jsx("div",{className:"sf-strip-wrap",children:S.jsx(K_,{title:"",variant:U,items:ge})}),_&&S.jsxs("div",{className:"sf-table-panel",children:[S.jsx("div",{className:"sf-table-title",children:B}),S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{className:"sf-table",children:[S.jsx("thead",{children:S.jsxs("tr",{children:[S.jsx("th",{children:"序号"}),J.map(ye=>S.jsx("th",{children:R(ye)},ye))]})}),S.jsxs("tbody",{children:[oe.map((ye,Ne)=>S.jsxs("tr",{children:[S.jsx("td",{children:Ne+1}),J.map(Re=>S.jsx("td",{children:DZ(Re,ye[Re])},Re))]},Ne)),!oe.length&&S.jsx("tr",{children:S.jsx("td",{colSpan:J.length+1,className:"empty",children:Ee})})]})]})})]})]})]})]})}function X_(e){if(typeof e=="string")return e.trim();if(e&&typeof e=="object"){const t=e;for(const n of["label","title","name","text"])if(typeof t[n]=="string"&&String(t[n]).trim())return String(t[n]).trim()}return""}function VZ(e){if(!e||typeof e!="object")return"";const t=e;for(const n of["route","path","href","url"])if(typeof t[n]=="string"&&String(t[n]).trim())return String(t[n]).trim();return""}function EE(e,t=[]){return(Array.isArray(e)?e:t).map(X_).filter(Boolean)}function nd(e,t){return e.title||e.id}function WZ(e,t){var r,o,s;const n=(((r=e==null?void 0:e.apis)==null?void 0:r.resources)||[]).find(i=>i.entity===t)||((s=(o=e==null?void 0:e.apis)==null?void 0:o.resources)==null?void 0:s[0]);return String((n==null?void 0:n.path)||`/${t}`).replace(/^\//,"")}function IE(e,t){var r;const n=((e==null?void 0:e.entities)||[]).find(o=>o.name===t)||((r=e==null?void 0:e.entities)==null?void 0:r[0]);return((n==null?void 0:n.fields)||[]).map(o=>{var s;return{name:o.name,label:o.label||o.name,type:o.type||"string",enum_values:o.enum_values||o.enumValues,widget:(s=o.ui)==null?void 0:s.widget}})}const KZ=new Set(["id","tenant_id","org_unit_id","created_by","created_at","updated_at"]),PE=/(status|type|category|state|分类|类型|状态)$/i;function Bf(e){return e.type==="enum"||e.widget==="select"||e.enum_values&&e.enum_values.length>0?!0:PE.test(e.name)||PE.test(e.label)}function H0(e){return e.type==="datetime"||Lf(e)?!1:e.type==="date"||e.widget==="datepicker"?!0:/日期/.test(e.label)||/(^|_)date$/i.test(e.name)}function Lf(e){return e.type==="datetime"||e.widget==="datetime"||/(_at$|时间|datetime)/i.test(e.name)}function V0(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return t==="date"?e.slice(0,10):e.length>=16?e.slice(0,16):e;const r=l=>String(l).padStart(2,"0"),o=n.getFullYear(),s=r(n.getMonth()+1),i=r(n.getDate());return t==="date"?`${o}-${s}-${i}`:`${o}-${s}-${i}T${r(n.getHours())}:${r(n.getMinutes())}`}function UZ(e,t){if(!e)return"";const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toISOString()}function qZ(e){return/status_check|_status_check/i.test(e)?"状态值不合法:请从下拉框选择蓝图允许的枚举值。":/violates check constraint/i.test(e)||/检查约束/.test(e)?`字段值不符合约束:${e}`:/null value|非空|not-null/i.test(e)?`必填字段为空:${e}`:e}function GZ({meta:e,value:t,options:n,onChange:r}){if(Bf(e)||n.length>0){const o=n.length?n:e.enum_values||[];return S.jsxs("select",{value:t,onChange:s=>r(s.target.value),children:[S.jsx("option",{value:"",children:"请选择"}),o.map(s=>S.jsx("option",{value:s,children:s},s))]})}return e.type==="boolean"||e.widget==="checkbox"?S.jsxs("select",{value:t,onChange:o=>r(o.target.value),children:[S.jsx("option",{value:"",children:"请选择"}),S.jsx("option",{value:"true",children:"是"}),S.jsx("option",{value:"false",children:"否"})]}):Lf(e)?S.jsx("input",{type:"datetime-local",value:V0(t,"datetime"),onChange:o=>r(UZ(o.target.value))}):H0(e)?S.jsx("input",{type:"date",value:V0(t,"date"),onChange:o=>r(o.target.value)}):e.type==="int"||e.type==="bigint"||e.type==="decimal"||e.widget==="number"?S.jsx("input",{type:"number",step:e.type==="decimal"?"0.01":"1",value:t,onChange:o=>r(o.target.value)}):e.type==="text"||e.widget==="textarea"?S.jsx("textarea",{rows:3,value:t,onChange:o=>r(o.target.value)}):S.jsx("input",{type:"text",value:t,onChange:o=>r(o.target.value)})}function Y_(e,t){if(t==null||t==="")return"—";if(String(e).endsWith("_at")){const n=new Date(String(t));if(!Number.isNaN(n.getTime()))return n.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}return String(t)}function XZ(e){return/在售|正常|启用|合格/.test(e)?"ok":/停售|禁用|缺货|超限|异常|逾期/.test(e)?"bad":"warn"}function YZ({session:e,blueprint:t,onBack:n}){var M,O,k,B,j,z,A,D,L,H,K,V,W,q,ee,se,le,ce,G,ne,re,U,J,oe,Z,Q,ae,te,Y,de;const r=(M=t==null?void 0:t.meta)==null?void 0:M.slug,o=(t==null?void 0:t.pages)||[],s=o.find(ue=>ue.type==="list")||o[0],[i,l]=a.useState((s==null?void 0:s.id)||""),[c,u]=a.useState(null),[d,m]=a.useState(""),[f,p]=a.useState(""),[h,b]=a.useState(!1),x=a.useMemo(()=>{var ue,ge;if(i.startsWith("__edit__")){const we=i.replace("__edit__",""),he=o.find(be=>be.type==="list"&&be.entity===we),Be=IE(t,we);return{id:i,title:"编辑",route:`/${we}/edit`,type:"form_edit",entity:we,layout:{form_fields:((ge=(ue=he==null?void 0:he.layout)==null?void 0:ue.columns)==null?void 0:ge.filter(be=>be!=="id"))||Be.map(be=>be.name).filter(be=>be!=="id"),actions:["edit"]}}}return o.find(we=>we.id===i)||s},[i,o,s,t]),v=x?WZ(t,x.entity):"",g=a.useMemo(()=>x?IE(t,x.entity):[],[x,t]),y=a.useMemo(()=>Object.fromEntries(g.map(ue=>[ue.name,ue])),[g]),$=a.useMemo(()=>{const ue=/^(欢迎您|退出|帮助|登录|注册|返回|系统首页|修改密码)$/,ge=o.filter(he=>he.type!=="form_edit"&&he.type!=="detail"&&!ue.test(String(he.title||""))),we=he=>he.type==="list"?0:he.type==="form_create"?1:he.type==="dashboard"?2:3;return[...ge].sort((he,Be)=>we(he)-we(Be))},[o]),w=a.useMemo(()=>{var he,Be;const ue=Array.isArray((Be=(he=t==null?void 0:t.meta)==null?void 0:he.ui)==null?void 0:Be.nav_items)?t.meta.ui.nav_items:[];if(!ue.length)return[];const ge=$.find(be=>be.type==="dashboard"),we=be=>be.replace(/\/+$/,"").toLowerCase();return ue.map(be=>{const Fe=X_(be),_e=VZ(be);if(!Fe&&!_e)return null;let Ee=(_e?$.find(Te=>we(String(Te.route||""))===we(_e)):void 0)||$.find(Te=>Te.title===Fe||String(Te.title||"").includes(Fe)||Fe&&Fe.includes(String(Te.title||"")));return!Ee&&ge&&Fe&&(ge.title===Fe||String(ge.title||"").includes(Fe))&&(Ee=ge),{label:Fe||(Ee==null?void 0:Ee.title)||_e,pageId:Ee==null?void 0:Ee.id}}).filter(Boolean)},[(k=(O=t==null?void 0:t.meta)==null?void 0:O.ui)==null?void 0:k.nav_items,$]),I=a.useMemo(()=>{var ue,ge;return EE((ge=(ue=t==null?void 0:t.meta)==null?void 0:ue.ui)==null?void 0:ge.shell_links,["欢迎您","退出","帮助"])},[(j=(B=t==null?void 0:t.meta)==null?void 0:B.ui)==null?void 0:j.shell_links]),C=((A=(z=t==null?void 0:t.meta)==null?void 0:z.ui)==null?void 0:A.platform_subtitle)||((D=t==null?void 0:t.meta)==null?void 0:D.platform_subtitle)||"",N=a.useMemo(()=>{var ue,ge;return EE((ge=(ue=t==null?void 0:t.meta)==null?void 0:ue.ui)==null?void 0:ge.float_actions,["客服","电话","点击隐藏"])},[(H=(L=t==null?void 0:t.meta)==null?void 0:L.ui)==null?void 0:H.float_actions]),E=((K=t==null?void 0:t.meta)==null?void 0:K.ui_preset)||((W=(V=o.find(ue=>{var ge;return(ge=ue.layout)==null?void 0:ge.preset}))==null?void 0:V.layout)==null?void 0:W.preset)||"default",R=((q=t==null?void 0:t.meta)==null?void 0:q.project_context)||"",P=ue=>{var he,Be,be;if(!ue||ue.type!=="dashboard")return!1;if(((he=ue.layout)==null?void 0:he.preset)==="screenshot_faithful"||((Be=ue.layout)==null?void 0:Be.preset)==="ops_monitor")return!0;const ge=((be=ue.layout)==null?void 0:be.widgets)||[],we=new Set(ge.map(Fe=>Fe.type));return(we.has("line_chart")||we.has("bar_chart"))&&(we.has("status_strip")||we.has("table"))},T=E==="screenshot_faithful"||E==="ops_monitor"||!!((se=(ee=t==null?void 0:t.meta)==null?void 0:ee.source)!=null&&se.screenshot_faithful)||!!((G=(ce=(le=t==null?void 0:t.meta)==null?void 0:le.source)==null?void 0:ce.image_refs)!=null&&G.length)||!!((U=(re=(ne=t==null?void 0:t.meta)==null?void 0:ne.source)==null?void 0:re.layout_refs)!=null&&U.length)||P(o.find(ue=>ue.type==="dashboard")),_=((oe=(J=t==null?void 0:t.meta)==null?void 0:J.ui)==null?void 0:oe.platform_title)||((Z=t==null?void 0:t.meta)==null?void 0:Z.platform_title)||"";return a.useEffect(()=>{if(!T)return;const ue=o.find(ge=>ge.type==="dashboard");ue&&(!i||i===(s==null?void 0:s.id))&&(s==null?void 0:s.type)!=="dashboard"&&l(ue.id)},[T,(Q=t==null?void 0:t.meta)==null?void 0:Q.slug]),S.jsxs("div",{className:`gen-app ${T?"gen-app-ops":""}`,children:[T?S.jsxs("header",{className:"sf-shell-bar",children:[S.jsxs("div",{className:"sf-shell-left",children:[_||"业务管理平台",C?S.jsx("span",{className:"sf-shell-en",children:C}):null]}),S.jsx("div",{className:"sf-shell-center",children:((ae=t==null?void 0:t.meta)==null?void 0:ae.name)||r}),S.jsxs("div",{className:"sf-shell-right",children:[I.map(ue=>S.jsx("span",{className:"sf-shell-link",children:ue},ue)),S.jsx("button",{type:"button",className:"sf-shell-back",onClick:n,children:"返回控制台"})]})]}):S.jsxs("header",{className:"gen-header",children:[S.jsxs("div",{children:[S.jsx("p",{className:"gen-eyebrow",children:"业务模块"}),S.jsx("h1",{className:"gen-title",children:((te=t==null?void 0:t.meta)==null?void 0:te.name)||r}),S.jsx("p",{className:"gen-desc",children:((Y=t==null?void 0:t.meta)==null?void 0:Y.description)||"由蓝图自动生成的业务页面"})]}),S.jsx("button",{type:"button",className:"btn secondary",onClick:n,children:"返回控制台"})]}),S.jsxs("nav",{className:`gen-nav ${T?"gen-nav-ops":""}`,children:[(T&&w.length>0?w:$.map(ue=>({label:nd(ue),pageId:ue.id}))).map((ue,ge)=>{const we=ue.pageId?(x==null?void 0:x.id)===ue.pageId&&!c:!1;return S.jsx("button",{type:"button",className:`gen-nav-item ${we?"active":""} ${ue.pageId?"":"is-chrome"}`,onClick:()=>{ue.pageId&&(u(null),l(ue.pageId),m(""),p(""))},children:ue.label},`${ue.label}-${ge}`)}),T&&w.length>0?$.filter(ue=>ue.type==="list"||ue.type==="dashboard").filter(ue=>!w.some(ge=>ge.pageId===ue.id||ge.label===ue.title)).map(ue=>S.jsx("button",{type:"button",className:`gen-nav-item ${(x==null?void 0:x.id)===ue.id&&!c?"active":""}`,onClick:()=>{u(null),l(ue.id),m(""),p("")},children:nd(ue)},ue.id)):null]}),T&&R&&(x==null?void 0:x.type)!=="dashboard"&&S.jsx("div",{className:"sf-mini-context",children:R}),d&&S.jsx("p",{className:"flash err",children:d}),f&&S.jsx("p",{className:"flash ok",children:f}),x&&v&&S.jsx(AZ,{slug:r,resource:v,page:x,blueprint:t}),(x==null?void 0:x.type)==="list"&&!c&&S.jsx(QZ,{session:e,slug:r,resource:v,page:x,fieldMap:y,busy:h,setBusy:b,setError:m,setInfo:p,onCreate:()=>{const ue=o.find(ge=>ge.type==="form_create"&&ge.entity===x.entity);ue&&l(ue.id)},onEdit:ue=>{u(ue);const ge=o.find(we=>we.type==="form_edit"&&we.entity===x.entity);l(ge?ge.id:`__edit__${x.entity}`)}}),((x==null?void 0:x.type)==="form_create"||(x==null?void 0:x.type)==="form_edit")&&S.jsx(JZ,{session:e,slug:r,resource:v,page:x,title:nd(x),fields:g,editId:x.type==="form_edit"?c:null,busy:h,setBusy:b,setError:m,setInfo:p,onDone:()=>{u(null);const ue=o.find(ge=>ge.type==="list"&&ge.entity===x.entity);ue&&l(ue.id)}}),(x==null?void 0:x.type)==="dashboard"&&!c&&(T||P(x)?S.jsx(HZ,{session:e,slug:r,resource:v,title:nd(x),widgets:(((de=x.layout)==null?void 0:de.widgets)||[]).filter(ue=>ue.type!=="kpi"),fieldMap:y,meta:(t==null?void 0:t.meta)||{},setError:m}):S.jsx(ZZ,{session:e,slug:r,resource:v,page:x,fieldMap:y,setError:m})),T&&N.length>0?S.jsx("aside",{className:"sf-float-dock","aria-label":"快捷操作",children:N.map(ue=>S.jsx("button",{type:"button",tabIndex:-1,children:ue},ue))}):null]})}function QZ(e){var T,_,M,O,k,B,j;const{session:t,slug:n,resource:r,page:o,fieldMap:s,busy:i,setBusy:l,setError:c,setInfo:u,onCreate:d,onEdit:m}=e,f=(_=(T=o.layout)==null?void 0:T.columns)!=null&&_.length?o.layout.columns:Object.keys(s).filter(z=>!["id","tenant_id"].includes(z)).slice(0,8),p=a.useMemo(()=>{var z;return((z=o.layout)==null?void 0:z.filters)||[]},[(M=o.layout)==null?void 0:M.filters]),h=((O=o.layout)==null?void 0:O.actions)||["refresh"],b=((k=o.layout)==null?void 0:k.action_labels)||{},x=(z,A)=>b[z]||A,v=h.filter(z=>!["edit","delete"].includes(z)),[g,y]=a.useState({}),[$,w]=a.useState({}),[I,C]=a.useState([]),[N,E]=a.useState(0),R=a.useCallback(async()=>{var z;l(!0),c("");try{const A=await np(t,n,r,g);C(A.items||[]),E(A.total||0);const D={};for(const L of p){const H=s[L];if((z=H==null?void 0:H.enum_values)!=null&&z.length){D[L]=H.enum_values;continue}const K=new Set;for(const V of A.items||[]){const W=V[L];W!=null&&String(W).trim()!==""&&K.add(String(W))}D[L]=Array.from(K).sort()}w(L=>{let H=!1;const K={...L};for(const[V,W]of Object.entries(D)){const q=L[V]||[];(q.length!==W.length||q.some((ee,se)=>ee!==W[se]))&&(K[V]=W,H=!0)}return H?K:L})}catch(A){c(A.message||String(A))}finally{l(!1)}},[t,n,r,g,l,c,p,s]);a.useEffect(()=>{R()},[R]);async function P(z){if(confirm("确认删除该行?")){l(!0);try{await kY(t,n,r,z),u("已删除"),await R()}catch(A){c(A.message||String(A))}finally{l(!1)}}}return S.jsxs("section",{className:"panel gen-panel",children:[S.jsx(G_,{slug:n,resource:r,blockId:`list:${o.id}`,endpoint:{method:"GET",path:`/api/v1/apps/${n}/${r}`},extra:{page_type:"list",filters:p,columns:f}}),S.jsxs("div",{className:"gen-toolbar",children:[S.jsx("h2",{className:"section-title",style:{margin:0},children:o.title}),S.jsx("div",{className:"actions",style:{margin:0},children:v.map(z=>{if(z==="create")return S.jsx("button",{type:"button",className:"btn",disabled:i,onClick:d,children:x("create","新增")},z);if(z==="refresh")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:x("refresh","刷新")},z);if(z==="import")return S.jsxs("label",{className:"file-field btn secondary",style:{margin:0,padding:"8px 12px",cursor:"pointer"},children:[x("import","导入 Excel"),S.jsx("input",{type:"file",accept:".xlsx,.xlsm,.csv",hidden:!0,onChange:async D=>{var H,K;const L=(H=D.target.files)==null?void 0:H[0];if(L){l(!0);try{const V=await FY(t,n,r,L),W=V.inserted||0,q=V.skipped||0,ee=(V.errors||[]).length;u(`导入完成:成功 ${W} 行`+(q?`,跳过 ${q}`:"")+(ee?`,错误 ${ee} 条(仅展示部分)`:"")),ee&&((K=V.errors)!=null&&K[0])&&c(String(V.errors[0])),await R()}catch(V){c(V.message||String(V))}finally{l(!1),D.target.value=""}}}})]},z);if(z==="export")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:async()=>{l(!0);try{await HY(t,n,r,"xlsx"),u("已导出 Excel")}catch(D){c(D.message||String(D))}finally{l(!1)}},children:x("export","导出 Excel")},z);if(z==="search")return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:x("search","查询")},z);const A=x(z,z.replace(/^custom_/,""));return S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>u(`按键「${A}」已按说明展示(业务逻辑可后续绑定)`),children:A},z)})})]}),p.length>0&&(((B=o.layout)==null?void 0:B.filter_style)==="section_radios"||((j=o.layout)==null?void 0:j.filter_style)==="radios")?S.jsx("div",{className:"ops-section-radios",children:(()=>{const z=p.find(L=>{var H;return(((H=s[L])==null?void 0:H.enum_values)||[]).length>0})||p[0],A=s[z]||{label:z},D=$[z]||A.enum_values||[];return S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"ops-radio-label",children:A.label||"类型"}),["",...D].map(L=>S.jsx("button",{type:"button",className:`ops-radio ${(g[z]||"")===L?"active":""}`,onClick:()=>{y(H=>({...H,[z]:L})),setTimeout(()=>void R(),0)},children:L||"全部"},L||"all")),p.filter(L=>L!==z).map(L=>{const H=s[L]||{label:L};return S.jsxs("label",{className:"ops-extra-filter",children:[H.label||L,S.jsx("input",{value:g[L]||"",placeholder:"筛选…",onChange:K=>y(V=>({...V,[L]:K.target.value}))})]},L)}),S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:"应用筛选"})]})})()}):p.length>0?S.jsxs("div",{className:"row compact gen-filters",children:[p.map(z=>{const A=s[z]||{name:z,label:z,type:"string"},D=$[z]||A.enum_values||[],L=Bf(A)||D.length>0;return S.jsxs("label",{children:[A.label||z,L?S.jsxs("select",{value:g[z]||"",onChange:H=>y(K=>({...K,[z]:H.target.value})),children:[S.jsx("option",{value:"",children:"全部"}),D.map(H=>S.jsx("option",{value:H,children:H},H))]}):S.jsx("input",{value:g[z]||"",placeholder:"筛选…",onChange:H=>y(K=>({...K,[z]:H.target.value}))})]},z)}),S.jsx("div",{className:"actions",style:{marginTop:0},children:S.jsx("button",{type:"button",className:"btn secondary",disabled:i,onClick:()=>void R(),children:"应用筛选"})})]}):null,S.jsxs("p",{className:"pages-line",children:["共 ",N," 条"]}),I.length===0?S.jsx("div",{className:"empty",children:"暂无数据,可点「新增」或导入 Excel"}):S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{children:[S.jsx("thead",{children:S.jsxs("tr",{children:[f.map(z=>{var A;return S.jsx("th",{children:((A=s[z])==null?void 0:A.label)||z},z)}),(h.includes("edit")||h.includes("delete"))&&S.jsx("th",{children:"操作"})]})}),S.jsx("tbody",{children:I.map((z,A)=>S.jsxs("tr",{children:[f.map(D=>{const L=Y_(D,z[D]);return D==="status"?S.jsx("td",{className:"cell-status",children:S.jsx("span",{className:`badge ${XZ(L)}`,children:L})},D):S.jsx("td",{className:D.endsWith("_at")?"cell-muted":void 0,children:L},D)}),(h.includes("edit")||h.includes("delete"))&&S.jsx("td",{children:S.jsxs("div",{className:"actions",style:{margin:0,gap:6},children:[h.includes("edit")&&S.jsx("button",{type:"button",className:"btn secondary",style:{padding:"6px 10px"},onClick:()=>m(String(z.id)),children:x("edit","编辑")}),h.includes("delete")&&S.jsx("button",{type:"button",className:"btn secondary",style:{padding:"6px 10px"},onClick:()=>void P(String(z.id)),children:x("delete","删除")})]})})]},String(z.id??A)))})]})})]})}function JZ(e){var w,I;const{session:t,slug:n,resource:r,page:o,title:s,fields:i,editId:l,busy:c,setBusy:u,setError:d,setInfo:m,onDone:f}=e,p=(((w=o.layout)==null?void 0:w.form_fields)||i.map(C=>C.name)).filter(C=>!KZ.has(C)),h=((I=o.layout)==null?void 0:I.action_labels)||{},b=(C,N)=>h[C]||N,[x,v]=a.useState({}),[g,y]=a.useState({});a.useEffect(()=>{const C={};for(const N of p)C[N]="";v(C),(async()=>{var E,R;const N={};for(const P of p){const T=i.find(_=>_.name===P);T&&(E=T.enum_values)!=null&&E.length&&(N[P]=T.enum_values)}try{const T=(await np(t,n,r)).items||[];for(const _ of p){const M=i.find(k=>k.name===_);if(!M||!Bf(M)||(R=N[_])!=null&&R.length)continue;const O=new Set;for(const k of T){const B=k[_];B!=null&&String(B).trim()!==""&&O.add(String(B))}O.size>0&&O.size<=50&&(N[_]=Array.from(O).sort())}if(l){const _=T.find(M=>String(M.id)===l);if(_){const M={};for(const O of p){const k=i.find(j=>j.name===O),B=_[O]==null?"":String(_[O]);k&&Lf(k)?M[O]=B:k&&H0(k)?M[O]=V0(B,"date"):M[O]=B}v(M)}}}catch(P){l&&d(P.message||String(P))}y(N)})()},[l,n,r]);async function $(){u(!0),d("");try{const C={};for(const N of p){const E=i.find(P=>P.name===N),R=x[N];if((E==null?void 0:E.type)==="int"||(E==null?void 0:E.type)==="bigint"||(E==null?void 0:E.type)==="decimal"?C[N]=R===""?null:Number(R):(E==null?void 0:E.type)==="boolean"?C[N]=R==="true":E&&Lf(E)||E&&H0(E)?C[N]=R===""?null:R:C[N]=R,Bf(E||{name:N,label:N,type:"string"})&&!R)throw new Error(`请选择「${(E==null?void 0:E.label)||N}」`)}l?(await LY(t,n,r,l,C),m("已更新")):(await BY(t,n,r,C),m("已创建")),f()}catch(C){d(qZ(C.message||String(C)))}finally{u(!1)}}return S.jsxs("section",{className:"panel gen-panel",style:{maxWidth:560},children:[S.jsx("h2",{className:"section-title",children:s}),S.jsx("div",{className:"row",children:p.map(C=>{const N=i.find(R=>R.name===C)||{name:C,label:C,type:"string"},E=g[C]||N.enum_values||[];return S.jsxs("label",{children:[N.label||C,S.jsx(GZ,{meta:N,value:x[C]||"",options:E,onChange:R=>v(P=>({...P,[C]:R}))})]},C)})}),S.jsxs("div",{className:"actions",children:[S.jsx("button",{type:"button",className:"btn",disabled:c,onClick:()=>void $(),children:l?b("save","保存"):b("create","创建")}),S.jsx("button",{type:"button",className:"btn secondary",disabled:c,onClick:f,children:b("cancel","取消")})]})]})}function ZZ(e){var g,y,$,w,I,C,N,E,R,P;const{session:t,slug:n,resource:r,page:o,fieldMap:s={},setError:i}=e,l=((g=o.layout)==null?void 0:g.widgets)||[],[c,u]=a.useState(null),[d,m]=a.useState([]),f=((y=l.find(T=>T.type==="bar_chart"||T.type==="pie_chart"))==null?void 0:y.group_by)||(($=l.find(T=>T.group_by))==null?void 0:$.group_by)||"",p=((w=l.find(T=>T.metric&&T.metric!=="count"))==null?void 0:w.metric)||((C=(I=l.find(T=>{var _;return(_=T.metrics)==null?void 0:_.length}))==null?void 0:I.metrics)==null?void 0:C[0])||"",h=a.useMemo(()=>JSON.stringify(l),[(N=o.layout)==null?void 0:N.widgets]);if(a.useEffect(()=>{(async()=>{try{if(f){const _=await AY(t,n,r,f,p||void 0);u(_)}if(l.some(_=>["line_chart","table","status_strip"].includes(_.type))||!f){const _=await np(t,n,r);m(_.items||[]),f||u({total:_.total||(_.items||[]).length})}}catch(T){i(T.message||String(T))}})()},[t,n,r,f,p,i,h]),!c)return S.jsx("div",{className:"panel gen-panel",children:S.jsx("div",{className:"empty",children:"加载看板…"})});function b(T){var _;return((_=s[T])==null?void 0:_.label)||T}function x(T){const _=T.x_field||T.group_by||"",M=(T.metrics&&T.metrics.length?T.metrics:T.metric&&T.metric!=="count"?[T.metric]:[]).filter(Boolean);if(!_||!M.length||!d.length)return null;const k=[...d].sort((j,z)=>String(j[_]??"").localeCompare(String(z[_]??""),"zh")).slice(0,100).map(j=>{const z={};for(const A of M){const D=Number(j[A]);Number.isFinite(D)&&(z[A]=D)}return{x:String(j[_]??""),values:z}}),B=M.map(j=>({key:j,label:b(j)}));return S.jsx(W_,{title:T.title||"趋势图",points:k,series:B,yUnit:T.y_unit||""},`line-${T.title}-${_}`)}function v(T,_){if(!_.filter_field)return!0;const M=T[_.filter_field],O=Number(M),k=_.filter_op||"gt",B=Number(_.filter_value??0);return k==="gt"?Number.isFinite(O)&&O>B:k==="gte"?Number.isFinite(O)&&O>=B:k==="lt"?Number.isFinite(O)&&OT.type==="kpi").length?l.filter(T=>T.type==="kpi"):[{type:"kpi",title:"记录数",metric:"count"}]).map((T,_)=>S.jsx(_Z,{title:T.title||"KPI",value:T.metric==="count"||!T.metric?c.total:Number(c.sum||0).toFixed(2)},`${T.title}-${_}`))}),l.filter(T=>T.type==="line_chart").map(T=>x(T)),l.filter(T=>T.type==="status_strip").map((T,_)=>{const M=T.label_field||"",O=T.value_field||"",k=T.secondary_field||"",B=T.warn_field||"",j=Number(T.cycle_days)||30,z=T.variant==="stacked"||T.variant==="stacked_days"||!!k;if(!M||!O)return null;const A=d.slice(0,48).map(D=>{let L=Number(D[O]??0),H=k?Number(D[k]??0):0;if(z&&L+H>50&&L+H<120){const K=Math.round(L/100*j);H=Math.max(0,j-K),L=K}return{label:String(D[M]??""),value:L,secondary:z?H:void 0,tone:B&&Number(D[B]??0)>0?"warn":"ok",stop:String(D.status||"").includes("停")||z&&L===0&&H===0}});return S.jsx(K_,{title:T.title||"状态条",variant:z?"stacked":"cells",items:A},`strip-${_}`)}),l.filter(T=>T.type==="table").map((T,_)=>{var k;const M=(k=T.columns)!=null&&k.length?T.columns:Object.keys(d[0]||{}).slice(0,6),O=d.filter(B=>v(B,T)).slice(0,50);return S.jsxs("div",{className:"chart-card",children:[S.jsx("h4",{children:T.title||"明细表"}),S.jsx("div",{className:"table-wrap",children:S.jsxs("table",{children:[S.jsx("thead",{children:S.jsx("tr",{children:M.map(B=>S.jsx("th",{children:b(B)},B))})}),S.jsxs("tbody",{children:[O.map((B,j)=>S.jsx("tr",{children:M.map(z=>S.jsx("td",{children:Y_(z,B[z])},z))},j)),!O.length&&S.jsx("tr",{children:S.jsx("td",{colSpan:M.length,className:"empty",children:"暂无数据"})})]})]})})]},`tbl-${_}`)}),S.jsxs("div",{className:"chart-grid",children:[l.filter(T=>T.type==="bar_chart").map((T,_)=>S.jsx(wE,{title:T.title||"分布",buckets:c.buckets||[]},`bar-${_}`)),l.filter(T=>T.type==="pie_chart").map((T,_)=>S.jsx(MZ,{title:T.title||"占比",buckets:c.buckets||[]},`pie-${_}`)),!l.some(T=>T.type==="bar_chart"||T.type==="pie_chart")&&(((P=c.buckets)==null?void 0:P.length)||0)>0&&S.jsx(wE,{title:"分布",buckets:c.buckets||[]})]})]})}async function jg(e){const t=`${Dc}/api/v1/demo/file/${e.split("/").map(encodeURIComponent).join("/")}`,n=await fetch(t);if(!n.ok)return null;const r=await n.blob(),o=e.split("/").pop()||"file";return{blob:r,name:o}}function Bg(e,t,n){return new File([e],t,{type:n||e.type||"application/octet-stream"})}async function eee(){var d,m,f,p,h,b;const e=[],t=await fetch(`${Dc}/api/v1/demo/fixtures`);if(!t.ok)throw new Error(`无法读取测试素材清单 HTTP ${t.status}`);const n=await t.json();if(!n.available)throw new Error(`测试目录不可用:${n.root||"test/"}`);const o=await(await fetch(`${Dc}/api/v1/demo/prompt`)).json(),s=String(o.prompt||"");s||e.push(n.prompt||"prompt");const i=n.data||((m=(d=n.files)==null?void 0:d.data)==null?void 0:m.path);let l=null;if(i){const x=await jg(i);x?l=Bg(x.blob,x.name,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"):e.push(i)}const c=[];for(const x of n.images||((p=(f=n.files)==null?void 0:f.images)==null?void 0:p.map(v=>v.path))||[]){const v=await jg(x);v?c.push(Bg(v.blob,v.name,"image/png")):e.push(x)}const u=[];for(const x of n.layouts||((b=(h=n.files)==null?void 0:h.layouts)==null?void 0:b.map(v=>v.path))||[]){const v=await jg(x);v?u.push(Bg(v.blob,v.name,"text/html")):e.push(x)}return{prompt:s,slug:n.slug||"settlement_observation_system",excel:l,images:c,layouts:u,label:n.label||"演示包",missing:e}}const{Header:tee,Sider:nee,Content:ree}=Fs,oee={platform:"平台管理",generate:"生成与发布",modules:"模块管理",sync:"数据同步",agent:"智能体胶囊",roles:"角色管理",agents:"智能体账号",orgs:"组织管理",invites:"邀请加入",members:"成员管理",audit:"审计"};function see({session:e,entitlements:t,tab:n,onTabChange:r,onOpenApp:o,onLogout:s,onSession:i,busy:l,banner:c,children:u}){const[d,m]=a.useState(!1),[f,p]=a.useState(!1),[h,b]=a.useState(!1),[x,v]=a.useState(!1),[g,y]=a.useState(!1),[$,w]=a.useState(!1),[I]=De.useForm(),[C]=De.useForm(),{token:N}=gX.useToken(),{message:E}=wo.useApp(),R=a.useMemo(()=>{const P=[],T=Nr(e.role),_=(e.tenantId||0)>0;if(T&&!_)return P.push({key:"platform",icon:S.jsx(vE,{}),label:"平台管理"}),P;if(!_)return P;T&&P.push({key:"platform",icon:S.jsx(vE,{}),label:"平台管理"});const M=k=>EY(t,k),O=jl(e.role)||T;return(M("发布模块")||M("写入模块")||M("读取模块"))&&P.push({key:"generate",icon:S.jsx(cZ,{}),label:"生成与发布"}),M("读取模块")&&P.push({key:"modules",icon:S.jsx(UQ,{}),label:"模块管理"}),O&&M("数据同步")&&P.push({key:"sync",icon:S.jsx(aJ,{}),label:"数据同步"}),M("读取模块")&&P.push({key:"agent",icon:S.jsx(b_,{}),label:"智能体胶囊"}),M("管理智能体")&&(P.push({key:"roles",icon:S.jsx(jf,{}),label:"角色管理"}),P.push({key:"agents",icon:S.jsx(WJ,{}),label:"智能体账号"})),O&&M("管理组织")&&P.push({key:"orgs",icon:S.jsx(AQ,{}),label:"组织管理"}),O&&M("邀请成员")&&(P.push({key:"invites",icon:S.jsx(mZ,{}),label:"邀请加入"}),P.push({key:"members",icon:S.jsx(sZ,{}),label:"成员管理"})),M("查看审计")&&P.push({key:"audit",icon:S.jsx(eJ,{}),label:"审计"}),P},[e,t]);return S.jsxs(Fs,{className:"console-root",style:{minHeight:"100vh"},children:[S.jsxs(nee,{collapsible:!0,collapsed:d,trigger:null,width:232,className:"console-sider",theme:"light",children:[S.jsxs("div",{className:`console-brand ${d?"is-collapsed":""}`,children:[S.jsx("span",{className:"console-brand-mark",children:"宇"}),!d&&S.jsxs("div",{className:"console-brand-text",children:[S.jsx("strong",{children:"宇信达智建"}),S.jsx("span",{children:Nr(e.role)?"平台超管工作台":"AI 建站控制台"})]})]}),S.jsx(Fi,{mode:"inline",selectedKeys:[n],items:R,onClick:({key:P})=>r(P),style:{borderInlineEnd:0,padding:"8px 8px 24px"}})]}),S.jsxs(Fs,{children:[S.jsxs(tee,{className:"console-header",style:{background:N.colorBgContainer},children:[S.jsxs(Mt,{size:"middle",children:[S.jsx(Ke,{type:"text",icon:d?S.jsx(RJ,{}):S.jsx(EJ,{}),onClick:()=>m(P=>!P)}),S.jsx(Oe.Title,{level:4,style:{margin:0},children:oee[n]||"控制台"})]}),S.jsxs(Mt,{size:"middle",wrap:!0,children:[S.jsxs(Mt,{size:8,children:[S.jsx($T,{size:"small",icon:S.jsx(yZ,{}),style:{background:N.colorPrimary}}),S.jsx("span",{className:"console-user",children:e.displayName||e.username}),e.username?S.jsx(Oe.Text,{type:"secondary",code:!0,style:{fontSize:12},children:e.username}):null,e.phone?S.jsx(Dt,{icon:S.jsx(bE,{}),children:e.phone}):S.jsx(Dt,{children:"未绑手机"}),S.jsx(Dt,{color:"green",children:rc(e.role||"管理员")}),Nr(e.role)&&e.tenantId>0?S.jsxs(S.Fragment,{children:[S.jsxs(Dt,{color:"orange",children:["管理:",e.tenantName||`公司 #${e.tenantId}`]}),S.jsx(Ke,{size:"small",icon:S.jsx(YQ,{}),loading:$,onClick:async()=>{w(!0);try{const P=await g_(e);y0(P),i==null||i(P),r("platform"),E.success("已回到平台工作台")}catch(P){E.error(P.message||String(P))}finally{w(!1)}},children:"返回平台工作台"})]}):e.tenantId>0?S.jsxs(Dt,{children:["公司 #",e.tenantId]}):null]}),S.jsx(Ke,{icon:S.jsx(bE,{}),onClick:()=>{C.setFieldsValue({phone:e.phone||""}),v(!0)},children:e.phone?"更换手机":"绑定手机"}),S.jsx(Ke,{icon:S.jsx(jf,{}),onClick:()=>{I.resetFields(),p(!0)},children:"修改密码"}),S.jsx(Ke,{onClick:o,disabled:l,children:"打开模块"}),S.jsx(Ke,{icon:S.jsx(R_,{}),onClick:s,children:"退出"})]})]}),S.jsxs(ree,{className:"console-content",children:[c,S.jsx("div",{className:"console-panel",children:u})]})]}),S.jsx(tn,{title:"修改密码",open:f,onCancel:()=>p(!1),confirmLoading:h,onOk:async()=>{const P=await I.validateFields();b(!0);try{await OQ(e,P.old_password,P.new_password),E.success("密码已更新"),p(!1),I.resetFields()}catch(T){E.error(T.message||String(T))}finally{b(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:I,layout:"vertical",children:[S.jsxs(Oe.Paragraph,{type:"secondary",children:["账号 ",S.jsx(Oe.Text,{code:!0,children:e.username})," 为系统分配、不可更改;仅可修改密码。 绑定手机后也可用手机号 + 密码登录。"]}),S.jsx(De.Item,{name:"old_password",label:"当前密码",rules:[{required:!0,message:"请输入当前密码"}],children:S.jsx(Pt.Password,{autoComplete:"current-password"})}),S.jsx(De.Item,{name:"new_password",label:"新密码",rules:[{required:!0,message:"请输入新密码"},{min:6,message:"至少 6 位"}],children:S.jsx(Pt.Password,{autoComplete:"new-password"})}),S.jsx(De.Item,{name:"confirm",label:"确认新密码",dependencies:["new_password"],rules:[{required:!0,message:"请再次输入"},({getFieldValue:P})=>({validator(T,_){return!_||P("new_password")===_?Promise.resolve():Promise.reject(new Error("两次输入不一致"))}})],children:S.jsx(Pt.Password,{autoComplete:"new-password"})})]})}),S.jsx(tn,{title:e.phone?"更换手机号":"绑定手机号",open:x,onCancel:()=>v(!1),confirmLoading:g,onOk:async()=>{const P=await C.validateFields();y(!0);try{const T=(P.phone||"").trim(),_=await zQ(e,T),M={...e,phone:_.phone||void 0,usernameLoginDisabled:!!_.username_login_disabled};y0(M),i==null||i(M),E.success(_.phone?`已绑定 ${_.phone}`:"已更新"),v(!1)}catch(T){E.error(T.message||String(T))}finally{y(!1)}},destroyOnHidden:!0,children:S.jsxs(De,{form:C,layout:"vertical",children:[S.jsx(Oe.Paragraph,{type:"secondary",children:"绑定后可用手机号+密码或短信登录。有 License 期限控制时也可用用户名登录。"}),S.jsx(De.Item,{name:"phone",label:"手机号",rules:[{validator:async(P,T)=>{const _=String(T||"").trim();if(_&&!/^1[3-9]\d{9}$/.test(_)&&!/^\+?86\s*1[3-9]\d{9}$/.test(_.replace(/\s/g,"")))throw new Error("请输入 11 位大陆手机号")}}],children:S.jsx(Pt,{placeholder:"例如 13800138000",maxLength:20,allowClear:!0})})]})})]})}function $$({children:e,subtitle:t}){return S.jsxs("div",{className:"auth-shell",children:[S.jsx("div",{className:"auth-backdrop","aria-hidden":!0}),S.jsxs(rr,{className:"auth-card",bordered:!1,children:[S.jsx(Oe.Title,{level:2,className:"auth-brand",children:"宇信达智建"}),S.jsx(Oe.Paragraph,{type:"secondary",style:{marginTop:-8},children:t}),e]})]})}function ro(e,t){var r;const n=(r=e.current)==null?void 0:r.input;return n&&typeof n.value=="string"?n.value:t}function iee(e){const[t,n]=a.useState("account_password"),[r,o]=a.useState(""),[s,i]=a.useState(""),[l,c]=a.useState(0),[u,d]=a.useState(!1),m=a.useRef(null),f=a.useRef(null),p=a.useRef(null),h=a.useRef(null),b=a.useRef(null);a.useEffect(()=>{if(l<=0)return;const y=window.setTimeout(()=>c($=>$-1),1e3);return()=>window.clearTimeout(y)},[l]);const x=()=>{if(t==="phone_sms"){const w=ro(h,e.username).trim(),I=ro(b,r).trim();e.onUsername(w),e.onLogin({mode:t,phone:w,sms_code:I});return}if(t==="phone_password"){const w=ro(h,e.username).trim(),I=ro(f,e.password);e.onUsername(w),e.onPassword(I),e.onLogin({mode:t,phone:w,password:I});return}const y=ro(m,e.username).trim(),$=ro(f,e.password);e.onUsername(y),e.onPassword($),e.onLogin({mode:t,username:y,password:$})},v=()=>{const y=ro(m,e.username).trim()||ro(h,e.username).trim(),$=ro(f,e.password),w=ro(p,e.displayName).trim();e.onUsername(y),e.onPassword($),e.onDisplayName(w),e.onRegister(y,$,w)};async function g(){const y=ro(h,e.username).trim();if(!/^1[3-9]\d{9}$/.test(y)){i("请先填写正确的 11 位手机号");return}d(!0),i("");try{const $=await RY(y);c($.retry_after&&$.retry_after>0?$.retry_after:60),$.debug_code?(o($.debug_code),i(`开发模式验证码:${$.debug_code}(正式环境将发短信)`)):i($.message||"验证码已发送")}catch($){i($.message||String($))}finally{d(!1)}}return S.jsxs($$,{subtitle:"描述 + Excel/CSV/JSON → 自动建库建 API → 生成可操作的前端页面",children:[S.jsx(hV,{block:!0,style:{marginBottom:16},value:t,onChange:y=>n(y),options:[{label:"账号密码",value:"account_password"},{label:"手机密码",value:"phone_password"},{label:"短信登录",value:"phone_sms"}]}),S.jsxs(De,{layout:"vertical",requiredMark:!1,onFinish:x,children:[t==="account_password"?S.jsx(De.Item,{label:"用户名",children:S.jsx(Pt,{ref:m,size:"large",value:e.username,onChange:y=>e.onUsername(y.target.value),autoComplete:"username",placeholder:"系统分配的用户名",allowClear:!0})}):S.jsx(De.Item,{label:"手机号",children:S.jsx(Pt,{ref:h,size:"large",value:e.username,onChange:y=>e.onUsername(y.target.value),autoComplete:"tel",placeholder:"已绑定的 11 位手机号",allowClear:!0})}),t==="phone_sms"?S.jsx(De.Item,{label:"短信验证码",children:S.jsxs(Mt.Compact,{style:{width:"100%"},children:[S.jsx(Pt,{ref:b,size:"large",value:r,onChange:y=>o(y.target.value),placeholder:"6 位验证码",maxLength:8}),S.jsx(Ke,{size:"large",loading:u,disabled:l>0||e.busy,onClick:()=>void g(),children:l>0?`${l}s`:"获取验证码"})]})}):S.jsx(De.Item,{label:"密码",children:S.jsx(Pt.Password,{ref:f,size:"large",value:e.password,onChange:y=>e.onPassword(y.target.value),autoComplete:"current-password"})}),t==="account_password"?S.jsx(De.Item,{label:"显示名(仅注册用,登录可忽略)",children:S.jsx(Pt,{ref:p,size:"large",value:e.displayName,onChange:y=>e.onDisplayName(y.target.value)})}):null,e.error?S.jsx(po,{type:"error",showIcon:!0,message:e.error,style:{marginBottom:16}}):null,s?S.jsx(po,{type:"info",showIcon:!0,message:s,style:{marginBottom:16}}):null,e.info&&!e.info.startsWith("已填入测试默认")?S.jsx(po,{type:"success",showIcon:!0,message:e.info,style:{marginBottom:16}}):null,t==="account_password"?S.jsxs(Mt,{wrap:!0,style:{marginBottom:12},children:[S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("demo"),e.onPassword("demo123"),e.onDisplayName("演示用户")},children:"填入 demo"}),S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("ljk_admin"),e.onPassword("ljk_admin"),e.onDisplayName("平台超级管理员")},children:"填入 ljk_admin"})]}):S.jsxs(Mt,{wrap:!0,style:{marginBottom:12},children:[S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("13800000001"),e.onPassword("demo123")},children:"填入 demo 手机"}),S.jsx(Ke,{type:"link",size:"small",onClick:()=>{e.onUsername("13531041945"),e.onPassword("ljk_admin")},children:"填入超管手机"})]}),S.jsxs("div",{className:"auth-actions",children:[S.jsx(Ke,{type:"primary",htmlType:"submit",size:"large",block:!0,loading:e.busy,children:"登录"}),t==="account_password"?S.jsx(Ke,{htmlType:"button",size:"large",block:!0,disabled:e.busy,onClick:v,children:"注册"}):null]}),S.jsx(Oe.Paragraph,{type:"secondary",style:{marginTop:20,marginBottom:0,fontSize:13},children:"支持用户名+密码、手机号+密码、手机号+短信。外公司部署用 License 控期限时,不必强制手机登录。"})]})]})}function aee(e){return S.jsxs($$,{subtitle:"账号已注册,但尚未加入任何公司。未入驻前不能查看未公布数据与业务页面。",children:[S.jsxs(Oe.Text,{type:"secondary",children:[e.displayLabel," · pending"]}),e.error&&S.jsx(po,{type:"error",showIcon:!0,message:e.error,style:{margin:"16px 0"}}),e.info&&S.jsx(po,{type:"success",showIcon:!0,message:e.info,style:{margin:"16px 0"}}),S.jsxs(De,{layout:"vertical",style:{marginTop:16},requiredMark:!1,children:[S.jsx(De.Item,{label:"邀请码",children:S.jsx(Pt,{size:"large",value:e.inviteCode,onChange:t=>e.onInviteCode(t.target.value),placeholder:"粘贴公司管理员发来的邀请码"})}),S.jsx(Ke,{type:"primary",size:"large",block:!0,loading:e.busy,disabled:!e.inviteCode.trim(),onClick:e.onAcceptInvite,children:"加入已有公司"}),S.jsx(rV,{children:"或"}),S.jsx(De.Item,{label:"公司名称",children:S.jsx(Pt,{size:"large",value:e.companyName,onChange:t=>e.onCompanyName(t.target.value),placeholder:"创建自己的公司(成为管理员)"})}),S.jsxs(Mt,{direction:"vertical",style:{width:"100%"},children:[S.jsx(Ke,{size:"large",block:!0,loading:e.busy,onClick:e.onCreateCompany,children:"创建公司"}),S.jsx(Ke,{size:"large",block:!0,onClick:e.onLogout,children:"退出"})]})]})]})}function lee(e){return S.jsx($$,{subtitle:e.message,children:e.error?S.jsx(po,{type:"error",showIcon:!0,message:e.error}):null})}function Lg(){const t=(window.location.hash||"").replace(/^#/,"").match(/^\/?app\/([a-zA-Z][a-zA-Z0-9_]{0,63})\/?$/);return t?t[1]:null}function cee(e){const t=`#/app/${encodeURIComponent(e)}`;window.location.hash===t?window.dispatchEvent(new Event("hashchange")):window.location.hash=t}function rd(){!window.location.hash||window.location.hash==="#/"||window.location.hash==="#"||(window.location.hash="#/")}function ia(e,t){if(e)try{const n=new DataTransfer;for(const r of t)n.items.add(r);e.files=n.files}catch{}}function uee(){var ke,je,We;const[e,t]=a.useState("generate"),[n,r]=a.useState("console"),[o,s]=a.useState(null),[i,l]=a.useState(""),[c,u]=a.useState(""),[d,m]=a.useState("demo"),[f,p]=a.useState("demo123"),[h,b]=a.useState("演示用户"),[x,v]=a.useState(""),[g,y]=a.useState(""),[$,w]=a.useState(""),[I,C]=a.useState(null),[N,E]=a.useState([]),[R,P]=a.useState([]),T=a.useRef(null),_=a.useRef(null),M=a.useRef(null),O=a.useRef(0),[k,B]=a.useState("schema_per_app"),[j,z]=a.useState("deepseek"),[A,D]=a.useState("deepseek-chat"),[L,H]=a.useState([]),[K,V]=a.useState(null),[W,q]=a.useState([]),[ee,se]=a.useState(null),[le,ce]=a.useState(null),[G,ne]=a.useState("myapp"),[re,U]=a.useState("__new__"),[J,oe]=a.useState([]),[Z,Q]=a.useState(null),[ae,te]=a.useState("records"),[Y,de]=a.useState(""),[ue,ge]=a.useState(!0),[we,he]=a.useState(!1),[Be,be]=a.useState(!1),[Fe,_e]=a.useState([]),[Ee,Te]=a.useState(null),[$e,Ce]=a.useState(!1),[qe,Qe]=a.useState("");async function ye(fe=!1){if(!zg()&&!o){fe||l("请先登录后再填入测试默认");return}he(!0),fe||l("");try{const ze=await eee();w(ze.prompt),C(ze.excel),E(ze.images),P(ze.layouts),ne(ze.slug),Ce(!0),ia(T.current,ze.excel?[ze.excel]:[]),ia(_.current,ze.images),ia(M.current,ze.layouts);const lt=[ze.excel?ze.excel.name:null,ze.images.length?`${ze.images.length} 张截图`:null,ze.layouts.length?`${ze.layouts.length} 个 HTML`:null].filter(Boolean);Qe(lt.join(" · ")||"仅需求文本");const Ze=ze.missing.length?`(缺:${ze.missing.join(", ")})`:"";u(`已填入测试默认:${ze.label}${Ze}`)}catch(ze){fe||l(ze.message||String(ze))}finally{he(!1)}}a.useEffect(()=>{const fe=zg();fe&&s(fe);const ze=()=>{s(null),!(td()||Lg())&&(l("登录已失效,请重新登录"),rd(),r("console"),Q(null))};return window.addEventListener("ajz:session-expired",ze),_Y().then(lt=>{var gt,kt,rt;H(lt.providers||[]);const Ze=lt.default||"deepseek",wt=(lt.providers||[]).find(Ge=>Ge.id===Ze)||((gt=lt.providers)==null?void 0:gt[0]);wt&&(z(wt.id),D(wt.default_model||((rt=(kt=wt.models)==null?void 0:kt[0])==null?void 0:rt.id)||""))}).catch(()=>{}),()=>window.removeEventListener("ajz:session-expired",ze)},[]),a.useEffect(()=>{!(o!=null&&o.accessToken)||Og(o)||Nr(o.role)&&!(o.tenantId>0)||localStorage.getItem("ajz_skip_demo_autoload")==="1"||$e||ye(!0).catch(()=>{})},[o==null?void 0:o.accessToken,o==null?void 0:o.tenantId]),a.useEffect(()=>{if(!(o!=null&&o.accessToken)||Og(o)){oe([]),Te(null);return}if(Nr(o.role)&&!(o.tenantId>0)){t("platform"),oe([]),Te(null);return}oc(o).then(fe=>oe(fe.items||[])).catch(()=>oe([])),o.tenantId>0?h_(o).then(fe=>Te(fe.permissions||[])).catch(()=>Te(Nr(o.role)?null:[])):Te(null)},[o]),a.useEffect(()=>{let fe=!1;async function ze(){var kt,rt,Ge,He,Ae,dt,vt,ct;const lt=++O.current,Ze=()=>fe||lt!==O.current,wt=td();if(wt){Ze()||(he(!0),l(""),Q(null));try{const yt=await SY(wt);if(Ze())return;Q(yt.blueprint),V(yt.blueprint),ne(((rt=(kt=yt.blueprint)==null?void 0:kt.meta)==null?void 0:rt.slug)||"preview"),te(yt.resource||"records"),r("app")}catch(yt){Ze()||(Mg(),l(yt.message||String(yt)),r("console"),Q(null),rd())}finally{Ze()||he(!1)}return}Mg();const gt=Lg();if(!gt){Ze()||(r("console"),Q(null));return}Ze()||(he(!0),l(""),ne(gt),Q(null));try{const yt=o||zg(),St=await pE(yt,gt);if(Ze())return;if(String(((Ge=St==null?void 0:St.meta)==null?void 0:Ge.slug)||"")!==gt)throw new Error(`模块路由不匹配:请求 ${gt},返回 ${String(((He=St==null?void 0:St.meta)==null?void 0:He.slug)||"空")}`);Q(St),V(St);const Tt=((ct=(vt=(dt=(Ae=St==null?void 0:St.apis)==null?void 0:Ae.resources)==null?void 0:dt[0])==null?void 0:vt.path)==null?void 0:ct.replace(/^\//,""))||ae;te(Tt),r("app")}catch(yt){Ze()||(l(yt.message||String(yt)),r("console"),Q(null),rd())}finally{Ze()||he(!1)}}return ze(),window.addEventListener("hashchange",ze),()=>{fe=!0,O.current++,window.removeEventListener("hashchange",ze)}},[o]),a.useEffect(()=>{!$e&&!I&&!N.length&&!R.length||(ia(T.current,I?[I]:[]),ia(_.current,N),ia(M.current,R))},[$e,I,N,R,e,o,n]);function Ne(fe){s(fe),y0(fe)}async function Re(fe){be(!0),l(""),u("");try{const ze=fe.mode==="phone_sms"?{phone:String(fe.phone||"").trim(),sms_code:String(fe.sms_code||"").trim()}:fe.mode==="phone_password"?{phone:String(fe.phone||"").trim(),password:String(fe.password||"")}:{username:String(fe.username||"").trim(),password:String(fe.password||"")},lt=await NY(ze);(Nr(lt.role)||lt.username==="ljk_admin")&&t("platform"),Ne(lt),u(`已登录 ${lt.displayName||lt.phone||lt.username}(${lt.role||"用户"})`)}catch(ze){l(ze.message||String(ze))}finally{be(!1)}}async function Xe(fe=d,ze=f,lt=h){be(!0),l(""),u("");try{const Ze=await TY(String(fe||"").trim(),String(ze||""),String(lt||"").trim());Ne(Ze),u("注册成功:待加入公司(pending)。请输入邀请码,或创建自己的公司。")}catch(Ze){l(Ze.message||String(Ze))}finally{be(!1)}}async function Ye(){if(o){be(!0),l("");try{const fe=await YY(o,x.trim());Ne(fe),u(fe.displayName?`已加入租户 #${fe.tenantId}`:`已加入租户 #${fe.tenantId}`),v("")}catch(fe){l(fe.message||String(fe))}finally{be(!1)}}}async function Ve(){if(o){be(!0),l("");try{const fe=await QY(o,g.trim()||h||d);Ne(fe),u(`已创建公司(租户 #${fe.tenantId}),你是管理员`),y("")}catch(fe){l(fe.message||String(fe))}finally{be(!1)}}}async function at(){var fe,ze,lt,Ze,wt,gt,kt,rt,Ge,He;he(!0),l(""),se(null),ce(null);try{const Ae=await MY($,I,N,k,j,A,R);V(Ae.draft),q(Ae.warnings||[]),se(Ae.fidelity||null),ce(Ae.generate_log||null),(ze=(fe=Ae.draft)==null?void 0:fe.meta)!=null&&ze.slug&&ne(Ae.draft.meta.slug);const dt=(kt=(gt=(wt=(Ze=(lt=Ae.draft)==null?void 0:lt.apis)==null?void 0:Ze.resources)==null?void 0:wt[0])==null?void 0:gt.path)==null?void 0:kt.replace(/^\//,"");dt&&te(dt);const vt=Ae.fidelity;let ct="";vt&&!vt.skipped&&(ct=vt.passed?`还原度达标 ${vt.final_score}%(目标 ${vt.target}%)。`:`还原度 ${vt.final_score??"—"}%(目标 ${vt.target}%),请查看差异后继续微调或再生成。`);const yt=(rt=Ae.generate_log)!=null&&rt.run_id?` run=${Ae.generate_log.run_id}`:"";let St="";if(o&&((He=(Ge=Ae.draft)==null?void 0:Ge.meta)!=null&&He.slug))try{const Tt=String(Ae.draft.meta.slug).trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").slice(0,48);if(Tt){await zY(o,Tt,Ae.draft);const fn=await oc(o);oe(fn.items||[]),U("__new__"),St=`已登记为在建模块「${Tt}」。`}}catch(Tt){St=`(在建登记未成功:${Tt.message||Tt})`}u(`草稿置信度 ${Ae.confidence}。${ct}${St}确认发布后将打开模块页。${yt}`)}catch(Ae){l(Ae.message||String(Ae))}finally{he(!1)}}function xe(fe){ne(fe),cee(fe)}async function Le(){var fe,ze,lt,Ze,wt,gt,kt,rt;if(!(!o||!K)){he(!0),l("");try{const Ge=JSON.parse(JSON.stringify(K)),He=re!=="__new__";let Ae=He?re:String(((fe=Ge==null?void 0:Ge.meta)==null?void 0:fe.slug)||"app").trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");He||((!Ae||!/^[a-z]/.test(Ae))&&(Ae=`app_${Ae||"draft"}`.replace(/_+/g,"_")),Ae=Ae.slice(0,48).replace(/_+$/g,"")||"app");const dt=He?J.find(_t=>_t.slug===Ae):null;Ge.meta={...Ge.meta||{},slug:Ae,name:(dt==null?void 0:dt.name)||((ze=Ge.meta)==null?void 0:ze.name)||Ae},Ge.meta.name||(Ge.meta.name=Ae),Ge.version||(Ge.version="1.0"),Ge.storage||(Ge.storage={mode:"schema_per_app",engine:"postgres"}),Ge.security||(Ge.security={visibility:"private",roles:[],row_policies:[]}),Ge.apis&&(Ge.apis={...Ge.apis,base_path:`/api/v1/apps/${Ae}`});const vt=_t=>String(_t||"").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),ct={};for(const _t of Ge.entities||[]){const Zt=String(_t.name||"");_t.name&&(_t.name=vt(_t.name)||"record"),_t.table&&(_t.table=vt(_t.table)||_t.name),Zt&&(ct[Zt]=_t.name,ct[vt(Zt)]=_t.name);for(const gn of _t.fields||[]){gn.name&&(gn.name=vt(String(gn.name).replace(/\./g,"_"))||"field");const In=String(gn.type||"string").toLowerCase();["float","float64","double","number","numeric"].includes(In)?gn.type="decimal":["integer","int32"].includes(In)?gn.type="int":["int64","long"].includes(In)?gn.type="bigint":In==="bool"?gn.type="boolean":["varchar","str"].includes(In)&&(gn.type="string")}}for(const _t of((lt=Ge.apis)==null?void 0:lt.resources)||[]){const Zt=String(_t.entity||"");_t.entity=ct[Zt]||ct[vt(Zt)]||vt(Zt)||_t.entity,_t.path&&(_t.path="/"+(vt(String(_t.path).replace(/^\//,""))||"items"))}for(const _t of Ge.pages||[]){const Zt=String(_t.entity||"");_t.entity=ct[Zt]||ct[vt(Zt)]||vt(Zt)||_t.entity}const yt=((kt=(gt=(wt=(Ze=Ge==null?void 0:Ge.apis)==null?void 0:Ze.resources)==null?void 0:wt[0])==null?void 0:gt.path)==null?void 0:kt.replace(/^\//,""))||ae;te(yt);const Tt=await jY(o,Ae,Ge,He?"add_pages":"create");V(Ge),ne(Ae);try{const _t=await oc(o);oe(_t.items||[])}catch{}const fn=Tt.publish_mode==="pages_added"||Tt.publish_mode==="merged"?`已发布新页面${(rt=Tt.added_pages)!=null&&rt.length?`(${Tt.added_pages.join(", ")})`:""}`:"已新建模块";u(`${fn} ${Ae} → ${Tt.schema_name}。正在跳转模块页…`),xe(Ae)}catch(Ge){l(Ge.message||String(Ge))}finally{he(!1)}}}function me(){if(!o)return;if(l(""),!G.trim()){l("请填写已发布模块 slug");return}const fe=J.find(ze=>ze.slug===G.trim());if(fe&&fe.status!=="published"){l(`模块「${G}」状态为${fe.status_label||fe.status},请先发布后再打开;可在「模块管理」继续编辑`);return}u(`正在跳转模块:/#/app/${G}`),xe(G.trim())}async function Pe(){if(o){he(!0),l("");try{const fe=await DY(o,G);de(fe.capsule),u(fe.hint),t("agent")}catch(fe){l(fe.message||String(fe))}finally{he(!1)}}}if(n==="app"&&Z)return S.jsx(YZ,{session:o,blueprint:Z,onBack:()=>{Mg(),rd()}},String(((ke=Z==null?void 0:Z.meta)==null?void 0:ke.slug)||G));const ve=async fe=>{if(t(fe),l(""),fe==="audit"&&o)try{const ze=await VY(o);_e(ze.items||[])}catch(ze){l(ze.message||String(ze))}};if((td()||Lg())&&!Z)return S.jsx(lee,{message:`正在打开${td()?"草稿预览":"模块"}…`,error:i||void 0});if(!o)return S.jsx(iee,{username:d,password:f,displayName:h,busy:Be,error:i,info:c,onUsername:m,onPassword:p,onDisplayName:b,onLogin:Re,onRegister:Xe});if(Og(o))return S.jsx(aee,{displayLabel:o.displayName||o.username||"",inviteCode:x,companyName:g,busy:Be,error:i,info:c,onInviteCode:v,onCompanyName:y,onAcceptInvite:Ye,onCreateCompany:Ve,onLogout:()=>{Oa(),s(null)}});const Me=(L.length?L:[{id:"deepseek",label:"DeepSeek",configured:!0,default_model:"",models:[]},{id:"minimax",label:"MiniMax",configured:!0,default_model:"",models:[]},{id:"heuristic",label:"本地启发式",configured:!0,default_model:"",models:[]}]).map(fe=>({value:fe.id,label:`${fe.label}${fe.configured===!1?"(未配置 Key)":""}`})),Ie=(((je=L.find(fe=>fe.id===j))==null?void 0:je.models)||[]).map(fe=>({value:fe.id,label:fe.label}));return!Ie.length&&A&&Ie.push({value:A,label:A||"默认"}),S.jsxs(see,{session:o,entitlements:Ee,tab:e,busy:we,onTabChange:ve,onOpenApp:me,onSession:Ne,onLogout:()=>{Oa(),s(null)},banner:S.jsxs(S.Fragment,{children:[i?S.jsx(po,{type:"error",showIcon:!0,closable:!0,message:i,onClose:()=>l(""),style:{marginBottom:12}}):null,c?S.jsx(po,{type:"success",showIcon:!0,closable:!0,message:c,onClose:()=>u(""),style:{marginBottom:12}}):null]}),children:[e==="generate"&&S.jsxs(Tv,{gutter:[16,16],children:[S.jsx(si,{xs:24,lg:14,children:S.jsx(rr,{title:"需求与素材",extra:S.jsxs(Mt,{children:[S.jsx(Ke,{disabled:we,onClick:()=>ye(!1),children:"填入测试默认"}),$e&&S.jsxs(Oe.Text,{type:"secondary",children:["已加载:",qe]})]}),children:S.jsxs(De,{layout:"vertical",requiredMark:!1,children:[S.jsx(De.Item,{label:"需求描述",extra:"可写业务要求、按键,以及截图关系。上传截图后,未点名修改的部分按原图还原。",children:S.jsx(Pt.TextArea,{rows:6,placeholder:`示例: 两张截图为同一界面:一张展开监督条,一张为收起态;以展开态为准还原。 平台抬头:…… 操作:新增、刷新、导入 Excel、导出 Excel`,value:$,onChange:fe=>w(fe.target.value)})}),S.jsx(De.Item,{label:"数据文件(xlsx / csv / json)",extra:I?`当前:${I.name}`:void 0,children:S.jsx("input",{ref:T,type:"file",accept:".xlsx,.xls,.csv,.json",onChange:fe=>{var ze;return C(((ze=fe.target.files)==null?void 0:ze[0])||null)}})}),S.jsx(De.Item,{label:"界面截图",extra:N.length?`当前:${N.map(fe=>fe.name).join("、")}`:"上传后自动走还原闭环",children:S.jsx("input",{ref:_,type:"file",accept:"image/*",multiple:!0,onChange:fe=>E(Array.from(fe.target.files||[]))})}),S.jsx(De.Item,{label:"页面源码(Ctrl+S 另存为)",extra:R.length?`当前:${R.map(fe=>fe.name).join("、")}`:"支持 .html / .htm / .mhtml",children:S.jsx("input",{ref:M,type:"file",accept:".html,.htm,.mhtml,.mht,.xhtml,text/html,multipart/related",multiple:!0,onChange:fe=>P(Array.from(fe.target.files||[]))})}),S.jsxs(Tv,{gutter:12,children:[S.jsx(si,{xs:24,md:8,children:S.jsx(De.Item,{label:"大模型",children:S.jsx(Qt,{value:j,options:Me,onChange:fe=>{var lt,Ze;z(fe);const ze=L.find(wt=>wt.id===fe);D((ze==null?void 0:ze.default_model)||((Ze=(lt=ze==null?void 0:ze.models)==null?void 0:lt[0])==null?void 0:Ze.id)||"")}})})}),S.jsx(si,{xs:24,md:8,children:S.jsx(De.Item,{label:"模型",children:S.jsx(Qt,{value:A,options:Ie,onChange:D})})}),S.jsx(si,{xs:24,md:8,children:S.jsx(De.Item,{label:"存储模式",children:S.jsx(Qt,{value:k,onChange:fe=>B(fe),options:[{value:"schema_per_app",label:"共享库 · schema"},{value:"database_per_app",label:"独立库"}]})})})]}),S.jsx(De.Item,{label:"发布目标",children:S.jsx(Qt,{value:re,onChange:fe=>{U(fe),fe!=="__new__"&&ne(fe)},options:[{value:"__new__",label:"新建模块(草稿 slug)"},...J.map(fe=>({value:fe.slug,label:`${fe.name||fe.slug}(${fe.slug} · ${fe.status_label||fe.status} · ${fe.page_count} 页)`}))]})}),S.jsx(Oe.Paragraph,{type:"secondary",style:{marginTop:-8},children:re==="__new__"?"将创建新模块;slug 取自蓝图 meta.slug。不同用户可访问的模块由授权决定。":"将把草稿里新生成的页面发布到该模块(page id / route 不可与现有重复)。"}),S.jsx(De.Item,{label:"已发布 slug(打开模块用)",children:S.jsx(Pt,{value:G,onChange:fe=>ne(fe.target.value)})}),S.jsx(De.Item,{label:"持久化上传(对象存储)",children:S.jsx("input",{type:"file",onChange:async fe=>{var lt;const ze=(lt=fe.target.files)==null?void 0:lt[0];if(!(!ze||!o))try{const Ze=await jQ(o,ze);u(`已上传 ${Ze.filename} → ${Ze.url}`)}catch(Ze){l(Ze.message||String(Ze))}}})}),S.jsxs(Mt,{wrap:!0,children:[S.jsx(Ke,{type:"primary",loading:we,onClick:at,children:"生成蓝图草稿"}),S.jsx(Ke,{disabled:we||!K,onClick:Le,children:re==="__new__"?"确认发布(新建模块)":"确认发布(新页面)"}),S.jsx(Ke,{disabled:we,onClick:me,children:"打开已有模块"})]}),W.length>0&&S.jsx(po,{style:{marginTop:16},type:"warning",showIcon:!0,message:"生成警告",description:S.jsx("ul",{style:{margin:0,paddingLeft:18},children:W.map(fe=>S.jsx("li",{children:fe},fe))})}),ee&&!ee.skipped&&S.jsx(rr,{size:"small",style:{marginTop:16},title:`还原度迭代 ${ee.passed?"已达标":"未达标"} · ${ee.final_score??"—"}% / 目标 ${ee.target}%`,children:S.jsx("ul",{style:{margin:0,paddingLeft:18},children:(ee.rounds||[]).map(fe=>S.jsxs("li",{children:["第",fe.round,"轮:",fe.score??"—","%",fe.pass?" ✓":"",(fe.fails||[]).length?` · 差异:${(fe.fails||[]).slice(0,5).join(";")}${(fe.fails||[]).length>5?"…":""}`:""]},fe.round))})}),((We=le==null?void 0:le.lines)==null?void 0:We.length)>0&&S.jsxs(rr,{size:"small",style:{marginTop:16},title:`生成日志 · ${le.run_id||"—"}`,children:[S.jsxs(Oe.Paragraph,{type:"secondary",style:{marginBottom:8},children:["服务端同步写入 .runtime/logs/generate/",le.log_file?`(本次:${String(le.log_file).replace(/^.*[\\/]/,"")})`:""]}),S.jsx("pre",{className:"generate-log-body",children:le.lines.map(fe=>`${(fe.level||"info").toUpperCase().padEnd(7)} ${fe.message||""}`).join(` diff --git a/web/dist/index.html b/web/dist/index.html index 276b623..17b51b1 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -7,7 +7,7 @@ - + diff --git a/web/src/api.ts b/web/src/api.ts index 61f78df..ee8b2e8 100644 --- a/web/src/api.ts +++ b/web/src/api.ts @@ -386,7 +386,12 @@ export async function listRows( : `${PLATFORM}/api/v1/public/apps/${slug}/${resource}?${qs}`; // 草稿预览:优先用预览包内嵌行数据(未发布也可出图) const prev = getActivePreview(); - if (prev && (!resource || resource === prev.resource || !prev.resource)) { + const previewSlug = String(prev?.blueprint?.meta?.slug || ""); + if ( + prev && + previewSlug === slug && + (!resource || resource === prev.resource || !prev.resource) + ) { let items = prev.rows || []; if (filters) { items = items.filter((row) => diff --git a/联调后修改意见-宇恒松离线.md b/联调后修改意见-宇恒松离线.md index 3bbe3bf..ed87901 100644 --- a/联调后修改意见-宇恒松离线.md +++ b/联调后修改意见-宇恒松离线.md @@ -1285,10 +1285,10 @@ POST /api/v1/agent/sync/channels/{id}/pull 1. **根因修复**:智能体绑定的 `database_name` 是多模块共享库;旧逻辑却强制 `database_per_app/public`,导致不同 slug 的同名实体表复用。现改为共享库内 `schema_per_app`,每个模块使用独立 `app_t{tenant}_{slug}`;旧 `public` 模块重发时升级到独立 Schema,随后由双向同步重新灌入所属数据。 2. **标识符防碰撞**:Schema/独立库名超过 48 字符时保留可读前缀并附加 slug 内容哈希,不再直接截断造成长 slug 碰撞。 -3. **页面防串包**:hash 路由加载增加请求序号,快速切换模块时旧请求不得覆盖新蓝图;加载期间卸载旧模块,且校验返回蓝图 `meta.slug` 必须等于 URL slug。蓝图/数据 GET 使用 `no-store`。 +3. **页面防串包**:hash 路由加载增加请求序号,快速切换模块时旧请求不得覆盖新蓝图;加载期间卸载旧模块,且校验返回蓝图 `meta.slug` 必须等于 URL slug。预览行缓存同时校验 slug+resource;蓝图/数据 GET 使用 `no-store`。 4. **回执与 capsule 可核对**:publish 增加 `blueprint_revision`、`resource_tables`;agent-capsule 增加 `app_slug`、`schema_name`、revision 和各资源物理 table。 5. **诊断与拒绝回退**:CRUD 解析后强校验 requested slug 与 resolved app 一致、Schema/table 非空;日志记录 tenant、requested slug、resource、resolved Schema/table、revision。现有 Meta 查询仍严格按 `tenant_id + slug`,不存在默认模块回退。 -6. **缓存说明**:当前仓无按页面结构复用的构建产物缓存;以 tenant+slug 定位元数据并以蓝图 revision 作为诊断/响应标识,HTTP 明确 `no-store`,避免旧运行时配置被复用。 +6. **缓存与路径说明**:当前仓无按页面结构复用的构建产物缓存;以 tenant+slug 定位元数据并以蓝图 revision 作为诊断/响应标识,HTTP 明确 `no-store`。发布(含仅改 host_meta)无条件把 `apis.base_path` 重写为当前 slug,禁止克隆蓝图沿用旧模块路径。 #### 宇恒改(须)