@xopcai/xopc 0.0.128 → 0.0.129
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-Dx3HQkOk.js → agent-avatar-dicebear-DHzfg5D-.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Ceb_WmSZ.js → agents-CMxKKFQD.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DGtoXVvI.js → app-management-settings-panel-ptk9c5BN.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BQQf_iLu.js → appearance-settings-bYeEj3IW.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-D05daQF8.js → apps-page-DdZvDf5B.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-HuCFa2UL.js → archive-plugin-Dy6lsTHw.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-N3csiRso.js → attachment-load-qOtBYR6Y.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DeYEW2YQ.js → automation-suggestion-card-BFH-RfaV.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Dxn5-hGx.js → automations-page-B8JTjkCr.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DnJO0VG7.js → binary-plugins-DJvi_thc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DOAZkqfs.js → block-editor-DlMnizlt.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DSB-ZKIX.js → browser-settings-page-slHLiZgi.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-DRCu-s6d.js → capability-presets-api-D4q7vHVJ.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-M7jOJxZX.js → capability-presets-settings-panel-Dng8Grpv.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-C1iggCG3.js → channels-settings-KIsISXw0.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Df0TJNgv.js → connectors-page-C5fx4Qs9.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-MnqKnEgd.js → desktop-pet-Jmdn6q47.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-PRnTI9no.js → desktop-pet-settings-B-u63N4e.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DJNFtSWq.js → directory-picker-path-field-8p1ehIHn.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-D0_2JavX.js → dreaming-settings-CCkKP-I4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C4sQuETO.js → extension-debug-page-DJ1ABK95.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DhnpWAUJ.js → extension-page-CP9P2lGM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D7JDxFGh.js → extension-settings-page-DnhU-tx0.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B_VyPdKh.js → gateway-config-api-CjxDn46s.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-C0TutwM5.js → gateway-settings-TING7224.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-DrDGK2L5.js → goal-create-dialog-2lPbGfp3.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-aaIMRRor.js → goal-detail-page-DHWVRafk.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-CzTu01a1.js → goals-config-api-BqhuxG8P.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-CBfCPiNK.js → goals-page-CMk-9ZYN.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-4rKUC3EH.js → goals-settings-BHzOAU_l.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DqJBKlza.js → heartbeat-settings-BQIm0P3V.js} +1 -1
- package/dist/gateway/static/root/assets/{index-38TSE7ng.js → index-C4k6QSXw.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ClVhEihC.js → keyboard-shortcuts-settings-BrENZzM7.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-J8fw1O8x.js → logs-page-BiL302Ve.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-DQYDAL4r.js → markdown-split-BYF4ReGM.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-o5fchHfb.js → media-plugins-CpQDz-QJ.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-panel-D9csuY5T.js → models-hub-panel-CFPpl3Cq.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CeWoUGI-.js → notes-page-BurgcdVZ.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-D_oaF0Pq.js → notes-workbench-BAELRM_O.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-u0u41Gxz.js → page-tabs-RnYYOIWO.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BaYRX55y.js → preview-open-alternatives-CTRt06Ri.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-dkHzwhDL.js → project-detail-page-iXX1Ceo2.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DBp2WExF.js → projects-page-GDVTFAY7.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Cgzg4pNN.js → remote-access-hub-BUrbUnwv.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-8ebg7PIX.js → save-bar-controls-c4pZeikq.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-Cd7FPvsJ.js → schedule-field-Cb6R7iuP.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Bq9iqPeA.js → schema-form-BqET_hEP.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-vkORZvUB.js → sessions-page-CiOreA2k.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-DaVKl6I7.js → settings-collapsible-section-DuOvqNsI.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-C92Shabe.js → settings-form-section-DptSsbWd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-EJwzElLr.js → settings-loading-skeleton-BlVfBCb9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-dTbdUfAB.js → settings-page-layout-DVt69dJJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BLY6onMK.js → settings-page-xQx2Pkg5.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BU0JUWIA.js → setup-status-panel-DWB8VdLK.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-SgKIyNQ7.js → share-preview-page-8m_ACH0z.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-aiY_QGsl.js → shares-settings-CgxfhNxI.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-C44tGvK7.js → skill-reload-api-BBFUOxmf.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-C1re61FQ.js → skills-page-bo695odu.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CntJCZEg.js → system-settings-panel-CW22OkZ4.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CjULd6SF.js → typed-models-lib-BqpGAKxV.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DBgcbZfp.js → user-profile-settings-panel-CERVLuaW.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-icmWvHl6.js → utils-BnmysurA.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BfvNUIWI.js → voice-api-key-field-Jr3jvPcB.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-BYvZjBuJ.js → work-item-detail-page-B-8rex4u.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DMXd1znx.js → workflow-run-setup-panel-Ci9GSPnS.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-start-dialog-Dff4IHzz.js → workflow-start-dialog-BhDj8pqH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-0-640fQi.js → workflows-page-Brb3UGvs.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BFJsnSvx.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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s}from"./fetch-BMjlW0g1.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ao as l,Ba as u,Do as d,Fc as f,Ga as p,Ha as m,Ka as h,Oc as g,Ol as _,Ss as v,Ua as y,Va as b,Vo as x,Wa as S,ao as C,bo as w,bs as T,dl as E,ko as D,oo as O,ps as k,rc as A,rr as j,so as M}from"./index-38TSE7ng.js";import{n as N,t as P}from"./settings-page-layout-dTbdUfAB.js";import{n as F,t as I}from"./settings-loading-skeleton-EJwzElLr.js";import{n as L,t as R}from"./settings-form-section-C92Shabe.js";import{a as z,i as B,o as V,t as ee}from"./typed-models-lib-CjULd6SF.js";import{a as H,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./capability-presets-api-DRCu-s6d.js";var se=n(),U=e(t(),1),W=r();function G(e){return e.name||e.directoryId}function ce(e){let t=(0,se.c)(56),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,f=n===`allowlist`||n===`denylist`,p;t[0]===a?p=t[1]:(p=a.map(G).filter(Boolean),t[0]=a,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=u.inheritSummary;break bb0}if(n===`all`){h=u.allSummary;break bb0}if(n===`off`){h=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],h=i}let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),t[5]=_):_=t[5];let v;t[6]===u.overrideSummaryTitle?v=t[7]:(v=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=v);let y;t[8]===g?y=t[9]:(y=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:g}),t[8]=g,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===u.modeLabel?x=t[14]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=x);let S;t[15]===u.modeInherit?S=t[16]:(S=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=S);let C;t[17]===u.modeAll?C=t[18]:(C=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=C);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==T||t[26]!==D||t[27]!==S||t[28]!==C||t[29]!==w?(O=[S,C,w,T,D],t[25]=T,t[26]=D,t[27]=S,t[28]=C,t[29]=w,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==x?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,A]}),t[36]=A,t[37]=x,t[38]=j):j=t[38];let M;t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==o||t[48]!==l||t[49]!==f||t[50]!==r?(M=f?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:s||o||m.length===0,onClick:()=>l(new Set(m)),children:u.quickSelectAll}),(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,W.jsx)(I,{rows:3}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=G(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||u.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,t[40]=m,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=o,t[48]=l,t[49]=f,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==b?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,j,M]}),t[52]=j,t[53]=M,t[54]=b,t[55]=N):N=t[55],N}var K=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],q=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],J=[`send_message`,`send_media`,`text_to_speech`,`create_share`],Y=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],X=[...K,...J],le=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ue=[`send_message`,`send_media`];function Z(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function de(e){let t=(0,se.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let f=u,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(fe),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of H){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=re(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==a||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==f||t[16]!==a?(y=e=>{a(Z(f,e))},t[15]=f,t[16]=a,t[17]=y):y=t[17];let b=y;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let x;t[20]===l.quickActionsLabel?x=t[21]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=x);let S;t[22]===a?S=t[23]:(S=()=>a({}),t[22]=a,t[23]=S);let C;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==S?(C=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:S,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=S,t[27]=C):C=t[27];let w;t[28]===b?w=t[29]:(w=()=>b([[K,`deny`]]),t[28]=b,t[29]=w);let T;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==w?(T=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:w,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=w,t[33]=T):T=t[33];let E;t[34]===b?E=t[35]:(E=()=>b([[q,`deny`]]),t[34]=b,t[35]=E);let D;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==E?(D=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:E,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=E,t[39]=D):D=t[39];let O;t[40]===b?O=t[41]:(O=()=>b([[J,`deny`]]),t[40]=b,t[41]=O);let k;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==O?(k=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:O,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=O,t[45]=k):k=t[45];let A;t[46]===b?A=t[47]:(A=()=>b([[Y,`allow`],[X,`deny`]]),t[46]=b,t[47]=A);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==A?(j=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:A,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=A,t[51]=j):j=t[51];let M;t[52]===b?M=t[53]:(M=()=>b([[le,`allow`],[ue,`deny`]]),t[52]=b,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==N||t[62]!==C||t[63]!==T?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C,T,D,k,j,N]}),t[58]=D,t[59]=k,t[60]=j,t[61]=N,t[62]=C,t[63]=T,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==x?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,P]}),t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==m?(L=m.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=m,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let z;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==g||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==v||t[86]!==r?(z=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,n===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=g,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=v,t[86]=r,t[87]=z):z=t[87];let B;return t[88]!==F||t[89]!==R||t[90]!==z?(B=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,z]}),t[88]=F,t[89]=R,t[90]=z,t[91]=B):B=t[91],B}function fe(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var pe=[{id:`overview`,icon:f},{id:`models`,icon:A},{id:`tools`,icon:l},{id:`skills`,icon:T},{id:`impact`,icon:g}];function me(e){return B(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function he(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function ge(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function _e(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:me(e),toolModes:he(e),skillMode:e?.skills?.mode??`inherit`,skillPick:ge(e)}}function Q(e,t){let n=ee(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function ve(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function $(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function ye(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:Q(e,t),tools:ve(e),skills:$(e)}}function be(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function xe(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function Se(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful command execution, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,apply_patch:`deny`,exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function Ce(){let e=a(o(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:E,isLoading:I,mutate:B}=c(n?`settings-capability-presets`:null,ie,{revalidateOnFocus:!1}),{data:V=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,j,{revalidateOnFocus:!1}),[H,re]=_(),[se,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>Se(`blank`)),[X,le]=(0,U.useState)(!1),[ue,Z]=(0,U.useState)(null),[fe,me]=(0,U.useState)(null),he=r?.presets??[],ge=r?.defaultPresetId??`default`,Q=he.find(e=>e.id===ge)??null,ve=he.filter(e=>e.id!==ge),$=(0,U.useMemo)(()=>he.find(e=>e.id===se)??he[0]??null,[he,se]),Ce=!$||J.id.trim()!==$.id,Te=!!($&&$.id===ge),Ee=JSON.stringify(ye(J,$))!==JSON.stringify(be($)),De=ue??(E instanceof Error?E.message:null),Oe=H.get(`action`)===`new`||!!H.get(`preset`),ke=Ce?t.newPreset:$?.name??t.editorTitle,Ae=t=>e.agentsSettings.toolsDisableGroups[t],je=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(H.get(`action`)===`new`){let e=H.get(`starter`);G(``),Y(Se(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=H.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(_e(t)),q(H.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:_e($)))},[X,r,H,$]);function Me(e){G(e.id),Y(_e(e)),re({preset:e.id},{replace:!0}),q(`overview`)}function Ne(e){let t=Se(e);G(``),Y(t),Z(null),re(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function Pe(){re({},{replace:!0}),Z(null),Y(_e($)),q(`overview`)}async function Fe(){let e=z(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}le(!0),Z(null);try{if(Ce){let e=await oe({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=ye(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await B(t,{revalidate:!1}),G(e.presetId),re({preset:e.presetId},{replace:!0})}else if($){let e=ye(J,$);await B(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}async function Ie(){if($){le(!0),Z(null);try{let e=await ne($.id);await B(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(_e(t)),re(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}}return n?(0,W.jsxs)(P,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(N,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(d,{type:`button`,onClick:()=>Ne(`blank`),disabled:X,children:[(0,W.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,W.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,I?(0,W.jsx)(F,{sections:2}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:v,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ne(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(Q),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:xe(Q)})]})]}):null,(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.listTitle,subtitle:t.listHint}),ve.length===0?(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ve.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:xe(e)})]},e.id))})]})]}),(0,W.jsx)(p,{open:Oe,onOpenChange:e=>{e||Pe()},children:(0,W.jsxs)(S,{children:[(0,W.jsx)(y,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,M)}),(0,W.jsx)(b,{ref:me,className:i(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,O),onOpenAutoFocus:e=>e.preventDefault(),children:(0,W.jsxs)(C,{layer:`modal`,portalContainer:fe,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(h,{className:`truncate text-base font-semibold text-fg`,children:ke}),(0,W.jsx)(m,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ce?t.editorHint:J.id})]}),(0,W.jsx)(u,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(w,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,W.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,(0,W.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:pe.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:f,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:X||!Ce,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(we,{icon:A,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(we,{icon:l,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(we,{icon:T,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ae,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:l,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(de,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:je,getGroupTitle:Ae,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:T,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(ce,{mode:J.skillMode,selected:J.skillPick,catalog:V,loading:ee,disabled:X,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,K===`impact`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:g,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,W.jsx)(d,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(_e($)),children:t.discard}):null,$&&!Te?(0,W.jsxs)(d,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ie(),children:[(0,W.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(d,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ee,onClick:()=>void Fe(),children:[(0,W.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(P,{gap:`gap-3`,children:[(0,W.jsx)(N,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function we(e){let t=(0,se.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}export{Ce as CapabilityPresetsSettingsPanel};
|
|
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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s}from"./fetch-BMjlW0g1.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Ao as l,Ba as u,Do as d,Fc as f,Ga as p,Ha as m,Ka as h,Oc as g,Ol as _,Ss as v,Ua as y,Va as b,Vo as x,Wa as S,ao as C,bo as w,bs as T,dl as E,ko as D,oo as O,ps as k,rc as A,rr as j,so as M}from"./index-C4k6QSXw.js";import{n as N,t as P}from"./settings-page-layout-DVt69dJJ.js";import{n as F,t as I}from"./settings-loading-skeleton-BlVfBCb9.js";import{n as L,t as R}from"./settings-form-section-DptSsbWd.js";import{a as z,i as B,o as V,t as ee}from"./typed-models-lib-BqpGAKxV.js";import{a as H,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./capability-presets-api-D4q7vHVJ.js";var se=n(),U=e(t(),1),W=r();function G(e){return e.name||e.directoryId}function ce(e){let t=(0,se.c)(56),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,f=n===`allowlist`||n===`denylist`,p;t[0]===a?p=t[1]:(p=a.map(G).filter(Boolean),t[0]=a,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=u.inheritSummary;break bb0}if(n===`all`){h=u.allSummary;break bb0}if(n===`off`){h=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],h=i}let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),t[5]=_):_=t[5];let v;t[6]===u.overrideSummaryTitle?v=t[7]:(v=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=v);let y;t[8]===g?y=t[9]:(y=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:g}),t[8]=g,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===u.modeLabel?x=t[14]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=x);let S;t[15]===u.modeInherit?S=t[16]:(S=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=S);let C;t[17]===u.modeAll?C=t[18]:(C=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=C);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==T||t[26]!==D||t[27]!==S||t[28]!==C||t[29]!==w?(O=[S,C,w,T,D],t[25]=T,t[26]=D,t[27]=S,t[28]=C,t[29]=w,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==x?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,A]}),t[36]=A,t[37]=x,t[38]=j):j=t[38];let M;t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==o||t[48]!==l||t[49]!==f||t[50]!==r?(M=f?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:s||o||m.length===0,onClick:()=>l(new Set(m)),children:u.quickSelectAll}),(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,W.jsx)(I,{rows:3}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=G(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||u.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,t[40]=m,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=o,t[48]=l,t[49]=f,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==b?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,j,M]}),t[52]=j,t[53]=M,t[54]=b,t[55]=N):N=t[55],N}var K=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],q=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],J=[`send_message`,`send_media`,`text_to_speech`,`create_share`],Y=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],X=[...K,...J],le=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ue=[`send_message`,`send_media`];function Z(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function de(e){let t=(0,se.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let f=u,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(fe),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of H){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=re(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==a||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==f||t[16]!==a?(y=e=>{a(Z(f,e))},t[15]=f,t[16]=a,t[17]=y):y=t[17];let b=y;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let x;t[20]===l.quickActionsLabel?x=t[21]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=x);let S;t[22]===a?S=t[23]:(S=()=>a({}),t[22]=a,t[23]=S);let C;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==S?(C=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:S,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=S,t[27]=C):C=t[27];let w;t[28]===b?w=t[29]:(w=()=>b([[K,`deny`]]),t[28]=b,t[29]=w);let T;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==w?(T=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:w,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=w,t[33]=T):T=t[33];let E;t[34]===b?E=t[35]:(E=()=>b([[q,`deny`]]),t[34]=b,t[35]=E);let D;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==E?(D=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:E,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=E,t[39]=D):D=t[39];let O;t[40]===b?O=t[41]:(O=()=>b([[J,`deny`]]),t[40]=b,t[41]=O);let k;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==O?(k=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:O,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=O,t[45]=k):k=t[45];let A;t[46]===b?A=t[47]:(A=()=>b([[Y,`allow`],[X,`deny`]]),t[46]=b,t[47]=A);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==A?(j=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:A,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=A,t[51]=j):j=t[51];let M;t[52]===b?M=t[53]:(M=()=>b([[le,`allow`],[ue,`deny`]]),t[52]=b,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(d,{type:`button`,variant:`secondary`,className:V,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==N||t[62]!==C||t[63]!==T?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C,T,D,k,j,N]}),t[58]=D,t[59]=k,t[60]=j,t[61]=N,t[62]=C,t[63]=T,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==x?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,P]}),t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==m?(L=m.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=m,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let z;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==g||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==v||t[86]!==r?(z=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,n===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=g,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=v,t[86]=r,t[87]=z):z=t[87];let B;return t[88]!==F||t[89]!==R||t[90]!==z?(B=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,z]}),t[88]=F,t[89]=R,t[90]=z,t[91]=B):B=t[91],B}function fe(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var pe=[{id:`overview`,icon:f},{id:`models`,icon:A},{id:`tools`,icon:l},{id:`skills`,icon:T},{id:`impact`,icon:g}];function me(e){return B(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function he(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function ge(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function _e(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:me(e),toolModes:he(e),skillMode:e?.skills?.mode??`inherit`,skillPick:ge(e)}}function Q(e,t){let n=ee(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function ve(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function $(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function ye(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:Q(e,t),tools:ve(e),skills:$(e)}}function be(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function xe(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function Se(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful command execution, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,apply_patch:`deny`,exec_command:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function Ce(){let e=a(o(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:E,isLoading:I,mutate:B}=c(n?`settings-capability-presets`:null,ie,{revalidateOnFocus:!1}),{data:V=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,j,{revalidateOnFocus:!1}),[H,re]=_(),[se,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>Se(`blank`)),[X,le]=(0,U.useState)(!1),[ue,Z]=(0,U.useState)(null),[fe,me]=(0,U.useState)(null),he=r?.presets??[],ge=r?.defaultPresetId??`default`,Q=he.find(e=>e.id===ge)??null,ve=he.filter(e=>e.id!==ge),$=(0,U.useMemo)(()=>he.find(e=>e.id===se)??he[0]??null,[he,se]),Ce=!$||J.id.trim()!==$.id,Te=!!($&&$.id===ge),Ee=JSON.stringify(ye(J,$))!==JSON.stringify(be($)),De=ue??(E instanceof Error?E.message:null),Oe=H.get(`action`)===`new`||!!H.get(`preset`),ke=Ce?t.newPreset:$?.name??t.editorTitle,Ae=t=>e.agentsSettings.toolsDisableGroups[t],je=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(H.get(`action`)===`new`){let e=H.get(`starter`);G(``),Y(Se(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=H.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(_e(t)),q(H.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:_e($)))},[X,r,H,$]);function Me(e){G(e.id),Y(_e(e)),re({preset:e.id},{replace:!0}),q(`overview`)}function Ne(e){let t=Se(e);G(``),Y(t),Z(null),re(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function Pe(){re({},{replace:!0}),Z(null),Y(_e($)),q(`overview`)}async function Fe(){let e=z(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}le(!0),Z(null);try{if(Ce){let e=await oe({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=ye(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await B(t,{revalidate:!1}),G(e.presetId),re({preset:e.presetId},{replace:!0})}else if($){let e=ye(J,$);await B(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}async function Ie(){if($){le(!0),Z(null);try{let e=await ne($.id);await B(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(_e(t)),re(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{le(!1)}}}return n?(0,W.jsxs)(P,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(N,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(d,{type:`button`,onClick:()=>Ne(`blank`),disabled:X,children:[(0,W.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,W.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,I?(0,W.jsx)(F,{sections:2}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:v,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ne(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(Q),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:xe(Q)})]})]}):null,(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.listTitle,subtitle:t.listHint}),ve.length===0?(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ve.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Me(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:xe(e)})]},e.id))})]})]}),(0,W.jsx)(p,{open:Oe,onOpenChange:e=>{e||Pe()},children:(0,W.jsxs)(S,{children:[(0,W.jsx)(y,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,M)}),(0,W.jsx)(b,{ref:me,className:i(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,O),onOpenAutoFocus:e=>e.preventDefault(),children:(0,W.jsxs)(C,{layer:`modal`,portalContainer:fe,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(h,{className:`truncate text-base font-semibold text-fg`,children:ke}),(0,W.jsx)(m,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ce?t.editorHint:J.id})]}),(0,W.jsx)(u,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(w,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,W.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,(0,W.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:pe.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:f,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:X||!Ce,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(we,{icon:A,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(we,{icon:l,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(we,{icon:T,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:A,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ae,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:l,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(de,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:je,getGroupTitle:Ae,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:T,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(ce,{mode:J.skillMode,selected:J.skillPick,catalog:V,loading:ee,disabled:X,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,K===`impact`?(0,W.jsxs)(R,{children:[(0,W.jsx)(L,{icon:g,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,W.jsx)(d,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(_e($)),children:t.discard}):null,$&&!Te?(0,W.jsxs)(d,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ie(),children:[(0,W.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(d,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ee,onClick:()=>void Fe(),children:[(0,W.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(P,{gap:`gap-3`,children:[(0,W.jsx)(N,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function we(e){let t=(0,se.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}export{Ce as CapabilityPresetsSettingsPanel};
|
|
@@ -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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{t as u}from"./url-DFGNSBNT.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Bo as p,Dl as m,Do as h,El as g,Ga as _,Gs as v,Ha as y,Ka as b,Qc as x,Ua as S,Va as C,Wa as w,Yo as T,_a as E,_r as D,bo as O,gr as k,kc as A,ko as j,oo as M,qa as N,rt as P,so as ee,ss as F,va as I,vr as te,yi as L,ys as R}from"./index-38TSE7ng.js";import{n as ne,t as re}from"./settings-page-layout-dTbdUfAB.js";import{n as ie}from"./settings-loading-skeleton-EJwzElLr.js";import{t as ae}from"./schema-form-Bq9iqPeA.js";import{t as z}from"./browser-BLJWD7WI.js";import{t as oe}from"./use-channel-catalog-CPdJ0o0i.js";var B=n(),V=e(z(),1),H=e(t(),1),U=r();function W(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function G(e){let t=await l(u(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function K(e){return e?.type===`poll`&&e.phase===`done`}function q(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function se(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ce(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function le({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:a=!1,compact:o=!1}){let s=(0,H.useMemo)(()=>W(e),[e]),c=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,H.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await G({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{!a||!s||s[1].result!==`qr`||l.payload||l.busy||l.error||d(s[0])},[a,s,d,l.busy,l.error,l.payload]),(0,H.useEffect)(()=>{let t=se(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),V.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,H.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:K(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),K(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=s?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=q(l.payload),g=se(l.payload,e.id),_=g?l.generatedQr:ce(l.payload),y=s?.[1].result===`qr`&&(a||l.busy||l.payload?.type===`qr`||l.payload?.type===`poll`),b=l.payload?.type===`form`?l.payload:null,S=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,U.jsxs)(`div`,{className:o?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,o?`justify-end`:`justify-between`),children:[o?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,U.jsxs)(h,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(s[0]),children:[l.busy?(0,U.jsx)(v,{className:`size-4 animate-spin`}):(0,U.jsx)(R,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(h,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(T,{className:`size-4`}),p]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,y?(0,U.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base px-3 py-3 shadow-surface`,o?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(E,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,o&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(E,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(E,{className:`h-4 w-36 max-w-full`})]}),g?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(A,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(x,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ae,{schema:b.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:c}),(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(b.submitAction,l.formDraft),children:n.saveSetup})]}):null,S?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:S.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function ue(e,t=!1){return e===`drawer`?i(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,M):i(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,M,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function de(e){let t=(0,B.c)(30),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:p,wide:m,headerExtra:g}=e,v=m===void 0?!1:m,x=n===`drawer`,T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,U.jsx)(S,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=T):T=t[0];let E;t[1]!==n||t[2]!==v?(E=ue(n,v),t[1]=n,t[2]=v,t[3]=E):E=t[3];let D;t[4]===c?D=t[5]:(D=c?(0,U.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=D);let k;t[6]===l?k=t[7]:(k=l?(0,U.jsx)(y,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=k);let A;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==x||t[12]!==o?(A=x?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(f,{asChild:!0,children:(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(j,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(f,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:i(O,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(j,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=x,t[12]=o,t[13]=A):A=t[13];let M=x?`px-4 py-4`:`p-6`,N;t[14]===M?N=t[15]:(N=i(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,U.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==p||t[20]!==E||t[21]!==D||t[22]!==k||t[23]!==A||t[24]!==P?(F=(0,U.jsxs)(w,{children:[T,(0,U.jsxs)(C,{className:E,onOpenAutoFocus:J,children:[D,k,A,P,p]})]}),t[19]=p,t[20]=E,t[21]=D,t[22]=k,t[23]=A,t[24]=P,t[25]=F):F=t[25];let I;return t[26]!==a||t[27]!==r||t[28]!==F?(I=(0,U.jsx)(_,{open:r,onOpenChange:a,children:F}),t[26]=a,t[27]=r,t[28]=F,t[29]=I):I=t[29],I}function J(e){return e.preventDefault()}var fe=(0,H.memo)(function(e){let t=(0,B.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(L,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function pe(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(h,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(h,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:m,onClick:g,children:_}),t[13]=m,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function me(e){return e?u(`/api/channels/${encodeURIComponent(e)}/config`):null}async function he(e){return(await c(u(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var ge=[`enabled`];async function _e(){return(await c(u(`/api/config`))).payload?.config?.channels??{}}function ve(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Y(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function ye(e,t){let n=X(e);return n.state===`needs_setup`?t.hubStatusNeedsSetup:n.state===`error`?t.hubStatusError:n.enabled&&n.ready&&e.runtime===`loaded`?t.hubStatusRunning:n.enabled&&n.ready?t.hubStatusEnabled:n.ready?t.hubStatusConfigured:t.hubStatusNotConfigured}function be(e){let t=X(e);return t.state===`needs_setup`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:t.state===`error`?`bg-red-500/10 text-red-700 dark:text-red-300`:t.enabled&&t.ready&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:t.enabled||t.ready?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function xe(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!ge.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!ge.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Se(e,t){let n={...Q(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Q(r[n]),properties:{}}),e===t.length-1){o[n]=Q(r[n]);break}i=r[n],a=o[n]}}return n}function $(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&$(n)&&delete t[e];return Object.keys(t).length===0}function Ce(e,t){let n=Q(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return $(n),n}function we(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Te(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Ee(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function De(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Oe(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Me(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=De(e,Te(t,e),n);i&&r.push(i)}let a=Ee(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function ke(e,t){let n=X(e),r=W(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Ae(e,t){let n=W(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function je(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Me(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function Ne({entry:e}){let t=s(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(u(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ve(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function Pe(e){let t=(0,B.c)(16),{checked:n,disabled:r,onToggle:a,label:o}=e,s;t[0]===a?s=t[1]:(s=e=>{e.stopPropagation(),a()},t[0]=a,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==o||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":o,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=o,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function Fe(e){let t=(0,B.c)(70),{entry:n,config:r,busy:a,ch:o,onOpen:s,onToggle:c}=e,l;t[0]===n?l=t[1]:(l=X(n),t[0]=n,t[1]=l);let u=l,d,f,p,m,g,_,y;if(t[2]!==a||t[3]!==o||t[4]!==r||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u.enabled||t[9]!==u.ready){let e=Oe(n,r,o),l=je(n,o);d=!u.enabled&&u.ready,_=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let h;t[17]===n?h=t[18]:(h=(0,U.jsx)(Ne,{entry:n}),t[17]=n,t[18]=h);let v;t[19]===n.label?v=t[20]:(v=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[19]=n.label,t[20]=v);let b;t[21]===n?b=t[22]:(b=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,be(n)),t[21]=n,t[22]=b);let x;t[23]!==o||t[24]!==n?(x=ye(n,o),t[23]=o,t[24]=n,t[25]=x):x=t[25];let S;t[26]!==b||t[27]!==x?(S=(0,U.jsx)(`span`,{className:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==v?(C=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[v,S]}),t[29]=S,t[30]=v,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==h?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,C]}),t[32]=C,t[33]=h,t[34]=w):w=t[34];let T=u.enabled,E;t[35]!==o.toggleChannel||t[36]!==n.label?(E=o.toggleChannel.replace(`{{channel}}`,n.label),t[35]=o.toggleChannel,t[36]=n.label,t[37]=E):E=t[37];let D;t[38]!==a||t[39]!==c||t[40]!==u.enabled||t[41]!==E?(D=(0,U.jsx)(Pe,{checked:T,disabled:a,label:E,onToggle:c}),t[38]=a,t[39]=c,t[40]=u.enabled,t[41]=E,t[42]=D):D=t[42],t[43]!==w||t[44]!==D?(y=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[w,D]}),t[43]=w,t[44]=D,t[45]=y):y=t[45],f=`button`,p=s,m=`mt-5 min-h-[6.25rem] text-left`,g=u.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(Le)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Ae(n,o)}),l.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:l.map(Ie)}):null]}),t[2]=a,t[3]=o,t[4]=r,t[5]=n,t[6]=s,t[7]=c,t[8]=u.enabled,t[9]=u.ready,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=g,t[15]=_,t[16]=y}else d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15],y=t[16];let b;t[46]!==o.cardAdapterLabel||t[47]!==n.description||t[48]!==u.ready?(b=!u.ready&&n.description?(0,U.jsxs)(`p`,{className:`mt-3 truncate text-xs text-fg-subtle`,title:n.description,children:[o.cardAdapterLabel,`: `,n.description]}):null,t[46]=o.cardAdapterLabel,t[47]=n.description,t[48]=u.ready,t[49]=b):b=t[49];let x;t[50]!==f||t[51]!==p||t[52]!==m||t[53]!==g||t[54]!==b?(x=(0,U.jsxs)(`button`,{type:f,onClick:p,className:m,children:[g,b]}),t[50]=f,t[51]=p,t[52]=m,t[53]=g,t[54]=b,t[55]=x):x=t[55];let S=d?c:s,C;t[56]===a?C=t[57]:(C=a?(0,U.jsx)(v,{className:`size-4 animate-spin`}):null,t[56]=a,t[57]=C);let w;t[58]!==o||t[59]!==n?(w=ke(n,o),t[58]=o,t[59]=n,t[60]=w):w=t[60];let T;t[61]!==S||t[62]!==C||t[63]!==w?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(h,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:S,children:[C,w]})}),t[61]=S,t[62]=C,t[63]=w,t[64]=T):T=t[64];let E;return t[65]!==T||t[66]!==_||t[67]!==y||t[68]!==x?(E=(0,U.jsxs)(`article`,{className:_,children:[y,x,T]}),t[65]=T,t[66]=_,t[67]=y,t[68]=x,t[69]=E):E=t[69],E}function Ie(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Le(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function Re(e){let t=(0,B.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(p,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let m=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===m?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:m}),t[14]=m,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let h;t[16]===r?h=t[17]:(h=e=>(0,U.jsx)(`li`,{children:Me(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=h),a=e.issues.map(h)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let m;t[18]!==i||t[19]!==a?(m=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=m):m=t[20];let h;t[21]!==m||t[22]!==o||t[23]!==s||t[24]!==c?(h=(0,U.jsxs)(`div`,{className:o,children:[s,c,m]}),t[21]=m,t[22]=o,t[23]=s,t[24]=c,t[25]=h):h=t[25];let g;t[26]!==h||t[27]!==l||t[28]!==u?(g=(0,U.jsxs)(`div`,{className:l,children:[u,h]}),t[26]=h,t[27]=l,t[28]=u,t[29]=g):g=t[29];let _;return t[30]!==g||t[31]!==d?(_=(0,U.jsx)(`section`,{className:d,children:g}),t[30]=g,t[31]=d,t[32]=_):_=t[32],_}function ze(){let e=o(e=>e.language),t=a(e),n=s(e=>!!e.token),r=g(),{channelId:c}=m(),f=te(c),p=oe(n,e),h=p.entries,{data:_={},mutate:v}=d(n?`channels-config-map`:null,_e,{revalidateOnFocus:!1}),y=N(e=>e.setPageHeader),b=N(e=>e.clearPageHeader),x=(0,H.useMemo)(()=>h.find(e=>e.id===f),[f,h]),S=x?Y(x):null,{data:C,mutate:w}=d(n&&S?me(S):null,()=>he(S)),[T,E]=(0,H.useState)(null),[O,j]=(0,H.useState)(!1),[M,ee]=(0,H.useState)(null),[I,L]=(0,H.useState)(null),R=T??C??{},z=t.channelsSettings,B=(0,H.useMemo)(()=>x?.configSchema??{type:`object`,properties:{}},[x?.configSchema]),V=(0,H.useMemo)(()=>Ce(B,ge),[B]),G=(0,H.useMemo)(()=>xe(x),[x]),K=(0,H.useMemo)(()=>Se(V,G),[G,V]),q=(0,H.useMemo)(()=>Ce(V,G),[G,V]),se=(0,H.useMemo)(()=>we(K),[K]),ce=(0,H.useMemo)(()=>({defaultBooleanLabel:z.schemaBooleanDefault,unsupportedArrayType:z.schemaUnsupportedArrayType,arrayAddPlaceholder:z.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>z.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[z]),ue=(0,H.useMemo)(()=>n?(0,U.jsx)(fe,{ch:z,refreshing:p.isValidating,saveOk:!1,onRefresh:()=>void p.mutate()}):null,[p,z,n]);(0,H.useLayoutEffect)(()=>(y({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:ue}),()=>b()),[b,ue,t.settingsSections.channels,y]);let J=(0,H.useCallback)(e=>{r(D(e)),E(null),L(null)},[r]),ve=(0,H.useCallback)(()=>{r(k),E(null),L(null)},[r]),Z=(0,H.useCallback)(async()=>{if(!x||!T)return!1;let e=Y(x);j(!0),L(null);try{let t=await l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e]:T}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return await w(T,!1),await v(),await p.mutate(),E(null),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{j(!1)}},[x,p,T,v,w]),Q=(0,H.useCallback)(async e=>{let t=X(e),n=Y(e),r=x?.id===e.id?T:null;if(!t.enabled&&!t.ready&&!r){J(e.id);return}ee(e.id),L(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await p.mutate(),await v(),x?.id===e.id&&(await w(),E(null))}catch(e){L(e instanceof Error?e.message:String(e))}finally{ee(null)}},[x?.id,p,T,v,w,J]),$=x?.ui?.modal,Te=$?.placement!==`replace-config`;return n?(0,U.jsxs)(re,{gap:`gap-4`,children:[p.isLoading?(0,U.jsx)(ie,{sections:2}):p.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:h.map(e=>(0,U.jsx)(Fe,{entry:e,config:_[Y(e)]?.config,busy:M===e.id,ch:z,onOpen:()=>J(e.id),onToggle:()=>void Q(e)},e.id))}),I?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:I}):null,(0,U.jsx)(de,{presentation:`modal`,open:!!x,onOpenChange:e=>{e||ve()},closeAriaLabel:z.close,srTitle:x?.label??z.selectChannel,srDescription:x?.description,wide:!0,footer:x?(0,U.jsx)(pe,{ch:z,dirty:!!T,saving:O,onCancel:ve,onDiscard:()=>E(null),onSave:Z}):null,children:x?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(Ne,{entry:x}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:x.label}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,be(x)),children:ye(x,z)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:W(x)?.[1].result===`qr`?z.scanLoginHint.replace(`{{channel}}`,x.label):x.description}),x.docsPath?(0,U.jsxs)(`a`,{href:x.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[z.docs,(0,U.jsx)(A,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:z.enabledLabel}),(0,U.jsx)(Pe,{checked:X(x).enabled,disabled:M===x.id,label:z.toggleChannel.replace(`{{channel}}`,x.label),onToggle:()=>void Q(x)})]})]})}),(0,U.jsx)(Re,{entry:x,ch:z}),$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(P,{extensionId:x.extensionId,extensionName:x.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:x.id,entry:x,config:R}}):null,$?.placement===`replace-config`?null:(0,U.jsx)(le,{entry:x,locale:e,messages:z,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await w(),await p.mutate(),await v()}},x.id),$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(P,{extensionId:x.extensionId,extensionName:x.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:x.id,entry:x,config:R}}):null,Te&&se?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:z.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:z.basicConfigurationHint})]}),(0,U.jsx)(ae,{schema:K,values:R,onChange:e=>E(e),disabled:O,labels:ce})]}):null,Te&&we(q)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(F,{className:`size-4 text-fg-muted`}),z.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ae,{schema:q,values:R,onChange:e=>E(e),disabled:O,labels:ce})})]}):null,I?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:I}):null]}):null})]}):(0,U.jsxs)(re,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ne,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:z.tokenRequired})]})}export{ze as ChannelsSettingsPanel};
|
|
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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{t as u}from"./url-DFGNSBNT.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Bo as p,Dl as m,Do as h,El as g,Ga as _,Gs as v,Ha as y,Ka as b,Qc as x,Ua as S,Va as C,Wa as w,Yo as T,_a as E,_r as D,bo as O,gr as k,kc as A,ko as j,oo as M,qa as N,rt as P,so as ee,ss as F,va as I,vr as te,yi as L,ys as R}from"./index-C4k6QSXw.js";import{n as ne,t as re}from"./settings-page-layout-DVt69dJJ.js";import{n as ie}from"./settings-loading-skeleton-BlVfBCb9.js";import{t as ae}from"./schema-form-BqET_hEP.js";import{t as z}from"./browser-BLJWD7WI.js";import{t as oe}from"./use-channel-catalog-CPdJ0o0i.js";var B=n(),V=e(z(),1),H=e(t(),1),U=r();function W(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function G(e){let t=await l(u(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function K(e){return e?.type===`poll`&&e.phase===`done`}function q(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function se(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ce(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function le({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:a=!1,compact:o=!1}){let s=(0,H.useMemo)(()=>W(e),[e]),c=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,H.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await G({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{!a||!s||s[1].result!==`qr`||l.payload||l.busy||l.error||d(s[0])},[a,s,d,l.busy,l.error,l.payload]),(0,H.useEffect)(()=>{let t=se(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),V.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,H.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:K(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),K(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=s?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=q(l.payload),g=se(l.payload,e.id),_=g?l.generatedQr:ce(l.payload),y=s?.[1].result===`qr`&&(a||l.busy||l.payload?.type===`qr`||l.payload?.type===`poll`),b=l.payload?.type===`form`?l.payload:null,S=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,U.jsxs)(`div`,{className:o?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,o?`justify-end`:`justify-between`),children:[o?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,U.jsxs)(h,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(s[0]),children:[l.busy?(0,U.jsx)(v,{className:`size-4 animate-spin`}):(0,U.jsx)(R,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(h,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(T,{className:`size-4`}),p]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,y?(0,U.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base px-3 py-3 shadow-surface`,o?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(E,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,o&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(E,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(E,{className:`h-4 w-36 max-w-full`})]}),g?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(A,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(x,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ae,{schema:b.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:c}),(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(b.submitAction,l.formDraft),children:n.saveSetup})]}):null,S?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:S.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function ue(e,t=!1){return e===`drawer`?i(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,M):i(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,M,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function de(e){let t=(0,B.c)(30),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:p,wide:m,headerExtra:g}=e,v=m===void 0?!1:m,x=n===`drawer`,T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,U.jsx)(S,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=T):T=t[0];let E;t[1]!==n||t[2]!==v?(E=ue(n,v),t[1]=n,t[2]=v,t[3]=E):E=t[3];let D;t[4]===c?D=t[5]:(D=c?(0,U.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=D);let k;t[6]===l?k=t[7]:(k=l?(0,U.jsx)(y,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=k);let A;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==x||t[12]!==o?(A=x?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(f,{asChild:!0,children:(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(j,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(f,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:i(O,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(j,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=x,t[12]=o,t[13]=A):A=t[13];let M=x?`px-4 py-4`:`p-6`,N;t[14]===M?N=t[15]:(N=i(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,U.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==p||t[20]!==E||t[21]!==D||t[22]!==k||t[23]!==A||t[24]!==P?(F=(0,U.jsxs)(w,{children:[T,(0,U.jsxs)(C,{className:E,onOpenAutoFocus:J,children:[D,k,A,P,p]})]}),t[19]=p,t[20]=E,t[21]=D,t[22]=k,t[23]=A,t[24]=P,t[25]=F):F=t[25];let I;return t[26]!==a||t[27]!==r||t[28]!==F?(I=(0,U.jsx)(_,{open:r,onOpenChange:a,children:F}),t[26]=a,t[27]=r,t[28]=F,t[29]=I):I=t[29],I}function J(e){return e.preventDefault()}var fe=(0,H.memo)(function(e){let t=(0,B.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(L,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function pe(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(h,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(h,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:m,onClick:g,children:_}),t[13]=m,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function me(e){return e?u(`/api/channels/${encodeURIComponent(e)}/config`):null}async function he(e){return(await c(u(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var ge=[`enabled`];async function _e(){return(await c(u(`/api/config`))).payload?.config?.channels??{}}function ve(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Y(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function ye(e,t){let n=X(e);return n.state===`needs_setup`?t.hubStatusNeedsSetup:n.state===`error`?t.hubStatusError:n.enabled&&n.ready&&e.runtime===`loaded`?t.hubStatusRunning:n.enabled&&n.ready?t.hubStatusEnabled:n.ready?t.hubStatusConfigured:t.hubStatusNotConfigured}function be(e){let t=X(e);return t.state===`needs_setup`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:t.state===`error`?`bg-red-500/10 text-red-700 dark:text-red-300`:t.enabled&&t.ready&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:t.enabled||t.ready?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function xe(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!ge.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!ge.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Se(e,t){let n={...Q(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Q(r[n]),properties:{}}),e===t.length-1){o[n]=Q(r[n]);break}i=r[n],a=o[n]}}return n}function $(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&$(n)&&delete t[e];return Object.keys(t).length===0}function Ce(e,t){let n=Q(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return $(n),n}function we(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Te(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Ee(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function De(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Oe(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Me(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=De(e,Te(t,e),n);i&&r.push(i)}let a=Ee(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function ke(e,t){let n=X(e),r=W(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Ae(e,t){let n=W(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function je(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Me(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function Ne({entry:e}){let t=s(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(u(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ve(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function Pe(e){let t=(0,B.c)(16),{checked:n,disabled:r,onToggle:a,label:o}=e,s;t[0]===a?s=t[1]:(s=e=>{e.stopPropagation(),a()},t[0]=a,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==o||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":o,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=o,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function Fe(e){let t=(0,B.c)(70),{entry:n,config:r,busy:a,ch:o,onOpen:s,onToggle:c}=e,l;t[0]===n?l=t[1]:(l=X(n),t[0]=n,t[1]=l);let u=l,d,f,p,m,g,_,y;if(t[2]!==a||t[3]!==o||t[4]!==r||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u.enabled||t[9]!==u.ready){let e=Oe(n,r,o),l=je(n,o);d=!u.enabled&&u.ready,_=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let h;t[17]===n?h=t[18]:(h=(0,U.jsx)(Ne,{entry:n}),t[17]=n,t[18]=h);let v;t[19]===n.label?v=t[20]:(v=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[19]=n.label,t[20]=v);let b;t[21]===n?b=t[22]:(b=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,be(n)),t[21]=n,t[22]=b);let x;t[23]!==o||t[24]!==n?(x=ye(n,o),t[23]=o,t[24]=n,t[25]=x):x=t[25];let S;t[26]!==b||t[27]!==x?(S=(0,U.jsx)(`span`,{className:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==v?(C=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[v,S]}),t[29]=S,t[30]=v,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==h?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,C]}),t[32]=C,t[33]=h,t[34]=w):w=t[34];let T=u.enabled,E;t[35]!==o.toggleChannel||t[36]!==n.label?(E=o.toggleChannel.replace(`{{channel}}`,n.label),t[35]=o.toggleChannel,t[36]=n.label,t[37]=E):E=t[37];let D;t[38]!==a||t[39]!==c||t[40]!==u.enabled||t[41]!==E?(D=(0,U.jsx)(Pe,{checked:T,disabled:a,label:E,onToggle:c}),t[38]=a,t[39]=c,t[40]=u.enabled,t[41]=E,t[42]=D):D=t[42],t[43]!==w||t[44]!==D?(y=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[w,D]}),t[43]=w,t[44]=D,t[45]=y):y=t[45],f=`button`,p=s,m=`mt-5 min-h-[6.25rem] text-left`,g=u.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(Le)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Ae(n,o)}),l.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:l.map(Ie)}):null]}),t[2]=a,t[3]=o,t[4]=r,t[5]=n,t[6]=s,t[7]=c,t[8]=u.enabled,t[9]=u.ready,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=g,t[15]=_,t[16]=y}else d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15],y=t[16];let b;t[46]!==o.cardAdapterLabel||t[47]!==n.description||t[48]!==u.ready?(b=!u.ready&&n.description?(0,U.jsxs)(`p`,{className:`mt-3 truncate text-xs text-fg-subtle`,title:n.description,children:[o.cardAdapterLabel,`: `,n.description]}):null,t[46]=o.cardAdapterLabel,t[47]=n.description,t[48]=u.ready,t[49]=b):b=t[49];let x;t[50]!==f||t[51]!==p||t[52]!==m||t[53]!==g||t[54]!==b?(x=(0,U.jsxs)(`button`,{type:f,onClick:p,className:m,children:[g,b]}),t[50]=f,t[51]=p,t[52]=m,t[53]=g,t[54]=b,t[55]=x):x=t[55];let S=d?c:s,C;t[56]===a?C=t[57]:(C=a?(0,U.jsx)(v,{className:`size-4 animate-spin`}):null,t[56]=a,t[57]=C);let w;t[58]!==o||t[59]!==n?(w=ke(n,o),t[58]=o,t[59]=n,t[60]=w):w=t[60];let T;t[61]!==S||t[62]!==C||t[63]!==w?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(h,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:S,children:[C,w]})}),t[61]=S,t[62]=C,t[63]=w,t[64]=T):T=t[64];let E;return t[65]!==T||t[66]!==_||t[67]!==y||t[68]!==x?(E=(0,U.jsxs)(`article`,{className:_,children:[y,x,T]}),t[65]=T,t[66]=_,t[67]=y,t[68]=x,t[69]=E):E=t[69],E}function Ie(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Le(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function Re(e){let t=(0,B.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(p,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let m=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===m?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:m}),t[14]=m,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let h;t[16]===r?h=t[17]:(h=e=>(0,U.jsx)(`li`,{children:Me(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=h),a=e.issues.map(h)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let m;t[18]!==i||t[19]!==a?(m=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=m):m=t[20];let h;t[21]!==m||t[22]!==o||t[23]!==s||t[24]!==c?(h=(0,U.jsxs)(`div`,{className:o,children:[s,c,m]}),t[21]=m,t[22]=o,t[23]=s,t[24]=c,t[25]=h):h=t[25];let g;t[26]!==h||t[27]!==l||t[28]!==u?(g=(0,U.jsxs)(`div`,{className:l,children:[u,h]}),t[26]=h,t[27]=l,t[28]=u,t[29]=g):g=t[29];let _;return t[30]!==g||t[31]!==d?(_=(0,U.jsx)(`section`,{className:d,children:g}),t[30]=g,t[31]=d,t[32]=_):_=t[32],_}function ze(){let e=o(e=>e.language),t=a(e),n=s(e=>!!e.token),r=g(),{channelId:c}=m(),f=te(c),p=oe(n,e),h=p.entries,{data:_={},mutate:v}=d(n?`channels-config-map`:null,_e,{revalidateOnFocus:!1}),y=N(e=>e.setPageHeader),b=N(e=>e.clearPageHeader),x=(0,H.useMemo)(()=>h.find(e=>e.id===f),[f,h]),S=x?Y(x):null,{data:C,mutate:w}=d(n&&S?me(S):null,()=>he(S)),[T,E]=(0,H.useState)(null),[O,j]=(0,H.useState)(!1),[M,ee]=(0,H.useState)(null),[I,L]=(0,H.useState)(null),R=T??C??{},z=t.channelsSettings,B=(0,H.useMemo)(()=>x?.configSchema??{type:`object`,properties:{}},[x?.configSchema]),V=(0,H.useMemo)(()=>Ce(B,ge),[B]),G=(0,H.useMemo)(()=>xe(x),[x]),K=(0,H.useMemo)(()=>Se(V,G),[G,V]),q=(0,H.useMemo)(()=>Ce(V,G),[G,V]),se=(0,H.useMemo)(()=>we(K),[K]),ce=(0,H.useMemo)(()=>({defaultBooleanLabel:z.schemaBooleanDefault,unsupportedArrayType:z.schemaUnsupportedArrayType,arrayAddPlaceholder:z.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>z.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[z]),ue=(0,H.useMemo)(()=>n?(0,U.jsx)(fe,{ch:z,refreshing:p.isValidating,saveOk:!1,onRefresh:()=>void p.mutate()}):null,[p,z,n]);(0,H.useLayoutEffect)(()=>(y({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:ue}),()=>b()),[b,ue,t.settingsSections.channels,y]);let J=(0,H.useCallback)(e=>{r(D(e)),E(null),L(null)},[r]),ve=(0,H.useCallback)(()=>{r(k),E(null),L(null)},[r]),Z=(0,H.useCallback)(async()=>{if(!x||!T)return!1;let e=Y(x);j(!0),L(null);try{let t=await l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e]:T}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return await w(T,!1),await v(),await p.mutate(),E(null),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{j(!1)}},[x,p,T,v,w]),Q=(0,H.useCallback)(async e=>{let t=X(e),n=Y(e),r=x?.id===e.id?T:null;if(!t.enabled&&!t.ready&&!r){J(e.id);return}ee(e.id),L(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await p.mutate(),await v(),x?.id===e.id&&(await w(),E(null))}catch(e){L(e instanceof Error?e.message:String(e))}finally{ee(null)}},[x?.id,p,T,v,w,J]),$=x?.ui?.modal,Te=$?.placement!==`replace-config`;return n?(0,U.jsxs)(re,{gap:`gap-4`,children:[p.isLoading?(0,U.jsx)(ie,{sections:2}):p.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:h.map(e=>(0,U.jsx)(Fe,{entry:e,config:_[Y(e)]?.config,busy:M===e.id,ch:z,onOpen:()=>J(e.id),onToggle:()=>void Q(e)},e.id))}),I?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:I}):null,(0,U.jsx)(de,{presentation:`modal`,open:!!x,onOpenChange:e=>{e||ve()},closeAriaLabel:z.close,srTitle:x?.label??z.selectChannel,srDescription:x?.description,wide:!0,footer:x?(0,U.jsx)(pe,{ch:z,dirty:!!T,saving:O,onCancel:ve,onDiscard:()=>E(null),onSave:Z}):null,children:x?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(Ne,{entry:x}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:x.label}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,be(x)),children:ye(x,z)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:W(x)?.[1].result===`qr`?z.scanLoginHint.replace(`{{channel}}`,x.label):x.description}),x.docsPath?(0,U.jsxs)(`a`,{href:x.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[z.docs,(0,U.jsx)(A,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:z.enabledLabel}),(0,U.jsx)(Pe,{checked:X(x).enabled,disabled:M===x.id,label:z.toggleChannel.replace(`{{channel}}`,x.label),onToggle:()=>void Q(x)})]})]})}),(0,U.jsx)(Re,{entry:x,ch:z}),$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(P,{extensionId:x.extensionId,extensionName:x.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:x.id,entry:x,config:R}}):null,$?.placement===`replace-config`?null:(0,U.jsx)(le,{entry:x,locale:e,messages:z,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await w(),await p.mutate(),await v()}},x.id),$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(P,{extensionId:x.extensionId,extensionName:x.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:x.id,entry:x,config:R}}):null,Te&&se?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:z.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:z.basicConfigurationHint})]}),(0,U.jsx)(ae,{schema:K,values:R,onChange:e=>E(e),disabled:O,labels:ce})]}):null,Te&&we(q)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(F,{className:`size-4 text-fg-muted`}),z.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ae,{schema:q,values:R,onChange:e=>E(e),disabled:O,labels:ce})})]}):null,I?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:I}):null]}):null})]}):(0,U.jsxs)(re,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ne,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:z.tokenRequired})]})}export{ze as ChannelsSettingsPanel};
|