@xopcai/xopc 0.0.151 → 0.0.152
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.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BuO-OVfD.js → agent-avatar-dicebear-CXe2KDZj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Bpv3h31T.js → agents-BjLxhsVX.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B6OU3Eol.js → app-management-settings-panel-DekP2_hC.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BaP4GFvN.js → appearance-settings-Cfd5YavF.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DZKNIMRg.js → apps-page-PS-uUoSk.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CJX3zIh_.js → archive-plugin-DWglUgbp.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CI1ejk_l.js → attachment-load-BJdxo2Vn.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CjmhICbv.js → automation-suggestion-card-B-TfxjJF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BtZl3B8m.js → automations-page-CtNevo3y.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CZ8nOXqK.js → binary-plugins-DwrYsL8l.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BoSfyS_j.js → block-editor-CIxjL5Kp.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CL1UiPcb.js → browser-settings-page-QncZ-2vS.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-XzDKxPZ8.js → capability-presets-api-ChR2rMfo.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dc_uHYgl.js → capability-presets-settings-panel-_JBmJl5A.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-mALvXpJj.js → channels-settings-Bz3tyWpH.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-logo-BSjlInHT.js → connector-logo-KsRvub5G.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Cm_E3mmI.js → connectors-page-_pT0aE0S.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DcJc91-C.js → desktop-pet-CRCERvWy.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CdeqTa3Q.js → desktop-pet-settings-vGrxshsU.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Cp3fpm0k.js → directory-picker-path-field-BGPYrtx6.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-Bwj1O3zr.js → dreaming-settings-B5pzvNgs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D_1xpKbZ.js → extension-debug-page-BaCko1XU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CqZNCj96.js → extension-page-TTXKCMtb.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-5MWbtQaQ.js → extension-settings-page-CEMb3uXY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Co_IaS34.js → gateway-config-api-Bf37OGhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-kmeWm2Pt.js → gateway-settings-cu-vyeNk.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-FoO-R4_U.js → goal-create-dialog-C-bL8rj8.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-CkJq7N5g.js → goal-detail-page-p5zPrlTq.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-DrtsYjXz.js → goals-config-api-D2pEoiiO.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-DRAN-R64.js → goals-page-D-H2u2-J.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-wq9TKhIZ.js → goals-settings-BVZaBqPa.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-B5zDoHbo.js → heartbeat-settings-B-AC_uwa.js} +1 -1
- package/dist/gateway/static/root/assets/{index-apLU0Hun.js → index-DSydVlxZ.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-3tC9iD21.js → keyboard-shortcuts-settings-w0yIP0UB.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CT-vDTLK.js → local-app-workbench-page-CTq0TIH4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-B9ruF9GV.js → local-apps-page-srIyxJuy.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Ca1X8X2P.js → logs-page-MQB6-NKt.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CzuhSQAB.js → markdown-split-Du5yPuDb.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-a3R4y-EL.js → media-plugins-Cd1Rmw15.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-panel-CbTlz9Of.js → models-hub-panel-BMg_Xqd9.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BCxDy2dV.js → notes-page-DhfrFd89.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-z6sBX9B2.js → notes-workbench-CwJk-D7Y.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-CJfk6M78.js → page-tabs-HACawonJ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-MFopTSgF.js → preview-open-alternatives-CjEZt_F5.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-DU29deIr.js → project-detail-page-Dut_micj.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-Ck3DLTlZ.js → projects-page-sTRlCEZ5.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-gLsLyAyi.js → remote-access-hub-Fx81YH7S.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-D0uhU3Z8.js → save-bar-controls-CbktHUqt.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-NGOH-7wV.js → schedule-field-BGx_Nb45.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BJz5LoqG.js → schema-form-Cg-LJVvG.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-TmNoWpa_.js → sessions-page-DFnmyBpj.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BlWxQ6Ea.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-oDnUHnX_.js → settings-collapsible-section-yYK4O-5E.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DND90dDt.js → settings-form-section-DPSA8tG8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CEJtaoQp.js → settings-loading-skeleton-ClHNJwRL.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B1LJlRi9.js → settings-page-lPM7md10.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CsrLuDsW.js → settings-page-layout-B_-VepeK.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BPCJPHHY.js → setup-status-panel-hORJvGAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C1PwLh-p.js → share-preview-page-DyzplAEL.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DCuqr7js.js → shares-settings-DO3IIgcC.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-kn1Vypcy.js → skill-reload-api-C9BqzDjZ.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-k6VIqTkK.js → skills-page-CvOIrcCJ.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BEsrEkSx.js → system-settings-panel-eIyklo0K.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-dOypdlMf.js → typed-models-lib-BgOpEx3h.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-B9Y_Ciav.js → user-context-page-BG_1IrIJ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-DGC38Lx7.js → user-profile-fields-editor-CfLUK6MT.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DFkZ-tan.js → user-profile-settings-panel-BmzPREhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CEIYZihF.js → utils-DbFnvDPi.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DK6gaQsA.js → voice-api-key-field-1xyza74n.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-DSJb9Kq7.js → work-discovery-page-Dhyk4LHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-DVavwV3D.js → work-item-detail-page-CxBRnWeQ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-page-foJDp0nz.js → work-page-Btq3YeCH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYqZpFCC.js → workflow-run-setup-panel-8HLqUALq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DgO0WAzs.js → workflows-page-D48bPgLI.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/product-delivery.js +63 -0
- package/dist/src/agent/code-intelligence/tool-gating.d.ts +5 -0
- package/dist/src/agent/code-intelligence/tool-gating.js +6 -0
- package/dist/src/agent/tools/automation-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent/tools/goal-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/status.d.ts +8 -0
- package/dist/src/gateway/hono/routes/status.js +71 -1
- package/package.json +9 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CtPhh2m9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-B0B40tpO.js";import{n as a}from"./locale-store-GfSwnwIZ.js";import{Cs as o,au as s,t as c}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-B0B40tpO.js";import{n as a}from"./locale-store-GfSwnwIZ.js";import{Cs as o,au as s,t as c}from"./index-DSydVlxZ.js";import{t as l}from"./desktop-pet-sprite-DqZ6fbIj.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function x(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function S(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function C(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function w(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.feedbackLevel!==`quiet`&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}var T=8e3;function E(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+T:void 0}}function D(e,t){let n={...e};for(let e of t){let t=n[e.sessionKey];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.sessionKey]=E(t,e))}return n}function O(e,t){return t?.runId===e.runId&&t.state===e.state}function k(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function A(e){return e?`/chat/${e.sessionKey}`:void 0}var j=r();function M(e,t,n){return y(e,n)||t===`chatty`||v(e,n)&&t===`normal`?!0:t===`quiet`?e.priority===`high`||e.state===`waiting`||e.state===`error`:e.priority!==`low`}function N(e){return e?e.state===`error`?`error`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function P(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.sessionKey}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function F(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return P(r?.success,t);if(t.state===`waiting`)return P(r?.waiting,t);if(t.state===`error`)return P(r?.error,t)}function I(e,t,n){return e?n?`${e} · ${t}`:e:t}function L(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function R(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function z(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(R),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),T=(0,u.useRef)(null),E=(0,u.useRef)(!1),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useRef)(null),H=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),U=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),W=(0,u.useMemo)(()=>k(Object.values(r),p),[r,p]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?W.filter(e=>!O(e,d[e.sessionKey])&&M(e,t.prefs.feedbackLevel,p)):[],[W,d,p,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),K=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?W.filter(e=>O(e,d[e.sessionKey])&&M(e,t.prefs.feedbackLevel,p)).length:0,[W,d,p,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),q=G[0]??W[0],J=N(q),Y=e.personaPhrases[H?.persona?.tone??`calm`],X=w({bubbleEnabled:t.prefs.bubbleEnabled,feedbackLevel:t.prefs.feedbackLevel,collapsed:t.prefs.collapsed,queuedCount:G.length,activeCount:W.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>D(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),D(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useLayoutEffect)(()=>{let e=z.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[B.current,V.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),B.current&&r.observe(B.current),V.current&&r.observe(V.current),n(),()=>r.disconnect()},[X,G.length,t.prefs.collapsed,U]);let Z=(e=q)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.sessionKey,e.runId),c(t=>{let{[e.sessionKey]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(A(e))},ee=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},te=(0,u.useCallback)(e=>{e.button===0&&(T.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ne=(0,u.useCallback)(e=>{let t=T.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=T.current;!t||t.pointerId!==e.pointerId||(T.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(E.current=!0,window.setTimeout(()=>{E.current=!1},0)))},[]),re=()=>{E.current||Z()};if(!H)return null;let ie={"--desktop-pet-stage-size":`${Math.round(132*U)}px`,"--desktop-pet-menu-size":`${Math.round(28*U)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*U)}px`},$=t.prefs.collapsed?G.length:K;return(0,j.jsxs)(`div`,{ref:z,className:`desktop-pet-window`,style:ie,children:[!t.prefs.collapsed&&G.length>0?(0,j.jsx)(`div`,{ref:B,className:`desktop-pet-bubble desktop-pet-queue`,children:G.map(t=>{let n=S(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=x(t,e.tipCompleteSummary),i=C(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,s=I(F(H,t,Y),a,!!(r||n||i)),c=L(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:t.sessionLabel}),(0,j.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,j.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.sessionKey,t.runId),f(e=>({...e,[t.sessionKey]:{runId:t.runId,state:t.state}}))},children:(0,j.jsx)(o,{size:12})})]},t.sessionKey)})}):null,X?(0,j.jsx)(`div`,{ref:B,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:e.idleTipTitle}),(0,j.jsx)(`span`,{children:P(H.persona?.phrases?.greeting??Y.greeting,{sessionKey:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,j.jsx)(o,{size:12})})]})}):null,(0,j.jsxs)(`div`,{ref:V,className:`desktop-pet-stage`,children:[(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void ee(),"aria-label":e.menu,children:$>0?(0,j.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,j.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:re,onPointerDown:te,onPointerMove:ne,onPointerUp:Q,onPointerCancel:Q,title:e.openApp,children:(0,j.jsx)(l,{pet:H,action:J,displayHeight:Math.round(112*U)})})]})]})}function B(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,j.jsx)(z,{}),e[0]=t):t=e[0],t}export{B as DesktopPetPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./circle-alert-RzVebuX2.js";import{t as s}from"./messages-B0B40tpO.js";import{n as c}from"./locale-store-GfSwnwIZ.js";import{Ec as l,Es as u,Ml as d,Rc as f,Vo as p,Yo as m,Zo as h,fc as g,lo as _,ps as v,uc as y}from"./index-apLU0Hun.js";import{t as b}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as x,r as S}from"./settings-page-layout-CsrLuDsW.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=s(c(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!p()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(_,{className:`h-14 rounded-xl`}),(0,T.jsx)(_,{className:`h-14 rounded-xl`}),(0,T.jsx)(_,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(_,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,v.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(g,{className:a(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,v.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(u,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,v.press),onClick:B,children:[(0,T.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,v.press),onClick:()=>V(t),children:[(0,T.jsx)(l,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,v.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(o,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,v.press),onClick:()=>H(t),children:[(0,T.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void W(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&W()},onPointerUp:()=>void W()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,T.jsxs)(m,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void N({feedbackLevel:e.target.value}),children:[(0,T.jsx)(h,{value:`quiet`,children:e.feedbackQuiet}),(0,T.jsx)(h,{value:`normal`,children:e.feedbackNormal}),(0,T.jsx)(h,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,v.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./circle-alert-RzVebuX2.js";import{t as s}from"./messages-B0B40tpO.js";import{n as c}from"./locale-store-GfSwnwIZ.js";import{Ec as l,Es as u,Ml as d,Rc as f,Vo as p,Yo as m,Zo as h,fc as g,lo as _,ps as v,uc as y}from"./index-DSydVlxZ.js";import{t as b}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as x,r as S}from"./settings-page-layout-B_-VepeK.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=s(c(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!p()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(_,{className:`h-14 rounded-xl`}),(0,T.jsx)(_,{className:`h-14 rounded-xl`}),(0,T.jsx)(_,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(_,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,v.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(g,{className:a(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,v.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(u,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,v.press),onClick:B,children:[(0,T.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,v.press),onClick:()=>V(t),children:[(0,T.jsx)(l,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,v.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(o,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,v.press),onClick:()=>H(t),children:[(0,T.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void W(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&W()},onPointerUp:()=>void W()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,T.jsxs)(m,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void N({feedbackLevel:e.target.value}),children:[(0,T.jsx)(h,{value:`quiet`,children:e.feedbackQuiet}),(0,T.jsx)(h,{value:`normal`,children:e.feedbackNormal}),(0,T.jsx)(h,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,v.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{At as r,Ft as i,Pt as a}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{At as r,Ft as i,Pt as a}from"./index-DSydVlxZ.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=a(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(r,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Bs as f,Fs as p,Hc as m,Jr as h,Nc as g,Nt as _,Tu as v,Uc as y,Vr as b,Yo as x,Ys as S,Zo as C,fc as w,hs as T,nc as E,ol as D,sc as O,so as k,ws as A,xc as j,ys as M}from"./index-apLU0Hun.js";import{n as ee,r as N,t as P}from"./settings-page-layout-CsrLuDsW.js";import{n as F,t as te}from"./settings-form-section-DND90dDt.js";import{t as I}from"./page-tabs-CJfk6M78.js";import{n as L,t as R}from"./schedule-field-NGOH-7wV.js";import{t as z}from"./format-cron-label-arqgGlVV.js";var B=e(t(),1),V=n();function H(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ne(e){return l(`/api/dreaming${H(e)}`)}async function re(e){let t=await u(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ne(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await u(l(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await u(l(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await u(l(`/api/dreaming/preview${H(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await u(l(`/api/dreaming/events${H(t,{limit:e})}`))).payload?.events??[]}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var W={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},G={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},K={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},q={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:W,deep:G,rem:K};function J(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function ce(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=U(e)?e:{},n=U(t.memory)?t.memory:{},r=U(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||U(t.phases)?t:{},a=U(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=U(a.phases)?a.phases:{},s=U(o.light)?o.light:{},c=U(o.deep)?o.deep:{},l=U(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():q.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:J(typeof c.minScore==`number`?c.minScore:Number(c.minScore),q.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,q.minRecallCount)),limit:Y(c.limit,q.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():W.cron,lookbackDays:Math.max(1,Y(s.lookbackDays,W.lookbackDays)),limit:Y(s.limit,W.limit),dedupeSimilarity:J(ce(s.dedupeSimilarity,W.dedupeSimilarity),W.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():G.cron,minScore:J(ce(c.minScore,G.minScore),G.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,G.minRecallCount)),minUniqueQueries:Math.max(1,Y(c.minUniqueQueries,G.minUniqueQueries)),limit:Y(c.limit,G.limit),recencyHalfLifeDays:Math.max(1,ce(c.recencyHalfLifeDays,G.recencyHalfLifeDays)),maxAgeDays:Math.max(1,ce(c.maxAgeDays,G.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():K.cron,lookbackDays:Math.max(1,Y(l.lookbackDays,K.lookbackDays)),limit:Y(l.limit,K.limit),minPatternStrength:J(ce(l.minPatternStrength,K.minPatternStrength),K.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await u(l(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:U(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:J(t.light.dedupeSimilarity,W.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:J(t.deep.minScore,G.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:J(t.rem.minPatternStrength,K.minPatternStrength)}}}}})}),k()}var de=`p-4 sm:px-5`,fe=`mb-3`,pe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=a(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,T);function me(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function he(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ge(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),_e=`text-xs font-medium text-fg-muted`,ve=`text-sm font-medium text-fg`;function Q(e){let t=(0,V.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:_e,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,V.c)(11),{label:n,children:r,className:i}=e,o;t[0]===i?o=t[1]:(o=a(`min-w-0`,i),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:_e,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=a(ve,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ye(e){let t=(0,V.c)(5),{label:n,className:r}=e,i;t[0]===r?i=t[1]:(i=a(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=i);let o;return t[2]!==n||t[3]!==i?(o=(0,Z.jsx)(`h3`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=o):o=t[4],o}function be(e){let t=(0,V.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(R,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:pe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function xe(e){let t=(0,V.c)(23),{icon:n,label:r,enabled:i,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(pe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=i?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=a(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=i?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function Se(e){let t=(0,V.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ye,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Ce(e){let t=(0,V.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=he(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function we(e){let t=(0,V.c)(56),{t:n,schedulePickerLabels:r,hasToken:i,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:p,doRunNow:m}=e,h;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==i||t[5]!==d||t[6]!==u||t[7]!==n?(h=(e,t)=>o?.enabled?(0,Z.jsx)(De,{t:n,busy:d&&u===e,disabled:!i||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=i,t[5]=d,t[6]=u,t[7]=n,t[8]=h):h=t[8];let _=h,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,b;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==i||t[19]!==y||t[20]!==_||t[21]!==r||t[22]!==p||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(b=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:a(pe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:a(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!i||l,onChange:e=>p(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:a(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(D,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:pe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(R,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>p(t=>t&&{...t,frequency:e}),labels:r,disabled:!i||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!i||l,onChange:e=>p(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.phasesTitle}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>p(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>p(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Ee,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(g,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>p(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>p(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Ee,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(S,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>p(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>p(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Ee,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=i,t[19]=y,t[20]=_,t[21]=r,t[22]=p,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=b):b=t[55],b}function Te(e){let t=(0,V.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,V.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function De(e){let t=(0,V.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Oe(e){let t=(0,V.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(M,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:v,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ke)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function ke(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:a(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:he(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:me(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Ae(e){let t=(0,V.c)(41),{t:n,agentsMessages:r,hasToken:i,agents:a,selectedAgentId:o,onAgentChange:s,cfgForm:c,cfgSaving:l,enableAllBusy:u,cfgDirty:d,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:m}=e,h;t[0]!==a||t[1]!==r||t[2]!==l||t[3]!==i||t[4]!==s||t[5]!==o?(h=a.length>0?(0,Z.jsx)(x,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:o,disabled:!i||l,onChange:e=>s(e.currentTarget.value),"aria-label":`Agent`,children:a.map(e=>(0,Z.jsx)(C,{value:e.id,children:b(e,r)},e.id))}):null,t[0]=a,t[1]=r,t[2]=l,t[3]=i,t[4]=s,t[5]=o,t[6]=h):h=t[6];let g=!i||l||u||a.length===0,_;t[7]===p?_=t[8]:(_=()=>void p(),t[7]=p,t[8]=_);let v;t[9]===u?v=t[10]:(v=u?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[9]=u,t[10]=v);let S;t[11]!==n.enableAllAgentsDreaming||t[12]!==g||t[13]!==_||t[14]!==v?(S=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:g,onClick:_,children:[v,n.enableAllAgentsDreaming]}),t[11]=n.enableAllAgentsDreaming,t[12]=g,t[13]=_,t[14]=v,t[15]=S):S=t[15];let T=!i||!c||l||u||!d,E;t[16]===f?E=t[17]:(E=()=>void f(),t[16]=f,t[17]=E);let D;t[18]===l?D=t[19]:(D=l?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[18]=l,t[19]=D);let O;t[20]!==n.saveConfig||t[21]!==T||t[22]!==E||t[23]!==D?(O=(0,Z.jsxs)(M,{type:`button`,variant:`primary`,disabled:T,onClick:E,children:[D,n.saveConfig]}),t[20]=n.saveConfig,t[21]=T,t[22]=E,t[23]=D,t[24]=O):O=t[24];let k=!i,A;t[25]===m?A=t[26]:(A=()=>void m(),t[25]=m,t[26]=A);let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(w,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=j):j=t[27];let N;t[28]!==n.refresh||t[29]!==k||t[30]!==A?(N=(0,Z.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:k,title:n.refresh,"aria-label":n.refresh,onClick:A,children:j}),t[28]=n.refresh,t[29]=k,t[30]=A,t[31]=N):N=t[31];let P;t[32]!==h||t[33]!==N||t[34]!==S||t[35]!==O?(P=(0,Z.jsxs)(Z.Fragment,{children:[h,S,O,N]}),t[32]=h,t[33]=N,t[34]=S,t[35]=O,t[36]=P):P=t[36];let F;return t[37]!==n.subtitle||t[38]!==n.title||t[39]!==P?(F=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:P}),t[37]=n.subtitle,t[38]=n.title,t[39]=P,t[40]=F):F=t[40],F}function je(e){let t=(0,V.c)(30),{t:n,disabled:r,actionBusy:i,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=a(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(F,{className:fe,icon:A,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===i?u=t[8]:(u=i===`reset_store`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=i,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(M,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let h;t[17]===i?h=t[18]:(h=i===`clear_lock`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(m,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=i,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==h?(g=(0,Z.jsxs)(M,{variant:`secondary`,disabled:r,onClick:f,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==d||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,g]}),t[24]=d,t[25]=g,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(te,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function Me(e){let t=(0,V.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(M,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:O,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&L.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,V.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?z(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,V.c)(100),{t:n,data:r,isLoading:i,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?ge(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`min-w-0`,de),t[3]=u):u=t[3];let d;t[4]===i?d=t[5]:(d=i?(0,Z.jsx)(y,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=i,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(F,{className:fe,icon:v,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(ye,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let h=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==h?(_=(0,Z.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=_):_=t[14];let b=l?.className,x=l?l.text:`—`,C;t[15]!==b||t[16]!==x?(C=(0,Z.jsx)(`span`,{className:b,children:x}),t[15]=b,t[16]=x,t[17]=C):C=t[17];let w;t[18]!==n.lock||t[19]!==C?(w=(0,Z.jsx)($,{label:n.lock,children:C}),t[18]=n.lock,t[19]=C,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==_?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=_,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==m?(j=(0,Z.jsxs)(`div`,{className:pe,children:[m,A]}),t[39]=A,t[40]=m,t[41]=j):j=t[41];let M;t[42]===n.subsectionStore?M=t[43]:(M=(0,Z.jsx)(ye,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=M);let ee=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ee?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ee}),t[44]=n.storeEntries,t[45]=ee,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let L;t[50]===r?L=t[51]:(L=r?me(r.store.updatedAt):`—`,t[50]=r,t[51]=L);let R;t[52]!==n.storeUpdatedAt||t[53]!==L?(R=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:L}),t[52]=n.storeUpdatedAt,t[53]=L,t[54]=R):R=t[54];let B;t[55]===r?B=t[56]:(B=r?me(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=B);let H;t[57]!==n.storeLastPromotedAt||t[58]!==B?(H=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:B}),t[57]=n.storeLastPromotedAt,t[58]=B,t[59]=H):H=t[59];let ne;t[60]!==N||t[61]!==I||t[62]!==R||t[63]!==H?(ne=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,R,H]}),t[60]=N,t[61]=I,t[62]=R,t[63]=H,t[64]=ne):ne=t[64];let re;t[65]!==M||t[66]!==ne?(re=(0,Z.jsxs)(`div`,{className:pe,children:[M,ne]}),t[65]=M,t[66]=ne,t[67]=re):re=t[67];let ie;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ie=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ye,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(xe,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:z(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(g,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:z(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(S,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:z(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ie):ie=t[72];let ae;t[73]===n.subsectionLastRun?ae=t[74]:(ae=(0,Z.jsx)(ye,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=ae);let oe;t[75]===n.lastRunBlockHint?oe=t[76]:(oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=oe);let se;t[77]!==r||t[78]!==n?(se=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Ce,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=se):se=t[79];let U;t[80]!==ae||t[81]!==oe||t[82]!==se?(U=(0,Z.jsxs)(`div`,{className:pe,children:[ae,oe,se]}),t[80]=ae,t[81]=oe,t[82]=se,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(Se,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(Se,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==re||t[92]!==ie||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,re,ie,U,G,q]}),t[90]=j,t[91]=re,t[92]=ie,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==p?(Y=(0,Z.jsxs)(te,{className:u,children:[p,J]}),t[97]=J,t[98]=p,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:E,runtime:v,insights:O,maintenance:A};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=c(e=>e.language),t=o(e),n=t.dreamingSettings,r=t.cron.schedulePicker,a=t.cron.scheduleBadge,l=e===`zh`?`zh-CN`:`en-US`,u=!!s(e=>e.token),[f,p]=i(),m=He(f.get(`tab`)),g=f.get(`agentId`)?.trim()||``,v=(0,B.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[y,x]=(0,B.useReducer)(_,Ke),{actionBusy:S,actionError:C,runBusy:w,runError:T,runPhase:E,cfgSaving:D,cfgError:O,enableAllBusy:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:ee,eventsError:P,events:F}=y,[te,I]=(0,B.useReducer)(Ge,{form:null,baseline:null}),L=te.form,R=te.baseline,z=(0,B.useRef)(!1),V=d(u?`dreaming-settings-agents`:null,h,{revalidateOnFocus:!1}),H=V.data?.agents??[],U=g||V.data?.defaultId||``,W=(0,B.useMemo)(()=>H.find(e=>e.id===U),[H,U]),G=(0,B.useCallback)(e=>{z.current=!1,I({type:`reset`}),p(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[p]),{data:K,error:q,isLoading:J,mutate:Y}=d(u&&U?ne(U):null,re,{revalidateOnFocus:!1}),ce=(0,B.useMemo)(()=>{let e=[];return q&&e.push(q instanceof Error?q.message:String(q)),C&&e.push(C),T&&e.push(T),j&&e.push(j),P&&e.push(P),O&&e.push(O),e},[q,C,T,j,P,O]),de=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await Y()},[Y]),fe=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{x({type:`patch`,patch:{previewItems:(await oe(20,U)).items??[]}})}catch(e){x({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{previewLoading:!1}})}},[U]),pe=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{x({type:`patch`,patch:{events:await se(50,U)}})}catch(e){x({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{eventsLoading:!1}})}},[U]),X=(0,B.useCallback)(async(e=`deep`)=>{let n=Date.now(),r=H.length>0?H.map(e=>({id:e.id,name:b(e,t.agentsSettings),avatar:e.avatar})):[{id:U,name:W?b(W,t.agentsSettings):void 0,avatar:W?.avatar}].filter(e=>e.id),i=r.length>0?r:[{id:U}],a=[];x({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=i.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||U)}catch(e){let n=t.name||t.id||U||`default`,r=e instanceof Error?e.message:String(e);a.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),x({type:`patch`,patch:a.length>0?{runError:a.join(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B0B40tpO.js";import{l as s,n as c,r as l,s as u}from"./locale-store-GfSwnwIZ.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Bs as f,Fs as p,Hc as m,Jr as h,Nc as g,Nt as _,Tu as v,Uc as y,Vr as b,Yo as x,Ys as S,Zo as C,fc as w,hs as T,nc as E,ol as D,sc as O,so as k,ws as A,xc as j,ys as M}from"./index-DSydVlxZ.js";import{n as ee,r as N,t as P}from"./settings-page-layout-B_-VepeK.js";import{n as F,t as te}from"./settings-form-section-DPSA8tG8.js";import{t as I}from"./page-tabs-HACawonJ.js";import{n as L,t as R}from"./schedule-field-BGx_Nb45.js";import{t as z}from"./format-cron-label-arqgGlVV.js";var B=e(t(),1),V=n();function H(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ne(e){return l(`/api/dreaming${H(e)}`)}async function re(e){let t=await u(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ne(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await u(l(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await u(l(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await u(l(`/api/dreaming/preview${H(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await u(l(`/api/dreaming/events${H(t,{limit:e})}`))).payload?.events??[]}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var W={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},G={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},K={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},q={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:W,deep:G,rem:K};function J(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function ce(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=U(e)?e:{},n=U(t.memory)?t.memory:{},r=U(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||U(t.phases)?t:{},a=U(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=U(a.phases)?a.phases:{},s=U(o.light)?o.light:{},c=U(o.deep)?o.deep:{},l=U(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():q.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:J(typeof c.minScore==`number`?c.minScore:Number(c.minScore),q.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,q.minRecallCount)),limit:Y(c.limit,q.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():W.cron,lookbackDays:Math.max(1,Y(s.lookbackDays,W.lookbackDays)),limit:Y(s.limit,W.limit),dedupeSimilarity:J(ce(s.dedupeSimilarity,W.dedupeSimilarity),W.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():G.cron,minScore:J(ce(c.minScore,G.minScore),G.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,G.minRecallCount)),minUniqueQueries:Math.max(1,Y(c.minUniqueQueries,G.minUniqueQueries)),limit:Y(c.limit,G.limit),recencyHalfLifeDays:Math.max(1,ce(c.recencyHalfLifeDays,G.recencyHalfLifeDays)),maxAgeDays:Math.max(1,ce(c.maxAgeDays,G.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():K.cron,lookbackDays:Math.max(1,Y(l.lookbackDays,K.lookbackDays)),limit:Y(l.limit,K.limit),minPatternStrength:J(ce(l.minPatternStrength,K.minPatternStrength),K.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await u(l(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:U(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:J(t.light.dedupeSimilarity,W.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:J(t.deep.minScore,G.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:J(t.rem.minPatternStrength,K.minPatternStrength)}}}}})}),k()}var de=`p-4 sm:px-5`,fe=`mb-3`,pe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=a(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,T);function me(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function he(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ge(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),_e=`text-xs font-medium text-fg-muted`,ve=`text-sm font-medium text-fg`;function Q(e){let t=(0,V.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:_e,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,V.c)(11),{label:n,children:r,className:i}=e,o;t[0]===i?o=t[1]:(o=a(`min-w-0`,i),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:_e,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=a(ve,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ye(e){let t=(0,V.c)(5),{label:n,className:r}=e,i;t[0]===r?i=t[1]:(i=a(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=i);let o;return t[2]!==n||t[3]!==i?(o=(0,Z.jsx)(`h3`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=o):o=t[4],o}function be(e){let t=(0,V.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(R,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:pe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function xe(e){let t=(0,V.c)(23),{icon:n,label:r,enabled:i,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(pe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=i?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=a(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=i?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function Se(e){let t=(0,V.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ye,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Ce(e){let t=(0,V.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=he(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function we(e){let t=(0,V.c)(56),{t:n,schedulePickerLabels:r,hasToken:i,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:p,doRunNow:m}=e,h;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==i||t[5]!==d||t[6]!==u||t[7]!==n?(h=(e,t)=>o?.enabled?(0,Z.jsx)(De,{t:n,busy:d&&u===e,disabled:!i||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=i,t[5]=d,t[6]=u,t[7]=n,t[8]=h):h=t[8];let _=h,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,b;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==i||t[19]!==y||t[20]!==_||t[21]!==r||t[22]!==p||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(b=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:a(pe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:a(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!i||l,onChange:e=>p(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:a(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(D,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:pe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(R,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>p(t=>t&&{...t,frequency:e}),labels:r,disabled:!i||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!i||l,onChange:e=>p(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.phasesTitle}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>p(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>p(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Ee,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!i||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(g,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>p(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>p(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Ee,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(S,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>p(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>p(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Ee,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!i||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=i,t[19]=y,t[20]=_,t[21]=r,t[22]=p,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=b):b=t[55],b}function Te(e){let t=(0,V.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,V.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function De(e){let t=(0,V.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Oe(e){let t=(0,V.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(M,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:v,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ke)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function ke(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:a(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:he(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:me(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Ae(e){let t=(0,V.c)(41),{t:n,agentsMessages:r,hasToken:i,agents:a,selectedAgentId:o,onAgentChange:s,cfgForm:c,cfgSaving:l,enableAllBusy:u,cfgDirty:d,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:m}=e,h;t[0]!==a||t[1]!==r||t[2]!==l||t[3]!==i||t[4]!==s||t[5]!==o?(h=a.length>0?(0,Z.jsx)(x,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:o,disabled:!i||l,onChange:e=>s(e.currentTarget.value),"aria-label":`Agent`,children:a.map(e=>(0,Z.jsx)(C,{value:e.id,children:b(e,r)},e.id))}):null,t[0]=a,t[1]=r,t[2]=l,t[3]=i,t[4]=s,t[5]=o,t[6]=h):h=t[6];let g=!i||l||u||a.length===0,_;t[7]===p?_=t[8]:(_=()=>void p(),t[7]=p,t[8]=_);let v;t[9]===u?v=t[10]:(v=u?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[9]=u,t[10]=v);let S;t[11]!==n.enableAllAgentsDreaming||t[12]!==g||t[13]!==_||t[14]!==v?(S=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:g,onClick:_,children:[v,n.enableAllAgentsDreaming]}),t[11]=n.enableAllAgentsDreaming,t[12]=g,t[13]=_,t[14]=v,t[15]=S):S=t[15];let T=!i||!c||l||u||!d,E;t[16]===f?E=t[17]:(E=()=>void f(),t[16]=f,t[17]=E);let D;t[18]===l?D=t[19]:(D=l?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[18]=l,t[19]=D);let O;t[20]!==n.saveConfig||t[21]!==T||t[22]!==E||t[23]!==D?(O=(0,Z.jsxs)(M,{type:`button`,variant:`primary`,disabled:T,onClick:E,children:[D,n.saveConfig]}),t[20]=n.saveConfig,t[21]=T,t[22]=E,t[23]=D,t[24]=O):O=t[24];let k=!i,A;t[25]===m?A=t[26]:(A=()=>void m(),t[25]=m,t[26]=A);let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(w,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=j):j=t[27];let N;t[28]!==n.refresh||t[29]!==k||t[30]!==A?(N=(0,Z.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:k,title:n.refresh,"aria-label":n.refresh,onClick:A,children:j}),t[28]=n.refresh,t[29]=k,t[30]=A,t[31]=N):N=t[31];let P;t[32]!==h||t[33]!==N||t[34]!==S||t[35]!==O?(P=(0,Z.jsxs)(Z.Fragment,{children:[h,S,O,N]}),t[32]=h,t[33]=N,t[34]=S,t[35]=O,t[36]=P):P=t[36];let F;return t[37]!==n.subtitle||t[38]!==n.title||t[39]!==P?(F=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:P}),t[37]=n.subtitle,t[38]=n.title,t[39]=P,t[40]=F):F=t[40],F}function je(e){let t=(0,V.c)(30),{t:n,disabled:r,actionBusy:i,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=a(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(F,{className:fe,icon:A,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===i?u=t[8]:(u=i===`reset_store`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=i,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(M,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let h;t[17]===i?h=t[18]:(h=i===`clear_lock`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(m,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=i,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==h?(g=(0,Z.jsxs)(M,{variant:`secondary`,disabled:r,onClick:f,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==d||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,g]}),t[24]=d,t[25]=g,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(te,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function Me(e){let t=(0,V.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(M,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:O,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&L.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,V.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?z(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,V.c)(100),{t:n,data:r,isLoading:i,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?ge(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`min-w-0`,de),t[3]=u):u=t[3];let d;t[4]===i?d=t[5]:(d=i?(0,Z.jsx)(y,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=i,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(F,{className:fe,icon:v,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(ye,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let h=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==h?(_=(0,Z.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=_):_=t[14];let b=l?.className,x=l?l.text:`—`,C;t[15]!==b||t[16]!==x?(C=(0,Z.jsx)(`span`,{className:b,children:x}),t[15]=b,t[16]=x,t[17]=C):C=t[17];let w;t[18]!==n.lock||t[19]!==C?(w=(0,Z.jsx)($,{label:n.lock,children:C}),t[18]=n.lock,t[19]=C,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==_?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=_,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==m?(j=(0,Z.jsxs)(`div`,{className:pe,children:[m,A]}),t[39]=A,t[40]=m,t[41]=j):j=t[41];let M;t[42]===n.subsectionStore?M=t[43]:(M=(0,Z.jsx)(ye,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=M);let ee=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ee?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ee}),t[44]=n.storeEntries,t[45]=ee,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let L;t[50]===r?L=t[51]:(L=r?me(r.store.updatedAt):`—`,t[50]=r,t[51]=L);let R;t[52]!==n.storeUpdatedAt||t[53]!==L?(R=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:L}),t[52]=n.storeUpdatedAt,t[53]=L,t[54]=R):R=t[54];let B;t[55]===r?B=t[56]:(B=r?me(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=B);let H;t[57]!==n.storeLastPromotedAt||t[58]!==B?(H=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:B}),t[57]=n.storeLastPromotedAt,t[58]=B,t[59]=H):H=t[59];let ne;t[60]!==N||t[61]!==I||t[62]!==R||t[63]!==H?(ne=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,R,H]}),t[60]=N,t[61]=I,t[62]=R,t[63]=H,t[64]=ne):ne=t[64];let re;t[65]!==M||t[66]!==ne?(re=(0,Z.jsxs)(`div`,{className:pe,children:[M,ne]}),t[65]=M,t[66]=ne,t[67]=re):re=t[67];let ie;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ie=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ye,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(xe,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:z(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(g,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:z(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(S,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:z(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ie):ie=t[72];let ae;t[73]===n.subsectionLastRun?ae=t[74]:(ae=(0,Z.jsx)(ye,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=ae);let oe;t[75]===n.lastRunBlockHint?oe=t[76]:(oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=oe);let se;t[77]!==r||t[78]!==n?(se=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Ce,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=se):se=t[79];let U;t[80]!==ae||t[81]!==oe||t[82]!==se?(U=(0,Z.jsxs)(`div`,{className:pe,children:[ae,oe,se]}),t[80]=ae,t[81]=oe,t[82]=se,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(Se,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(Se,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==re||t[92]!==ie||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,re,ie,U,G,q]}),t[90]=j,t[91]=re,t[92]=ie,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==p?(Y=(0,Z.jsxs)(te,{className:u,children:[p,J]}),t[97]=J,t[98]=p,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:E,runtime:v,insights:O,maintenance:A};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=c(e=>e.language),t=o(e),n=t.dreamingSettings,r=t.cron.schedulePicker,a=t.cron.scheduleBadge,l=e===`zh`?`zh-CN`:`en-US`,u=!!s(e=>e.token),[f,p]=i(),m=He(f.get(`tab`)),g=f.get(`agentId`)?.trim()||``,v=(0,B.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[y,x]=(0,B.useReducer)(_,Ke),{actionBusy:S,actionError:C,runBusy:w,runError:T,runPhase:E,cfgSaving:D,cfgError:O,enableAllBusy:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:ee,eventsError:P,events:F}=y,[te,I]=(0,B.useReducer)(Ge,{form:null,baseline:null}),L=te.form,R=te.baseline,z=(0,B.useRef)(!1),V=d(u?`dreaming-settings-agents`:null,h,{revalidateOnFocus:!1}),H=V.data?.agents??[],U=g||V.data?.defaultId||``,W=(0,B.useMemo)(()=>H.find(e=>e.id===U),[H,U]),G=(0,B.useCallback)(e=>{z.current=!1,I({type:`reset`}),p(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[p]),{data:K,error:q,isLoading:J,mutate:Y}=d(u&&U?ne(U):null,re,{revalidateOnFocus:!1}),ce=(0,B.useMemo)(()=>{let e=[];return q&&e.push(q instanceof Error?q.message:String(q)),C&&e.push(C),T&&e.push(T),j&&e.push(j),P&&e.push(P),O&&e.push(O),e},[q,C,T,j,P,O]),de=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await Y()},[Y]),fe=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{x({type:`patch`,patch:{previewItems:(await oe(20,U)).items??[]}})}catch(e){x({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{previewLoading:!1}})}},[U]),pe=(0,B.useCallback)(async()=>{x({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{x({type:`patch`,patch:{events:await se(50,U)}})}catch(e){x({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{eventsLoading:!1}})}},[U]),X=(0,B.useCallback)(async(e=`deep`)=>{let n=Date.now(),r=H.length>0?H.map(e=>({id:e.id,name:b(e,t.agentsSettings),avatar:e.avatar})):[{id:U,name:W?b(W,t.agentsSettings):void 0,avatar:W?.avatar}].filter(e=>e.id),i=r.length>0?r:[{id:U}],a=[];x({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=i.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||U)}catch(e){let n=t.name||t.id||U||`default`,r=e instanceof Error?e.message:String(e);a.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),x({type:`patch`,patch:a.length>0?{runError:a.join(`
|
|
2
2
|
`)}:{runOk:!0}}),await Y()}catch(e){x({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=qe-(Date.now()-n);e>0&&await new Promise(t=>setTimeout(t,e)),x({type:`patch`,patch:{runBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]),me=(0,B.useCallback)(async e=>{x({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ie(e,U),x({type:`patch`,patch:{actionOk:!0}}),await Y()}catch(e){x({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{actionBusy:null}})}},[Y,U]),he=!u||J||!!S,ge=(0,B.useMemo)(()=>{let e=K?.config;return le(e??{})},[K]),_e=K?.agentId||U||`main`,ve=K?.memory;(0,B.useEffect)(()=>{if(!u){I({type:`reset`}),z.current=!1;return}z.current||I({type:`sync`,value:ge})},[ge,u]);let Q=(0,B.useMemo)(()=>!L||!R?!1:JSON.stringify(L)!==JSON.stringify(R),[L,R]),$=(0,B.useCallback)(async()=>{if(L){x({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await ue(_e,L,ve),I({type:`saved`,value:L}),z.current=!1,x({type:`patch`,patch:{cfgOk:!0}}),await Y()}catch(e){x({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{x({type:`patch`,patch:{cfgSaving:!1}})}}},[_e,ve,L,Y]),ye=(0,B.useCallback)(async()=>{let e=H.length>0?H:U?[{id:U,name:W?.name,avatar:W?.avatar}]:[];if(e.length===0)return;x({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let n=[];try{for(let r of e)try{let e=await re(r.id),t=le(e.config);await ue(r.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let i=b(r,t.agentsSettings);n.push(`${i}: ${e instanceof Error?e.message:String(e)}`)}n.length>0?x({type:`patch`,patch:{cfgError:n.join(`
|
|
3
3
|
`)}}):x({type:`patch`,patch:{cfgOk:!0}}),await Y()}finally{x({type:`patch`,patch:{enableAllBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]);return(0,Z.jsxs)(N,{children:[(0,Z.jsx)(Ae,{t:n,agentsMessages:t.agentsSettings,hasToken:u,agents:H,selectedAgentId:U,onAgentChange:G,cfgForm:L,cfgSaving:D,enableAllBusy:k,cfgDirty:Q,saveConfig:$,enableAllAgentsDreaming:ye,doRefresh:de}),ce.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:ce.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ze,{t:n,activeTab:m,onChange:v}),(0,Z.jsx)(Qe,{t:n,id:`config`,activeTab:m,children:(0,Z.jsx)(we,{t:n,schedulePickerLabels:r,hasToken:u,cfgForm:L,cfgBaseline:R,cfgDirty:Q,cfgSaving:D,runPhase:E,runBusy:w,setCfgForm:e=>{z.current=!0;let t=typeof e==`function`?e(L):e;t&&I({type:`set`,value:t})},doRunNow:X})}),(0,Z.jsx)(Qe,{t:n,id:`runtime`,activeTab:m,children:(0,Z.jsx)(ze,{t:n,data:K,isLoading:J,localeTag:l,scheduleBadgeLabels:a})}),(0,Z.jsx)(Qe,{t:n,id:`insights`,activeTab:m,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Me,{t:n,hasToken:u,previewLoading:A,previewItems:M,loadPreview:fe}),(0,Z.jsx)(Oe,{t:n,hasToken:u,eventsLoading:ee,events:F,loadEvents:pe})]})}),(0,Z.jsx)(Qe,{t:n,id:`maintenance`,activeTab:m,children:(0,Z.jsx)(je,{t:n,disabled:he,actionBusy:S,doAction:me})})]})}function Ze(e){let t=(0,V.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Be.map(e=>({id:e,label:Ue(n,e),icon:Ve[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(I,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Qe(e){let t=(0,V.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ue(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=We(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(P,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Xe as DreamingSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-B0B40tpO.js";import{n as i}from"./locale-store-GfSwnwIZ.js";import{fo as a}from"./index-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-B0B40tpO.js";import{n as i}from"./locale-store-GfSwnwIZ.js";import{fo as a}from"./index-DSydVlxZ.js";var o=t();e();var s=n();function c(){let e=(0,o.c)(44),t=i(d),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let c=n.extensionDebug,f=a(),p;e[2]===f?p=e[3]:(p=f.toSorted(u),e[2]=f,e[3]=p);let m=p,h;e[4]===c.title?h=e[5]:(h=(0,s.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:c.title}),e[4]=c.title,e[5]=h);let g;e[6]===c.subtitle?g=e[7]:(g=(0,s.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.subtitle}),e[6]=c.subtitle,e[7]=g);let _;e[8]!==h||e[9]!==g?(_=(0,s.jsxs)(`div`,{children:[h,g]}),e[8]=h,e[9]=g,e[10]=_):_=e[10];let v;e[11]===c.listHeading?v=e[12]:(v=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.listHeading}),e[11]=c.listHeading,e[12]=v);let y;e[13]===c.colId?y=e[14]:(y=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colId}),e[13]=c.colId,e[14]=y);let b;e[15]===c.colName?b=e[16]:(b=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colName}),e[15]=c.colName,e[16]=b);let x;e[17]===c.colPermissions?x=e[18]:(x=(0,s.jsx)(`th`,{className:`py-2`,children:c.colPermissions}),e[17]=c.colPermissions,e[18]=x);let S;e[19]!==y||e[20]!==b||e[21]!==x?(S=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[19]=y,e[20]=b,e[21]=x,e[22]=S):S=e[22];let C;e[23]===m?C=e[24]:(C=m.map(l),e[23]=m,e[24]=C);let w;e[25]===C?w=e[26]:(w=(0,s.jsx)(`tbody`,{children:C}),e[25]=C,e[26]=w);let T;e[27]!==w||e[28]!==S?(T=(0,s.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[S,w]})}),e[27]=w,e[28]=S,e[29]=T):T=e[29];let E;e[30]!==T||e[31]!==v?(E=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[v,T]}),e[30]=T,e[31]=v,e[32]=E):E=e[32];let D;e[33]===c.futureHeading?D=e[34]:(D=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.futureHeading}),e[33]=c.futureHeading,e[34]=D);let O;e[35]===c.futureBody?O=e[36]:(O=(0,s.jsx)(`p`,{className:`mt-2`,children:c.futureBody}),e[35]=c.futureBody,e[36]=O);let k;e[37]!==D||e[38]!==O?(k=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[D,O]}),e[37]=D,e[38]=O,e[39]=k):k=e[39];let A;return e[40]!==E||e[41]!==k||e[42]!==_?(A=(0,s.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[_,E,k]}),e[40]=E,e[41]=k,e[42]=_,e[43]=A):A=e[43],A}function l(e){return(0,s.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,s.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,s.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,s.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function u(e,t){return e.id.localeCompare(t.id)}function d(e){return e.language}export{c as ExtensionDebugPage};
|
package/dist/gateway/static/root/assets/{extension-page-CqZNCj96.js → extension-page-TTXKCMtb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{Bo as a,ct as o,fo as s,ho as c}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{Bo as a,ct as o,fo as s,ho as c}from"./index-DSydVlxZ.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=i(),r=s(),f=a(m),g=a(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&c(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(o,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i,u as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./messages-B0B40tpO.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-GfSwnwIZ.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Yo as m,Zo as h,_s as g,ct as _,fo as v,gs as y,vs as b,ys as x}from"./index-apLU0Hun.js";import{t as S}from"./settings-loading-skeleton-CEJtaoQp.js";import{a as C,f as w,h as T,l as E,m as D,o as O,p as k,t as A}from"./voice-api-key-field-DK6gaQsA.js";import{t as j}from"./schema-form-BJz5LoqG.js";var M=n(),N=e(t(),1),P=r(),F=()=>d(T);function I(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function L(e){let t=(0,M.c)(40),{extensionId:n}=e,r=l(R),i;t[0]===r?i=t[1]:(i=s(r),t[0]=r,t[1]=i);let a=i,o=a.imageModelsSettings,u=c(ee),d;t[2]===u?d=t[3]:(d=u?F():null,t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:m,isLoading:h}=p(d,D,f),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=w(y),x;t[12]===o?x=t[13]:(x=I(o),t[12]=o,t[13]=x);let C=x,T;t[14]!==a.providersSettings.getApiKey||t[15]!==a.providersSettings.getApiKeyCn||t[16]!==a.providersSettings.getApiKeyIntl?(T={getApiKey:a.providersSettings.getApiKey,getApiKeyIntl:a.providersSettings.getApiKeyIntl,getApiKeyCn:a.providersSettings.getApiKeyCn},t[14]=a.providersSettings.getApiKey,t[15]=a.providersSettings.getApiKeyCn,t[16]=a.providersSettings.getApiKeyIntl,t[17]=T):T=t[17];let E=T;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let O;t[21]!==b||t[22]!==o.credentialsSaveError?(O=()=>void b.saveCredentials(o.credentialsSaveError),t[21]=b,t[22]=o.credentialsSaveError,t[23]=O):O=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[24]=A):A=t[24];let j;return t[25]!==E||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==y||t[38]!==O?(j=(0,P.jsx)(k,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:O,extensionIds:A,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=C,t[37]=y,t[38]=O,t[39]=j):j=t[39],j}function ee(e){return!!e.token}function R(e){return e.language}function z(e){let t=(0,M.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var B=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function V(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function H(){return o(g,y)}function U(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function W(e,t){if(!e||!t)return{apiKey:``,model:B[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:B[0].id}}function G({providerId:e,voiceSettings:t,mutateVoice:n}){let r=s(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,c={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=p(d(`/api/voice/stt-providers`),O,{revalidateOnFocus:!1}),f=(0,N.useMemo)(()=>u?.providers.some(t=>t.id===e&&t.configured)??!1,[e,u]),g=(0,N.useMemo)(()=>W(t,e),[e,t]),_=(0,N.useRef)(!1),[v,b]=(0,N.useState)(null),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[D,k]=(0,N.useState)(!1),j=v??g,M=g,F=j.apiKey!==M.apiKey||j.model!==M.model,I=(0,N.useCallback)(async()=>{C(!0),T(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:j.apiKey,model:j.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:j.apiKey,model:j.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:j.apiKey,model:j.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await E(r),await n(r,!1),_.current=!1,b(null),k(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[j.apiKey,j.model,n,e,t]),L=e===`groq`?B:[{id:j.model,name:j.model}];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(z,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:j.apiKey,onChange:e=>{_.current=!0,b(t=>({...t??g,apiKey:e})),T(null)},labels:c,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(z,{children:i.stt.model}),e===`groq`?(0,P.jsx)(m,{className:H(),value:j.model,onChange:e=>{_.current=!0,b(t=>({...t??g,model:e.target.value})),T(null)},children:L.map(e=>(0,P.jsx)(h,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:U(),value:j.model,onChange:e=>{_.current=!0,b(t=>({...t??g,model:e.target.value})),T(null)}})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:w}):null,(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>{_.current=!1,b(null),T(null)},children:i.discard}),(0,P.jsx)(x,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>void I(),children:S?i.saving:i.save})]})]})}function K(e){let t=(0,M.c)(13),{extensionId:n}=e,r=l(J),i=c(q),a;t[0]===n?a=t[1]:(a=()=>f(d(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=p(i&&n?`ext-stt-detail-${n}`:null,a),u;t[2]===o?u=t[3]:(u=V(o),t[2]=o,t[3]=u);let m=u,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=p(i?`voice-settings-ext-stt`:null,C,h);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(G,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function q(e){return!!e.token}function J(e){return e.language}function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){let t={};if(e.type!==`object`||!Y(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Y(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function Z(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Q({extensionId:e}){let t=s(l(e=>e.language)).agentSettings,n=c(e=>!!e.token),{data:r,error:i}=p(n&&e?`ext-detail-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}`))),{data:a,mutate:o,error:m}=p(n&&e?`ext-cfg-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}/config`))),h=r?.manifest?.configSchema,g=(0,N.useMemo)(()=>h&&h.type===`object`?X(h):{},[h]),_=(0,N.useMemo)(()=>({...g,...a??{}}),[g,a]),[v,y]=(0,N.useReducer)(Z,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[b,S]=(0,N.useState)(!1),C=(0,N.useRef)(!1),w=(0,N.useRef)(_);!C.current&&w.current!==_&&(w.current=_,y({type:`sync`,value:_}));let T=(0,N.useCallback)(e=>{C.current=!0,y({type:`change`,value:e})},[]),E=(0,N.useCallback)(()=>{C.current=!1,y({type:`discard`,value:_})},[_]),D=(0,N.useCallback)(()=>{!h||h.type!==`object`||(C.current=!0,y({type:`reset-defaults`,value:{...X(h)}}))},[h]),O=(0,N.useCallback)(async()=>{if(e){y({type:`save-start`});try{let t=await u(d(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(v.localValues)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await o(v.localValues,!1),C.current=!1,y({type:`save-success`,value:v.localValues}),S(!0)}catch(e){y({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[v.localValues,e,o]);if(!n)return null;if(i||m){let e=i??m;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!h||h.type!==`object`?null:(0,P.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v.saveError?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:v.saveError}):null,(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!v.isDirty,onClick:E,children:t.discard}),(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:D,children:`Reset to defaults`}),(0,P.jsx)(x,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!v.isDirty||v.saving,onClick:()=>void O(),children:v.saving?t.saving:t.save})]})]}),(0,P.jsx)(j,{schema:h,values:v.localValues,onChange:T,disabled:v.saving})]})}function te(){let e=(0,M.c)(47),t=l(ne),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,o=r.extensionImageGen,c=r.extensionSttMedia,{extensionId:u,panelId:d}=a(),f=v();if(!u){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let p,m,h;if(e[3]!==u||e[4]!==f||e[5]!==d){h=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===u?t=e[10]:(t=e=>e.id===u,e[9]=u,e[10]=t),p=f.find(t),!p){let t=`Extension "${u}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)($,{message:t}),e[11]=t,e[12]=n),h=n;break bb0}let n=p.ui?.contributions?.settingsPanels;m=d?n?.find(e=>e.id===d||e.id===`${u}.${d}`):n?.[0]}e[3]=u,e[4]=f,e[5]=d,e[6]=p,e[7]=m,e[8]=h}else p=e[6],m=e[7],h=e[8];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g=m,y=!!(g&&p.ui),b=!!p.hasConfigSchema,x=p.kind===`image-generation`,S=p.kind===`media-provider`;if(!b&&!y&&!(x||S)){let t=`Extension "${u}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=g?.title??`${p.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,P.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==o?(T=x?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:o.banner}),(0,P.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:o.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=o,e[20]=T):T=e[20];let E;e[21]!==u||e[22]!==x?(E=x?(0,P.jsx)(L,{extensionId:u}):null,e[21]=u,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==c?(D=S?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:c.banner}),(0,P.jsx)(i,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:c.openVoice})]}):null,e[24]=S,e[25]=c,e[26]=D):D=e[26];let O;e[27]!==u||e[28]!==S?(O=S?(0,P.jsx)(K,{extensionId:u}):null,e[27]=u,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==u||e[31]!==b?(k=b?(0,P.jsx)(Q,{extensionId:u}):null,e[30]=u,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==p.name||e[34]!==p.ui||e[35]!==u||e[36]!==y||e[37]!==g?(A=y&&g&&p.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(_,{extensionId:u,extensionName:p.name,entrypoint:g.entrypoint,permissions:p.ui?.permissions,title:g.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=p.name,e[34]=p.ui,e[35]=u,e[36]=y,e[37]=g,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,P.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function ne(e){return e.language}function $(e){let t=(0,M.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{te as ExtensionSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i,u as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./messages-B0B40tpO.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-GfSwnwIZ.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Yo as m,Zo as h,_s as g,ct as _,fo as v,gs as y,vs as b,ys as x}from"./index-DSydVlxZ.js";import{t as S}from"./settings-loading-skeleton-ClHNJwRL.js";import{a as C,f as w,h as T,l as E,m as D,o as O,p as k,t as A}from"./voice-api-key-field-1xyza74n.js";import{t as j}from"./schema-form-Cg-LJVvG.js";var M=n(),N=e(t(),1),P=r(),F=()=>d(T);function I(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function L(e){let t=(0,M.c)(40),{extensionId:n}=e,r=l(R),i;t[0]===r?i=t[1]:(i=s(r),t[0]=r,t[1]=i);let a=i,o=a.imageModelsSettings,u=c(ee),d;t[2]===u?d=t[3]:(d=u?F():null,t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:m,isLoading:h}=p(d,D,f),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=w(y),x;t[12]===o?x=t[13]:(x=I(o),t[12]=o,t[13]=x);let C=x,T;t[14]!==a.providersSettings.getApiKey||t[15]!==a.providersSettings.getApiKeyCn||t[16]!==a.providersSettings.getApiKeyIntl?(T={getApiKey:a.providersSettings.getApiKey,getApiKeyIntl:a.providersSettings.getApiKeyIntl,getApiKeyCn:a.providersSettings.getApiKeyCn},t[14]=a.providersSettings.getApiKey,t[15]=a.providersSettings.getApiKeyCn,t[16]=a.providersSettings.getApiKeyIntl,t[17]=T):T=t[17];let E=T;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let O;t[21]!==b||t[22]!==o.credentialsSaveError?(O=()=>void b.saveCredentials(o.credentialsSaveError),t[21]=b,t[22]=o.credentialsSaveError,t[23]=O):O=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[24]=A):A=t[24];let j;return t[25]!==E||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==y||t[38]!==O?(j=(0,P.jsx)(k,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:O,extensionIds:A,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=C,t[37]=y,t[38]=O,t[39]=j):j=t[39],j}function ee(e){return!!e.token}function R(e){return e.language}function z(e){let t=(0,M.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var B=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function V(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function H(){return o(g,y)}function U(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function W(e,t){if(!e||!t)return{apiKey:``,model:B[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:B[0].id}}function G({providerId:e,voiceSettings:t,mutateVoice:n}){let r=s(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,c={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=p(d(`/api/voice/stt-providers`),O,{revalidateOnFocus:!1}),f=(0,N.useMemo)(()=>u?.providers.some(t=>t.id===e&&t.configured)??!1,[e,u]),g=(0,N.useMemo)(()=>W(t,e),[e,t]),_=(0,N.useRef)(!1),[v,b]=(0,N.useState)(null),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[D,k]=(0,N.useState)(!1),j=v??g,M=g,F=j.apiKey!==M.apiKey||j.model!==M.model,I=(0,N.useCallback)(async()=>{C(!0),T(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:j.apiKey,model:j.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:j.apiKey,model:j.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:j.apiKey,model:j.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await E(r),await n(r,!1),_.current=!1,b(null),k(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[j.apiKey,j.model,n,e,t]),L=e===`groq`?B:[{id:j.model,name:j.model}];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(z,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:j.apiKey,onChange:e=>{_.current=!0,b(t=>({...t??g,apiKey:e})),T(null)},labels:c,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(z,{children:i.stt.model}),e===`groq`?(0,P.jsx)(m,{className:H(),value:j.model,onChange:e=>{_.current=!0,b(t=>({...t??g,model:e.target.value})),T(null)},children:L.map(e=>(0,P.jsx)(h,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:U(),value:j.model,onChange:e=>{_.current=!0,b(t=>({...t??g,model:e.target.value})),T(null)}})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:w}):null,(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>{_.current=!1,b(null),T(null)},children:i.discard}),(0,P.jsx)(x,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>void I(),children:S?i.saving:i.save})]})]})}function K(e){let t=(0,M.c)(13),{extensionId:n}=e,r=l(J),i=c(q),a;t[0]===n?a=t[1]:(a=()=>f(d(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=p(i&&n?`ext-stt-detail-${n}`:null,a),u;t[2]===o?u=t[3]:(u=V(o),t[2]=o,t[3]=u);let m=u,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=p(i?`voice-settings-ext-stt`:null,C,h);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(G,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function q(e){return!!e.token}function J(e){return e.language}function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){let t={};if(e.type!==`object`||!Y(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Y(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function Z(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Q({extensionId:e}){let t=s(l(e=>e.language)).agentSettings,n=c(e=>!!e.token),{data:r,error:i}=p(n&&e?`ext-detail-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}`))),{data:a,mutate:o,error:m}=p(n&&e?`ext-cfg-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}/config`))),h=r?.manifest?.configSchema,g=(0,N.useMemo)(()=>h&&h.type===`object`?X(h):{},[h]),_=(0,N.useMemo)(()=>({...g,...a??{}}),[g,a]),[v,y]=(0,N.useReducer)(Z,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[b,S]=(0,N.useState)(!1),C=(0,N.useRef)(!1),w=(0,N.useRef)(_);!C.current&&w.current!==_&&(w.current=_,y({type:`sync`,value:_}));let T=(0,N.useCallback)(e=>{C.current=!0,y({type:`change`,value:e})},[]),E=(0,N.useCallback)(()=>{C.current=!1,y({type:`discard`,value:_})},[_]),D=(0,N.useCallback)(()=>{!h||h.type!==`object`||(C.current=!0,y({type:`reset-defaults`,value:{...X(h)}}))},[h]),O=(0,N.useCallback)(async()=>{if(e){y({type:`save-start`});try{let t=await u(d(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(v.localValues)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await o(v.localValues,!1),C.current=!1,y({type:`save-success`,value:v.localValues}),S(!0)}catch(e){y({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[v.localValues,e,o]);if(!n)return null;if(i||m){let e=i??m;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!h||h.type!==`object`?null:(0,P.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v.saveError?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:v.saveError}):null,(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!v.isDirty,onClick:E,children:t.discard}),(0,P.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:D,children:`Reset to defaults`}),(0,P.jsx)(x,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!v.isDirty||v.saving,onClick:()=>void O(),children:v.saving?t.saving:t.save})]})]}),(0,P.jsx)(j,{schema:h,values:v.localValues,onChange:T,disabled:v.saving})]})}function te(){let e=(0,M.c)(47),t=l(ne),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,o=r.extensionImageGen,c=r.extensionSttMedia,{extensionId:u,panelId:d}=a(),f=v();if(!u){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let p,m,h;if(e[3]!==u||e[4]!==f||e[5]!==d){h=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===u?t=e[10]:(t=e=>e.id===u,e[9]=u,e[10]=t),p=f.find(t),!p){let t=`Extension "${u}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)($,{message:t}),e[11]=t,e[12]=n),h=n;break bb0}let n=p.ui?.contributions?.settingsPanels;m=d?n?.find(e=>e.id===d||e.id===`${u}.${d}`):n?.[0]}e[3]=u,e[4]=f,e[5]=d,e[6]=p,e[7]=m,e[8]=h}else p=e[6],m=e[7],h=e[8];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g=m,y=!!(g&&p.ui),b=!!p.hasConfigSchema,x=p.kind===`image-generation`,S=p.kind===`media-provider`;if(!b&&!y&&!(x||S)){let t=`Extension "${u}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=g?.title??`${p.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,P.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==o?(T=x?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:o.banner}),(0,P.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:o.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=o,e[20]=T):T=e[20];let E;e[21]!==u||e[22]!==x?(E=x?(0,P.jsx)(L,{extensionId:u}):null,e[21]=u,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==c?(D=S?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:c.banner}),(0,P.jsx)(i,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:c.openVoice})]}):null,e[24]=S,e[25]=c,e[26]=D):D=e[26];let O;e[27]!==u||e[28]!==S?(O=S?(0,P.jsx)(K,{extensionId:u}):null,e[27]=u,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==u||e[31]!==b?(k=b?(0,P.jsx)(Q,{extensionId:u}):null,e[30]=u,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==p.name||e[34]!==p.ui||e[35]!==u||e[36]!==y||e[37]!==g?(A=y&&g&&p.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(_,{extensionId:u,extensionName:p.name,entrypoint:g.entrypoint,permissions:p.ui?.permissions,title:g.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=p.name,e[34]=p.ui,e[35]=u,e[36]=y,e[37]=g,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,P.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function ne(e){return e.language}function $(e){let t=(0,M.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{te as ExtensionSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-GfSwnwIZ.js";import{ds as a,oi as o,so as s}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-GfSwnwIZ.js";import{ds as a,oi as o,so as s}from"./index-DSydVlxZ.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=o(y),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=o(x),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return a(e)}async function E(e){let t=await i(r(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function z(e){let t=R(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function B(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:L(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):S,auth:{mode:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function V(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!T(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!T(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function H(e){let t=z(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:V(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},maxSseConnections:e.maxSseConnections,channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),s()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h as u};
|