@tom2012/cc-web 2026.4.20-d → 2026.4.22-a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/index.d.ts.map +1 -1
  3. package/backend/dist/index.js +41 -0
  4. package/backend/dist/index.js.map +1 -1
  5. package/backend/dist/routes/sync.d.ts.map +1 -1
  6. package/backend/dist/routes/sync.js +61 -11
  7. package/backend/dist/routes/sync.js.map +1 -1
  8. package/backend/dist/sync-service.d.ts +44 -0
  9. package/backend/dist/sync-service.d.ts.map +1 -1
  10. package/backend/dist/sync-service.js +188 -21
  11. package/backend/dist/sync-service.js.map +1 -1
  12. package/frontend/dist/assets/{AssistantMessageContent-BhfKqZ7C.js → AssistantMessageContent-Cbd8kEKb.js} +1 -1
  13. package/frontend/dist/assets/{GraphPreview-BzH3Wak5.js → GraphPreview-oSG5zw4O.js} +1 -1
  14. package/frontend/dist/assets/{MobilePage-BQRuj2Cs.js → MobilePage-DNkQnE7-.js} +4 -4
  15. package/frontend/dist/assets/{OfficePreview-B-VYapp6.js → OfficePreview-C5YVCs_i.js} +2 -2
  16. package/frontend/dist/assets/{ProjectPage-CsiEfciU.js → ProjectPage-BI-45S2D.js} +5 -5
  17. package/frontend/dist/assets/SettingsPage-BBVvLPDr.js +13 -0
  18. package/frontend/dist/assets/{SkillHubPage-Bl50eKHR.js → SkillHubPage-fxW189Ca.js} +3 -3
  19. package/frontend/dist/assets/{chevron-down-WeK3LuVf.js → chevron-down-DwQtRZFp.js} +1 -1
  20. package/frontend/dist/assets/{chevron-up-CJDXUdmI.js → chevron-up-B43U8MiF.js} +1 -1
  21. package/frontend/dist/assets/{index-vHzDarwZ.css → index-CjKxGpPA.css} +1 -1
  22. package/frontend/dist/assets/{index-BrqN6Jet.js → index-CjiPKISh.js} +4 -4
  23. package/frontend/dist/assets/{index-Bu3s8sE1.js → index-CqX-dw66.js} +1 -1
  24. package/frontend/dist/assets/{index-c0ovO67g.js → index-DHlRaHat.js} +1 -1
  25. package/frontend/dist/assets/{jszip.min-BwsPvdp_.js → jszip.min-COVqv5KF.js} +1 -1
  26. package/frontend/dist/assets/{search-0gpkXlAu.js → search-Bg2yBV9K.js} +1 -1
  27. package/frontend/dist/index.html +2 -2
  28. package/package.json +1 -1
  29. package/frontend/dist/assets/SettingsPage-oMXzGZc9.js +0 -13
