@vellumai/web 0.11.3-dev.202608111333.7065e2a → 0.11.3-dev.202608111523.8a0fdc8
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/assets/{Trans-BzokqVLo.js → Trans-Bu2MQd7D.js} +1 -1
- package/dist/assets/{account-page-BnvTRpk2.js → account-page-DKw6uaES.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-Ba2nY91V.js → acp-run-detail-panel-MsAjz6xr.js} +1 -1
- package/dist/assets/{activity-steps-panel-Dn59P0mN.js → activity-steps-panel-B3bCzXoD.js} +1 -1
- package/dist/assets/{ai-page-EwbBjp6b.js → ai-page-WUsGAe9E.js} +1 -1
- package/dist/assets/{app-card-CeHnCA38.js → app-card-ItvfnwYG.js} +1 -1
- package/dist/assets/{background-task-detail-panel-CZkBFGtY.js → background-task-detail-panel-C_T0z4zA.js} +1 -1
- package/dist/assets/{billing-page-B2o6PmsI.js → billing-page-Cc1p_dFD.js} +1 -1
- package/dist/assets/{bookmarks-page-DcL8n8L8.js → bookmarks-page-Dsn_ZbWn.js} +1 -1
- package/dist/assets/{channels-page-route-DVuvHgtW.js → channels-page-route-Du7x3n3a.js} +1 -1
- package/dist/assets/{chat-markdown-message-DSejLc-r.js → chat-markdown-message-SgZ5OjpS.js} +1 -1
- package/dist/assets/{connect-page-9C03hDt1.js → connect-page-BonINpqK.js} +1 -1
- package/dist/assets/contacts-DGS1EL_T.js +1 -0
- package/dist/assets/contacts-page-route-BJoz2DKk.js +1 -0
- package/dist/assets/{conversation-navigation-DVPypW7B.js → conversation-navigation-Cyp-1-4j.js} +1 -1
- package/dist/assets/{credential-entry-page-CkVcSRT1.js → credential-entry-page-CfgIPJ4G.js} +1 -1
- package/dist/assets/{credentials-page-B1DSvE3f.js → credentials-page-Bzs39AUE.js} +1 -1
- package/dist/assets/{daily-reset-time-D3Lr8V_c.js → daily-reset-time-CY--vFkw.js} +1 -1
- package/dist/assets/{debug-page-D6YV_UQA.js → debug-page-BrWpb8AI.js} +1 -1
- package/dist/assets/{document-viewer-page-BGm-wELl.js → document-viewer-page-CwLwx3F6.js} +1 -1
- package/dist/assets/{emails-page-CbNbhtZK.js → emails-page-CB4ia-mI.js} +1 -1
- package/dist/assets/{general-page-BcnE1usF.js → general-page-DDg3Vozg.js} +1 -1
- package/dist/assets/{home-page-route-Ddd1yJbT.js → home-page-route-B9yl50eY.js} +1 -1
- package/dist/assets/{home-tool-permission-card-DOjhxzJl.js → home-tool-permission-card-BIG76RNY.js} +1 -1
- package/dist/assets/{hosting-screen-C_UK9m5v.js → hosting-screen-C-s2Ktyf.js} +1 -1
- package/dist/assets/{i18n-CQ2OzReX.js → i18n-COT45qvD.js} +1 -1
- package/dist/assets/{index-BsEaIM93.js → index-DCNS_Whe.js} +1 -1
- package/dist/assets/{inspect-page-DoxZZRmA.js → inspect-page-UrPurVK5.js} +1 -1
- package/dist/assets/{integrations-page-eoOK9r11.js → integrations-page-S8qz57Po.js} +1 -1
- package/dist/assets/{library-detail-page-0UdVHA79.js → library-detail-page-ClMWRXQG.js} +1 -1
- package/dist/assets/{library-page-CyPzo9Yw.js → library-page-B4z_KD7z.js} +1 -1
- package/dist/assets/{login-page-CbHwLcTe.js → login-page-le6VloqU.js} +1 -1
- package/dist/assets/{logout-page-DyLRrt0F.js → logout-page-C4ClS2c6.js} +1 -1
- package/dist/assets/{logs-layout-BSRj_Baw.js → logs-layout-Cg8cTVDD.js} +1 -1
- package/dist/assets/{memory-page-route-PEtILXuS.js → memory-page-route-NxNVUMPa.js} +1 -1
- package/dist/assets/{message-files-panel-CFaNtWop.js → message-files-panel-U4fISlnd.js} +1 -1
- package/dist/assets/{messages-BVPdCxLa.js → messages-vdNLgZfC.js} +1 -1
- package/dist/assets/{multi-activity-group-DohRjE9D.js → multi-activity-group-BCjJLDKW.js} +1 -1
- package/dist/assets/{not-found-BIqQQC_v.js → not-found-CQtSFoZe.js} +1 -1
- package/dist/assets/{oauth-complete-page-DD4Lw4DJ.js → oauth-complete-page-Dt8pslyI.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-BS3AmQN_.js → oauth-popup-complete-page-CSR0u2QA.js} +1 -1
- package/dist/assets/{open-workspace-file-CtEia9vF.js → open-workspace-file-Bgc9XoWQ.js} +2 -2
- package/dist/assets/{pairing-page-QQFCI2di.js → pairing-page-eN-FcZXv.js} +1 -1
- package/dist/assets/{platform-login-notice-CdvGW9ab.js → platform-login-notice-CoOWZqVQ.js} +1 -1
- package/dist/assets/{platform-loopback-page-BRQzFNAB.js → platform-loopback-page-DcOOnJyE.js} +1 -1
- package/dist/assets/{privacy-page-CECGX8rW.js → privacy-page-nm4PTB6M.js} +1 -1
- package/dist/assets/{provider-callback-page-DdJeMDeY.js → provider-callback-page-DgD9K1Lp.js} +1 -1
- package/dist/assets/{provider-signup-page-DMonFGJX.js → provider-signup-page-D5-ui1FG.js} +1 -1
- package/dist/assets/{routes-DYDrbZMf.js → routes-D3tH8CjB.js} +4 -4
- package/dist/assets/{schedules-page-WIl5Hia6.js → schedules-page-BXqd303T.js} +1 -1
- package/dist/assets/{select-assistant-screen-DxdGO4u5.js → select-assistant-screen-D1jNvhTR.js} +1 -1
- package/dist/assets/{settings-layout-BuQEPwxi.js → settings-layout-BBJnCN0y.js} +1 -1
- package/dist/assets/{sidebar-tree-CU8SMFtS.js → sidebar-tree-C3lWLkJA.js} +1 -1
- package/dist/assets/{signup-page-Dr1QuhlM.js → signup-page-Bjl4EYeW.js} +1 -1
- package/dist/assets/{skill-detail-page-CCOwKm33.js → skill-detail-page-KVgaEI2m.js} +1 -1
- package/dist/assets/{subagent-detail-panel-DDHgbY8m.js → subagent-detail-panel-a8Hfc7SC.js} +1 -1
- package/dist/assets/{system-events-page-DrtjMSeU.js → system-events-page-DfY4YP5J.js} +1 -1
- package/dist/assets/{tool-detail-panel-DZyd_zqV.js → tool-detail-panel-CedK-MKe.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-jue3Gpmn.js → upgrade-cancel-page-2w64D46Y.js} +1 -1
- package/dist/assets/{upgrade-success-page-BrdDRRMn.js → upgrade-success-page-CEVgVkX8.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-BqtnOy-b.js → use-edge-swipe-back-DL0qNQ8W.js} +2 -2
- package/dist/assets/{use-edit-app-RyS-aCj4.js → use-edit-app-BpmekVJD.js} +1 -1
- package/dist/assets/{use-onboarding-login-EO4RhMQy.js → use-onboarding-login-CHUoOzda.js} +1 -1
- package/dist/assets/{use-return-to-short-circuit-Cv77J5ZO.js → use-return-to-short-circuit-BKCYdRgf.js} +1 -1
- package/dist/assets/{use-sticky-profiles-DYdRGSVc.js → use-sticky-profiles-CwhMQz1W.js} +1 -1
- package/dist/assets/use-transcript-message-by-id-Cvhgpuef.js +1 -0
- package/dist/assets/{use-transcript-messages-D20sgHiS.js → use-transcript-messages-CUcPMRda.js} +1 -1
- package/dist/assets/{useTranslation-B7PUkzNb.js → useTranslation-C2KmIWVV.js} +1 -1
- package/dist/assets/{viewer-store-D4NSJJd4.js → viewer-store-2m3eQrth.js} +1 -1
- package/dist/assets/{welcome-screen-Yplw2hBu.js → welcome-screen-CdLIwybr.js} +1 -1
- package/dist/assets/{workspace-page-Cbjvwx5v.js → workspace-page-Bui468ww.js} +1 -1
- package/dist/index.html +19 -19
- package/package.json +1 -1
- package/dist/assets/contacts-DbCgmCMd.js +0 -1
- package/dist/assets/contacts-page-route-CtKFzd1i.js +0 -1
- package/dist/assets/use-transcript-message-by-id-jTrN7IuI.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{a as n,i as r,n as i,r as a}from"./i18n-CQ2OzReX.js";import{a as o,i as s,n as c,o as l,r as u}from"./useTranslation-B7PUkzNb.js";var d=e(t()),f={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},p=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function m(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(f[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(p),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var h=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/<\/?([^\s]+?)[/\s>]/,_=/^\s*$/,v=/^(script|style)$/i,y=`\0`,b=Object.create(null);function x(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(y).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(y).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(y)>-1&&(e.attrs[t]=n.split(y).join(`<`))}e.children.length&&x(e.children)})}function S(e,t){let n=t&&t.components||b,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;h.lastIndex=0;let o;for(;o=h.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(g);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=y,a=o.index+1,h.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=h.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let h=i.charAt(1)!==`/`,g=i.startsWith(`<!--`),y=p+i.length,b=e.charAt(y),x=f[r+1],S;if(b===`<`&&x){let t=e.substring(y,x.index);S=t.split(`<`).length>t.split(`>`).length}let C;if(g){let t=m(i);if(c<0)return a.push(t),a;C=o[c],C.children.push(t);let n=e.slice(y,x?x.index:void 0);return n.length>0&&C.children.push({type:`text`,content:n}),a}if(h){c++,s=m(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&v.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,y),r=n===-1?e.length:n,i=e.slice(y,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&b&&b!==`<`&&s.children.push({type:`text`,content:e.slice(y,x?x.index:void 0)}),c===0&&a.push(s),C=o[c-1],C&&C.children.push(s),o[c]=s}if((!h||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(b!==`<`||S)&&b)){C=c===-1?a:o[c].children;let t=x?x.index:-1,n=e.slice(y,t===-1?void 0:t);_.test(n)&&(n=` `),(t>-1&&c+C.length>=0||n!==` `)&&C.push({type:`text`,content:n})}}),i&&x(a),a}function C(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`"`)+`"`);return t.length?` `+t.join(` `):``}function w(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?C(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(w,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function T(e){return e.reduce(function(e,t){return e+w(``,t)},``)}var E={parse:S,stringify:T},D=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},O=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(t):t},k=e=>Array.isArray(e)&&e.every(d.isValidElement),A=e=>Array.isArray(e)?e:[e],j=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},M=e=>{let t={};if(!e)return t;let n=e=>{A(e).forEach(e=>{s(e)||(D(e)?n(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},N=(e,t,n,r)=>{if(!e)return``;let i=``,a=A(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(s(e)){i+=`${e}`;return}if((0,d.isValidElement)(e)){let{props:o,type:l}=e,u=Object.keys(o).length,d=c.indexOf(l)>-1,f=o.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||o.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(d&&u<=1){let e=s(f)?f:N(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=N(f,t,n,r);i+=`<${a}>${p}</${a}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(u(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},P=(e,t,n,i,o,c,l)=>{if(n===``)return[];let f=o.transKeepBasicHtmlNodesFor||[],p=n&&new RegExp(f.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!p&&!l)return[n];let m=t??{},h=e=>{A(e).forEach(e=>{s(e)||(D(e)?h(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=Object.keys(m),_=E.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||f.indexOf(e)>-1||g.indexOf(e)>-1}),v={...m,...c},y=(e,t,n)=>{let r=O(e),i=x(r,t.children,n);return k(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,d.cloneElement)(e,{key:r},i?void 0:t))):n.push(...d.Children.map([e],e=>{if(e.type===d.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,d.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,d.cloneElement)(e,n,i?null:t)}))},x=(e,n,c)=>{let m=A(e),h=A(n),g={};return h.reduce((e,n,h)=>{let _=n.children?.[0]?.content&&i.services.interpolator.interpolate(n.children[0].content,v,i.language);if(n.type===`tag`){let a=m[parseInt(n.name,10)];!a&&t&&(a=t[n.name]),c.length===1&&!a&&(a=c[0][n.name]),a||={};let S={...n.attrs};l&&Object.keys(S).forEach(e=>{let t=S[e];s(t)&&(S[e]=r(t))});let C=Object.keys(S).length===0?a:j({props:S},a),w=(0,d.isValidElement)(C),T=w&&D(n,!0)&&!n.voidElement,E=p&&u(C)&&C.dummy&&!w,k=u(t)&&Object.hasOwnProperty.call(t,n.name);if(s(C)){let t=i.services.interpolator.interpolate(C,v,i.language);e.push(t)}else if(D(C)||T)b(C,y(C,n,c),e,h);else if(E)b(C,x(m,n.children,c),e,h);else if(Number.isNaN(parseFloat(n.name)))if(k)b(C,y(C,n,c),e,h,n.voidElement);else if(o.transSupportBasicHtmlNodes&&f.indexOf(n.name)>-1)if(n.voidElement)e.push((0,d.createElement)(n.name,{key:`${n.name}-${h}`}));else{let t=g[n.name]||0;g[n.name]=t+1;let r,i=0;for(let e=0;e<m.length;e+=1){let a=m[e];if((0,d.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=x(r?A(O(r)):m,n.children,c);e.push((0,d.createElement)(n.name,{key:`${n.name}-${h}`},a))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(m,n.children,c);e.push(`<${n.name}>${t}</${n.name}>`)}else if(u(C)&&!w){let t=n.children[0]?_:null;t&&e.push(t)}else b(C,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=o.transWrapTextNodes,r=typeof o.unescape==`function`?o.unescape:a().unescape,s=l?r(i.services.interpolator.interpolate(n.content,v,i.language)):i.services.interpolator.interpolate(n.content,v,i.language);t?e.push((0,d.createElement)(t,{key:`${n.name}-${h}`},s)):e.push(s)}return e},[])};return O(x([{dummy:!0,children:e||[]}],_,A(e||[]))[0])},F=(e,t,n)=>{let r=e.key||t,i=(0,d.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,d.createElement)(d.Fragment,null,i)}return(0,d.createElement)(a,{key:r})},I=(e,t)=>e.map((e,n)=>F(e,n,t)),L=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:F(e[r],r,t)})}),n},R=(e,t,n,r)=>e?Array.isArray(e)?I(e,t):u(e)?L(e,t):(l(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,z=e=>!u(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function B({children:e,count:t,parent:r,i18nKey:o,context:c,tOptions:u={},values:f,defaults:p,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||i();if(!b)return l(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...a(),...b.options?.react},C=h||x.ns||b.options?.defaultNS;C=s(C)?[C]:C||[`translation`];let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...u}:u,E=v??w?.shouldUnescape,D=w?.values?{...w.values,...f}:f,O=w?.components?{...w.components,...m}:m,k=N(e,S,b,o),A=p||T?.defaultValue||k||S.transEmptyNodeValue||(typeof o==`function`?n(o):o),{hashTransKey:j}=S,F=o||(j?j(k||A):k||A);f=b.options?.interpolation?.defaultVariables?D&&Object.keys(D).length>0?{...D,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:D;let I=M(e);I&&typeof I.count==`number`&&t===void 0&&(t=I.count);let L=f||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:c||T.context,count:t,...f,...L,defaultValue:A,ns:C},V=F?x(F,B):A;V===F&&A&&(V=A);let H=R(O,V,b,o),U=H||e,W=null;z(H)&&(W=H,U=e);let G=P(U,W,V,b,S,B,E),K=r??S.defaultTransParent;return K?(0,d.createElement)(K,y,G):G}function V({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o={},values:s,defaults:l,components:u,ns:f,i18n:p,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,d.useContext)(c)||{},y=p||_||i(),b=m||y?.t.bind(y);return B({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o,values:s,defaults:l,components:u,ns:f||b?.ns||v||y?.options?.defaultNS,i18n:y,t:m,shouldUnescape:h,...g})}export{V as t};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{a as n,i as r,n as i,r as a}from"./i18n-COT45qvD.js";import{a as o,i as s,n as c,o as l,r as u}from"./useTranslation-C2KmIWVV.js";var d=e(t()),f={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},p=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function m(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(f[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(p),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var h=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/<\/?([^\s]+?)[/\s>]/,_=/^\s*$/,v=/^(script|style)$/i,y=`\0`,b=Object.create(null);function x(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(y).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(y).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(y)>-1&&(e.attrs[t]=n.split(y).join(`<`))}e.children.length&&x(e.children)})}function S(e,t){let n=t&&t.components||b,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;h.lastIndex=0;let o;for(;o=h.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(g);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=y,a=o.index+1,h.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=h.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let h=i.charAt(1)!==`/`,g=i.startsWith(`<!--`),y=p+i.length,b=e.charAt(y),x=f[r+1],S;if(b===`<`&&x){let t=e.substring(y,x.index);S=t.split(`<`).length>t.split(`>`).length}let C;if(g){let t=m(i);if(c<0)return a.push(t),a;C=o[c],C.children.push(t);let n=e.slice(y,x?x.index:void 0);return n.length>0&&C.children.push({type:`text`,content:n}),a}if(h){c++,s=m(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&v.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,y),r=n===-1?e.length:n,i=e.slice(y,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&b&&b!==`<`&&s.children.push({type:`text`,content:e.slice(y,x?x.index:void 0)}),c===0&&a.push(s),C=o[c-1],C&&C.children.push(s),o[c]=s}if((!h||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(b!==`<`||S)&&b)){C=c===-1?a:o[c].children;let t=x?x.index:-1,n=e.slice(y,t===-1?void 0:t);_.test(n)&&(n=` `),(t>-1&&c+C.length>=0||n!==` `)&&C.push({type:`text`,content:n})}}),i&&x(a),a}function C(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`"`)+`"`);return t.length?` `+t.join(` `):``}function w(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?C(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(w,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function T(e){return e.reduce(function(e,t){return e+w(``,t)},``)}var E={parse:S,stringify:T},D=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},O=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(t):t},k=e=>Array.isArray(e)&&e.every(d.isValidElement),A=e=>Array.isArray(e)?e:[e],j=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},M=e=>{let t={};if(!e)return t;let n=e=>{A(e).forEach(e=>{s(e)||(D(e)?n(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},N=(e,t,n,r)=>{if(!e)return``;let i=``,a=A(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(s(e)){i+=`${e}`;return}if((0,d.isValidElement)(e)){let{props:o,type:l}=e,u=Object.keys(o).length,d=c.indexOf(l)>-1,f=o.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||o.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(d&&u<=1){let e=s(f)?f:N(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=N(f,t,n,r);i+=`<${a}>${p}</${a}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(u(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},P=(e,t,n,i,o,c,l)=>{if(n===``)return[];let f=o.transKeepBasicHtmlNodesFor||[],p=n&&new RegExp(f.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!p&&!l)return[n];let m=t??{},h=e=>{A(e).forEach(e=>{s(e)||(D(e)?h(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=Object.keys(m),_=E.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||f.indexOf(e)>-1||g.indexOf(e)>-1}),v={...m,...c},y=(e,t,n)=>{let r=O(e),i=x(r,t.children,n);return k(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,d.cloneElement)(e,{key:r},i?void 0:t))):n.push(...d.Children.map([e],e=>{if(e.type===d.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,d.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,d.cloneElement)(e,n,i?null:t)}))},x=(e,n,c)=>{let m=A(e),h=A(n),g={};return h.reduce((e,n,h)=>{let _=n.children?.[0]?.content&&i.services.interpolator.interpolate(n.children[0].content,v,i.language);if(n.type===`tag`){let a=m[parseInt(n.name,10)];!a&&t&&(a=t[n.name]),c.length===1&&!a&&(a=c[0][n.name]),a||={};let S={...n.attrs};l&&Object.keys(S).forEach(e=>{let t=S[e];s(t)&&(S[e]=r(t))});let C=Object.keys(S).length===0?a:j({props:S},a),w=(0,d.isValidElement)(C),T=w&&D(n,!0)&&!n.voidElement,E=p&&u(C)&&C.dummy&&!w,k=u(t)&&Object.hasOwnProperty.call(t,n.name);if(s(C)){let t=i.services.interpolator.interpolate(C,v,i.language);e.push(t)}else if(D(C)||T)b(C,y(C,n,c),e,h);else if(E)b(C,x(m,n.children,c),e,h);else if(Number.isNaN(parseFloat(n.name)))if(k)b(C,y(C,n,c),e,h,n.voidElement);else if(o.transSupportBasicHtmlNodes&&f.indexOf(n.name)>-1)if(n.voidElement)e.push((0,d.createElement)(n.name,{key:`${n.name}-${h}`}));else{let t=g[n.name]||0;g[n.name]=t+1;let r,i=0;for(let e=0;e<m.length;e+=1){let a=m[e];if((0,d.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=x(r?A(O(r)):m,n.children,c);e.push((0,d.createElement)(n.name,{key:`${n.name}-${h}`},a))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(m,n.children,c);e.push(`<${n.name}>${t}</${n.name}>`)}else if(u(C)&&!w){let t=n.children[0]?_:null;t&&e.push(t)}else b(C,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=o.transWrapTextNodes,r=typeof o.unescape==`function`?o.unescape:a().unescape,s=l?r(i.services.interpolator.interpolate(n.content,v,i.language)):i.services.interpolator.interpolate(n.content,v,i.language);t?e.push((0,d.createElement)(t,{key:`${n.name}-${h}`},s)):e.push(s)}return e},[])};return O(x([{dummy:!0,children:e||[]}],_,A(e||[]))[0])},F=(e,t,n)=>{let r=e.key||t,i=(0,d.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,d.createElement)(d.Fragment,null,i)}return(0,d.createElement)(a,{key:r})},I=(e,t)=>e.map((e,n)=>F(e,n,t)),L=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:F(e[r],r,t)})}),n},R=(e,t,n,r)=>e?Array.isArray(e)?I(e,t):u(e)?L(e,t):(l(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,z=e=>!u(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function B({children:e,count:t,parent:r,i18nKey:o,context:c,tOptions:u={},values:f,defaults:p,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||i();if(!b)return l(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...a(),...b.options?.react},C=h||x.ns||b.options?.defaultNS;C=s(C)?[C]:C||[`translation`];let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...u}:u,E=v??w?.shouldUnescape,D=w?.values?{...w.values,...f}:f,O=w?.components?{...w.components,...m}:m,k=N(e,S,b,o),A=p||T?.defaultValue||k||S.transEmptyNodeValue||(typeof o==`function`?n(o):o),{hashTransKey:j}=S,F=o||(j?j(k||A):k||A);f=b.options?.interpolation?.defaultVariables?D&&Object.keys(D).length>0?{...D,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:D;let I=M(e);I&&typeof I.count==`number`&&t===void 0&&(t=I.count);let L=f||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:c||T.context,count:t,...f,...L,defaultValue:A,ns:C},V=F?x(F,B):A;V===F&&A&&(V=A);let H=R(O,V,b,o),U=H||e,W=null;z(H)&&(W=H,U=e);let G=P(U,W,V,b,S,B,E),K=r??S.defaultTransParent;return K?(0,d.createElement)(K,y,G):G}function V({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o={},values:s,defaults:l,components:u,ns:f,i18n:p,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,d.useContext)(c)||{},y=p||_||i(),b=m||y?.t.bind(y);return B({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o,values:s,defaults:l,components:u,ns:f||b?.ns||v||y?.options?.defaultNS,i18n:y,t:m,shouldUnescape:h,...g})}export{V as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./chunk-5KNZJZUH-BUqIilZr.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import"./i18n-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./chunk-5KNZJZUH-BUqIilZr.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import"./i18n-COT45qvD.js";import{t as i}from"./useTranslation-C2KmIWVV.js";import{a,n as o,s}from"./auth-store-CnWKQqaE.js";import{D as c}from"./platform-detection-BIfuAgU8.js";import{d as l}from"./routes-C293MsBG.js";import{t as u}from"./hard-navigate-oyyORA6r.js";import{n as d,t as f}from"./login-flow-DW7DcWVy.js";import{r as p,t as m}from"./account-shell-G1qEVe2D.js";var h=e(t(),1),g=r();function _(){let{t:e}=i(`account`),t=a(),r=s(),_=o.use.user(),v=o.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await c(d,f)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return r?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):t?(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:_?.username?e(`accountPage.signedInTitleNamed`,{name:_.username}):e(`accountPage.signedInTitle`),subtitle:e(`accountPage.signedInSubtitle`)}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,g.jsx)(n,{to:l.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:e(`accountPage.goToAssistant`)}),(0,g.jsx)(`button`,{type:`button`,onClick:async()=>{await v(),u(l.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:e(`accountPage.signOut`)})]})]}):(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:e(`accountPage.welcomeTitle`),subtitle:e(`accountPage.welcomeSubtitle`)}),y&&(0,g.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:y}),(0,g.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:x,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:e(`accountPage.signIn`)})})]})}export{_ as AccountPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DVxOKq30.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-DSjqKLvM.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-BeUa5Fd-.js";import"./src-DFSK6m8o.js";import{t as o}from"./createLucideIcon-C_IfoPaZ.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-DrwJ-EhZ.js";import{t as p}from"./arrow-left-xVF3p2Qp.js";import{t as m}from"./brain-BkpxPjmn.js";import{t as h}from"./chevron-down-B_6pb9kS.js";import{t as g}from"./chevron-right-Dx_5VMo6.js";import{t as _}from"./circle-check-BG2g8udA.js";import{t as v}from"./circle-minus-CHiR1az9.js";import{w as y}from"./menu-Gu_6PRrL.js";import{t as b}from"./code-CvwdlCR7.js";import{t as x}from"./file-text-Ha6XXdS_.js";import{t as S}from"./globe-BQ4oUIDW.js";import{t as C}from"./chat-markdown-message-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DVxOKq30.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-DSjqKLvM.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-BeUa5Fd-.js";import"./src-DFSK6m8o.js";import{t as o}from"./createLucideIcon-C_IfoPaZ.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-DrwJ-EhZ.js";import{t as p}from"./arrow-left-xVF3p2Qp.js";import{t as m}from"./brain-BkpxPjmn.js";import{t as h}from"./chevron-down-B_6pb9kS.js";import{t as g}from"./chevron-right-Dx_5VMo6.js";import{t as _}from"./circle-check-BG2g8udA.js";import{t as v}from"./circle-minus-CHiR1az9.js";import{w as y}from"./menu-Gu_6PRrL.js";import{t as b}from"./code-CvwdlCR7.js";import{t as x}from"./file-text-Ha6XXdS_.js";import{t as S}from"./globe-BQ4oUIDW.js";import{t as C}from"./chat-markdown-message-SgZ5OjpS.js";import{t as ee}from"./repeat-PaQ1rsKC.js";import{t as te}from"./search-DbyaO8rG.js";import{t as ne}from"./send-CpbQGYQ9.js";import{t as w}from"./square-DD_y88hI.js";import{t as T}from"./terminal-BDxxes3v.js";import{t as re}from"./trash-2-DL_3_16e.js";import{t as ie}from"./triangle-alert-C5SOfs-q.js";import{t as ae}from"./x-BY-Np61T.js";import{t as oe}from"./tag-D0oiSRye.js";import{a as E,i as se,n as D,r as O}from"./acp-run-store-DuZBobsh.js";import{t as k}from"./three-dot-indicator-DA4TVlyR.js";import{t as ce}from"./status-badge-pill-DTFsjfA_.js";var le=o(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),A=e(n(),1),j=``;function M(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function ue(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function N(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(D.length):t}function P(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function F(e,t){if(t.updateType===`agent_message_chunk`&&ue(t)){P(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:N(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??j,r=N(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(P(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??j,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==j&&r&&r.kind===`agent`&&r.messageId===j&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}P(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??j,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}P(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;P(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:M(t.toolStatus,`running`),content:t.content,locations:I(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=I(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:M(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=de(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(P(e),e.push(i)):e[r]=i;return}}}function I(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function de(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function fe(e){let t=[];for(let n of e)F(t,n);return t}function pe(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function me(){let e=null,t=[];function n(n){return t=fe(n),e=n,t}function r(r){let i=pe(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)F(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function L(e){let t=(0,A.useRef)(null);return t.current??=me(),t.current.project(e)}function R(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=z(e);t&&r.push(t)}return r}function z(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:he(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=ge(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function he(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function ge(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function B(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function V(e){return R(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
|
|
2
2
|
`)}function H(e){if(e!=null){if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}}function U(e,t){let n=new Map;for(let t of e)t.type===`diff`&&n.set(t.path,{path:t.path,newText:t.newText,...t.oldText===void 0?{}:{oldText:t.oldText}});for(let e of t??[])n.has(e.path)||n.set(e.path,{path:e.path});return Array.from(n.values())}var W=i();function _e({content:e,isComplete:t,assistantId:n}){return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-agent-message`,className:`flex w-full flex-col items-start text-chat text-[var(--content-default)]`,children:[(0,W.jsx)(C,{content:e,assistantId:n}),!t&&(0,W.jsx)(k,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function ve({entries:e}){return e.length===0?null:(0,W.jsxs)(`div`,{"data-testid":`acp-chat-plan-block`,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-[var(--content-tertiary)]`,children:[(0,W.jsx)(c,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`text-inherit`,children:`Plan`})]}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>(0,W.jsxs)(`li`,{"data-testid":`acp-chat-plan-entry`,"data-checked":e.checked,className:`flex items-start gap-2`,children:[e.checked?(0,W.jsx)(_,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,W.jsx)(y,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`}),(0,W.jsx)(`span`,{className:e.checked?`text-body-small-default text-[var(--content-tertiary)] line-through`:`text-body-small-default text-[var(--content-default)]`,children:e.label})]},t))})]})}function ye(e){switch(e){case`max_tokens`:case`max_turn_requests`:return`Stopped: limit reached`;case`refusal`:return`Refused`;case`cancelled`:return`Cancelled`;default:return`Completed`}}function be(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({completedAt:e}){return e===void 0?null:(0,W.jsxs)(`span`,{"data-testid":`acp-chat-terminal-time`,children:[`at `,be(e)]})}function xe({status:e,stopReason:t,error:n,completedAt:r}){if(E(e))return null;if(e===`failed`)return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`failed`,className:`flex items-start gap-2 rounded-lg bg-[var(--system-negative-weak)] px-3 py-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,W.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-terminal-failed-icon`,className:`flex h-[12px] w-4 shrink-0 items-center justify-center`,children:(0,W.jsx)(ie,{className:`h-4 w-4`})}),(0,W.jsx)(`span`,{children:n??`Run failed`})]});if(e===`cancelled`)return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`cancelled`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,W.jsx)(v,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:`Cancelled`}),(0,W.jsx)(G,{completedAt:r})]});let i=ye(t);return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`completed`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,W.jsx)(_,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(G,{completedAt:r})]})}function Se({showDot:e,isLast:t,children:n}){return(0,W.jsxs)(`div`,{className:`relative flex items-start gap-2${t?``:` pb-4`}`,children:[!t&&(0,W.jsx)(`div`,{"aria-hidden":!0,className:`absolute bottom-0 left-[6.5px] w-px bg-[var(--border-element)] ${e?`top-[16px]`:`top-0`}`}),e?(0,W.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-timeline-dot`,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,W.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}):(0,W.jsx)(`span`,{"aria-hidden":!0,className:`h-[14px] w-[14px] shrink-0`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Ce({content:e,isComplete:t,assistantId:n}){let[r,i]=(0,A.useState)(null),a=r??!t,o=e.trim().length>0,s=t?`Thought process`:`Thinking`,c=t?(0,W.jsx)(m,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(k,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return o?(0,W.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>i(!a),"data-testid":`acp-chat-thinking-toggle`,className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,children:[a?(0,W.jsx)(h,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),c,(0,W.jsx)(`span`,{children:s})]}),a&&(0,W.jsx)(`div`,{"data-testid":`acp-chat-thinking-body`,className:`mt-1.5 border-l-2 border-[var(--border-base)] pl-3 text-body-small-default text-[var(--content-tertiary)]`,children:(0,W.jsx)(C,{content:e,assistantId:n})})]}):(0,W.jsx)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:[c,(0,W.jsx)(`span`,{children:s})]})})}var we={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Te={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},Ee={read:`Read file`,edit:`Edit file`,delete:`Delete file`,move:`Move file`,search:`Search`,execute:`Run command`,think:`Thinking`,fetch:`Fetch`,switch_mode:`Switch mode`},De=`Tool call`,Oe={read:x,edit:le,delete:re,move:s,search:te,execute:T,think:m,fetch:S,switch_mode:ee},ke=new Set([`read`,`edit`,`delete`,`move`]);function Ae({toolKind:e}){return(0,W.jsx)(e&&Oe[e]||b,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`})}function K({label:e,value:t,testId:n}){return(0,W.jsxs)(`div`,{"data-testid":n,children:[(0,W.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-tertiary)]`,children:e}),(0,W.jsx)(`pre`,{className:`max-h-60 overflow-auto rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] p-2.5 font-mono text-body-small-default text-[var(--content-secondary)]`,children:t})]})}function je({block:e,isTerminal:t=!1,onOpenDiff:n,onOpenOutput:r}){let[i,o]=(0,A.useState)(!1),s=(0,A.useMemo)(()=>R(e.content),[e.content]),c=(0,A.useMemo)(()=>V(e.content),[e.content]),l=(0,A.useMemo)(()=>c.split(`
|
|
3
3
|
`).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[c]),u=(0,A.useMemo)(()=>U(s,e.locations),[s,e.locations]),d=t&&e.status===`running`?`ended`:e.status,f=d===`running`,p=e.toolKind&&Ee[e.toolKind]||De,m=B(e.rawInput)??e.title,_=m&&m!==p&&(!ke.has(e.toolKind??``)||u.length===0)?m:null,v=H(e.rawInput),y=H(e.rawOutput),b=v!==void 0||y!==void 0;return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-tool-card`,"data-status":e.status,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ae,{toolKind:e.toolKind}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:p}),(0,W.jsx)(oe,{tone:we[d],"data-testid":`acp-chat-tool-status`,children:Te[d]}),f&&(0,W.jsx)(k,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),_&&(0,W.jsx)(`div`,{"data-testid":`acp-chat-tool-detail`,className:`mt-1.5 font-mono text-body-small-default whitespace-pre-wrap break-words text-[var(--content-secondary)]`,children:_}),u.length>0&&(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:u.map(t=>{let r=t.oldText!==void 0||t.newText!==void 0,i=`flex max-w-full items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-1 text-body-small-default text-[var(--content-secondary)]`;return r?(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>n(e.toolCallId,t),title:t.path,className:`${i} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(x,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path):(0,W.jsxs)(`span`,{"data-testid":`acp-chat-tool-file-ref`,title:t.path,className:i,children:[(0,W.jsx)(x,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path)})}),c.length>0&&(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>r?.(e.toolCallId),className:`mt-2 flex w-full items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:l}),(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`})]}),b&&(0,W.jsxs)(`div`,{className:`mt-2`,"data-testid":`acp-chat-tool-raw`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-raw-toggle`,"aria-expanded":i,onClick:()=>o(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[i?(0,W.jsx)(h,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:i?`Hide raw input/output`:`Show raw input/output`})]}),i&&(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[v!==void 0&&(0,W.jsx)(K,{label:`Raw input`,value:v,testId:`acp-chat-tool-raw-input`}),y!==void 0&&(0,W.jsx)(K,{label:`Raw output`,value:y,testId:`acp-chat-tool-raw-output`})]})]})]})}function Me({content:e}){return(0,W.jsx)(`div`,{"data-testid":`acp-chat-user-turn`,className:`flex w-full justify-end`,children:(0,W.jsx)(`div`,{className:`max-w-[80%] rounded-lg bg-[var(--surface-lift)] px-4 py-3 whitespace-pre-wrap text-chat text-[var(--content-default)]`,children:e})})}function Ne(e,t){let n=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e);return e>0&&e<.01?`<${n(.01)}`:n(e)}var q=new Intl.NumberFormat(`en-US`);function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`flex items-baseline gap-1`,"data-usage-stat":e.toLowerCase(),children:[(0,W.jsx)(a,{variant:`label-small-default`,className:`text-[var(--content-tertiary)]`,children:e}),(0,W.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-secondary)] tabular-nums`,children:t})]})}function Pe({entry:e}){let{inputTokens:t,outputTokens:n,costAmount:r,costCurrency:i}=e;if(t===void 0&&n===void 0)return null;let a=t??0,o=n??0,s=r!=null&&i!=null;return(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`acp-usage-meter`,children:[(0,W.jsx)(J,{label:`Input`,value:q.format(a)}),(0,W.jsx)(J,{label:`Output`,value:q.format(o)}),s&&(0,W.jsx)(J,{label:`Cost`,value:Ne(r,i)})]})}function Fe({content:e,assistantId:t}){return(0,W.jsx)(`div`,{"data-testid":`acp-chat-command-output`,className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3 [&_pre]:!max-h-none`,children:(0,W.jsx)(C,{content:V(e),hardLineBreaks:!0,assistantId:t})})}var Y=2e3;function X(e){if(e===``)return[];let t=e.split(`
|
|
4
4
|
`);return e.endsWith(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-DSjqKLvM.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-BeUa5Fd-.js";import"./src-DFSK6m8o.js";import{h as a,n as o,t as s}from"./message-content-BrFs5fmC.js";import{a as c,d as l,f as u,i as d,n as f,r as p,u as m,x as h}from"./multi-activity-group-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-DSjqKLvM.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-BeUa5Fd-.js";import"./src-DFSK6m8o.js";import{h as a,n as o,t as s}from"./message-content-BrFs5fmC.js";import{a as c,d as l,f as u,i as d,n as f,r as p,u as m,x as h}from"./multi-activity-group-BCjJLDKW.js";import{t as g}from"./chevron-left-B7yHWg2l.js";import{t as _}from"./chat-markdown-message-SgZ5OjpS.js";import{t as v}from"./workflow-store-BKYjjnxf.js";import{t as y}from"./background-task-store-Cwy1jq22.js";import{r as b}from"./acp-run-store-DuZBobsh.js";import{a as x,g as S,i as C,n as w,r as T,s as E,w as D,x as O}from"./site-favicon-Ck0mgaU0.js";import{t as k}from"./detail-shell-B3moyzaC.js";import{t as A}from"./use-transcript-message-by-id-Cvhgpuef.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-CedK-MKe.js";var N=e(t(),1);function P(e,t,n){let r=l(t,n.workflow),i=e=>{let t=h(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=m(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=u(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function F(e,t){let n=A(e),r=v.use.byId(),i=v.use.byToolUseId(),a=v.use.notFoundRunIds(),c=v.use.hydrationFailedRunIds(),l=b.use.byId(),u=b.use.byToolUseId(),d=y.use.byId();return(0,N.useMemo)(()=>{if(!n||t==null)return null;let e=o(n.contentBlocks??[],{splitInlineThinking:n.role!==`user`})[t];if(!e||e.type!==`activity`)return null;let{cardItems:f,toolCalls:p}=s(e.items);return P(f,p,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:a,hydrationFailedRunIds:c},acpById:l,acpByToolUseId:u,backgroundTaskById:d})},[n,t,r,i,a,c,l,u,d])}var I=r(),L=60;function R({payload:e,onClose:t,assistantId:r}){let[a,o]=(0,N.useState)(null),s=F(e.messageId,e.groupIndex),l=s?.items??e.items,u=s?.toolCalls??e.toolCalls,m=c(l),h=p(m.steps),_=d(m.state,m.steps),v=_===`loading`,y=f(_,m.totalDurationLabel??``,h.failed),b=v&&m.currentStepTitle||y,x=new Map(u.map(e=>[e.id,e])),C=a?a.kind===`thinking`?`Thinking`:a.activity||a.title:``;return(0,I.jsx)(k,{titleNode:a?(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 py-0.5`,children:[(0,I.jsx)(n,{variant:`ghost`,iconOnly:(0,I.jsx)(g,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>o(null),className:`-ml-2.5 shrink-0`}),(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:C})]}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:v?(0,I.jsx)(S,{children:b}):b}),m.stepCount?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}),(0,I.jsx)(i,{variant:`title-medium`,className:`shrink-0 whitespace-nowrap leading-snug text-[var(--content-secondary)]`,children:m.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:a?(0,I.jsx)(B,{detail:a,assistantId:r}):(0,I.jsx)(E,{steps:m.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:a,onOpenDetail:o,lookupToolCall:e=>x.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:o}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:o,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(C,{iconName:`brain`,label:a(D(e.text),L),ariaLabel:`View thinking`,active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:`Thinking`,activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,I.jsx)(T,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(w,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(x,{step:e});let s=r(e.toolCallId);return(0,I.jsx)(C,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{s&&n(O(s))}})}function B({detail:e,assistantId:t}){let n=M(e.kind===`thinking`?e.messageId:void 0,e.thinkingGroupIndex,e.thinkingItemIndex);return(0,I.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,I.jsx)(_,{content:n??e.thinkingText??``,hardLineBreaks:!0,assistantId:t}):(0,I.jsx)(j,{detail:e,assistantId:t})})}export{R as ActivityStepsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{r as i,t as a}from"./capture-error-DVxOKq30.js";import{t as o}from"./react-BFJW0bSv.js";import{n as s,t as c}from"./button-DSjqKLvM.js";import{d as l,h as u}from"./chunk-5KNZJZUH-BUqIilZr.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./typography-BeUa5Fd-.js";import{J as g,W as _,i as v}from"./src-DFSK6m8o.js";import{t as y}from"./check-CNBoUiyR.js";import{t as b}from"./circle-alert-DEIiXMF-.js";import{t as x}from"./circle-check-BG2g8udA.js";import{t as S}from"./menu-Gu_6PRrL.js";import{t as C}from"./clock-DSx5dIWv.js";import{t as w}from"./ellipsis-vertical-CAYfw0qB.js";import{t as T}from"./external-link-D65yhWAV.js";import{t as E}from"./info-Bjcv3rf9.js";import{t as D}from"./list-COQcQTOh.js";import{t as O}from"./loader-circle-oY5laABh.js";import{t as k}from"./mail-B0iH8Wii.js";import{t as A}from"./checkbox-DyHMOWN6.js";import{t as j}from"./plus-CwK68LCA.js";import{t as M}from"./search-DbyaO8rG.js";import{t as N}from"./trash-2-DL_3_16e.js";import{t as P}from"./triangle-alert-C5SOfs-q.js";import{t as F}from"./notice-C9v3KOP3.js";import{t as I}from"./tag-D0oiSRye.js";import{t as L}from"./modal-Bt1DPFgW.js";import{t as R}from"./input-BG94bPcH.js";import{t as z}from"./toggle-C-v4x7_A.js";import{n as B}from"./toast-BrKo5b4d.js";import{t as V}from"./confirm-dialog-DNaRfy4W.js";import{t as H}from"./select-B86W_Hs8.js";import{t as U}from"./skeleton-CzdJByjE.js";import{C as W,E as G,F as K,L as ee,M as q,S as te,_ as ne,a as J,b as Y,c as re,f as X,g as ie,h as ae,i as oe,j as se,l as Z,m as ce,n as le,o as ue,p as de,r as fe,s as pe,t as me,v as he,w as ge,x as _e,y as ve,z as ye}from"./profile-pickers-DkKPLcgs.js";import{B as be,C as xe,F as Se,G as Ce,H as we,I as Te,J as Ee,K as De,L as Oe,M as ke,N as Ae,P as je,R as Me,S as Ne,T as Pe,U as Fe,V as Ie,W as Le,X as Re,Y as ze,_ as Be,a as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,j as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,q as et,r as tt,s as nt,t as rt,u as it,v as at,w as ot,x as st,y as ct,z as lt}from"./use-sticky-profiles-DYdRGSVc.js";import{t as ut}from"./assistant-identity-store-kRH_OiG9.js";import{n as dt,o as ft,r as pt}from"./utils-IInmQ0Wp.js";import{i as mt,r as ht}from"./api-errors-Cbz9vgty.js";import{Jt as gt,Yt as _t,dt as vt,fr as yt,j as bt,kn as xt,mt as St}from"./sdk.gen-Br55zhZN.js";import{p as Ct}from"./platform-detection-BIfuAgU8.js";import{d as wt}from"./routes-C293MsBG.js";import{i as Tt}from"./use-platform-gate-CzjAnErv.js";import{r as Et}from"./use-is-org-ready-jiX84kb4.js";import{Ct as Dt,Gt as Ot,J as kt,K as At,St as jt,Tt as Mt,Xt as Nt,Y as Pt,_ as Ft,d as It,f as Lt,g as Rt,h as zt,m as Bt,p as Vt,q as Ht,sn as Ut,u as Wt}from"./react-query.gen-vkBavCkI.js";import{c as Gt,d as Kt,f as qt,ft as Jt,g as Yt,h as Xt,l as Zt,m as Qt,o as $t,p as en,s as tn,u as nn,v as rn,y as an}from"./react-query.gen-DCPOsBjb.js";import{n as on}from"./use-is-mobile-DznTMSWZ.js";import{t as sn}from"./platform-login-notice-CdvGW9ab.js";import{t as cn}from"./android-consumption-only-DGpN9EGi.js";import{a as ln,c as un,i as dn,n as fn,o as pn}from"./voice-list-BfdPgz53.js";import{n as mn}from"./use-voice-sample-preview-RRMzeYRk.js";import{t as hn}from"./use-active-assistant-id-B4vGntPc.js";import{t as gn}from"./detail-shell-B3moyzaC.js";import{t as _n}from"./detail-card-DQWk035Y.js";import{n as vn,t as yn}from"./detail-drawer-Ce5X0KA6.js";import{a as bn}from"./schedules-CVj4ZaDZ.js";import{t as xn}from"./use-platform-assistant-id-BrviSqKQ.js";import{t as Sn}from"./environment-store-UqJJCyAL.js";import{t as Cn}from"./stt-language-picker-modal-CuKZbgVo.js";var Q=e(o(),1),$=m();function wn({mode:e,onChange:t}){return(0,$.jsx)(`div`,{className:`max-w-[280px]`,children:(0,$.jsx)(_,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Tn({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,$.jsxs)(_n,{id:e,title:t,subtitle:n,accessory:(0,$.jsx)(wn,{mode:r,onChange:i}),children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:a})]})}function En({id:e,title:t,subtitle:n,children:r}){return(0,$.jsxs)(_n,{id:e,title:t,subtitle:n,children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:r})]})}function Dn(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,$.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,$.jsx)(T,{className:`h-3.5 w-3.5`})]})]})]})}function On({status:e,message:t,isLoading:n}){return n?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,$.jsx)(y,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,$.jsx)(C,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,$.jsx)(b,{className:`h-3 w-3`}),`Verification failed`]}):(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function kn({onClick:e,disabled:t}){return(0,$.jsx)(c,{onClick:e,disabled:t,children:`Save`})}function An({onClick:e,filled:t=!1}){return(0,$.jsx)(c,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function jn({guide:e}){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{children:e.description}),(0,$.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,$.jsx)(T,{className:`h-3 w-3`})]})]})]})}function Mn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,$.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function Nn({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=d(),i=l(),o=Ct(),[s,m]=u(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_||!t||h||(g(t),v(!0))},[t,_,h]);let P=f({...Jt(),enabled:!0}),I=P.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,H=!I&&P.isError&&!P.isFetching,U=f({...Gt({path:{assistant_id:e}}),enabled:!z}),W=f({...en({path:{assistant_id:e}}),enabled:!z}),G=U.data?.results?.[0],K=W.data?.results?.[0],ee=G?`${G.subdomain}.${n}`:null,q=f({...Xt({path:{assistant_id:e,id:K?.id??``}}),enabled:!!K?.id,refetchOnWindowFocus:!1}),te=f({...nn({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Q.useEffect)(()=>{s.get(`release`)!==`1`||!G||K||(A(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[K,G,s,m]);let ne=p($t()),J=p(tn()),Y=p(Kt()),re=p(qt()),X=(0,Q.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:Zt({path:t})}),r.invalidateQueries({queryKey:Qt({path:t})}),K?.id&&r.invalidateQueries({queryKey:Yt({path:{...t,id:K.id}})}),r.invalidateQueries({queryKey:an()})},[K?.id,e,r]),ie=(0,Q.useCallback)(async()=>{let t=h.trim().toLowerCase();if(!t){b(`Enter a subdomain.`);return}E(!1);try{await ne.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),g(``),b(null),X(),B.success(`Domain ${t}.${n} registered.`)}catch(e){b(mt(e,void 0,`Failed to register domain.`))}},[e,n,X,ne,h]),ae=(0,Q.useCallback)(async()=>{let t=x.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await Y.mutateAsync({path:{assistant_id:e},body:{username:t}}),S(``),w(null),X(),B.success(`Email address created.`)}catch(e){w(mt(e,void 0,`Failed to create email address.`))}},[e,X,Y,x]),oe=(0,Q.useCallback)(async()=>{if(K?.id){M(!1);try{await re.mutateAsync({path:{assistant_id:e,id:K.id}}),X(),B.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),B.error(`Failed to remove email address.`)}}},[K?.id,e,re,X]),se=(0,Q.useCallback)(async()=>{if(!G?.id)return;if(K){B.error(`Remove the email address first.`);return}A(!1);let t=G.subdomain;try{await J.mutateAsync({path:{assistant_id:e,id:G.id}}),g(t),X(),B.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),B.error(`Failed to release domain.`)}},[K,e,J,G?.id,G?.subdomain,X]);if(P.isLoading)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,$.jsx)(F,{tone:`info`,icon:(0,$.jsx)(k,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:o?void 0:(0,$.jsx)(c,{size:`compact`,onClick:()=>i(wt.plans),children:`Upgrade`}),children:o?cn:(0,$.jsx)($.Fragment,{children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`})});let Z=H?(0,$.jsx)(F,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,$.jsx)(c,{size:`compact`,variant:`outlined`,onClick:()=>P.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return G?K?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:K.address}),(0,$.jsx)(On,{status:te.data?.status,message:te.data?.message,isLoading:te.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(N,{}),onClick:()=>M(!0),disabled:re.isPending,"aria-label":`Remove email address`})]}),(0,$.jsx)(V,{open:j,title:`Remove Email Address`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to remove`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:K.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:oe,onCancel:()=>M(!1)})]}),q.data?.usage&&(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[q.data.usage.sent_today,` /`,` `,q.data.usage.daily_limit,` sent today ·`,` `,q.data.usage.received_today,` received`]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[G.subdomain,`.`,n]}),(0,$.jsx)(On,{status:te.data?.status,message:te.data?.message,isLoading:te.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(N,{}),onClick:()=>A(!0),disabled:J.isPending,"aria-label":`Release domain`})]}),(0,$.jsx)(V,{open:D,title:`Release Domain`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to release`,` `,(0,$.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[G.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:se,onCancel:()=>A(!1)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,$.jsx)(`input`,{value:x,onChange:e=>{S(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,$.jsx)(c,{onClick:ae,disabled:Y.isPending||!x.trim(),children:Y.isPending?`Creating…`:`Create`})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[Z,(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,$.jsx)(Mn,{subdomain:h,onSubdomainChange:e=>{g(e),y&&b(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:y}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,$.jsx)(c,{onClick:()=>E(!0),disabled:ne.isPending||!h.trim(),children:ne.isPending?`Registering…`:`Register`}),(0,$.jsx)(V,{open:T,title:`Set Subdomain`,message:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:h.trim().toLowerCase()||`subdomain`}),` `,`will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ie,onCancel:()=>E(!1)})]})}function Pn(){let e=hn(),r=Et(),{data:o}=f({...rn(),enabled:r}),s=o?.results?.[0]?.handle,c=Sn.use.emailRootDomain(),l=Tt(),[u,d]=(0,Q.useState)(()=>l===`gated`?`your-own`:ce(t(Qe,`managed`),`managed`)),[p,m]=(0,Q.useState)(()=>{let e=t(Ve,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=xn(e,l===`full`&&u===`managed`),_=h??(g?e:null),v=f({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await vt({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Q.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,b=(0,Q.useCallback)(e=>{d(e),n(Qe,e)},[]),S=(0,Q.useCallback)(()=>{n(Ve,p),B.success(`Email settings saved.`)},[p]),C=(0,Q.useMemo)(()=>Ge.find(e=>e.id===p)??Ge[0],[p]),w=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{children:[`Configure `,C.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(T,{className:`h-3 w-3`})]})]})]}),D=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:Ge.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,$.jsx)(x,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`span`,{children:[C.displayName,` API key configured. To reconfigure, run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill.`]})]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(T,{className:`h-3 w-3`})]})]}):w,(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(kn,{onClick:S,disabled:!1})})]});return l===`gated`?(0,$.jsx)(En,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:D}):(0,$.jsx)(Tn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:b,children:u===`managed`?(0,$.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,$.jsx)(sn,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,$.jsx)(Nn,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):D})}function Fn(){let e=hn();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await yt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});re(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?B.error(`Assistant not ready. Please try again.`):B.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function In(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var Ln=`0.11.0`;function Rn(){return dt(Ln)}var zn=`gemini-3.1-flash-image-preview`;function Bn(){let e=hn(),r=d(),i=Et(),{data:o}=f({...Wt({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=Nt({onSuccess:t=>{Lt(r,{path:{assistant_id:e}},t)}}),c=Fn(),[l,u]=In((0,Q.useMemo)(()=>{if(!o)return t(He,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||t(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Q.useState)(()=>t(nt,zn)),h=xe(l),g=h.includes(p)?p:h[0]??zn,[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=at.map(e=>({value:e,label:ct[e]??e})),S=(0,Q.useMemo)(()=>xe(l).map(e=>({value:e,label:Be[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=we({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),T=u,E=(0,Q.useCallback)(async()=>{b(!0);let t=_.trim(),i=C&&t.length>0;try{i&&await c(ot(g),t),await ft();let n=l===`vellum`&&!Rn()?{mode:`managed`}:{provider:l,mode:l===`vellum`?`managed`:`your-own`};await s.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":n}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await xt({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw B.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{r.invalidateQueries({queryKey:It({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(He,l),n(nt,g),i){let t=Ie(e,`api_key`,l);r.setQueryData(t,!0),r.invalidateQueries({queryKey:t}),v(``)}B.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,r]),D=(0,Q.useCallback)(()=>{v(``),m(zn),n(nt,zn)},[]);return(0,$.jsx)(En,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Image generation provider`,value:l,onChange:T,options:x})]}),l===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:Te(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,$.jsx)(H,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:E,disabled:y}),y&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(An,{onClick:D})]})]})})}function Vn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(h,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(h,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function Hn(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Un=5;function Wn(e,t){return`${e} ${t}${e===1?``:`s`}`}function Gn(e){return e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(`is your default profile`),e.callSiteIds.length>0&&n.push(`is used by ${Wn(e.callSiteIds.length,`action override`)}`);let r=[];return e.scheduleNames.length>0&&r.push(Wn(e.scheduleNames.length,`schedule`)),e.deferredReminderCount>0&&r.push(Wn(e.deferredReminderCount,`reminder`)),r.length>0&&n.push(`runs ${Gn(r)}`),n.length===0?`Choose a replacement profile for "${t}". Anything still pointing at it moves there before it is deleted.`:`"${t}" ${Gn(n)}. Pick a replacement below and those references move to it, then "${t}" is deleted.`}function qn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function Jn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let l=e?.scheduleNames??[],u=l.slice(0,Un),d=l.length-u.length,f=e!=null&&Hn(e);return(0,$.jsx)(L.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(L.Content,{size:`sm`,children:[(0,$.jsx)(L.Header,{children:(0,$.jsx)(L.Title,{children:`Choose a Replacement Profile`})}),(0,$.jsxs)(L.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:Kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(qn,{title:`Action overrides`,items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(qn,{title:`Schedules`,items:u}),d>0&&(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:[`and `,d,` more`]})]}),e?.scheduleLookupFailed&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:`We could not check which schedules use this profile. Any schedule pinned to it moves to the replacement as well.`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:`Replacement profile`}),(0,$.jsx)(H,{"aria-label":`Replacement profile`,value:n,onChange:r,placeholder:`Select a replacement…`,options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:fe(e),disabled:t,tooltip:t?`Enable this profile to move schedules onto it.`:void 0}})})]}),i&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(L.Footer,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Yn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:l,onDelete:u}){let d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(ke(e.provider??void 0,e.model,r)),d&&m.push(`Managed by Vellum`);let h=e.availability,g=h?.status===`incomplete`,_=h!=null&&h.status!==`ok`?`${h.message??`This profile's provider is not available.`}${g?` Click to fix.`:``}`:null;return(0,$.jsx)(v,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:`Open profile ${p}`,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[_==null?null:(0,$.jsx)(s,{content:_,children:g?(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":_,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(b,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(b,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":_,role:`img`})})}),f?(0,$.jsx)(I,{tone:`neutral`,children:`Disabled`}):null,t?(0,$.jsx)(I,{tone:`positive`,children:`Default`}):null,(0,$.jsxs)(S.Root,{children:[(0,$.jsx)(S.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(w,{}),"aria-label":`Actions for ${p}`,disabled:i})}),(0,$.jsxs)(S.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(S.Item,{onSelect:a,children:d?`View`:`Edit`}),!t&&!f?(0,$.jsx)(S.Item,{onSelect:o,children:`Make Default`}):null,f?(0,$.jsx)(S.Item,{onSelect:()=>l(!0),children:`Enable`}):d?null:(0,$.jsx)(S.Item,{onSelect:()=>l(!1),children:`Disable`}),d?null:(0,$.jsx)(S.Item,{onSelect:u,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`})]})]})]})})}function Xn(e,t){let n=tt(),{data:r}=f({...At({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=rt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:Z(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}function Zn(e){let t=d();return Nt({onSuccess:n=>{Lt(t,{path:{assistant_id:e}},n),t.invalidateQueries({queryKey:Ht({path:{assistant_id:e}})}),t.invalidateQueries({queryKey:Bt({path:{assistant_id:e}})})}})}var Qn=`0.10.8`;function $n(e){return pt(Qn,e)}var er=`settings-ai-profile-make-active`,tr=`Failed to set the active profile. Please try again.`;function nr(e){let t=Zn(e),n=d(),r=$n(e),i=Ut({onSuccess:()=>{n.invalidateQueries({queryKey:It({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:Ht({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw a(e,{context:r}),B.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},er,tr);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ht(e);throw B.error(t??tr),t||a(e,{context:er}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:o,isPending:t.isPending||i.isPending}}var rr=`The profile was not deleted.`,ir=`Failed to move the schedules. ${rr}`;function ar(e){let t=ht(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${rr}`:ir}function or(e,t,n){let r=nr(e),i=d(),o=pe(),s=t?.llm?.activeProfile??null,c=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),f=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>Z(u,f),[u,f]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:me(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await r.deleteProfile(e,f,{isAdvisor:e===c}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,o=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),c=[],d=0,f=!1;try{let n=(await i.fetchQuery({...jt({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];c=n.filter(e=>!e.isDeferred).map(e=>e.name),d=n.filter(e=>e.isDeferred).length}catch(e){a(e,{context:`settings-ai-profile-delete-schedule-scan`}),f=!0}if(!(r||o.length>0||c.length>0||d>0)&&!f){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:o,scheduleNames:c,deferredReminderCount:d,scheduleLookupFailed:f};h(p),y(E(t,Hn(p))),_(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),Hn(m))try{await bn(e,m.name,v),await i.invalidateQueries({queryKey:Dt({path:{assistant_id:e}})})}catch(e){a(e,{context:`settings-ai-profile-reassign-schedules`}),_(ar(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function sr(){}function cr({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{entries:s}=Xn(e,t),l=nr(e),u=or(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vn,{title:`Profiles`,action:(0,$.jsx)(c,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(j,{}),disabled:t==null,children:`Create Profile`}),children:t==null?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`Loading profiles…`}):s.length===0?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):s.map(e=>(0,$.jsx)(Yn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(sr),onSetStatus:t=>void l.setStatus(e.name,t).catch(sr),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Jn,{...u.blockedDeleteModalProps})]})}var lr={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function ur(e){return e in lr}function dr(e){let t=e.baseUrl??``;try{e.baseUrl&&(t=new URL(e.baseUrl).host)}catch{}let n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function fr(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function pr(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return dr(e);let t=[],n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?ze(n):ye(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=fr(e);return a&&t.push(a),t.join(` • `)}function mr({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let l=e.isManaged??!1,u=et(e),d=ur(e.provider),f=pr(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(v,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?`Open provider ${u}`:void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(I,{tone:`neutral`,title:`Runs on Vellum's managed credentials.`,children:`Managed`}):null,t?(0,$.jsx)(I,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Cost, Speed) use this provider.`,children:`Default`}):null,e.provider===`ollama`?(0,$.jsx)(I,{tone:`neutral`,title:`Runs models on this machine.`,children:`Local`}):null,e.provider===`openai-compatible`?(0,$.jsx)(I,{tone:`neutral`,title:`A provider you created, served by an OpenAI-compatible endpoint.`,children:`Custom`}):null,g?(0,$.jsxs)(S.Root,{children:[(0,$.jsx)(S.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(w,{}),"aria-label":`Actions for ${u}`})}),(0,$.jsxs)(S.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(S.Item,{onSelect:a,children:`Edit`}):null,p?(0,$.jsx)(S.Item,{disabled:i,onSelect:o,children:`Set as default`}):null,h?(0,$.jsx)(S.Item,{onSelect:s,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function hr(e,t){let n=d(),r={path:{assistant_id:e}},i=p({...Ft(),onSuccess:()=>{n.invalidateQueries({queryKey:Rt(r)}),n.invalidateQueries({queryKey:It(r)}),n.invalidateQueries({queryKey:Ht(r)})},onError:e=>{a(e,{context:`settings-ai-set-default-provider`}),B.error(`Failed to set the default provider. Please try again.`)}});function o(t){ur(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function s(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await gt({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Pt(r)}),t?.onDeleted?.(i)):a?.status===409?B.error(`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`):B.error(`Failed to delete the provider. Please try again.`)}catch(e){a(e,{context:`settings-ai-provider-delete`}),B.error(`Failed to delete the provider. Please try again.`)}}return{setDefault:o,isSettingDefault:s,deleteConnection:c}}function gr({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{data:a,isLoading:o,isError:s}=f(kt({path:{assistant_id:e}})),l=qe(),{data:u}=f({...zt({path:{assistant_id:e}}),enabled:l}),d=l?u?.resolvedConnectionName??null:null,p=hr(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=a?.connections??[];return[...e.filter(e=>e.provider===se),...e.filter(e=>e.provider!==se)]},[a]);return(0,$.jsx)(Vn,{title:`Providers`,action:(0,$.jsx)(c,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(j,{}),children:`Add Provider`}),children:o?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(U,{className:`h-10 rounded-lg`},e))}):s?(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):m.length===0?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):m.map(e=>(0,$.jsx)(mr,{connection:e,isDefault:e.name===d,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function _r({panel:e,onOpenPanel:t,onClosePanel:n}){let r=hn(),{data:i}=f({...Wt({path:{assistant_id:r}}),staleTime:3e4}),a=qe(),{data:o}=f({...zt({path:{assistant_id:r}}),enabled:a}),s=o?.availability,{data:l}=f({...kt({path:{assistant_id:r}})}),u=l?.connections,d=i?.llm?.callSites??{},p=Object.entries(d).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(En,{title:`Language Model`,subtitle:`Profiles choose which model answers. Providers supply access to it`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s&&s.status!==`ok`&&(0,$.jsx)(F,{tone:s.status===`unknown`?`warning`:`error`,children:s.message??`Your default provider is not available.`}),r&&(0,$.jsx)(cr,{assistantId:r,config:i,connections:u,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),r&&(0,$.jsx)(gr,{assistantId:r,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Vn,{title:`Overrides`,count:p,action:(0,$.jsx)(c,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:`Manage`})})]})})}function vr(e,{onSaved:t}={}){let n=Zn(e),{data:r}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),o=r?.llm?.profileOrder??[];async function s(r,s,c){let l=c?.mode??`replace`,u=!(r in i);if(l===`merge`&&!u){await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:s}}}}),t?.();return}let d={profiles:{[r]:s}};if(u&&(d.profileOrder=o.includes(r)?o:[...o,r]),u)await n.mutateAsync({path:{assistant_id:e},body:{llm:d}});else{let t=i[r];await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:null}}}});try{await n.mutateAsync({path:{assistant_id:e},body:{llm:d}})}catch(i){throw a(i,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:t}}}}).catch(()=>{}),i}}u&&B.success(`Profile "${s.label??r}" created`),t?.()}return{saveProfile:s,isPending:n.isPending}}function yr({assistantId:e,profileName:t,onClose:n}){let{data:r}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),{data:i}=f({...kt({path:{assistant_id:e}})}),a=i?.connections,o=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),s=Object.keys(o),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=o[t];return e?{name:t,...e}:void 0},[t,o]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:p}=vr(e,{onSaved:n}),m=Je({mode:u,profileName:t??void 0,initialValues:l,existingNames:s,connections:a,assistantId:e,onSave:d}),h=or(e,r,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&r!=null&&!(t in o);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{title:m.effectiveMode===`create`?`New Profile`:l?.label??t??`Profile`,closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(I,{tone:`neutral`,children:`Managed by Vellum`}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(N,{}),tintColor:`var(--system-negative-strong)`,onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g,children:g?`Deleting…`:`Delete`}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(c,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:`Save As New`}),m.hasViewModeChanges?(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?`Saving…`:`Save`}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?`Saving…`:m.effectiveMode===`create`?`Create Profile`:`Save Changes`})}),children:(0,$.jsx)(Ae,{editor:m,assistantId:e,connections:a,variant:`panel`})}),(0,$.jsx)(Jn,{...h.blockedDeleteModalProps})]})}function br({value:e,profileOptions:t,disabled:n,onChange:r}){return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:`Advisor`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`The profile your assistant consults for a second opinion when it wants to check a plan or review its own work.`})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,$.jsx)(H,{value:e,onChange:r,options:t,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`,disabled:n})})]})})}var xr=`__custom__`;function Sr(e){return e?!!(e.profile||e.provider||e.model):!1}function Cr(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function wr(e,t){let n=Sr(e);return n===Sr(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function Tr(e){return`${e} ${e===1?`action`:`actions`}`}function Er({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:o,onApplied:s}){let l=Zn(e),u=pe(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=Cr(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,f]),[m,g]=(0,Q.useState)(()=>p[0]?.name??``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>f.get(e.id)?.profile===m),[t,f,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:fe(e)})),[p]),D=(0,Q.useMemo)(()=>ue(i,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:fe(e)})),[i,m,d]),k=ae(i,m),j=ae(i,_),M=y.size===0;function N(e){g(e),b(new Set),e===_&&v(``)}function P(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!_||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:_};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),B.success(`Updated ${Tr(T.length)} to "${j}".`),s(),o()}catch(e){let t=ht(e);B.error(t??`Failed to update overrides. Please try again.`),t||a(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(L.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(L.Content,{size:`md`,children:[(0,$.jsx)(L.Header,{children:(0,$.jsx)(L.Title,{children:`Change Action Overrides`})}),(0,$.jsxs)(L.Body,{className:`space-y-4`,children:[(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:`Update the actions that currently use one profile. The result is saved as individual overrides.`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(H,{id:`bulk-swap-source`,label:`Currently using`,value:m,onChange:N,options:E}),(0,$.jsx)(H,{id:`bulk-swap-target`,label:`Change to`,value:_,onChange:v,options:D,placeholder:`Select a profile…`})]}),(0,$.jsxs)(F,{tone:`info`,title:`This happens once.`,children:[`It changes the selected actions that use `,k,` today. It does not create an ongoing rule between profiles.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(h,{variant:`body-medium-default`,as:`p`,children:[Tr(w.length),` currently`,` `,w.length===1?`uses`:`use`,` `,k]}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:`Choose which actions to update.`})]}),(0,$.jsx)(c,{variant:`ghost`,onClick:()=>b(M?new Set(w.map(e=>e.id)):new Set),children:M?`Clear all`:`Select all`})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(A,{checked:!y.has(e.id),onCheckedChange:t=>P(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?`Override`:`Default`})]},e.id))})]})]}),(0,$.jsxs)(L.Footer,{children:[(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:[Tr(T.length),` will change`]}),(0,$.jsx)(c,{variant:`ghost`,onClick:o,disabled:x,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,disabled:!m||!_||T.length===0||x,onClick:()=>void I(),children:x?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Apply to ${Tr(T.length)}`})]})]})})}function Dr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let l=Sr(i),u=!i||!l?``:i.provider||i.model?xr:i.profile??``,d=u===xr,f=Le(),p=(o??[]).some(e=>e.provider===ge),m=[...f,...p?[ge]:[]],h=f[0]??G[0],g=i?.provider,_=q(g)?g:g===`chatgpt`?ge:void 0,v=_!==void 0&&m.some(e=>e===_),y=_??h,b=Re(y,``,(o??[]).filter(e=>Fe(e.provider,y)))?ze(y):ye(y),x=b.map(e=>({value:e.id,label:e.displayName})),S=typeof i?.model==`string`?i.model:``;if(S&&!b.some(e=>e.id===S)){let e=ye(y).find(e=>e.id===S)?.displayName??S;x.push({value:S,label:`${e} (unavailable)`})}let C=!!i?.provider&&!i?.model,w=[...m.map(e=>({value:e,label:K[e]??e})),..._&&!v?[{value:_,label:`${K[_]??_} (unavailable)`}]:[]];function T(t){t===`__custom__`?s(e,{profile:null,provider:h,model:ee(h)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function E(t){let n=ee(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function D(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,$.jsx)(H,{value:u,onChange:T,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,$.jsx)(z,{checked:l,onChange:t=>c(e,t),"aria-label":`Override ${t}`})]})]}),l&&d&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y??``,onChange:E,options:w})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,$.jsx)(H,{value:i?.model??``,onChange:D,options:x})]})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Or({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!Sr(n)?``:n.provider||n.model?xr:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(Dr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function kr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;Sr(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function Ar(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function jr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!wr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>Sr(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>kr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>Ar(c),[c])}}function Mr({assistantId:e,onClose:t}){let{data:n}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),r=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),i=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>n?.llm?.callSites??{},[n?.llm?.callSites]),s=(0,Q.useMemo)(()=>Z(r,i),[r,i]),l=Le(),u=pe(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),p=Zn(e),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:E}=f({...Vt({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:D}=f({...kt({path:{assistant_id:e}}),enabled:!!e}),k=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),A=!w&&!T&&!!C,j=!!n,N=A&&j,P=(0,Q.useMemo)(()=>k.map(e=>e.id),[k]),F=n?.llm?.advisorProfile??``,{drafts:I,advisorProfile:L,advisorDirty:z,callSiteDraftsDirty:H,hasUnsavedDrafts:U,hasValidationError:W,setDraft:K,setAdvisor:q,clearEdits:te,buildSavePatch:ne,buildResetPatch:Y}=jr({catalogCallSiteIds:P,persistedOverrides:o,persistedAdvisor:F,isSeeded:N}),re=(0,Q.useMemo)(()=>new Set(P),[P]),X=(0,Q.useCallback)(e=>ae(s,e),[s]),ie=(0,Q.useCallback)(e=>({value:e.name,label:fe(e),...le(e,s,d)===`undispatchable`?{icon:(0,$.jsx)(b,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:J(e)}:{}}),[s,d]),se=(0,Q.useMemo)(()=>ue(s,[F],d).map(ie),[s,F,ie,d]),ce=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),de=(0,Q.useMemo)(()=>k.some(e=>Cr(e,o[e.id])!==null),[k,o]),me=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>re.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,re]),he=(0,Q.useCallback)(e=>[...ue(s,[e],d).map(ie),{value:xr,label:`Custom`}],[s,ie,d]),ge=(0,Q.useMemo)(()=>{if(!m.trim())return k;let e=m.toLowerCase();return k.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[k,m]),_e=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ge.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=ge.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[C,ge]),ve=(0,Q.useCallback)((e,t)=>{if(!t){K(e,null);return}let n=oe(s,k.find(t=>t.id===e)?.defaultProfile,d);if(n)K(e,{profile:n});else{let t=l[0]??G[0];K(e,{provider:t,model:ee(t)??``})}},[k,s,l,K,d]),ye=(0,Q.useCallback)(async()=>{_(!0);try{let n=ne();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...H?{callSites:n}:{},...z?{advisorProfile:L}:{}}}}),t(),B.success(`Overrides saved.`)}catch(e){B.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[ne,H,z,L,t,p,e]),be=(0,Q.useCallback)(async()=>{_(!0);try{let n=Y();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),B.success(`Overrides reset.`)}catch(e){B.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[Y,t,p,e]);return(0,$.jsxs)(gn,{title:`Action Overrides`,closeVariant:`outlined`,onClose:t,footer:(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(c,{variant:`outlined`,onClick:()=>y(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,$.jsx)(c,{variant:`primary`,onClick:()=>void ye(),disabled:!U||W||g,children:g?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Save`})]}),children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(R,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search actions…`,leftIcon:(0,$.jsx)(M,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>S(!0),disabled:!N||g||U||!de,title:U?`Save or reset your changes first`:de?void 0:`No actions currently use a profile`,children:`Bulk change`})]}),j&&ce&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:`Advisor`}),(0,$.jsx)(br,{value:L,profileOptions:se,disabled:g,onChange:q})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(O,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&C&&(0,$.jsx)(Or,{groups:_e,drafts:I,buildProfileOptionsForRow:he,profileLabelFor:X,advisorMatchesSearch:ce,connections:D?.connections,onDraftChange:K,onToggle:ve})]}),x&&C&&(0,$.jsx)(Er,{assistantId:e,callSites:k,domains:C.domains,persistedOverrides:o,orderedProfiles:s,onClose:()=>S(!1),onApplied:te}),(0,$.jsx)(V,{open:v,title:`Reset to Defaults`,message:`Every action override will be reset and will follow its default. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{y(!1),be()},onCancel:()=>y(!1)})]})}function Nr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,onSave:o,onCancel:s}){let[l,u]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[g,_]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[v,y]=(0,Q.useState)(t?.baseUrl??``),[b,x]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),j=d(),M=(0,Q.useMemo)(()=>De(g),[g]),N=m===`api_key`&&M!==null,{hasStoredCredential:P,isLoading:F}=we({assistantId:n,credentialKind:`credential`,credentialName:M?`${M.service}:${M.field}`:``,enabled:N}),{credentials:I}=Se({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;u(t?.label??``),t?.auth.type===`api_key`?_(t.auth.credential):_(t?``:`credential/${e}/api_key`),T(null),y(t?.baseUrl??``),x(t?.models?t.models.map(e=>e.id).join(`, `):``),O(``),A(!1)},[t]);let z=l.trim()!==(t?.label??``).trim(),B=E&&z?lt(l,i,t?.name):null,V=f.trim().length>0&&B===null;async function H(){if(V){C(!0),T(null);try{let e;if(m===`api_key`){let t=g.trim()||`credential/${p}/api_key`,r=D.trim();if(r){A(!0);try{let e=De(t);await yt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Ie(n,`credential`,e?`${e.service}:${e.field}`:``);j.setQueryData(i,!0),j.invalidateQueries({queryKey:Mt({path:{assistant_id:n}})})}catch{T(`Failed to save API key. Please try again.`);return}finally{A(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(`Nothing to edit. Close and try again.`);return}let r=l.trim()||null,i={auth:e,label:r,...E&&{base_url:v.trim()||null,models:b.trim()?b.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:s,response:c}=await _t({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ee(c?.status,s)??Ce(c?.status));return}if(!a){T(`Server returned an empty response. Please try again.`);return}o(a)}catch{T(`Failed to save provider. Please try again.`)}finally{C(!1)}}}let U=I.filter(e=>e.service===p),W=e!==`create`&&t?.auth.type===`api_key`,G=U.length>0||W,K=Te(`Enter your API key`,P);if(e===`create`)return(0,$.jsx)(je,{variant:a===`panel`?`inline`:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:o,onCancel:s});let ee=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,$.jsx)(R,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),B?(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Me[B]}):null]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,$.jsx)(R,{value:v,onChange:e=>y(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,$.jsx)(R,{value:b,onChange:e=>x(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),m===`api_key`&&(0,$.jsx)(Oe,{apiKeyValue:D,onApiKeyChange:O,credential:g,onCredentialChange:_,isLoadingCredential:F,apiKeyPlaceholder:K,provider:p,providerCredentials:U,showAdvancedSection:G,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(be,{assistantId:n,onConnected:o}),w&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),q=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!V||S||k,onClick:()=>void H(),children:S?`Saving…`:`Save Changes`})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ee,(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:q})]}):(0,$.jsxs)(L.Content,{size:`md`,children:[(0,$.jsxs)(L.Header,{children:[(0,$.jsx)(L.Title,{children:`Edit Provider`}),(0,$.jsx)(L.Description,{children:t?`Editing ${et(t)}.`:`Edit provider settings.`})]}),(0,$.jsx)(L.Body,{children:ee}),(0,$.jsx)(L.Footer,{children:q})]})}function Pr({assistantId:e,connectionName:t,onClose:n}){let r=d(),{data:i}=f(kt({path:{assistant_id:e}})),a=(0,Q.useMemo)(()=>i?.connections??[],[i]),o=(0,Q.useMemo)(()=>t==null?void 0:a.find(e=>e.name===t),[t,a]),s=t!=null&&i!=null&&o==null;(0,Q.useEffect)(()=>{s&&n()},[s,n]);function c(){r.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})}),r.invalidateQueries({queryKey:Rt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(gn,{title:o?et(o):`Add Provider`,closeVariant:`outlined`,onClose:n,children:t==null||o!=null?(0,$.jsx)(Nr,{mode:o?`edit`:`create`,connection:o,variant:`panel`,assistantId:e,existingNames:a.map(e=>e.name),connections:a,onSave:c,onCancel:n}):null})}var Fr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Ir={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Lr=`deepgram`;function Rr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=hn(),s=e??o,c=Et(),l=d(),[u]=(0,Q.useState)(()=>st.filter(e=>!e.requiresNativeDictation||Pe())),p=Lr,{data:m}=f({...Wt({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?Ir[g]:void 0;if(e&&u.some(t=>t.id===e))return e;let n=t(it,p);return u.some(e=>e.id===n)?n:p},[g,u,p]),v=!!g,[y,b]=In(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=ln(s),[E,D]=(0,Q.useState)(!1),O=x&&y===_&&(Fr[y]?.provider===C||!!g&&!Ir[g]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=t(it,p);e===`macos-native`&&!u.some(t=>t.id===e)&&n(it,p)},[u,p]);let I=(0,Q.useMemo)(()=>u.find(e=>e.id===y)??u[0],[u,y]),L=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(t(Ye+y,``).length>0),A(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=k.trim().length>0;return e||t},[y,_,k]),V=(0,Q.useCallback)(async()=>{let e=k.trim();n(it,y),e.length>0&&n(Ye+y,e);let r=Fr[y];F(!0);try{if(r?.credentialService){let n=e.length>0?e:t(Ye+y,``);if(n.length>0){let{response:e}=await St({path:{assistant_id:s},body:{service:r.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(r&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=r?.provider??Lr,{response:t}=await bt({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return e.length>0&&M(!0),A(``),l.invalidateQueries({queryKey:It({path:{assistant_id:s}})}),B.success(`Speech-to-text settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{F(!1)}},[s,y,k,I,_,v,g,l]);(0,Q.useEffect)(()=>{a?.({hasChanges:z,saving:N,save:V})},[a,z,N,V]);let U=(0,Q.useCallback)(()=>{n(Ye+y,``),M(!1),A(``)},[y]),W=j?`•••••••• (Enter a new key to replace)`:I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y,onChange:b,options:u.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Spoken language`}),(0,$.jsx)(Ze,{"aria-label":`Spoken language`,"aria-haspopup":`dialog`,onClick:()=>D(!0),value:un(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Applies from your next spoken turn.`}),(0,$.jsx)(Cn,{open:E,onOpenChange:D,title:`Spoken language`,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),L&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(R,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:W,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(P,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!i&&I.credentialsGuide&&(0,$.jsx)(jn,{guide:I.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!r||j)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!r&&(0,$.jsx)(kn,{onClick:V,disabled:!z||N}),j&&(0,$.jsx)(An,{onClick:U})]})]})}function zr(){return(0,$.jsx)(En,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,$.jsx)(Rr,{})})}async function Br(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Vr(n,r,i):t===`deepgram`?await Hr(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Vr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await Ur(i,`ElevenLabs rejected the request.`)}}async function Hr(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await Ur(n,`Deepgram rejected the request.`)}}async function Ur(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Wr({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Q.useState)(!1),{voices:o}=pn(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,$.jsxs)(g.Root,{open:i,onOpenChange:a,children:[(0,$.jsx)(g.Trigger,{asChild:!0,children:(0,$.jsx)(Ze,{"aria-label":`Voice`,value:s?dn(s.description):`Select a voice`,className:r})}),(0,$.jsx)(g.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(fn,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Gr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Kr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=hn(),s=e??o,l=ut.use.name()??`your assistant`,u=Et(),p=d(),{data:m}=f({...Ot({path:{assistant_id:s}}),enabled:u,staleTime:1/0}),h=(0,Q.useMemo)(()=>{let e=m?.providers;if(!e)return Ne;if(e.some(e=>e.id===`vellum`))return e;let t=Ne.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=f({...Wt({path:{assistant_id:s}}),enabled:u,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Q.useMemo)(()=>v??t(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=In(b),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),{voices:L,defaultModel:z,fetched:V}=mn(s,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??z??``,[W,G]=In(U),K=L.find(e=>e.model===W)??L[0],[ee,q]=(0,Q.useState)(null),te=L.some(e=>e.model===U),ne=ee??(V&&U!==``&&!te),J=(0,Q.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),Y=S===`vellum`&&J.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,re=(0,Q.useCallback)(e=>{let n=t(Ue+e,``),r=t($e+e,``);M(n.length>0),O(r),A(r),T(``)},[]);(0,Q.useEffect)(()=>{re(S)},[S,re]);let X=(0,Q.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=E.trim()!==k;return e||t||n||Y},[S,b,w,E,k,Y]),ie=(0,Q.useCallback)(async()=>{let e=w.trim(),r=E.trim(),i=J.id;n(We,i),e.length>0&&n(Ue+i,e),n($e+i,r);let a=e.length>0?e:t(Ue+i,``),o=Gr[i];I(!0);try{if(a.length>0){let{response:e}=await St({path:{assistant_id:s},body:{service:i,field:`api_key`,value:a,label:`${J.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:r}}}:{},...Y?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await bt({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(r),T(``),p.invalidateQueries({queryKey:It({path:{assistant_id:s}})}),B.success(`Text-to-speech settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{I(!1)}},[s,S,W,Y,w,E,J,b,x,p]);(0,Q.useEffect)(()=>{a?.({hasChanges:X,saving:F,save:ie})},[a,X,F,ie]);let ae=(0,Q.useCallback)(()=>{n(Ue+S,``),M(!1),T(``)},[S]),oe=(0,Q.useCallback)(async()=>{P(!0);try{let e=t(Ue+S,``),n=w.trim(),r=n.length>0?n:e;if(r.length===0){B.error(`Save an API key for this provider before testing.`);return}let i=t($e+S,``),a=E.trim(),o=await Br({provider:S,apiKey:r,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){B.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{P(!1)}},[l,w,S,E]),se=j?`•••••••• (Enter a new key to replace)`:J.apiKeyPlaceholder,Z=S===`vellum`,ce=Z&&J.supportsVoiceSelection,le=(0,$.jsxs)(c,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),L.some(e=>e.model===W)||G(z||L[0]?.model||``)},children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),ue=ce&&ne&&L.length>0?le:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(R,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:se,fullWidth:!0})]}),ce&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),ne?(0,$.jsx)(R,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):K?(0,$.jsx)(Wr,{assistantId:s,value:W,onChange:G}):V&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),J.supportsVoiceSelection&&!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,$.jsx)(R,{type:`text`,value:E,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!Z&&(0,$.jsx)(jn,{guide:J.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!Z&&(0,$.jsx)(c,{variant:`outlined`,onClick:oe,disabled:N,children:N?`Testing…`:`Test`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[ue,!r&&(0,$.jsx)(kn,{onClick:ie,disabled:!X||F}),j&&!Z&&(0,$.jsx)(An,{onClick:ae})]})]})]})}function qr(){return(0,$.jsx)(En,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,$.jsx)(Kr,{})})}var Jr=`default`;function Yr(){let e=hn(),i=d(),{data:o}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),s=Nt({onSuccess:t=>{Lt(i,{path:{assistant_id:e}},t)}}),c=Fn(),l=(0,Q.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||t(`vellum:ai:webFetchProvider`,Jr):t(Xe,Jr),[o]),[u,p]=(0,Q.useState)(!1),[m,h]=In(l),[g,_]=(0,Q.useState)(``),v=Y.has(m),{hasStoredCredential:y}=we({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=u||v&&!y&&!b||m===l&&!b,S=Te(W[m]??`Enter your API key`,y),C=(0,Q.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(Xe,m),r){let r=X(m);r&&n(r,t);let a=Ie(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}B.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Q.useCallback)(()=>{let e=X(m);e&&r(e),_(``),h(Jr),n(Xe,Jr)},[m,h]);return(0,$.jsx)(En,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:m,onChange:h,options:te.map(e=>({value:e,label:_e[e]??e}))})]}),v&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:C,disabled:x}),u&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(An,{onClick:w,filled:!0})]})]})})}var Xr=`0.10.12`;function Zr(){return dt(Xr)}function Qr(){let e=hn(),i=d(),o=Et(),{data:s}=f({...Wt({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=Nt({onSuccess:t=>{Lt(i,{path:{assistant_id:e}},t)}}),l=Fn(),u=(0,Q.useMemo)(()=>{if(!s)return t(Ke,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||t(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Q.useState)(!1),[h,g]=In(u),[_,v]=(0,Q.useState)(``),y=ie.has(h),{hasStoredCredential:b}=we({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===u&&!x,C=Te(ve[h]??`Enter your API key`,b),w=(0,Q.useCallback)(async()=>{m(!0);let t=_.trim(),r=de(h),o=y&&t.length>0;try{o&&await l(h,t),await ft();let n=h===`vellum`?Zr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(Ke,h),o){r&&n(r,t);let a=Ie(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}B.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),T=(0,Q.useCallback)(()=>{let e=de(h);e&&r(e),v(``),g(`inference-provider-native`),n(Ke,`inference-provider-native`)},[h,g]);return(0,$.jsx)(En,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Web search provider`,value:h,onChange:g,options:he.map(e=>({value:e,label:ne[e]??e}))})]}),h===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:w,disabled:S}),p&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,$.jsx)(An,{onClick:T,filled:!0})]})]})})}function $r(){let e=hn(),t=on(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(Dn,{}),(0,$.jsx)(_r,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Qr,{}),(0,$.jsx)(Yr,{}),(0,$.jsx)(Pn,{}),(0,$.jsx)(Bn,{}),(0,$.jsx)(qr,{}),(0,$.jsx)(zr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(Mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(Pr,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(yr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(vn,{children:s}):s?(0,$.jsx)(yn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{$r as AiPage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{r as i,t as a}from"./capture-error-DVxOKq30.js";import{t as o}from"./react-BFJW0bSv.js";import{n as s,t as c}from"./button-DSjqKLvM.js";import{d as l,h as u}from"./chunk-5KNZJZUH-BUqIilZr.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./typography-BeUa5Fd-.js";import{J as g,W as _,i as v}from"./src-DFSK6m8o.js";import{t as y}from"./check-CNBoUiyR.js";import{t as b}from"./circle-alert-DEIiXMF-.js";import{t as x}from"./circle-check-BG2g8udA.js";import{t as S}from"./menu-Gu_6PRrL.js";import{t as C}from"./clock-DSx5dIWv.js";import{t as w}from"./ellipsis-vertical-CAYfw0qB.js";import{t as T}from"./external-link-D65yhWAV.js";import{t as E}from"./info-Bjcv3rf9.js";import{t as D}from"./list-COQcQTOh.js";import{t as O}from"./loader-circle-oY5laABh.js";import{t as k}from"./mail-B0iH8Wii.js";import{t as A}from"./checkbox-DyHMOWN6.js";import{t as j}from"./plus-CwK68LCA.js";import{t as M}from"./search-DbyaO8rG.js";import{t as N}from"./trash-2-DL_3_16e.js";import{t as P}from"./triangle-alert-C5SOfs-q.js";import{t as F}from"./notice-C9v3KOP3.js";import{t as I}from"./tag-D0oiSRye.js";import{t as L}from"./modal-Bt1DPFgW.js";import{t as R}from"./input-BG94bPcH.js";import{t as z}from"./toggle-C-v4x7_A.js";import{n as B}from"./toast-BrKo5b4d.js";import{t as V}from"./confirm-dialog-DNaRfy4W.js";import{t as H}from"./select-B86W_Hs8.js";import{t as U}from"./skeleton-CzdJByjE.js";import{C as W,E as G,F as K,L as ee,M as q,S as te,_ as ne,a as J,b as Y,c as re,f as X,g as ie,h as ae,i as oe,j as se,l as Z,m as ce,n as le,o as ue,p as de,r as fe,s as pe,t as me,v as he,w as ge,x as _e,y as ve,z as ye}from"./profile-pickers-DkKPLcgs.js";import{B as be,C as xe,F as Se,G as Ce,H as we,I as Te,J as Ee,K as De,L as Oe,M as ke,N as Ae,P as je,R as Me,S as Ne,T as Pe,U as Fe,V as Ie,W as Le,X as Re,Y as ze,_ as Be,a as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,j as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,q as et,r as tt,s as nt,t as rt,u as it,v as at,w as ot,x as st,y as ct,z as lt}from"./use-sticky-profiles-CwhMQz1W.js";import{t as ut}from"./assistant-identity-store-kRH_OiG9.js";import{n as dt,o as ft,r as pt}from"./utils-IInmQ0Wp.js";import{i as mt,r as ht}from"./api-errors-Cbz9vgty.js";import{Jt as gt,Yt as _t,dt as vt,fr as yt,j as bt,kn as xt,mt as St}from"./sdk.gen-Br55zhZN.js";import{p as Ct}from"./platform-detection-BIfuAgU8.js";import{d as wt}from"./routes-C293MsBG.js";import{i as Tt}from"./use-platform-gate-CzjAnErv.js";import{r as Et}from"./use-is-org-ready-jiX84kb4.js";import{Ct as Dt,Gt as Ot,J as kt,K as At,St as jt,Tt as Mt,Xt as Nt,Y as Pt,_ as Ft,d as It,f as Lt,g as Rt,h as zt,m as Bt,p as Vt,q as Ht,sn as Ut,u as Wt}from"./react-query.gen-vkBavCkI.js";import{c as Gt,d as Kt,f as qt,ft as Jt,g as Yt,h as Xt,l as Zt,m as Qt,o as $t,p as en,s as tn,u as nn,v as rn,y as an}from"./react-query.gen-DCPOsBjb.js";import{n as on}from"./use-is-mobile-DznTMSWZ.js";import{t as sn}from"./platform-login-notice-CoOWZqVQ.js";import{t as cn}from"./android-consumption-only-DGpN9EGi.js";import{a as ln,c as un,i as dn,n as fn,o as pn}from"./voice-list-BfdPgz53.js";import{n as mn}from"./use-voice-sample-preview-RRMzeYRk.js";import{t as hn}from"./use-active-assistant-id-B4vGntPc.js";import{t as gn}from"./detail-shell-B3moyzaC.js";import{t as _n}from"./detail-card-DQWk035Y.js";import{n as vn,t as yn}from"./detail-drawer-Ce5X0KA6.js";import{a as bn}from"./schedules-CVj4ZaDZ.js";import{t as xn}from"./use-platform-assistant-id-BrviSqKQ.js";import{t as Sn}from"./environment-store-UqJJCyAL.js";import{t as Cn}from"./stt-language-picker-modal-CuKZbgVo.js";var Q=e(o(),1),$=m();function wn({mode:e,onChange:t}){return(0,$.jsx)(`div`,{className:`max-w-[280px]`,children:(0,$.jsx)(_,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Tn({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,$.jsxs)(_n,{id:e,title:t,subtitle:n,accessory:(0,$.jsx)(wn,{mode:r,onChange:i}),children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:a})]})}function En({id:e,title:t,subtitle:n,children:r}){return(0,$.jsxs)(_n,{id:e,title:t,subtitle:n,children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:r})]})}function Dn(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,$.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,$.jsx)(T,{className:`h-3.5 w-3.5`})]})]})]})}function On({status:e,message:t,isLoading:n}){return n?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,$.jsx)(y,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,$.jsx)(C,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,$.jsx)(b,{className:`h-3 w-3`}),`Verification failed`]}):(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function kn({onClick:e,disabled:t}){return(0,$.jsx)(c,{onClick:e,disabled:t,children:`Save`})}function An({onClick:e,filled:t=!1}){return(0,$.jsx)(c,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function jn({guide:e}){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{children:e.description}),(0,$.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,$.jsx)(T,{className:`h-3 w-3`})]})]})]})}function Mn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,$.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function Nn({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=d(),i=l(),o=Ct(),[s,m]=u(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_||!t||h||(g(t),v(!0))},[t,_,h]);let P=f({...Jt(),enabled:!0}),I=P.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,H=!I&&P.isError&&!P.isFetching,U=f({...Gt({path:{assistant_id:e}}),enabled:!z}),W=f({...en({path:{assistant_id:e}}),enabled:!z}),G=U.data?.results?.[0],K=W.data?.results?.[0],ee=G?`${G.subdomain}.${n}`:null,q=f({...Xt({path:{assistant_id:e,id:K?.id??``}}),enabled:!!K?.id,refetchOnWindowFocus:!1}),te=f({...nn({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Q.useEffect)(()=>{s.get(`release`)!==`1`||!G||K||(A(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[K,G,s,m]);let ne=p($t()),J=p(tn()),Y=p(Kt()),re=p(qt()),X=(0,Q.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:Zt({path:t})}),r.invalidateQueries({queryKey:Qt({path:t})}),K?.id&&r.invalidateQueries({queryKey:Yt({path:{...t,id:K.id}})}),r.invalidateQueries({queryKey:an()})},[K?.id,e,r]),ie=(0,Q.useCallback)(async()=>{let t=h.trim().toLowerCase();if(!t){b(`Enter a subdomain.`);return}E(!1);try{await ne.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),g(``),b(null),X(),B.success(`Domain ${t}.${n} registered.`)}catch(e){b(mt(e,void 0,`Failed to register domain.`))}},[e,n,X,ne,h]),ae=(0,Q.useCallback)(async()=>{let t=x.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await Y.mutateAsync({path:{assistant_id:e},body:{username:t}}),S(``),w(null),X(),B.success(`Email address created.`)}catch(e){w(mt(e,void 0,`Failed to create email address.`))}},[e,X,Y,x]),oe=(0,Q.useCallback)(async()=>{if(K?.id){M(!1);try{await re.mutateAsync({path:{assistant_id:e,id:K.id}}),X(),B.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),B.error(`Failed to remove email address.`)}}},[K?.id,e,re,X]),se=(0,Q.useCallback)(async()=>{if(!G?.id)return;if(K){B.error(`Remove the email address first.`);return}A(!1);let t=G.subdomain;try{await J.mutateAsync({path:{assistant_id:e,id:G.id}}),g(t),X(),B.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),B.error(`Failed to release domain.`)}},[K,e,J,G?.id,G?.subdomain,X]);if(P.isLoading)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,$.jsx)(F,{tone:`info`,icon:(0,$.jsx)(k,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:o?void 0:(0,$.jsx)(c,{size:`compact`,onClick:()=>i(wt.plans),children:`Upgrade`}),children:o?cn:(0,$.jsx)($.Fragment,{children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`})});let Z=H?(0,$.jsx)(F,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,$.jsx)(c,{size:`compact`,variant:`outlined`,onClick:()=>P.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return G?K?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:K.address}),(0,$.jsx)(On,{status:te.data?.status,message:te.data?.message,isLoading:te.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(N,{}),onClick:()=>M(!0),disabled:re.isPending,"aria-label":`Remove email address`})]}),(0,$.jsx)(V,{open:j,title:`Remove Email Address`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to remove`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:K.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:oe,onCancel:()=>M(!1)})]}),q.data?.usage&&(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[q.data.usage.sent_today,` /`,` `,q.data.usage.daily_limit,` sent today ·`,` `,q.data.usage.received_today,` received`]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[G.subdomain,`.`,n]}),(0,$.jsx)(On,{status:te.data?.status,message:te.data?.message,isLoading:te.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(N,{}),onClick:()=>A(!0),disabled:J.isPending,"aria-label":`Release domain`})]}),(0,$.jsx)(V,{open:D,title:`Release Domain`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to release`,` `,(0,$.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[G.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:se,onCancel:()=>A(!1)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,$.jsx)(`input`,{value:x,onChange:e=>{S(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,$.jsx)(c,{onClick:ae,disabled:Y.isPending||!x.trim(),children:Y.isPending?`Creating…`:`Create`})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[Z,(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,$.jsx)(Mn,{subdomain:h,onSubdomainChange:e=>{g(e),y&&b(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:y}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,$.jsx)(c,{onClick:()=>E(!0),disabled:ne.isPending||!h.trim(),children:ne.isPending?`Registering…`:`Register`}),(0,$.jsx)(V,{open:T,title:`Set Subdomain`,message:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:h.trim().toLowerCase()||`subdomain`}),` `,`will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ie,onCancel:()=>E(!1)})]})}function Pn(){let e=hn(),r=Et(),{data:o}=f({...rn(),enabled:r}),s=o?.results?.[0]?.handle,c=Sn.use.emailRootDomain(),l=Tt(),[u,d]=(0,Q.useState)(()=>l===`gated`?`your-own`:ce(t(Qe,`managed`),`managed`)),[p,m]=(0,Q.useState)(()=>{let e=t(Ve,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=xn(e,l===`full`&&u===`managed`),_=h??(g?e:null),v=f({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await vt({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Q.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,b=(0,Q.useCallback)(e=>{d(e),n(Qe,e)},[]),S=(0,Q.useCallback)(()=>{n(Ve,p),B.success(`Email settings saved.`)},[p]),C=(0,Q.useMemo)(()=>Ge.find(e=>e.id===p)??Ge[0],[p]),w=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{children:[`Configure `,C.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(T,{className:`h-3 w-3`})]})]})]}),D=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:Ge.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,$.jsx)(x,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`span`,{children:[C.displayName,` API key configured. To reconfigure, run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill.`]})]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(T,{className:`h-3 w-3`})]})]}):w,(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(kn,{onClick:S,disabled:!1})})]});return l===`gated`?(0,$.jsx)(En,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:D}):(0,$.jsx)(Tn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:b,children:u===`managed`?(0,$.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,$.jsx)(sn,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,$.jsx)(Nn,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):D})}function Fn(){let e=hn();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await yt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});re(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?B.error(`Assistant not ready. Please try again.`):B.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function In(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var Ln=`0.11.0`;function Rn(){return dt(Ln)}var zn=`gemini-3.1-flash-image-preview`;function Bn(){let e=hn(),r=d(),i=Et(),{data:o}=f({...Wt({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=Nt({onSuccess:t=>{Lt(r,{path:{assistant_id:e}},t)}}),c=Fn(),[l,u]=In((0,Q.useMemo)(()=>{if(!o)return t(He,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||t(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Q.useState)(()=>t(nt,zn)),h=xe(l),g=h.includes(p)?p:h[0]??zn,[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=at.map(e=>({value:e,label:ct[e]??e})),S=(0,Q.useMemo)(()=>xe(l).map(e=>({value:e,label:Be[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=we({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),T=u,E=(0,Q.useCallback)(async()=>{b(!0);let t=_.trim(),i=C&&t.length>0;try{i&&await c(ot(g),t),await ft();let n=l===`vellum`&&!Rn()?{mode:`managed`}:{provider:l,mode:l===`vellum`?`managed`:`your-own`};await s.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":n}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await xt({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw B.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{r.invalidateQueries({queryKey:It({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(He,l),n(nt,g),i){let t=Ie(e,`api_key`,l);r.setQueryData(t,!0),r.invalidateQueries({queryKey:t}),v(``)}B.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,r]),D=(0,Q.useCallback)(()=>{v(``),m(zn),n(nt,zn)},[]);return(0,$.jsx)(En,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Image generation provider`,value:l,onChange:T,options:x})]}),l===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:Te(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,$.jsx)(H,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:E,disabled:y}),y&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(An,{onClick:D})]})]})})}function Vn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(h,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(h,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function Hn(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Un=5;function Wn(e,t){return`${e} ${t}${e===1?``:`s`}`}function Gn(e){return e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(`is your default profile`),e.callSiteIds.length>0&&n.push(`is used by ${Wn(e.callSiteIds.length,`action override`)}`);let r=[];return e.scheduleNames.length>0&&r.push(Wn(e.scheduleNames.length,`schedule`)),e.deferredReminderCount>0&&r.push(Wn(e.deferredReminderCount,`reminder`)),r.length>0&&n.push(`runs ${Gn(r)}`),n.length===0?`Choose a replacement profile for "${t}". Anything still pointing at it moves there before it is deleted.`:`"${t}" ${Gn(n)}. Pick a replacement below and those references move to it, then "${t}" is deleted.`}function qn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function Jn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let l=e?.scheduleNames??[],u=l.slice(0,Un),d=l.length-u.length,f=e!=null&&Hn(e);return(0,$.jsx)(L.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(L.Content,{size:`sm`,children:[(0,$.jsx)(L.Header,{children:(0,$.jsx)(L.Title,{children:`Choose a Replacement Profile`})}),(0,$.jsxs)(L.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:Kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(qn,{title:`Action overrides`,items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(qn,{title:`Schedules`,items:u}),d>0&&(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:[`and `,d,` more`]})]}),e?.scheduleLookupFailed&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:`We could not check which schedules use this profile. Any schedule pinned to it moves to the replacement as well.`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:`Replacement profile`}),(0,$.jsx)(H,{"aria-label":`Replacement profile`,value:n,onChange:r,placeholder:`Select a replacement…`,options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:fe(e),disabled:t,tooltip:t?`Enable this profile to move schedules onto it.`:void 0}})})]}),i&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(L.Footer,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Yn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:l,onDelete:u}){let d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(ke(e.provider??void 0,e.model,r)),d&&m.push(`Managed by Vellum`);let h=e.availability,g=h?.status===`incomplete`,_=h!=null&&h.status!==`ok`?`${h.message??`This profile's provider is not available.`}${g?` Click to fix.`:``}`:null;return(0,$.jsx)(v,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:`Open profile ${p}`,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[_==null?null:(0,$.jsx)(s,{content:_,children:g?(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":_,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(b,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(b,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":_,role:`img`})})}),f?(0,$.jsx)(I,{tone:`neutral`,children:`Disabled`}):null,t?(0,$.jsx)(I,{tone:`positive`,children:`Default`}):null,(0,$.jsxs)(S.Root,{children:[(0,$.jsx)(S.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(w,{}),"aria-label":`Actions for ${p}`,disabled:i})}),(0,$.jsxs)(S.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(S.Item,{onSelect:a,children:d?`View`:`Edit`}),!t&&!f?(0,$.jsx)(S.Item,{onSelect:o,children:`Make Default`}):null,f?(0,$.jsx)(S.Item,{onSelect:()=>l(!0),children:`Enable`}):d?null:(0,$.jsx)(S.Item,{onSelect:()=>l(!1),children:`Disable`}),d?null:(0,$.jsx)(S.Item,{onSelect:u,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`})]})]})]})})}function Xn(e,t){let n=tt(),{data:r}=f({...At({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=rt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:Z(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}function Zn(e){let t=d();return Nt({onSuccess:n=>{Lt(t,{path:{assistant_id:e}},n),t.invalidateQueries({queryKey:Ht({path:{assistant_id:e}})}),t.invalidateQueries({queryKey:Bt({path:{assistant_id:e}})})}})}var Qn=`0.10.8`;function $n(e){return pt(Qn,e)}var er=`settings-ai-profile-make-active`,tr=`Failed to set the active profile. Please try again.`;function nr(e){let t=Zn(e),n=d(),r=$n(e),i=Ut({onSuccess:()=>{n.invalidateQueries({queryKey:It({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:Ht({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw a(e,{context:r}),B.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},er,tr);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ht(e);throw B.error(t??tr),t||a(e,{context:er}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:o,isPending:t.isPending||i.isPending}}var rr=`The profile was not deleted.`,ir=`Failed to move the schedules. ${rr}`;function ar(e){let t=ht(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${rr}`:ir}function or(e,t,n){let r=nr(e),i=d(),o=pe(),s=t?.llm?.activeProfile??null,c=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),f=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>Z(u,f),[u,f]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:me(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await r.deleteProfile(e,f,{isAdvisor:e===c}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,o=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),c=[],d=0,f=!1;try{let n=(await i.fetchQuery({...jt({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];c=n.filter(e=>!e.isDeferred).map(e=>e.name),d=n.filter(e=>e.isDeferred).length}catch(e){a(e,{context:`settings-ai-profile-delete-schedule-scan`}),f=!0}if(!(r||o.length>0||c.length>0||d>0)&&!f){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:o,scheduleNames:c,deferredReminderCount:d,scheduleLookupFailed:f};h(p),y(E(t,Hn(p))),_(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),Hn(m))try{await bn(e,m.name,v),await i.invalidateQueries({queryKey:Dt({path:{assistant_id:e}})})}catch(e){a(e,{context:`settings-ai-profile-reassign-schedules`}),_(ar(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function sr(){}function cr({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{entries:s}=Xn(e,t),l=nr(e),u=or(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vn,{title:`Profiles`,action:(0,$.jsx)(c,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(j,{}),disabled:t==null,children:`Create Profile`}),children:t==null?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`Loading profiles…`}):s.length===0?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):s.map(e=>(0,$.jsx)(Yn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(sr),onSetStatus:t=>void l.setStatus(e.name,t).catch(sr),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Jn,{...u.blockedDeleteModalProps})]})}var lr={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function ur(e){return e in lr}function dr(e){let t=e.baseUrl??``;try{e.baseUrl&&(t=new URL(e.baseUrl).host)}catch{}let n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function fr(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function pr(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return dr(e);let t=[],n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?ze(n):ye(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=fr(e);return a&&t.push(a),t.join(` • `)}function mr({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let l=e.isManaged??!1,u=et(e),d=ur(e.provider),f=pr(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(v,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?`Open provider ${u}`:void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(I,{tone:`neutral`,title:`Runs on Vellum's managed credentials.`,children:`Managed`}):null,t?(0,$.jsx)(I,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Cost, Speed) use this provider.`,children:`Default`}):null,e.provider===`ollama`?(0,$.jsx)(I,{tone:`neutral`,title:`Runs models on this machine.`,children:`Local`}):null,e.provider===`openai-compatible`?(0,$.jsx)(I,{tone:`neutral`,title:`A provider you created, served by an OpenAI-compatible endpoint.`,children:`Custom`}):null,g?(0,$.jsxs)(S.Root,{children:[(0,$.jsx)(S.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(w,{}),"aria-label":`Actions for ${u}`})}),(0,$.jsxs)(S.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(S.Item,{onSelect:a,children:`Edit`}):null,p?(0,$.jsx)(S.Item,{disabled:i,onSelect:o,children:`Set as default`}):null,h?(0,$.jsx)(S.Item,{onSelect:s,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function hr(e,t){let n=d(),r={path:{assistant_id:e}},i=p({...Ft(),onSuccess:()=>{n.invalidateQueries({queryKey:Rt(r)}),n.invalidateQueries({queryKey:It(r)}),n.invalidateQueries({queryKey:Ht(r)})},onError:e=>{a(e,{context:`settings-ai-set-default-provider`}),B.error(`Failed to set the default provider. Please try again.`)}});function o(t){ur(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function s(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await gt({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Pt(r)}),t?.onDeleted?.(i)):a?.status===409?B.error(`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`):B.error(`Failed to delete the provider. Please try again.`)}catch(e){a(e,{context:`settings-ai-provider-delete`}),B.error(`Failed to delete the provider. Please try again.`)}}return{setDefault:o,isSettingDefault:s,deleteConnection:c}}function gr({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{data:a,isLoading:o,isError:s}=f(kt({path:{assistant_id:e}})),l=qe(),{data:u}=f({...zt({path:{assistant_id:e}}),enabled:l}),d=l?u?.resolvedConnectionName??null:null,p=hr(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=a?.connections??[];return[...e.filter(e=>e.provider===se),...e.filter(e=>e.provider!==se)]},[a]);return(0,$.jsx)(Vn,{title:`Providers`,action:(0,$.jsx)(c,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(j,{}),children:`Add Provider`}),children:o?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(U,{className:`h-10 rounded-lg`},e))}):s?(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):m.length===0?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):m.map(e=>(0,$.jsx)(mr,{connection:e,isDefault:e.name===d,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function _r({panel:e,onOpenPanel:t,onClosePanel:n}){let r=hn(),{data:i}=f({...Wt({path:{assistant_id:r}}),staleTime:3e4}),a=qe(),{data:o}=f({...zt({path:{assistant_id:r}}),enabled:a}),s=o?.availability,{data:l}=f({...kt({path:{assistant_id:r}})}),u=l?.connections,d=i?.llm?.callSites??{},p=Object.entries(d).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(En,{title:`Language Model`,subtitle:`Profiles choose which model answers. Providers supply access to it`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s&&s.status!==`ok`&&(0,$.jsx)(F,{tone:s.status===`unknown`?`warning`:`error`,children:s.message??`Your default provider is not available.`}),r&&(0,$.jsx)(cr,{assistantId:r,config:i,connections:u,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),r&&(0,$.jsx)(gr,{assistantId:r,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Vn,{title:`Overrides`,count:p,action:(0,$.jsx)(c,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:`Manage`})})]})})}function vr(e,{onSaved:t}={}){let n=Zn(e),{data:r}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),o=r?.llm?.profileOrder??[];async function s(r,s,c){let l=c?.mode??`replace`,u=!(r in i);if(l===`merge`&&!u){await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:s}}}}),t?.();return}let d={profiles:{[r]:s}};if(u&&(d.profileOrder=o.includes(r)?o:[...o,r]),u)await n.mutateAsync({path:{assistant_id:e},body:{llm:d}});else{let t=i[r];await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:null}}}});try{await n.mutateAsync({path:{assistant_id:e},body:{llm:d}})}catch(i){throw a(i,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:t}}}}).catch(()=>{}),i}}u&&B.success(`Profile "${s.label??r}" created`),t?.()}return{saveProfile:s,isPending:n.isPending}}function yr({assistantId:e,profileName:t,onClose:n}){let{data:r}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),{data:i}=f({...kt({path:{assistant_id:e}})}),a=i?.connections,o=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),s=Object.keys(o),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=o[t];return e?{name:t,...e}:void 0},[t,o]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:p}=vr(e,{onSaved:n}),m=Je({mode:u,profileName:t??void 0,initialValues:l,existingNames:s,connections:a,assistantId:e,onSave:d}),h=or(e,r,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&r!=null&&!(t in o);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{title:m.effectiveMode===`create`?`New Profile`:l?.label??t??`Profile`,closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(I,{tone:`neutral`,children:`Managed by Vellum`}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(N,{}),tintColor:`var(--system-negative-strong)`,onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g,children:g?`Deleting…`:`Delete`}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(c,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:`Save As New`}),m.hasViewModeChanges?(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?`Saving…`:`Save`}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?`Saving…`:m.effectiveMode===`create`?`Create Profile`:`Save Changes`})}),children:(0,$.jsx)(Ae,{editor:m,assistantId:e,connections:a,variant:`panel`})}),(0,$.jsx)(Jn,{...h.blockedDeleteModalProps})]})}function br({value:e,profileOptions:t,disabled:n,onChange:r}){return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:`Advisor`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`The profile your assistant consults for a second opinion when it wants to check a plan or review its own work.`})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,$.jsx)(H,{value:e,onChange:r,options:t,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`,disabled:n})})]})})}var xr=`__custom__`;function Sr(e){return e?!!(e.profile||e.provider||e.model):!1}function Cr(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function wr(e,t){let n=Sr(e);return n===Sr(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function Tr(e){return`${e} ${e===1?`action`:`actions`}`}function Er({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:o,onApplied:s}){let l=Zn(e),u=pe(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=Cr(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,f]),[m,g]=(0,Q.useState)(()=>p[0]?.name??``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>f.get(e.id)?.profile===m),[t,f,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:fe(e)})),[p]),D=(0,Q.useMemo)(()=>ue(i,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:fe(e)})),[i,m,d]),k=ae(i,m),j=ae(i,_),M=y.size===0;function N(e){g(e),b(new Set),e===_&&v(``)}function P(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!_||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:_};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),B.success(`Updated ${Tr(T.length)} to "${j}".`),s(),o()}catch(e){let t=ht(e);B.error(t??`Failed to update overrides. Please try again.`),t||a(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(L.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(L.Content,{size:`md`,children:[(0,$.jsx)(L.Header,{children:(0,$.jsx)(L.Title,{children:`Change Action Overrides`})}),(0,$.jsxs)(L.Body,{className:`space-y-4`,children:[(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:`Update the actions that currently use one profile. The result is saved as individual overrides.`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(H,{id:`bulk-swap-source`,label:`Currently using`,value:m,onChange:N,options:E}),(0,$.jsx)(H,{id:`bulk-swap-target`,label:`Change to`,value:_,onChange:v,options:D,placeholder:`Select a profile…`})]}),(0,$.jsxs)(F,{tone:`info`,title:`This happens once.`,children:[`It changes the selected actions that use `,k,` today. It does not create an ongoing rule between profiles.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(h,{variant:`body-medium-default`,as:`p`,children:[Tr(w.length),` currently`,` `,w.length===1?`uses`:`use`,` `,k]}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:`Choose which actions to update.`})]}),(0,$.jsx)(c,{variant:`ghost`,onClick:()=>b(M?new Set(w.map(e=>e.id)):new Set),children:M?`Clear all`:`Select all`})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(A,{checked:!y.has(e.id),onCheckedChange:t=>P(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?`Override`:`Default`})]},e.id))})]})]}),(0,$.jsxs)(L.Footer,{children:[(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:[Tr(T.length),` will change`]}),(0,$.jsx)(c,{variant:`ghost`,onClick:o,disabled:x,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,disabled:!m||!_||T.length===0||x,onClick:()=>void I(),children:x?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Apply to ${Tr(T.length)}`})]})]})})}function Dr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let l=Sr(i),u=!i||!l?``:i.provider||i.model?xr:i.profile??``,d=u===xr,f=Le(),p=(o??[]).some(e=>e.provider===ge),m=[...f,...p?[ge]:[]],h=f[0]??G[0],g=i?.provider,_=q(g)?g:g===`chatgpt`?ge:void 0,v=_!==void 0&&m.some(e=>e===_),y=_??h,b=Re(y,``,(o??[]).filter(e=>Fe(e.provider,y)))?ze(y):ye(y),x=b.map(e=>({value:e.id,label:e.displayName})),S=typeof i?.model==`string`?i.model:``;if(S&&!b.some(e=>e.id===S)){let e=ye(y).find(e=>e.id===S)?.displayName??S;x.push({value:S,label:`${e} (unavailable)`})}let C=!!i?.provider&&!i?.model,w=[...m.map(e=>({value:e,label:K[e]??e})),..._&&!v?[{value:_,label:`${K[_]??_} (unavailable)`}]:[]];function T(t){t===`__custom__`?s(e,{profile:null,provider:h,model:ee(h)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function E(t){let n=ee(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function D(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,$.jsx)(H,{value:u,onChange:T,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,$.jsx)(z,{checked:l,onChange:t=>c(e,t),"aria-label":`Override ${t}`})]})]}),l&&d&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y??``,onChange:E,options:w})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,$.jsx)(H,{value:i?.model??``,onChange:D,options:x})]})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Or({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!Sr(n)?``:n.provider||n.model?xr:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(Dr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function kr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;Sr(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function Ar(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function jr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!wr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>Sr(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>kr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>Ar(c),[c])}}function Mr({assistantId:e,onClose:t}){let{data:n}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),r=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),i=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>n?.llm?.callSites??{},[n?.llm?.callSites]),s=(0,Q.useMemo)(()=>Z(r,i),[r,i]),l=Le(),u=pe(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),p=Zn(e),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:E}=f({...Vt({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:D}=f({...kt({path:{assistant_id:e}}),enabled:!!e}),k=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),A=!w&&!T&&!!C,j=!!n,N=A&&j,P=(0,Q.useMemo)(()=>k.map(e=>e.id),[k]),F=n?.llm?.advisorProfile??``,{drafts:I,advisorProfile:L,advisorDirty:z,callSiteDraftsDirty:H,hasUnsavedDrafts:U,hasValidationError:W,setDraft:K,setAdvisor:q,clearEdits:te,buildSavePatch:ne,buildResetPatch:Y}=jr({catalogCallSiteIds:P,persistedOverrides:o,persistedAdvisor:F,isSeeded:N}),re=(0,Q.useMemo)(()=>new Set(P),[P]),X=(0,Q.useCallback)(e=>ae(s,e),[s]),ie=(0,Q.useCallback)(e=>({value:e.name,label:fe(e),...le(e,s,d)===`undispatchable`?{icon:(0,$.jsx)(b,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:J(e)}:{}}),[s,d]),se=(0,Q.useMemo)(()=>ue(s,[F],d).map(ie),[s,F,ie,d]),ce=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),de=(0,Q.useMemo)(()=>k.some(e=>Cr(e,o[e.id])!==null),[k,o]),me=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>re.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,re]),he=(0,Q.useCallback)(e=>[...ue(s,[e],d).map(ie),{value:xr,label:`Custom`}],[s,ie,d]),ge=(0,Q.useMemo)(()=>{if(!m.trim())return k;let e=m.toLowerCase();return k.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[k,m]),_e=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ge.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=ge.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[C,ge]),ve=(0,Q.useCallback)((e,t)=>{if(!t){K(e,null);return}let n=oe(s,k.find(t=>t.id===e)?.defaultProfile,d);if(n)K(e,{profile:n});else{let t=l[0]??G[0];K(e,{provider:t,model:ee(t)??``})}},[k,s,l,K,d]),ye=(0,Q.useCallback)(async()=>{_(!0);try{let n=ne();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...H?{callSites:n}:{},...z?{advisorProfile:L}:{}}}}),t(),B.success(`Overrides saved.`)}catch(e){B.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[ne,H,z,L,t,p,e]),be=(0,Q.useCallback)(async()=>{_(!0);try{let n=Y();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),B.success(`Overrides reset.`)}catch(e){B.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[Y,t,p,e]);return(0,$.jsxs)(gn,{title:`Action Overrides`,closeVariant:`outlined`,onClose:t,footer:(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(c,{variant:`outlined`,onClick:()=>y(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,$.jsx)(c,{variant:`primary`,onClick:()=>void ye(),disabled:!U||W||g,children:g?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Save`})]}),children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(R,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search actions…`,leftIcon:(0,$.jsx)(M,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>S(!0),disabled:!N||g||U||!de,title:U?`Save or reset your changes first`:de?void 0:`No actions currently use a profile`,children:`Bulk change`})]}),j&&ce&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:`Advisor`}),(0,$.jsx)(br,{value:L,profileOptions:se,disabled:g,onChange:q})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(O,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&C&&(0,$.jsx)(Or,{groups:_e,drafts:I,buildProfileOptionsForRow:he,profileLabelFor:X,advisorMatchesSearch:ce,connections:D?.connections,onDraftChange:K,onToggle:ve})]}),x&&C&&(0,$.jsx)(Er,{assistantId:e,callSites:k,domains:C.domains,persistedOverrides:o,orderedProfiles:s,onClose:()=>S(!1),onApplied:te}),(0,$.jsx)(V,{open:v,title:`Reset to Defaults`,message:`Every action override will be reset and will follow its default. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{y(!1),be()},onCancel:()=>y(!1)})]})}function Nr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,onSave:o,onCancel:s}){let[l,u]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[g,_]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[v,y]=(0,Q.useState)(t?.baseUrl??``),[b,x]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),j=d(),M=(0,Q.useMemo)(()=>De(g),[g]),N=m===`api_key`&&M!==null,{hasStoredCredential:P,isLoading:F}=we({assistantId:n,credentialKind:`credential`,credentialName:M?`${M.service}:${M.field}`:``,enabled:N}),{credentials:I}=Se({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;u(t?.label??``),t?.auth.type===`api_key`?_(t.auth.credential):_(t?``:`credential/${e}/api_key`),T(null),y(t?.baseUrl??``),x(t?.models?t.models.map(e=>e.id).join(`, `):``),O(``),A(!1)},[t]);let z=l.trim()!==(t?.label??``).trim(),B=E&&z?lt(l,i,t?.name):null,V=f.trim().length>0&&B===null;async function H(){if(V){C(!0),T(null);try{let e;if(m===`api_key`){let t=g.trim()||`credential/${p}/api_key`,r=D.trim();if(r){A(!0);try{let e=De(t);await yt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Ie(n,`credential`,e?`${e.service}:${e.field}`:``);j.setQueryData(i,!0),j.invalidateQueries({queryKey:Mt({path:{assistant_id:n}})})}catch{T(`Failed to save API key. Please try again.`);return}finally{A(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(`Nothing to edit. Close and try again.`);return}let r=l.trim()||null,i={auth:e,label:r,...E&&{base_url:v.trim()||null,models:b.trim()?b.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:s,response:c}=await _t({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ee(c?.status,s)??Ce(c?.status));return}if(!a){T(`Server returned an empty response. Please try again.`);return}o(a)}catch{T(`Failed to save provider. Please try again.`)}finally{C(!1)}}}let U=I.filter(e=>e.service===p),W=e!==`create`&&t?.auth.type===`api_key`,G=U.length>0||W,K=Te(`Enter your API key`,P);if(e===`create`)return(0,$.jsx)(je,{variant:a===`panel`?`inline`:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:o,onCancel:s});let ee=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,$.jsx)(R,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),B?(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Me[B]}):null]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,$.jsx)(R,{value:v,onChange:e=>y(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,$.jsx)(R,{value:b,onChange:e=>x(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),m===`api_key`&&(0,$.jsx)(Oe,{apiKeyValue:D,onApiKeyChange:O,credential:g,onCredentialChange:_,isLoadingCredential:F,apiKeyPlaceholder:K,provider:p,providerCredentials:U,showAdvancedSection:G,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(be,{assistantId:n,onConnected:o}),w&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),q=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!V||S||k,onClick:()=>void H(),children:S?`Saving…`:`Save Changes`})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ee,(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:q})]}):(0,$.jsxs)(L.Content,{size:`md`,children:[(0,$.jsxs)(L.Header,{children:[(0,$.jsx)(L.Title,{children:`Edit Provider`}),(0,$.jsx)(L.Description,{children:t?`Editing ${et(t)}.`:`Edit provider settings.`})]}),(0,$.jsx)(L.Body,{children:ee}),(0,$.jsx)(L.Footer,{children:q})]})}function Pr({assistantId:e,connectionName:t,onClose:n}){let r=d(),{data:i}=f(kt({path:{assistant_id:e}})),a=(0,Q.useMemo)(()=>i?.connections??[],[i]),o=(0,Q.useMemo)(()=>t==null?void 0:a.find(e=>e.name===t),[t,a]),s=t!=null&&i!=null&&o==null;(0,Q.useEffect)(()=>{s&&n()},[s,n]);function c(){r.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})}),r.invalidateQueries({queryKey:Rt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(gn,{title:o?et(o):`Add Provider`,closeVariant:`outlined`,onClose:n,children:t==null||o!=null?(0,$.jsx)(Nr,{mode:o?`edit`:`create`,connection:o,variant:`panel`,assistantId:e,existingNames:a.map(e=>e.name),connections:a,onSave:c,onCancel:n}):null})}var Fr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Ir={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Lr=`deepgram`;function Rr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=hn(),s=e??o,c=Et(),l=d(),[u]=(0,Q.useState)(()=>st.filter(e=>!e.requiresNativeDictation||Pe())),p=Lr,{data:m}=f({...Wt({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?Ir[g]:void 0;if(e&&u.some(t=>t.id===e))return e;let n=t(it,p);return u.some(e=>e.id===n)?n:p},[g,u,p]),v=!!g,[y,b]=In(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=ln(s),[E,D]=(0,Q.useState)(!1),O=x&&y===_&&(Fr[y]?.provider===C||!!g&&!Ir[g]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=t(it,p);e===`macos-native`&&!u.some(t=>t.id===e)&&n(it,p)},[u,p]);let I=(0,Q.useMemo)(()=>u.find(e=>e.id===y)??u[0],[u,y]),L=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(t(Ye+y,``).length>0),A(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=k.trim().length>0;return e||t},[y,_,k]),V=(0,Q.useCallback)(async()=>{let e=k.trim();n(it,y),e.length>0&&n(Ye+y,e);let r=Fr[y];F(!0);try{if(r?.credentialService){let n=e.length>0?e:t(Ye+y,``);if(n.length>0){let{response:e}=await St({path:{assistant_id:s},body:{service:r.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(r&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=r?.provider??Lr,{response:t}=await bt({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return e.length>0&&M(!0),A(``),l.invalidateQueries({queryKey:It({path:{assistant_id:s}})}),B.success(`Speech-to-text settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{F(!1)}},[s,y,k,I,_,v,g,l]);(0,Q.useEffect)(()=>{a?.({hasChanges:z,saving:N,save:V})},[a,z,N,V]);let U=(0,Q.useCallback)(()=>{n(Ye+y,``),M(!1),A(``)},[y]),W=j?`•••••••• (Enter a new key to replace)`:I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y,onChange:b,options:u.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Spoken language`}),(0,$.jsx)(Ze,{"aria-label":`Spoken language`,"aria-haspopup":`dialog`,onClick:()=>D(!0),value:un(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Applies from your next spoken turn.`}),(0,$.jsx)(Cn,{open:E,onOpenChange:D,title:`Spoken language`,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),L&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(R,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:W,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(P,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!i&&I.credentialsGuide&&(0,$.jsx)(jn,{guide:I.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!r||j)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!r&&(0,$.jsx)(kn,{onClick:V,disabled:!z||N}),j&&(0,$.jsx)(An,{onClick:U})]})]})}function zr(){return(0,$.jsx)(En,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,$.jsx)(Rr,{})})}async function Br(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Vr(n,r,i):t===`deepgram`?await Hr(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Vr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await Ur(i,`ElevenLabs rejected the request.`)}}async function Hr(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await Ur(n,`Deepgram rejected the request.`)}}async function Ur(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Wr({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Q.useState)(!1),{voices:o}=pn(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,$.jsxs)(g.Root,{open:i,onOpenChange:a,children:[(0,$.jsx)(g.Trigger,{asChild:!0,children:(0,$.jsx)(Ze,{"aria-label":`Voice`,value:s?dn(s.description):`Select a voice`,className:r})}),(0,$.jsx)(g.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(fn,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Gr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Kr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=hn(),s=e??o,l=ut.use.name()??`your assistant`,u=Et(),p=d(),{data:m}=f({...Ot({path:{assistant_id:s}}),enabled:u,staleTime:1/0}),h=(0,Q.useMemo)(()=>{let e=m?.providers;if(!e)return Ne;if(e.some(e=>e.id===`vellum`))return e;let t=Ne.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=f({...Wt({path:{assistant_id:s}}),enabled:u,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Q.useMemo)(()=>v??t(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=In(b),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),{voices:L,defaultModel:z,fetched:V}=mn(s,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??z??``,[W,G]=In(U),K=L.find(e=>e.model===W)??L[0],[ee,q]=(0,Q.useState)(null),te=L.some(e=>e.model===U),ne=ee??(V&&U!==``&&!te),J=(0,Q.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),Y=S===`vellum`&&J.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,re=(0,Q.useCallback)(e=>{let n=t(Ue+e,``),r=t($e+e,``);M(n.length>0),O(r),A(r),T(``)},[]);(0,Q.useEffect)(()=>{re(S)},[S,re]);let X=(0,Q.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=E.trim()!==k;return e||t||n||Y},[S,b,w,E,k,Y]),ie=(0,Q.useCallback)(async()=>{let e=w.trim(),r=E.trim(),i=J.id;n(We,i),e.length>0&&n(Ue+i,e),n($e+i,r);let a=e.length>0?e:t(Ue+i,``),o=Gr[i];I(!0);try{if(a.length>0){let{response:e}=await St({path:{assistant_id:s},body:{service:i,field:`api_key`,value:a,label:`${J.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:r}}}:{},...Y?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await bt({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(r),T(``),p.invalidateQueries({queryKey:It({path:{assistant_id:s}})}),B.success(`Text-to-speech settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{I(!1)}},[s,S,W,Y,w,E,J,b,x,p]);(0,Q.useEffect)(()=>{a?.({hasChanges:X,saving:F,save:ie})},[a,X,F,ie]);let ae=(0,Q.useCallback)(()=>{n(Ue+S,``),M(!1),T(``)},[S]),oe=(0,Q.useCallback)(async()=>{P(!0);try{let e=t(Ue+S,``),n=w.trim(),r=n.length>0?n:e;if(r.length===0){B.error(`Save an API key for this provider before testing.`);return}let i=t($e+S,``),a=E.trim(),o=await Br({provider:S,apiKey:r,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){B.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{P(!1)}},[l,w,S,E]),se=j?`•••••••• (Enter a new key to replace)`:J.apiKeyPlaceholder,Z=S===`vellum`,ce=Z&&J.supportsVoiceSelection,le=(0,$.jsxs)(c,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),L.some(e=>e.model===W)||G(z||L[0]?.model||``)},children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),ue=ce&&ne&&L.length>0?le:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(R,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:se,fullWidth:!0})]}),ce&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),ne?(0,$.jsx)(R,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):K?(0,$.jsx)(Wr,{assistantId:s,value:W,onChange:G}):V&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),J.supportsVoiceSelection&&!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,$.jsx)(R,{type:`text`,value:E,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!Z&&(0,$.jsx)(jn,{guide:J.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!Z&&(0,$.jsx)(c,{variant:`outlined`,onClick:oe,disabled:N,children:N?`Testing…`:`Test`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[ue,!r&&(0,$.jsx)(kn,{onClick:ie,disabled:!X||F}),j&&!Z&&(0,$.jsx)(An,{onClick:ae})]})]})]})}function qr(){return(0,$.jsx)(En,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,$.jsx)(Kr,{})})}var Jr=`default`;function Yr(){let e=hn(),i=d(),{data:o}=f({...Wt({path:{assistant_id:e}}),staleTime:3e4}),s=Nt({onSuccess:t=>{Lt(i,{path:{assistant_id:e}},t)}}),c=Fn(),l=(0,Q.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||t(`vellum:ai:webFetchProvider`,Jr):t(Xe,Jr),[o]),[u,p]=(0,Q.useState)(!1),[m,h]=In(l),[g,_]=(0,Q.useState)(``),v=Y.has(m),{hasStoredCredential:y}=we({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=u||v&&!y&&!b||m===l&&!b,S=Te(W[m]??`Enter your API key`,y),C=(0,Q.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(Xe,m),r){let r=X(m);r&&n(r,t);let a=Ie(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}B.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Q.useCallback)(()=>{let e=X(m);e&&r(e),_(``),h(Jr),n(Xe,Jr)},[m,h]);return(0,$.jsx)(En,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:m,onChange:h,options:te.map(e=>({value:e,label:_e[e]??e}))})]}),v&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:C,disabled:x}),u&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(An,{onClick:w,filled:!0})]})]})})}var Xr=`0.10.12`;function Zr(){return dt(Xr)}function Qr(){let e=hn(),i=d(),o=Et(),{data:s}=f({...Wt({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=Nt({onSuccess:t=>{Lt(i,{path:{assistant_id:e}},t)}}),l=Fn(),u=(0,Q.useMemo)(()=>{if(!s)return t(Ke,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||t(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Q.useState)(!1),[h,g]=In(u),[_,v]=(0,Q.useState)(``),y=ie.has(h),{hasStoredCredential:b}=we({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===u&&!x,C=Te(ve[h]??`Enter your API key`,b),w=(0,Q.useCallback)(async()=>{m(!0);let t=_.trim(),r=de(h),o=y&&t.length>0;try{o&&await l(h,t),await ft();let n=h===`vellum`?Zr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(Ke,h),o){r&&n(r,t);let a=Ie(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}B.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),T=(0,Q.useCallback)(()=>{let e=de(h);e&&r(e),v(``),g(`inference-provider-native`),n(Ke,`inference-provider-native`)},[h,g]);return(0,$.jsx)(En,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Web search provider`,value:h,onChange:g,options:he.map(e=>({value:e,label:ne[e]??e}))})]}),h===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,$.jsx)(R,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kn,{onClick:w,disabled:S}),p&&(0,$.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,$.jsx)(An,{onClick:T,filled:!0})]})]})})}function $r(){let e=hn(),t=on(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(Dn,{}),(0,$.jsx)(_r,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Qr,{}),(0,$.jsx)(Yr,{}),(0,$.jsx)(Pn,{}),(0,$.jsx)(Bn,{}),(0,$.jsx)(qr,{}),(0,$.jsx)(zr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(Mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(Pr,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(yr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(vn,{children:s}):s?(0,$.jsx)(yn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{$r as AiPage};
|