@@ -1,13 +0,0 @@
1
- import{c as e,r as s,U as t,aV as n,j as a,W as r,V as o,N as l,d as i,K as c,aW as d,aI as u,Q as h,aX as m,L as p,Y as x,$ as f,a0 as g,a1 as v,a2 as j,x as y,aY as b,t as w,af as N,I as k,B as S,aC as C,D as _,aZ as R,a_ as P,a$ as E,u as I,b0 as T,T as M,b1 as D,b2 as A,b3 as H,b4 as L,b5 as O,ax as V,b6 as F,b7 as B,h as z,S as W,b8 as K,ay as U,b9 as q,s as $,ba as G}from"./index-BrqN6Jet.js";import{k as Z,u as X,R as Y,d as Q,f as J,A as ee,C as se,j as te,h as ne,S as ae,U as re,i as oe,T as le,a as ie,b as ce,c as de}from"./index-Bu3s8sE1.js";import{C as ue}from"./chevron-down-WeK3LuVf.js";import{C as he,a as me}from"./chevron-up-CJDXUdmI.js";
2
- /**
3
- * @license lucide-react v0.309.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const pe=e("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),xe=e("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),fe=e("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]),ge=e("ExternalLink",[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]]),ve=e("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),je=e("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),ye=e("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),be=e("UploadCloud",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]]);
8
- /**
9
- * @license lucide-react v0.309.0 - ISC
10
- *
11
- * This source code is licensed under the ISC license.
12
- * See the LICENSE file in the root directory of this source tree.
13
- */function we(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ne="Switch",[ke]=l(Ne),[Se,Ce]=ke(Ne),_e=s.forwardRef((e,l)=>{const{__scopeSwitch:i,name:c,checked:d,defaultChecked:u,required:h,disabled:m,value:p="on",onCheckedChange:x,form:f,...g}=e,[v,j]=s.useState(null),y=t(l,e=>j(e)),b=s.useRef(!1),w=!v||(f||!!v.closest("form")),[N,k]=n({prop:d,defaultProp:u??!1,onChange:x,caller:Ne});return a.jsxs(Se,{scope:i,checked:N,disabled:m,children:[a.jsx(r.button,{type:"button",role:"switch","aria-checked":N,"aria-required":h,"data-state":Ie(N),"data-disabled":m?"":void 0,disabled:m,value:p,...g,ref:y,onClick:o(e.onClick,e=>{k(e=>!e),w&&(b.current=e.isPropagationStopped(),b.current||e.stopPropagation())})}),w&&a.jsx(Ee,{control:v,bubbles:!b.current,name:c,value:p,checked:N,required:h,disabled:m,form:f,style:{transform:"translateX(-100%)"}})]})});_e.displayName=Ne;var Re="SwitchThumb",Pe=s.forwardRef((e,s)=>{const{__scopeSwitch:t,...n}=e,o=Ce(Re,t);return a.jsx(r.span,{"data-state":Ie(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:s})});Pe.displayName=Re;var Ee=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:o=!0,...l},i)=>{const c=s.useRef(null),d=t(c,i),u=we(r),h=Z(n);return s.useEffect(()=>{const e=c.current;if(!e)return;const s=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(s,"checked").set;if(u!==r&&t){const s=new Event("click",{bubbles:o});t.call(e,r),e.dispatchEvent(s)}},[u,r,o]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...l,tabIndex:-1,ref:d,style:{...l.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Ie(e){return e?"checked":"unchecked"}Ee.displayName="SwitchBubbleInput";var Te=_e,Me=Pe;const De=s.forwardRef(({className:e,...s},t)=>a.jsx(Te,{className:i("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:t,children:a.jsx(Me,{className:i("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));function Ae(e){const t=He(e),n=s.forwardRef((e,n)=>{const{children:r,...o}=e,l=s.Children.toArray(r),i=l.find(Oe);if(i){const e=i.props.children,r=l.map(t=>t===i?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return a.jsx(t,{...o,ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,r):null})}return a.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function He(e){const t=s.forwardRef((e,t)=>{const{children:n,...a}=e;if(s.isValidElement(n)){const e=function(e){var s,t;let n=null==(s=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:s.get,a=n&&"isReactWarning"in n&&n.isReactWarning;if(a)return e.ref;if(n=null==(t=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:t.get,a=n&&"isReactWarning"in n&&n.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,s){const t={...s};for(const n in s){const a=e[n],r=s[n];/^on[A-Z]/.test(n)?a&&r?t[n]=(...e)=>{const s=r(...e);return a(...e),s}:a&&(t[n]=a):"style"===n?t[n]={...a,...r}:"className"===n&&(t[n]=[a,r].filter(Boolean).join(" "))}return{...e,...t}}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?c(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}De.displayName=Te.displayName;var Le=Symbol("radix.slottable");function Oe(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Le}var Ve=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});s.forwardRef((e,s)=>a.jsx(r.span,{...e,ref:s,style:{...Ve,...e.style}})).displayName="VisuallyHidden";var Fe=[" ","Enter","ArrowUp","ArrowDown"],Be=[" ","Enter"],ze="Select",[We,Ke,Ue]=J(ze),[qe]=l(ze,[Ue,Q]),$e=Q(),[Ge,Ze]=qe(ze),[Xe,Ye]=qe(ze),Qe=e=>{const{__scopeSelect:t,children:r,open:o,defaultOpen:l,onOpenChange:i,value:c,defaultValue:u,onValueChange:h,dir:m,name:p,autoComplete:x,disabled:f,required:g,form:v}=e,j=$e(t),[y,b]=s.useState(null),[w,N]=s.useState(null),[k,S]=s.useState(!1),C=X(m),[_,R]=n({prop:o,defaultProp:l??!1,onChange:i,caller:ze}),[P,E]=n({prop:c,defaultProp:u,onChange:h,caller:ze}),I=s.useRef(null),T=!y||(v||!!y.closest("form")),[M,D]=s.useState(new Set),A=Array.from(M).map(e=>e.props.value).join(";");return a.jsx(Y,{...j,children:a.jsxs(Ge,{required:g,scope:t,trigger:y,onTriggerChange:b,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:d(),value:P,onValueChange:E,open:_,onOpenChange:R,dir:C,triggerPointerDownPosRef:I,disabled:f,children:[a.jsx(We.Provider,{scope:t,children:a.jsx(Xe,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(s=>new Set(s).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(s=>{const t=new Set(s);return t.delete(e),t})},[]),children:r})}),T?a.jsxs(Os,{"aria-hidden":!0,required:g,tabIndex:-1,name:p,autoComplete:x,value:P,onChange:e=>E(e.target.value),disabled:f,form:v,children:[void 0===P?a.jsx("option",{value:""}):null,Array.from(M)]},A):null]})})};Qe.displayName=ze;var Je="SelectTrigger",es=s.forwardRef((e,n)=>{const{__scopeSelect:l,disabled:i=!1,...c}=e,d=$e(l),u=Ze(Je,l),h=u.disabled||i,m=t(n,u.onTriggerChange),p=Ke(l),x=s.useRef("touch"),[f,g,v]=Fs(e=>{const s=p().filter(e=>!e.disabled),t=s.find(e=>e.value===u.value),n=Bs(s,e,t);void 0!==n&&u.onValueChange(n.value)}),j=e=>{h||(u.onOpenChange(!0),v()),e&&(u.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return a.jsx(ee,{asChild:!0,...d,children:a.jsx(r.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:h,"data-disabled":h?"":void 0,"data-placeholder":Vs(u.value)?"":void 0,...c,ref:m,onClick:o(c.onClick,e=>{e.currentTarget.focus(),"mouse"!==x.current&&j(e)}),onPointerDown:o(c.onPointerDown,e=>{x.current=e.pointerType;const s=e.target;s.hasPointerCapture(e.pointerId)&&s.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(j(e),e.preventDefault())}),onKeyDown:o(c.onKeyDown,e=>{const s=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||g(e.key),s&&" "===e.key||Fe.includes(e.key)&&(j(),e.preventDefault())})})})});es.displayName=Je;var ss="SelectValue",ts=s.forwardRef((e,s)=>{const{__scopeSelect:n,className:o,style:l,children:i,placeholder:c="",...d}=e,h=Ze(ss,n),{onValueNodeHasChildrenChange:m}=h,p=void 0!==i,x=t(s,h.onValueNodeChange);return u(()=>{m(p)},[m,p]),a.jsx(r.span,{...d,ref:x,style:{pointerEvents:"none"},children:Vs(h.value)?a.jsx(a.Fragment,{children:c}):i})});ts.displayName=ss;var ns=s.forwardRef((e,s)=>{const{__scopeSelect:t,children:n,...o}=e;return a.jsx(r.span,{"aria-hidden":!0,...o,ref:s,children:n||"▼"})});ns.displayName="SelectIcon";var as=e=>a.jsx(h,{asChild:!0,...e});as.displayName="SelectPortal";var rs="SelectContent",os=s.forwardRef((e,t)=>{const n=Ze(rs,e.__scopeSelect),[r,o]=s.useState();if(u(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?m.createPortal(a.jsx(is,{scope:e.__scopeSelect,children:a.jsx(We.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(us,{...e,ref:t})});os.displayName=rs;var ls=10,[is,cs]=qe(rs),ds=Ae("SelectContent.RemoveScroll"),us=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:l="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:c,onPointerDownOutside:d,side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:y,collisionBoundary:b,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S,...C}=e,_=Ze(rs,r),[R,P]=s.useState(null),[E,I]=s.useState(null),T=t(n,e=>P(e)),[M,D]=s.useState(null),[A,H]=s.useState(null),L=Ke(r),[O,V]=s.useState(!1),F=s.useRef(!1);s.useEffect(()=>{if(R)return x(R)},[R]),f();const B=s.useCallback(e=>{const[s,...t]=L().map(e=>e.ref.current),[n]=t.slice(-1),a=document.activeElement;for(const r of e){if(r===a)return;if(null==r||r.scrollIntoView({block:"nearest"}),r===s&&E&&(E.scrollTop=0),r===n&&E&&(E.scrollTop=E.scrollHeight),null==r||r.focus(),document.activeElement!==a)return}},[L,E]),z=s.useCallback(()=>B([M,R]),[B,M,R]);s.useEffect(()=>{O&&z()},[O,z]);const{onOpenChange:W,triggerPointerDownPosRef:K}=_;s.useEffect(()=>{if(R){let e={x:0,y:0};const s=s=>{var t,n;e={x:Math.abs(Math.round(s.pageX)-((null==(t=K.current)?void 0:t.x)??0)),y:Math.abs(Math.round(s.pageY)-((null==(n=K.current)?void 0:n.y)??0))}},t=t=>{e.x<=10&&e.y<=10?t.preventDefault():R.contains(t.target)||W(!1),document.removeEventListener("pointermove",s),K.current=null};return null!==K.current&&(document.addEventListener("pointermove",s),document.addEventListener("pointerup",t,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",t,{capture:!0})}}},[R,W,K]),s.useEffect(()=>{const e=()=>W(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[W]);const[U,q]=Fs(e=>{const s=L().filter(e=>!e.disabled),t=s.find(e=>e.ref.current===document.activeElement),n=Bs(s,e,t);n&&setTimeout(()=>n.ref.current.focus())}),$=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&(D(e),n&&(F.current=!0))},[_.value]),G=s.useCallback(()=>null==R?void 0:R.focus(),[R]),Z=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&H(e)},[_.value]),X="popper"===l?ms:hs,Y=X===ms?{side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:y,collisionBoundary:b,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S}:{};return a.jsx(is,{scope:r,content:R,viewport:E,onViewportChange:I,itemRefCallback:$,selectedItem:M,onItemLeave:G,itemTextRefCallback:Z,focusSelectedItem:z,selectedItemText:A,position:l,isPositioned:O,searchRef:U,children:a.jsx(g,{as:ds,allowPinchZoom:!0,children:a.jsx(v,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:o(i,e=>{var s;null==(s=_.trigger)||s.focus({preventScroll:!0}),e.preventDefault()}),children:a.jsx(j,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:a.jsx(X,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...C,...Y,onPlaced:()=>V(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:o(C.onKeyDown,e=>{const s=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),s||1!==e.key.length||q(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let s=L().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(s=s.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const t=e.target,n=s.indexOf(t);s=s.slice(n+1)}setTimeout(()=>B(s)),e.preventDefault()}})})})})})})});us.displayName="SelectContentImpl";var hs=s.forwardRef((e,n)=>{const{__scopeSelect:o,onPlaced:l,...i}=e,c=Ze(rs,o),d=cs(rs,o),[h,m]=s.useState(null),[p,x]=s.useState(null),f=t(n,e=>x(e)),g=Ke(o),v=s.useRef(!1),j=s.useRef(!0),{viewport:y,selectedItem:b,selectedItemText:w,focusSelectedItem:N}=d,k=s.useCallback(()=>{if(c.trigger&&c.valueNode&&h&&p&&y&&b&&w){const e=c.trigger.getBoundingClientRect(),s=p.getBoundingClientRect(),t=c.valueNode.getBoundingClientRect(),n=w.getBoundingClientRect();if("rtl"!==c.dir){const a=n.left-s.left,r=t.left-a,o=e.left-r,l=e.width+o,i=Math.max(l,s.width),c=window.innerWidth-ls,d=te(r,[ls,Math.max(ls,c-i)]);h.style.minWidth=l+"px",h.style.left=d+"px"}else{const a=s.right-n.right,r=window.innerWidth-t.right-a,o=window.innerWidth-e.right-r,l=e.width+o,i=Math.max(l,s.width),c=window.innerWidth-ls,d=te(r,[ls,Math.max(ls,c-i)]);h.style.minWidth=l+"px",h.style.right=d+"px"}const a=g(),r=window.innerHeight-2*ls,o=y.scrollHeight,i=window.getComputedStyle(p),d=parseInt(i.borderTopWidth,10),u=parseInt(i.paddingTop,10),m=parseInt(i.borderBottomWidth,10),x=d+u+o+parseInt(i.paddingBottom,10)+m,f=Math.min(5*b.offsetHeight,x),j=window.getComputedStyle(y),N=parseInt(j.paddingTop,10),k=parseInt(j.paddingBottom,10),S=e.top+e.height/2-ls,C=r-S,_=b.offsetHeight/2,R=d+u+(b.offsetTop+_),P=x-R;if(R<=S){const e=a.length>0&&b===a[a.length-1].ref.current;h.style.bottom="0px";const s=p.clientHeight-y.offsetTop-y.offsetHeight,t=R+Math.max(C,_+(e?k:0)+s+m);h.style.height=t+"px"}else{const e=a.length>0&&b===a[0].ref.current;h.style.top="0px";const s=Math.max(S,d+y.offsetTop+(e?N:0)+_)+P;h.style.height=s+"px",y.scrollTop=R-S+y.offsetTop}h.style.margin=`${ls}px 0`,h.style.minHeight=f+"px",h.style.maxHeight=r+"px",null==l||l(),requestAnimationFrame(()=>v.current=!0)}},[g,c.trigger,c.valueNode,h,p,y,b,w,c.dir,l]);u(()=>k(),[k]);const[S,C]=s.useState();u(()=>{p&&C(window.getComputedStyle(p).zIndex)},[p]);const _=s.useCallback(e=>{e&&!0===j.current&&(k(),null==N||N(),j.current=!1)},[k,N]);return a.jsx(ps,{scope:o,contentWrapper:h,shouldExpandOnScrollRef:v,onScrollButtonChange:_,children:a.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:a.jsx(r.div,{...i,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});hs.displayName="SelectItemAlignedPosition";var ms=s.forwardRef((e,s)=>{const{__scopeSelect:t,align:n="start",collisionPadding:r=ls,...o}=e,l=$e(t);return a.jsx(se,{...l,...o,ref:s,align:n,collisionPadding:r,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ms.displayName="SelectPopperPosition";var[ps,xs]=qe(rs,{}),fs="SelectViewport",gs=s.forwardRef((e,n)=>{const{__scopeSelect:l,nonce:i,...c}=e,d=cs(fs,l),u=xs(fs,l),h=t(n,d.onViewportChange),m=s.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),a.jsx(We.Slot,{scope:l,children:a.jsx(r.div,{"data-radix-select-viewport":"",role:"presentation",...c,ref:h,style:{position:"relative",flex:1,overflow:"hidden auto",...c.style},onScroll:o(c.onScroll,e=>{const s=e.currentTarget,{contentWrapper:t,shouldExpandOnScrollRef:n}=u;if((null==n?void 0:n.current)&&t){const e=Math.abs(m.current-s.scrollTop);if(e>0){const n=window.innerHeight-2*ls,a=parseFloat(t.style.minHeight),r=parseFloat(t.style.height),o=Math.max(a,r);if(o<n){const a=o+e,r=Math.min(n,a),l=a-r;t.style.height=r+"px","0px"===t.style.bottom&&(s.scrollTop=l>0?l:0,t.style.justifyContent="flex-end")}}}m.current=s.scrollTop})})})]})});gs.displayName=fs;var vs="SelectGroup",[js,ys]=qe(vs);s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,o=d();return a.jsx(js,{scope:t,id:o,children:a.jsx(r.div,{role:"group","aria-labelledby":o,...n,ref:s})})}).displayName=vs;var bs="SelectLabel",ws=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,o=ys(bs,t);return a.jsx(r.div,{id:o.id,...n,ref:s})});ws.displayName=bs;var Ns="SelectItem",[ks,Ss]=qe(Ns),Cs=s.forwardRef((e,n)=>{const{__scopeSelect:l,value:i,disabled:c=!1,textValue:u,...h}=e,m=Ze(Ns,l),p=cs(Ns,l),x=m.value===i,[f,g]=s.useState(u??""),[v,j]=s.useState(!1),y=t(n,e=>{var s;return null==(s=p.itemRefCallback)?void 0:s.call(p,e,i,c)}),b=d(),w=s.useRef("touch"),N=()=>{c||(m.onValueChange(i),m.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(ks,{scope:l,value:i,disabled:c,textId:b,isSelected:x,onItemTextChange:s.useCallback(e=>{g(s=>s||((null==e?void 0:e.textContent)??"").trim())},[]),children:a.jsx(We.ItemSlot,{scope:l,value:i,disabled:c,textValue:f,children:a.jsx(r.div,{role:"option","aria-labelledby":b,"data-highlighted":v?"":void 0,"aria-selected":x&&v,"data-state":x?"checked":"unchecked","aria-disabled":c||void 0,"data-disabled":c?"":void 0,tabIndex:c?void 0:-1,...h,ref:y,onFocus:o(h.onFocus,()=>j(!0)),onBlur:o(h.onBlur,()=>j(!1)),onClick:o(h.onClick,()=>{"mouse"!==w.current&&N()}),onPointerUp:o(h.onPointerUp,()=>{"mouse"===w.current&&N()}),onPointerDown:o(h.onPointerDown,e=>{w.current=e.pointerType}),onPointerMove:o(h.onPointerMove,e=>{var s;w.current=e.pointerType,c?null==(s=p.onItemLeave)||s.call(p):"mouse"===w.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:o(h.onPointerLeave,e=>{var s;e.currentTarget===document.activeElement&&(null==(s=p.onItemLeave)||s.call(p))}),onKeyDown:o(h.onKeyDown,e=>{var s;""!==(null==(s=p.searchRef)?void 0:s.current)&&" "===e.key||(Be.includes(e.key)&&N()," "===e.key&&e.preventDefault())})})})})});Cs.displayName=Ns;var _s="SelectItemText",Rs=s.forwardRef((e,n)=>{const{__scopeSelect:o,className:l,style:i,...c}=e,d=Ze(_s,o),h=cs(_s,o),p=Ss(_s,o),x=Ye(_s,o),[f,g]=s.useState(null),v=t(n,e=>g(e),p.onItemTextChange,e=>{var s;return null==(s=h.itemTextRefCallback)?void 0:s.call(h,e,p.value,p.disabled)}),j=null==f?void 0:f.textContent,y=s.useMemo(()=>a.jsx("option",{value:p.value,disabled:p.disabled,children:j},p.value),[p.disabled,p.value,j]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=x;return u(()=>(b(y),()=>w(y)),[b,w,y]),a.jsxs(a.Fragment,{children:[a.jsx(r.span,{id:p.textId,...c,ref:v}),p.isSelected&&d.valueNode&&!d.valueNodeHasChildren?m.createPortal(c.children,d.valueNode):null]})});Rs.displayName=_s;var Ps="SelectItemIndicator",Es=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return Ss(Ps,t).isSelected?a.jsx(r.span,{"aria-hidden":!0,...n,ref:s}):null});Es.displayName=Ps;var Is="SelectScrollUpButton",Ts=s.forwardRef((e,n)=>{const r=cs(Is,e.__scopeSelect),o=xs(Is,e.__scopeSelect),[l,i]=s.useState(!1),c=t(n,o.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollTop>0;i(e)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?a.jsx(As,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop-s.offsetHeight)}}):null});Ts.displayName=Is;var Ms="SelectScrollDownButton",Ds=s.forwardRef((e,n)=>{const r=cs(Ms,e.__scopeSelect),o=xs(Ms,e.__scopeSelect),[l,i]=s.useState(!1),c=t(n,o.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollHeight-s.clientHeight,t=Math.ceil(s.scrollTop)<e;i(t)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?a.jsx(As,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop+s.offsetHeight)}}):null});Ds.displayName=Ms;var As=s.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:l,...i}=e,c=cs("SelectScrollButton",n),d=s.useRef(null),h=Ke(n),m=s.useCallback(()=>{null!==d.current&&(window.clearInterval(d.current),d.current=null)},[]);return s.useEffect(()=>()=>m(),[m]),u(()=>{var e;const s=h().find(e=>e.ref.current===document.activeElement);null==(e=null==s?void 0:s.ref.current)||e.scrollIntoView({block:"nearest"})},[h]),a.jsx(r.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:o(i.onPointerDown,()=>{null===d.current&&(d.current=window.setInterval(l,50))}),onPointerMove:o(i.onPointerMove,()=>{var e;null==(e=c.onItemLeave)||e.call(c),null===d.current&&(d.current=window.setInterval(l,50))}),onPointerLeave:o(i.onPointerLeave,()=>{m()})})}),Hs=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return a.jsx(r.div,{"aria-hidden":!0,...n,ref:s})});Hs.displayName="SelectSeparator";var Ls="SelectArrow";s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,r=$e(t),o=Ze(Ls,t),l=cs(Ls,t);return o.open&&"popper"===l.position?a.jsx(ne,{...r,...n,ref:s}):null}).displayName=Ls;var Os=s.forwardRef(({__scopeSelect:e,value:n,...o},l)=>{const i=s.useRef(null),c=t(l,i),d=we(n);return s.useEffect(()=>{const e=i.current;if(!e)return;const s=window.HTMLSelectElement.prototype,t=Object.getOwnPropertyDescriptor(s,"value").set;if(d!==n&&t){const s=new Event("change",{bubbles:!0});t.call(e,n),e.dispatchEvent(s)}},[d,n]),a.jsx(r.select,{...o,style:{...Ve,...o.style},ref:c,defaultValue:n})});function Vs(e){return""===e||void 0===e}function Fs(e){const t=p(e),n=s.useRef(""),a=s.useRef(0),r=s.useCallback(e=>{const s=n.current+e;t(s),function e(s){n.current=s,window.clearTimeout(a.current),""!==s&&(a.current=window.setTimeout(()=>e(""),1e3))}(s)},[t]),o=s.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,r,o]}function Bs(e,s,t){const n=s.length>1&&Array.from(s).every(e=>e===s[0])?s[0]:s,a=t?e.indexOf(t):-1;let r=(o=e,l=Math.max(a,0),o.map((e,s)=>o[(l+s)%o.length]));var o,l;1===n.length&&(r=r.filter(e=>e!==t));const i=r.find(e=>e.textValue.toLowerCase().startsWith(n.toLowerCase()));return i!==t?i:void 0}Os.displayName="SelectBubbleInput";var zs=es,Ws=ns,Ks=as,Us=os,qs=gs,$s=ws,Gs=Cs,Zs=Rs,Xs=Es,Ys=Ts,Qs=Ds,Js=Hs;const et=Qe,st=ts,tt=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(zs,{ref:n,className:i("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...t,children:[s,a.jsx(Ws,{asChild:!0,children:a.jsx(ue,{className:"h-4 w-4 opacity-50"})})]}));tt.displayName=zs.displayName;const nt=s.forwardRef(({className:e,...s},t)=>a.jsx(Ys,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(he,{className:"h-4 w-4"})}));nt.displayName=Ys.displayName;const at=s.forwardRef(({className:e,...s},t)=>a.jsx(Qs,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(ue,{className:"h-4 w-4"})}));at.displayName=Qs.displayName;const rt=s.forwardRef(({className:e,children:s,position:t="popper",...n},r)=>a.jsx(Ks,{children:a.jsxs(Us,{ref:r,className:i("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===t&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:t,...n,children:[a.jsx(nt,{}),a.jsx(qs,{className:i("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),a.jsx(at,{})]})}));rt.displayName=Us.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx($s,{ref:t,className:i("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s})).displayName=$s.displayName;const ot=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(Gs,{ref:n,className:i("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Xs,{children:a.jsx(y,{className:"h-4 w-4"})})}),a.jsx(Zs,{children:s})]}));ot.displayName=Gs.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx(Js,{ref:t,className:i("-mx-1 my-1 h-px bg-muted",e),...s})).displayName=Js.displayName;function lt(){const[e,t]=s.useState(null),[n,r]=s.useState(!0),[o,l]=s.useState(!1),[i,c]=s.useState(!1),[d,u]=s.useState(!1),[h,m]=s.useState(""),[p,x]=s.useState("");s.useEffect(()=>{let e=!1;return b().then(s=>{e||(t(s),x(s.defaultExcludes.join("\n")))}).catch(e=>w.error(`加载同步配置失败: ${e.message}`)).finally(()=>{e||r(!1)}),()=>{e=!0}},[]);const f=(e,s)=>{t(t=>t?{...t,[e]:s}:t)};return n||!e?a.jsx("div",{className:"text-sm text-muted-foreground",children:"加载中…"}):a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"服务器配置"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-host",children:"主机 (host)"}),a.jsx(k,{id:"sync-host",value:e.host,onChange:e=>f("host",e.target.value),placeholder:"example.com"})]}),a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-port",children:"端口"}),a.jsx(k,{id:"sync-port",type:"number",value:e.port,onChange:e=>f("port",Number(e.target.value)||22)})]}),a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-user",children:"用户名"}),a.jsx(k,{id:"sync-user",value:e.user,onChange:e=>f("user",e.target.value),placeholder:"tom"})]}),a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-remote",children:"远端根路径"}),a.jsx(k,{id:"sync-remote",value:e.remoteRoot,onChange:e=>f("remoteRoot",e.target.value),placeholder:"/data/projects"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["每个项目会同步到 ",a.jsx("code",{children:"远端路径/项目文件夹"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"认证"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(N,{children:"方式"}),a.jsxs(et,{value:e.authMethod,onValueChange:e=>f("authMethod",e),children:[a.jsx(tt,{children:a.jsx(st,{})}),a.jsxs(rt,{children:[a.jsx(ot,{value:"key",children:"SSH key"}),a.jsx(ot,{value:"password",children:"密码"})]})]})]}),"key"===e.authMethod?a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-key",children:"私钥路径"}),a.jsx(k,{id:"sync-key",value:e.keyPath??"",onChange:e=>f("keyPath",e.target.value),placeholder:"~/.ssh/id_rsa"})]}):a.jsxs("div",{children:[a.jsx(N,{htmlFor:"sync-pw",children:"密码"}),a.jsx(k,{id:"sync-pw",type:"password",value:h,onChange:e=>m(e.target.value),placeholder:e.passwordSet?"已设置,留空保持不变":"未设置"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["需要系统安装 ",a.jsx("code",{children:"sshpass"}),"(密码通过 SSHPASS env 传递,不会出现在 argv 里)"]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"同步策略"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(N,{children:"方向"}),a.jsxs(et,{value:e.direction,onValueChange:e=>f("direction",e),children:[a.jsx(tt,{children:a.jsx(st,{})}),a.jsxs(rt,{children:[a.jsx(ot,{value:"push",children:"单向:本地 → 远端(--delete)"}),a.jsx(ot,{value:"pull",children:"单向:远端 → 本地"}),a.jsx(ot,{value:"bidirectional",children:"双向(先 push 再 pull)"})]})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(N,{htmlFor:"sync-cron",children:"定时 cron 表达式"}),a.jsx(k,{id:"sync-cron",value:e.schedule.cron,onChange:s=>f("schedule",{...e.schedule,cron:s.target.value}),placeholder:"0 3 * * *"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["5 段:分 时 日 月 周。例:",a.jsx("code",{children:"0 3 * * *"})," 每天 03:00"]})]}),a.jsxs("div",{className:"flex items-center gap-2 pb-1.5",children:[a.jsx(De,{checked:e.schedule.enabled,onCheckedChange:s=>f("schedule",{...e.schedule,enabled:s})}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"启用"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"默认排除(每行一个 glob)"}),a.jsx("textarea",{value:p,onChange:e=>x(e.target.value),rows:6,className:"w-full font-mono text-xs p-2 rounded border border-input bg-background resize-y",placeholder:"node_modules/\n.git/objects/\n*.log"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["作为 ",a.jsx("code",{children:"rsync --exclude"})," 传入。项目级的额外排除暂通过 API 设置。"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t",children:[a.jsxs(S,{onClick:()=>{(async()=>{if(e){l(!0);try{const s=p.split("\n").map(e=>e.trim()).filter(Boolean),n={host:e.host,port:e.port,user:e.user,authMethod:e.authMethod,keyPath:e.keyPath,remoteRoot:e.remoteRoot,direction:e.direction,defaultExcludes:s,schedule:e.schedule};h&&"__keep__"!==h&&(n.password=h);const a=await R(n);t(a),x(a.defaultExcludes.join("\n")),m(""),w.success("已保存")}catch(s){w.error(`保存失败: ${s.message}`)}finally{l(!1)}}})()},disabled:o,children:[o?a.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(ae,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]}),a.jsxs(S,{variant:"outline",onClick:()=>{(async()=>{c(!0);try{const e=await P();e.ok?w.success(e.message||"连接成功"):w.error(e.message||"连接失败")}catch(e){w.error(`测试失败: ${e.message}`)}finally{c(!1)}})()},disabled:i,children:[i?a.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"}),"测试连接"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(S,{variant:"outline",onClick:()=>{(async()=>{u(!0);try{const e=await E(),s=e.results.filter(e=>e.ok).length,t=e.results.filter(e=>e.skipped).length,n=e.total-s-t;w.success(`同步完成:${s} 成功 / ${t} 跳过 / ${n} 失败`)}catch(e){w.error(`同步失败: ${e.message}`)}finally{u(!1)}})()},disabled:d,title:"按当前方向同步所有项目",children:[d?a.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(re,{className:"h-3.5 w-3.5 mr-1.5"}),"立即同步全部"]})]}),a.jsxs("div",{className:"border-t pt-4 text-xs text-muted-foreground",children:["一次性 push/pull 工具:进入项目内部,点击 header 的 ",a.jsx(re,{className:"inline h-3 w-3"})," / ",a.jsx(_,{className:"inline h-3 w-3"})," 按钮。 或通过 API 调用 ",a.jsx("code",{children:"POST /api/sync/project/:id"})," with body ",a.jsx("code",{children:'{ "direction": "push" }'}),"。"]})]})}function it(){const e=I(),[t,n]=s.useState(null),[r,o]=s.useState(!0),[l,i]=s.useState(""),[c,d]=s.useState(!1);s.useEffect(()=>{let e=!1;return T().then(s=>{e||n(s)}).catch(()=>{e||n({configured:!1,needsReset:!1})}).finally(()=>{e||o(!1)}),()=>{e=!0}},[]);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-1",children:"CCWeb Hub 直接提交"}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:['配置你的 GitHub PAT 后,在 Quick Prompts / Agent Prompts 卡片右键选择"共享"时可一键直接提交 Issue 到 ',a.jsx("code",{children:"zbc0315/ccweb-hub"}),"。 ccweb 本身不自带 token —— 使用你自己的账号身份提交,归属清晰,互不影响。"]})]}),r?a.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[a.jsx(C,{className:"h-4 w-4 animate-spin"}),"加载中…"]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"rounded-md border px-3 py-2.5 text-xs flex items-center gap-2",children:(null==t?void 0:t.configured)?a.jsxs(a.Fragment,{children:[a.jsx(me,{className:"h-4 w-4 text-green-500 shrink-0"}),a.jsx("span",{children:"已配置 token,可直接提交"}),a.jsx("div",{className:"flex-1"}),a.jsxs(S,{size:"sm",variant:"outline",onClick:()=>{(async()=>{if(await e({title:"清除 Hub Token",description:"清除后将无法直接提交到 ccweb-hub,需要重新配置 token。确认?",destructive:!0,confirmLabel:"清除"}))try{await D(),n({configured:!1,needsReset:!1}),w.success("已清除")}catch(s){w.error(`清除失败: ${s.message}`)}})()},children:[a.jsx(M,{className:"h-3.5 w-3.5 mr-1"}),"清除"]})]}):(null==t?void 0:t.needsReset)?a.jsxs(a.Fragment,{children:[a.jsx(xe,{className:"h-4 w-4 text-amber-500 shrink-0"}),a.jsx("span",{children:"之前的 token 已失效(服务端密钥可能已轮换),请重新设置"})]}):a.jsxs(a.Fragment,{children:[a.jsx(xe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{children:"尚未配置 token"})]})}),a.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2.5 text-xs space-y-2",children:[a.jsx("div",{className:"font-medium text-foreground",children:"如何获取 token"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[a.jsxs("li",{children:["打开"," ",a.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline inline-flex items-center gap-0.5",children:["GitHub fine-grained PAT",a.jsx(ge,{className:"h-3 w-3"})]})," ","创建页"]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository access"}),':选 "Only select repositories",添加 ',a.jsx("code",{children:"zbc0315/ccweb-hub"})]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository permissions → Issues"}),':设置为 "Read and write"']}),a.jsx("li",{children:"其余权限保持默认(全部无访问)"}),a.jsx("li",{children:"生成后复制 token 粘贴到下方"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(N,{htmlFor:"hub-token",className:"text-xs",children:["GitHub Token ",(null==t?void 0:t.configured)&&a.jsx("span",{className:"text-muted-foreground",children:"(填写会覆盖现有 token)"})]}),a.jsx(k,{id:"hub-token",type:"password",placeholder:"github_pat_...",value:l,onChange:e=>i(e.target.value),autoComplete:"off",spellCheck:!1}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Token 以 AES-256-GCM 加密存储于 ",a.jsx("code",{children:"~/.ccweb/hub-auth/"}),";per-user 独立,不会被其他用户读到。"]})]}),a.jsx("div",{className:"flex gap-2 pt-2 border-t",children:a.jsxs(S,{onClick:()=>{(async()=>{const e=l.trim();if(e){d(!0);try{const s=await A(e);n(s),i(""),w.success("已保存")}catch(s){w.error(`保存失败: ${s.message}`)}finally{d(!1)}}else w.error("请输入 token")})()},disabled:c||!l.trim(),children:[c?a.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(ae,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]})})]})]})}function ct(){const{t:e,i18n:s}=oe();return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs(et,{value:s.language,onValueChange:async t=>{if(H.includes(t)){try{localStorage.setItem(L,t)}catch{}await s.changeLanguage(t);try{await O(t)}catch{w.error(e("language.switch_failed"))}}},children:[a.jsx(tt,{className:"w-40",children:a.jsx(st,{})}),a.jsxs(rt,{children:[a.jsx(ot,{value:"zh",children:e("language.zh")}),a.jsx(ot,{value:"en",children:e("language.en")})]})]})]})}function dt(){const{t:e}=oe(),t=V(),[n]=F(),r=n.get("tab")||"sync",[o,l]=s.useState(()=>B()),[i,c]=s.useState(!1),[d,u]=s.useState({webhookEnabled:!1}),[h,m]=s.useState(""),[p,x]=s.useState(!1),[f,g]=s.useState(()=>z(W.usageMonitorTool,"claude"));s.useEffect(()=>{K().then(e=>{u(e),m(e.webhookUrl??"")}).catch(()=>{})},[]);const v=(e,s)=>{const t=parseInt(s,10);isNaN(t)||t<1||(l(s=>({...s,[e]:t})),c(!0))};return a.jsx("div",{className:"min-h-screen bg-background",children:a.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[a.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[a.jsx(U,{className:"h-4 w-4 mr-1"}),e("common.back")]}),a.jsx("h1",{className:"text-2xl font-bold",children:e("settings.title")})]}),a.jsxs(le,{defaultValue:r,children:[a.jsxs(ie,{className:"mb-4",children:[a.jsxs(ce,{value:"sync",children:[a.jsx(be,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_sync")]}),a.jsxs(ce,{value:"hub",children:[a.jsx(ve,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_hub")]}),a.jsxs(ce,{value:"notifications",children:[a.jsx(fe,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_notifications")]}),a.jsxs(ce,{value:"pomodoro",children:[a.jsx(q,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_pomodoro")]}),a.jsxs(ce,{value:"usage",children:[a.jsx(pe,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_usage")]}),a.jsxs(ce,{value:"language",children:[a.jsx(je,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_language")]})]}),a.jsx(de,{value:"sync",children:a.jsx(lt,{})}),a.jsx(de,{value:"hub",children:a.jsx(it,{})}),a.jsx(de,{value:"notifications",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.browser_notify.title")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.browser_notify.description")})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.webhook.title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.webhook.description")})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(N,{className:"text-xs",children:"Webhook URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(k,{placeholder:"https://hooks.slack.com/...",value:h,onChange:e=>m(e.target.value),className:"font-mono text-xs"}),a.jsx(S,{size:"sm",onClick:()=>{(async()=>{x(!0);try{const s=await G({webhookEnabled:h.trim().length>0,webhookUrl:h.trim()||void 0});u(s),w.success(e("settings.webhook.saved"))}catch{w.error(e("settings.webhook.save_failed"))}finally{x(!1)}})()},disabled:p,children:e(p?"common.saving":"common.save")})]}),d.webhookEnabled&&d.webhookUrl&&a.jsxs("p",{className:"text-xs text-green-500",children:[e("settings.webhook.enabled_prefix")," ",d.webhookUrl]})]})]})]})}),a.jsx(de,{value:"pomodoro",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.pomodoro.section_desc")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-6 max-w-xs",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(N,{className:"text-xs",children:e("settings.pomodoro.work_minutes")}),a.jsx(k,{type:"number",min:1,max:120,value:o.workMinutes,onChange:e=>v("workMinutes",e.target.value),className:"w-full"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(N,{className:"text-xs",children:e("settings.pomodoro.break_minutes")}),a.jsx(k,{type:"number",min:1,max:60,value:o.breakMinutes,onChange:e=>v("breakMinutes",e.target.value),className:"w-full"})]})]}),i&&a.jsxs(S,{size:"sm",onClick:()=>{$(W.pomodoroConfig,o,!0),c(!1),w.success(e("settings.pomodoro.saved"))},children:[a.jsx(ae,{className:"h-3.5 w-3.5 mr-1.5"}),e("common.save")]})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.howto_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsxs("li",{children:[a.jsx(q,{className:"h-3 w-3 inline-block mx-0.5"})," ",e("settings.pomodoro.howto_item_1")]}),a.jsx("li",{children:e("settings.pomodoro.howto_item_2")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_3")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_4")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_5")})]})]})]})}),a.jsx(de,{value:"usage",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.usage.section_desc")})]}),a.jsx("div",{className:"grid gap-3 max-w-md",children:[{key:"claude",label:"Claude Code",desc:e("settings.usage.tool_claude_desc")},{key:"codex",label:"Codex",desc:e("settings.usage.tool_codex_desc")},{key:"opencode",label:"OpenCode",desc:e("settings.usage.tool_opencode_desc")},{key:"qwen",label:"Qwen Code",desc:e("settings.usage.tool_qwen_desc")},{key:"gemini",label:"Gemini CLI",desc:e("settings.usage.tool_gemini_desc")}].map(s=>a.jsxs("label",{className:"flex items-start gap-3 rounded-lg border p-3 cursor-pointer transition-colors "+(f===s.key?"border-blue-500/50 bg-blue-500/5":"border-border hover:bg-muted/30"),children:[a.jsx("input",{type:"radio",name:"usageTool",value:s.key,checked:f===s.key,onChange:()=>{g(s.key),$(W.usageMonitorTool,s.key),window.dispatchEvent(new Event("ccweb:usage-tool-change")),w.success(e("settings.usage.switched_toast",{tool:s.label}))},className:"mt-0.5"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:s.label}),a.jsx("div",{className:"text-xs text-muted-foreground",children:s.desc})]})]},s.key))})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.info_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsx("li",{children:e("settings.usage.info_item_1")}),a.jsx("li",{children:e("settings.usage.info_item_2")}),a.jsx("li",{children:e("settings.usage.info_item_3")}),a.jsx("li",{children:e("settings.usage.info_item_4")})]})]})]})}),a.jsx(de,{value:"language",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[a.jsx("div",{children:a.jsx("h3",{className:"text-sm font-medium",children:e("language.label")})}),a.jsx(ct,{})]})})})]})]})})}export{dt as SettingsPage};