@redocly/replay 0.27.0-next.6 → 0.27.0-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{replay-AiChatProvider-D7E0a83D.js → replay-AiChatProvider-DHIxHTKX.js} +6 -6
  2. package/dist/{replay-AiChatProvider-p9SioFWy.js → replay-AiChatProvider-O8HHQobN.js} +1 -1
  3. package/dist/{replay-AiChatSqliteDBStorage-CKQJ5VZi.js → replay-AiChatSqliteDBStorage-DNMrzkJg.js} +1 -1
  4. package/dist/{replay-AiChatSqliteDBStorage-DgGB1XKW.js → replay-AiChatSqliteDBStorage-DjUq9VX3.js} +1 -1
  5. package/dist/{replay-AiPanel-DvOGYsWl.js → replay-AiPanel-CR815YqV.js} +1178 -1111
  6. package/dist/replay-AiPanel-CfYBCkrN.js +868 -0
  7. package/dist/{replay-SqliteDBStorage-D_31Bd3Z.js → replay-SqliteDBStorage-B3oYWXem.js} +1 -1
  8. package/dist/{replay-SqliteDBStorage-CNJbZXTw.js → replay-SqliteDBStorage-CC9kLioX.js} +1 -1
  9. package/dist/{replay-agent-loop-DklepPbJ.js → replay-agent-loop-CCYOzyHo.js} +3 -3
  10. package/dist/{replay-agent-loop-fKCHgyOD.js → replay-agent-loop-CTq5eJ4u.js} +1 -1
  11. package/dist/{replay-ai-chat-mappers-D-vUBq2s.js → replay-ai-chat-mappers-B_wovMvG.js} +1 -1
  12. package/dist/{replay-ai-chat-mappers-IWtvE0Nl.js → replay-ai-chat-mappers-C8y5UhCq.js} +1 -1
  13. package/dist/{replay-create-model-CfrWgdF7.js → replay-create-model-C5yvtnXA.js} +2 -2
  14. package/dist/{replay-create-model-xGRAIhcu.js → replay-create-model-CBCmuEKC.js} +2 -2
  15. package/dist/{replay-db-XlueEDU-.js → replay-db-CCBQadnT.js} +3 -3
  16. package/dist/{replay-db-BtdwaWh3.js → replay-db-DfOjLqsq.js} +7 -7
  17. package/dist/{replay-external-resolver-Skh0OGde.js → replay-external-resolver-B6tpqUZt.js} +1 -1
  18. package/dist/{replay-external-resolver-D6VSVDwt.js → replay-external-resolver-BRouROm6.js} +2 -2
  19. package/dist/{replay-index-BEzVYZeb.js → replay-index-B_OHqSlS.js} +5 -5
  20. package/dist/{replay-index-CCvitTKt.js → replay-index-Bzttek8l.js} +1 -1
  21. package/dist/{replay-index-DXnDNeqk.js → replay-index-BzzBKjHm.js} +22915 -22423
  22. package/dist/{replay-index-BOB__Jm6.js → replay-index-Cpkh9r0X.js} +1 -1
  23. package/dist/{replay-index-S_wAPmTA.js → replay-index-Dfnqt_IZ.js} +1153 -1131
  24. package/dist/{replay-index-fVC8e5y9.js → replay-index-Xq6K7XSm.js} +1 -1
  25. package/dist/{replay-lint-DjMIgYfF.js → replay-lint-DlDmPTBV.js} +6950 -6653
  26. package/dist/{replay-lint-graphql-Bltv-T6_.js → replay-lint-graphql-BQJ00lU4.js} +1 -1
  27. package/dist/{replay-lint-graphql-bkrdHRy7.js → replay-lint-graphql-DHOq8lRT.js} +1 -1
  28. package/dist/replay-lint-gtuMJgII.js +184 -0
  29. package/dist/{replay-resolve-CQL6WBG1.js → replay-resolve-DqFS69S_.js} +1 -1
  30. package/dist/{replay-resolve-BhcSceq-.js → replay-resolve-DsgcWnjC.js} +1 -1
  31. package/dist/{replay-respect-run-rJm4W93K.js → replay-respect-run-7Cwe1_ri.js} +23 -23
  32. package/dist/{replay-respect-run-CecN1j9r.js → replay-respect-run-D1zyh-5j.js} +297 -295
  33. package/dist/{replay-tauri-path--BfusnkB.js → replay-tauri-path-BAY3g5sW.js} +2 -2
  34. package/dist/{replay-tauri-path--8KtMkGg.js → replay-tauri-path-CaVeI3a-.js} +1 -1
  35. package/dist/{replay-useAiChatQueries-Btd-PmIH.js → replay-useAiChatQueries-CxZNLVje.js} +155 -153
  36. package/dist/{replay-useAiChatQueries-B1-NwsZz.js → replay-useAiChatQueries-D99tAUpY.js} +4 -2
  37. package/dist/{replay-validate-key-Bk0SFd3-.js → replay-validate-key-Cv0mvYDS.js} +1 -1
  38. package/dist/{replay-validate-key-CYsfegSv.js → replay-validate-key-Di8MCBz7.js} +2 -2
  39. package/dist/replay.cjs +1 -1
  40. package/dist/replay.js +1 -1
  41. package/package.json +4 -4
  42. package/dist/replay-AiPanel-BLkqnlmb.js +0 -849
  43. package/dist/replay-lint-BCVeL_wb.js +0 -184
@@ -1,849 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),h=require("react"),V=require("styled-components"),v=require("@redocly/theme"),f=require("./replay-index-S_wAPmTA.js"),g=require("./replay-useAiChatQueries-B1-NwsZz.js"),_=require("./replay-db-XlueEDU-.js");require("@tanstack/react-query");const Be=require("react-router-dom"),Fe=e=>e&&e.__esModule?e:{default:e},l=Fe(V),W=l.default.div`
2
- width: var(--search-ai-thinking-dot-size);
3
- height: var(--search-ai-thinking-dot-size);
4
- border-radius: 50%;
5
- background: var(--search-ai-thinking-dot-color);
6
- animation: bounce 1.4s infinite ease-in-out;
7
-
8
- &:nth-child(1) {
9
- animation-delay: -0.32s;
10
- }
11
-
12
- &:nth-child(2) {
13
- animation-delay: -0.16s;
14
- }
15
-
16
- &:nth-child(3) {
17
- animation-delay: 0s;
18
- }
19
-
20
- @keyframes bounce {
21
- 0%,
22
- 80%,
23
- 100% {
24
- opacity: 0.2;
25
- transform: scale(0.8);
26
- }
27
- 40% {
28
- opacity: 1;
29
- transform: scale(1);
30
- }
31
- }
32
- `,Ce=280;function te(){const[e,t]=h.useState(()=>f.getSemanticSearchService().getIndexingActivityState().inProgress);return h.useEffect(()=>f.getSemanticSearchService().subscribe("indexing-activity",r=>{t(r.inProgress)}),[]),i.jsx(Ge,{$open:e,children:i.jsx(We,{children:i.jsx(Ue,{$open:e,"aria-hidden":!e,children:i.jsx(v.Tooltip,{tip:"We're building a search index of your project. Until it's ready, the assistant may need more context in each reply to stay accurate, which can use more tokens.",placement:"top",width:"240px",arrowPosition:"left",children:i.jsxs(qe,{role:"status","aria-live":"polite","aria-label":"Indexing in progress...",children:[i.jsx("div",{children:i.jsx(W,{})}),i.jsx(Ye,{children:"Indexing in progress..."})]})})})})})}const Ge=l.default.div`
33
- display: grid;
34
- grid-template-rows: ${({$open:e})=>e?"1fr":"0fr"};
35
- transition: grid-template-rows ${Ce}ms ease-out;
36
- `,We=l.default.div`
37
- min-height: 0;
38
- overflow: hidden;
39
- `,Ue=l.default.div`
40
- opacity: ${({$open:e})=>e?1:0};
41
- transition: opacity ${Ce}ms ease-out;
42
- pointer-events: ${({$open:e})=>e?"auto":"none"};
43
- padding: var(--spacing-xs);
44
- padding-top: var(--spacing-xxs);
45
- `,qe=l.default.div`
46
- width: 100%;
47
- display: flex;
48
- align-items: center;
49
- gap: var(--spacing-xxs);
50
- background: var(--layer-color);
51
- padding: var(--spacing-xs) var(--spacing-sm);
52
- border-radius: var(--border-radius);
53
- font-size: var(--font-size-sm);
54
- line-height: var(--line-height-sm);
55
- `,Ye=l.default.div`
56
- flex: 1;
57
- min-width: 0;
58
- `,Ke=e=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:i.jsx("path",{d:"M13.0094 7.61066L3.38435 2.79816C3.30892 2.76043 3.22418 2.74532 3.14035 2.75463C3.05652 2.76394 2.97717 2.79729 2.91186 2.85066C2.84948 2.90294 2.80292 2.97158 2.77742 3.04886C2.75191 3.12615 2.74847 3.20902 2.76748 3.28816L3.92685 7.56253H8.87498V8.43753H3.92685L2.74998 12.6988C2.73214 12.7649 2.73006 12.8342 2.7439 12.9013C2.75774 12.9683 2.78712 13.0312 2.82968 13.0848C2.87223 13.1384 2.92677 13.1813 2.98891 13.21C3.05106 13.2387 3.11907 13.2524 3.18748 13.25C3.25597 13.2496 3.3234 13.2331 3.38435 13.2019L13.0094 8.38941C13.081 8.35269 13.1412 8.29692 13.1832 8.22821C13.2252 8.15951 13.2474 8.08055 13.2474 8.00003C13.2474 7.91951 13.2252 7.84056 13.1832 7.77185C13.1412 7.70315 13.081 7.64737 13.0094 7.61066Z",fill:"white"})}),Je=l.default(Ke).attrs({"data-component-name":"icons/SendIcon/SendIcon"})`
59
- path {
60
- fill: ${({color:e})=>f.getCssColorVariable(e)};
61
- }
62
-
63
- height: ${({size:e})=>e||"16px"};
64
- width: ${({size:e})=>e||"16px"};
65
- `,Ze=e=>i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",fill:"none",...e,children:i.jsx("path",{d:"M10.5 3.5V10.5H3.5V3.5H10.5ZM10.5 2.625H3.5C3.26794 2.625 3.04538 2.71719 2.88128 2.88128C2.71719 3.04538 2.625 3.26794 2.625 3.5V10.5C2.625 10.7321 2.71719 10.9546 2.88128 11.1187C3.04538 11.2828 3.26794 11.375 3.5 11.375H10.5C10.7321 11.375 10.9546 11.2828 11.1187 11.1187C11.2828 10.9546 11.375 10.7321 11.375 10.5V3.5C11.375 3.26794 11.2828 3.04538 11.1187 2.88128C10.9546 2.71719 10.7321 2.625 10.5 2.625Z"})}),Xe=l.default(Ze).attrs({"data-component-name":"icons/StopIcon/StopIcon"})`
66
- path {
67
- fill: ${({color:e})=>f.getCssColorVariable(e)};
68
- }
69
-
70
- height: ${({size:e})=>e||"16px"};
71
- width: ${({size:e})=>e||"16px"};
72
- `;function Qe({placeholder:e="Ask anything...",className:t,disabled:n,isStreaming:r=!1,onStop:o,modelSelector:a,value:s,onValueChange:c,onSubmit:d,textareaRef:u}){const p=s.trim(),x=!n&&p.length>0&&!r,m=!n&&p.length>0,b=T=>{c(T.target.value)},y=()=>{!p||n||r||d()},A=()=>{!r||!o||o()},C=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),r&&o?A():y())};return i.jsxs(et,{className:t,$isActive:m,children:[i.jsx(tt,{ref:u,rows:1,maxLength:v.AI_SEARCH_MAX_MESSAGE_LENGTH,placeholder:e,value:s,disabled:n,spellCheck:!1,onChange:b,onKeyDown:C}),i.jsxs(nt,{children:[a,r&&o?i.jsx(ot,{type:"button",size:"small","aria-label":"Stop generating",icon:i.jsx(Xe,{color:"var(--icon-color-on-color)"}),onClick:A}):i.jsx(rt,{type:"button",size:"small","aria-label":"Send message",icon:i.jsx(Je,{color:"var(--icon-color-on-color)"}),onClick:y,disabled:!x})]})]})}const et=l.default.div`
73
- display: flex;
74
- flex-direction: column;
75
- gap: var(--spacing-xs);
76
- width: 100%;
77
- padding: var(--spacing-xs);
78
- border: var(--search-ai-conversation-input-border, 1px solid var(--border-color-secondary));
79
- border-radius: var(--search-ai-conversation-input-border-radius, var(--border-radius-lg));
80
- background-color: var(--layer-color);
81
- box-sizing: border-box;
82
-
83
- &:hover,
84
- &:focus-within {
85
- border-color: transparent;
86
- background:
87
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
88
- var(--replay-ai-gradient-soft) border-box;
89
- }
90
-
91
- ${({$isActive:e})=>e&&V.css`
92
- border-color: transparent;
93
- background:
94
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
95
- var(--replay-ai-gradient-soft) border-box;
96
- `}
97
- `,tt=l.default.textarea`
98
- max-height: 150px;
99
- min-height: var(--search-ai-conversation-input-min-height);
100
-
101
- resize: none;
102
- border: none;
103
- outline: none;
104
- padding: 0;
105
- font-family: var(--font-family-base);
106
- font-size: var(--font-size-base);
107
- line-height: var(--line-height-base);
108
- color: var(--text-color-primary);
109
- caret-color: var(--text-color-primary);
110
- background-color: transparent;
111
- field-sizing: content;
112
-
113
- &::placeholder {
114
- color: var(--text-color-helper);
115
- text-indent: 2px;
116
- }
117
- `,nt=l.default.div`
118
- display: flex;
119
- justify-content: space-between;
120
- align-items: center;
121
- gap: var(--spacing-xs);
122
- `,rt=l.default(v.Button)`
123
- box-sizing: border-box;
124
- background: var(--search-ai-gradient);
125
-
126
- &:disabled {
127
- background: var(--replay-ai-gradient-disabled);
128
- border: var(--replay-ai-send-button-disabled-border);
129
- width: 24px;
130
- height: 24px;
131
- }
132
- `,ot=l.default(v.Button)`
133
- box-sizing: border-box;
134
- background: var(--color-warm-grey-9);
135
- border-radius: var(--border-radius-xxl);
136
- `,it=new Set(["collection","workflow","step","operation","workflow-run"]);function Ae(e){return`replay://step?${new URLSearchParams({collectionId:e.collectionId.trim(),workflowId:e.workflowId.trim(),stepId:e.stepId.trim()}).toString()}`}function L(e,t){const n=e.get(t);if(n==null)return null;const r=n.trim();return r.length>0?r:null}function at(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="replay:")return null;const n=t.hostname.toLowerCase();if(!it.has(n))return null;const r=t.searchParams;switch(n){case"collection":{const o=L(r,"collectionId");return o?{kind:"collection",collectionId:o}:null}case"workflow":{const o=L(r,"collectionId"),a=L(r,"workflowId");return!o||!a?null:{kind:"workflow",collectionId:o,workflowId:a}}case"step":{const o=L(r,"collectionId"),a=L(r,"workflowId"),s=L(r,"stepId");return!o||!a||!s?null:{kind:"step",collectionId:o,workflowId:a,stepId:s}}case"operation":{const o=L(r,"operationId");return o?{kind:"operation",operationId:o}:null}case"workflow-run":{const o=L(r,"collectionId"),a=L(r,"workflowId");if(!o||!a)return null;const s=L(r,"historyId"),c=s==="null"||s==="undefined"?null:s;return{kind:"workflow-run",collectionId:o,workflowId:a,...c?{historyId:c}:{}}}default:return null}}function st(e,t,n){return e.tabsState.tabs.get({noproxy:!0}).findIndex(({data:r})=>f.isTabType(r,f.TabDataType.WorkflowRun)&&r.collectionId===t&&r.workflowId===n)}function lt(e,t,n,r={}){switch(n.kind){case"collection":t.openCollectionTab({collectionId:n.collectionId,activeTabName:f.TAB_NAMES.COLLECTION_SETTINGS});break;case"workflow":t.openWorkflowTab({collectionId:n.collectionId,workflowId:n.workflowId,activeTabName:f.TAB_NAMES.WORKFLOW_SETTINGS});break;case"step":t.openStepTabFromCollection({collectionId:n.collectionId,workflowId:n.workflowId,stepId:n.stepId,state:f.TabState.Normal});break;case"workflow-run":{const o=r.workflowRunHistoryIds?.[g.workflowRunKey(n.collectionId,n.workflowId)]??[],a=n.historyId&&o.includes(n.historyId)?n.historyId:o.at(-1)??n.historyId;if(a){t.openWorkflowRunTabFromHistory(a,{state:f.TabState.Normal});break}const s=st(e,n.collectionId,n.workflowId);if(s!==-1){e.tabsState.tabs.get({noproxy:!0})[s].state===f.TabState.Preview&&t.changeTabState(s,f.TabState.Normal),t.handleTabChange(s);break}t.openWorkflowRunTab({collectionId:n.collectionId,workflowId:n.workflowId});break}case"operation":{const o=g.resolveOperation(e,n.operationId);if(!o.ok){console.warn("[executeReplayChatLink] Operation not resolved",{operationId:n.operationId,message:o.message});return}g.openOrFocusOperationEditorTab(e,g.operationListItemToCollectionOperation(o.value),t);break}}}function ct(e,t,n,r={}){const o=at(n);o&&lt(e,t,o,r)}function Te({workflowRunHistoryIds:e}={}){const t=f.useGlobalStore(),{getApiOperation:n}=f.useApiOperation(),{handleTabChange:r,addNewTab:o,openCollectionTab:a,openWorkflowTab:s,openStepTabFromCollection:c,openWorkflowRunTab:d,openWorkflowRunTabFromHistory:u,changeTabState:p}=f.useTabHandlers();return h.useCallback(x=>{const m=x.target;if(!(m instanceof Element))return;const b=m.closest("a[href]");if(!(b instanceof HTMLAnchorElement))return;const y=b.getAttribute("href");y?.startsWith("replay:")&&(x.preventDefault(),x.stopPropagation(),ct(t,{getApiOperation:n,handleTabChange:r,addNewTab:o,openCollectionTab:a,openWorkflowTab:s,openStepTabFromCollection:c,openWorkflowRunTab:d,openWorkflowRunTabFromHistory:u,changeTabState:p},y,{workflowRunHistoryIds:e}))},[e,t,n,r,o,a,s,c,d,u,p])}class dt{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(t,r),s=this.castInput(n,r),c=this.removeEmpty(this.tokenize(a,r)),d=this.removeEmpty(this.tokenize(s,r));return this.diffWithOptionsObj(c,d,r,o)}diffWithOptionsObj(t,n,r,o){var a;const s=w=>{if(w=this.postProcess(w,r),o){setTimeout(function(){o(w)},0);return}else return w},c=n.length,d=t.length;let u=1,p=c+d;r.maxEditLength!=null&&(p=Math.min(p,r.maxEditLength));const x=(a=r.timeout)!==null&&a!==void 0?a:1/0,m=Date.now()+x,b=[{oldPos:-1,lastComponent:void 0}];let y=this.extractCommon(b[0],n,t,0,r);if(b[0].oldPos+1>=d&&y+1>=c)return s(this.buildValues(b[0].lastComponent,n,t));let A=-1/0,C=1/0;const T=()=>{for(let w=Math.max(A,-u);w<=Math.min(C,u);w+=2){let I;const N=b[w-1],R=b[w+1];N&&(b[w-1]=void 0);let M=!1;if(R){const F=R.oldPos-w;M=R&&0<=F&&F<c}const B=N&&N.oldPos+1<d;if(!M&&!B){b[w]=void 0;continue}if(!B||M&&N.oldPos<R.oldPos?I=this.addToPath(R,!0,!1,0,r):I=this.addToPath(N,!1,!0,1,r),y=this.extractCommon(I,n,t,w,r),I.oldPos+1>=d&&y+1>=c)return s(this.buildValues(I.lastComponent,n,t))||!0;b[w]=I,I.oldPos+1>=d&&(C=Math.min(C,w-1)),y+1>=c&&(A=Math.max(A,w+1))}u++};if(o)(function w(){setTimeout(function(){if(u>p||Date.now()>m)return o(void 0);T()||w()},0)})();else for(;u<=p&&Date.now()<=m;){const w=T();if(w)return w}}addToPath(t,n,r,o,a){const s=t.lastComponent;return s&&!a.oneChangePerToken&&s.added===n&&s.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:s.count+1,added:n,removed:r,previousComponent:s.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:s}}}extractCommon(t,n,r,o,a){const s=n.length,c=r.length;let d=t.oldPos,u=d-o,p=0;for(;u+1<s&&d+1<c&&this.equals(r[d+1],n[u+1],a);)u++,d++,p++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return p&&!a.oneChangePerToken&&(t.lastComponent={count:p,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=d,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const o=[];let a;for(;t;)o.push(t),a=t.previousComponent,delete t.previousComponent,t=a;o.reverse();const s=o.length;let c=0,d=0,u=0;for(;c<s;c++){const p=o[c];if(p.removed)p.value=this.join(r.slice(u,u+p.count)),u+=p.count;else{if(!p.added&&this.useLongestToken){let x=n.slice(d,d+p.count);x=x.map(function(m,b){const y=r[u+b];return y.length>m.length?y:m}),p.value=this.join(x)}else p.value=this.join(n.slice(d,d+p.count));d+=p.count,p.added||(u+=p.count)}}return o}}class ut extends dt{constructor(){super(...arguments),this.tokenize=ht}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
137
- `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
138
- `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
139
- `)&&(t=t.slice(0,-1)),n.endsWith(`
140
- `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const ft=new ut;function pt(e,t,n){return ft.diff(e,t,n)}function ht(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
141
- `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const a=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=a:n.push(a)}return n}const gt=500;function xt(e,t){const n=vt(e,t);if(n.length===0)return[];const r=[];let o=0;for(;o<n.length;){let a=o;const s=n[o].type==="context";for(;a<n.length&&n[a].type==="context"===s;)a++;const c=n.slice(o,a);r.push({start:o,end:a,rows:c,hasAdditions:c.some(d=>d.type==="add"),hasRemovals:c.some(d=>d.type==="remove")}),o=a}return r}function vt(e,t){if(e===void 0)return t===void 0?[]:H(t,"add");if(t===void 0)return H(e,"remove");if(e===t)return H(t,"context");const n=mt(e,t);return n?n.flatMap(r=>H(r.value,r.added?"add":r.removed?"remove":"context")):[...H(e,"remove"),...H(t,"add")]}function mt(e,t){try{return pt(e,t,{timeout:gt})}catch{return}}function H(e,t){const n=e.split(`
142
- `);return n.length>1&&n[n.length-1]===""&&n.pop(),n.map(r=>({type:t,text:r}))}const ne=1,re=e=>e&&e.hasAdditions!==e.hasRemovals,oe=e=>e&&(e.hasAdditions||e.hasRemovals);function yt(e,t,n){if(e.hasAdditions||e.hasRemovals)return G(e.rows);const r=n[t-1],o=n[t+1],a=re(r)?ne:0,s=re(o)?ne:0;if(a+s>=e.rows.length)return G(e.rows);const c=e.rows.slice(0,a),d=s>0?e.rows.slice(-s):[],u=[];return u.push(...G(c)),oe(r)&&oe(o)&&u.push({kind:"separator"}),u.push(...G(d)),u}function G(e){return e.map(t=>({kind:"row",row:t}))}const bt=200;function ie({oldValue:e,newValue:t}){const n=h.useMemo(()=>xt(e,t),[e,t]),r=h.useMemo(()=>n.flatMap(yt),[n]);return h.useMemo(()=>n.some(a=>a.hasAdditions||a.hasRemovals),[n])?i.jsx(Ct,{$maxHeight:bt,children:r.map((a,s)=>{if(a.kind==="separator")return i.jsx(kt,{children:i.jsx(ae,{children:"···"})},s);const{row:c}=a,d=wt(c.type);return i.jsxs(d,{children:[i.jsxs(St,{children:[c.type==="remove"&&i.jsx(v.SubtractIcon,{size:"12px"}),c.type==="add"&&i.jsx(v.AddIcon,{size:"12px"})]}),i.jsx(ae,{children:c.text===""?" ":c.text})]},s)})}):null}function wt(e){return e==="remove"?At:e==="add"?Tt:jt}const Ct=l.default.div`
143
- display: flex;
144
- flex-direction: column;
145
- width: 100%;
146
- min-width: 0;
147
- max-height: ${({$maxHeight:e})=>e}px;
148
- overflow-y: auto;
149
- border-radius: var(--border-radius);
150
- &::-webkit-scrollbar-track {
151
- margin: var(--spacing-xxs) 0;
152
- }
153
- `,J=l.default.div`
154
- display: flex;
155
- font-size: var(--font-size-sm);
156
- line-height: var(--line-height-sm);
157
- font-weight: var(--font-weight-regular);
158
- padding-right: var(--spacing-xxs);
159
- `,At=l.default(J)`
160
- background: var(--admonition-danger-bg-color);
161
- color: var(--color-raspberry-7);
162
- `,Tt=l.default(J)`
163
- background: var(--admonition-success-bg-color);
164
- color: var(--color-green-7);
165
- `,jt=l.default(J)`
166
- background: transparent;
167
- color: var(--text-color-secondary);
168
- `,St=l.default.span`
169
- display: flex;
170
- align-items: center;
171
- justify-content: center;
172
- min-width: 16px;
173
- height: 20px;
174
- flex-shrink: 0;
175
- `,ae=l.default.span`
176
- width: 100%;
177
- min-width: 0;
178
- line-height: var(--line-height-sm);
179
- font-size: var(--font-size-sm);
180
- font-weight: var(--font-weight-regular);
181
- white-space: pre-wrap;
182
- word-break: break-all;
183
- `,kt=l.default(J)`
184
- user-select: none;
185
- `,It=e=>typeof e!="object"||e===null?!1:"kind"in e&&e.kind==="batch"?"changes"in e?Array.isArray(e.changes)&&e.changes.every(se):!1:se(e);function se(e){return typeof e!="object"||e===null||!("id"in e)||!("target"in e)||!("included"in e)||!("kind"in e)?!1:e.kind==="single"}const Et={approveLabel:"Approve",denyLabel:"Deny"};function Rt(e,t){const n=S(t,"action");if(n){const o=g.TOOL_APPROVAL_ACTION_BUTTON_LABELS[n];if(o)return o}const r=g.TOOL_APPROVAL_BUTTON_LABELS[e];return r||Et}function S(e,t){if(!e||typeof e!="object")return null;const n=e.payload;if(!n||typeof n!="object")return null;const r=n[t];return typeof r!="string"?null:r.trim()||null}function le(e,t){if(!(typeof t>"u"))return e?`${e}: ${t}`:t}function Pt(e){return e?"changes"in e?Array.isArray(e.changes)?e.changes.map(t=>!t||typeof t!="object"||!("approved"in t)?!1:t.approved===!0):[]:[]:[]}function Lt(e,t){if(!e||typeof e!="object")return;const n=q(e,f.REPLAY_MESSAGE_METADATA_NS),r=q(n,f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY);if(!(t in r))return;const o=r[t];if(Array.isArray(o)&&o.length!==0&&o.every(It))return o}function je(e,t){return g.isToolApprovalPart(e)&&g.isApprovalRequested(e)&&e.toolCallId===t}function Ot(e,t,n){const r=e.parts.map(d=>je(d,t)?{...d,input:_t(d.input,n)}:d),o=e.metadata&&typeof e.metadata=="object"?e.metadata:{},a=q(o,f.REPLAY_MESSAGE_METADATA_NS),c={...q(a,f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY),[t]:f.cloneObject(n)};return{...e,parts:r,metadata:{...o,[f.REPLAY_MESSAGE_METADATA_NS]:{...a,[f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY]:c}}}}function q(e,t){const n=e[t];return typeof n=="object"&&n!==null?n:{}}function _t(e,t){if(!e||!("changes"in e)||!Array.isArray(e.changes))return e;const{changes:n,...r}=e;return{...r,changes:n.map((o,a)=>({...o,approved:t[a]?.included??!1}))}}function Mt({preview:e,isIncluded:t,onToggle:n,readOnly:r}){if(e.kind==="batch")return i.jsx(ce,{isIncluded:t,onToggle:n,readOnly:r,primaryLabel:e.target.type,children:i.jsx(Ut,{children:e.changes.map(c=>i.jsx(ie,{oldValue:le(c.target.key,c.oldValue),newValue:le(c.target.key,c.newValue)},c.id))})});const{target:o,oldValue:a,newValue:s}=e;return i.jsx(ce,{isIncluded:t,onToggle:n,readOnly:r,primaryLabel:o.key??o.type,categoryLabel:o.key?o.type:void 0,children:i.jsx(ie,{oldValue:a,newValue:s})})}function ce({isIncluded:e,onToggle:t,readOnly:n,primaryLabel:r,categoryLabel:o,children:a}){return i.jsxs(Nt,{$dimmed:n&&!e,children:[i.jsxs(Dt,{children:[n?i.jsx(Ft,{children:e?i.jsx(Gt,{size:"16px"}):i.jsx(Wt,{size:"16px"})}):i.jsxs(Vt,{children:[i.jsx(zt,{checked:e}),i.jsx(Bt,{type:"checkbox",checked:e,onChange:t})]}),i.jsx($t,{children:r}),o?i.jsx(Ht,{children:o}):null]}),a]})}const Nt=l.default.div`
186
- display: flex;
187
- flex-direction: column;
188
- gap: var(--spacing-xs);
189
- min-width: 0;
190
- padding: var(--spacing-xs);
191
- border-bottom: 1px solid var(--border-color-secondary);
192
- box-sizing: border-box;
193
- opacity: ${({$dimmed:e})=>e?.4:1};
194
- &:last-child {
195
- border-bottom: none;
196
- }
197
- `,Dt=l.default.div`
198
- display: flex;
199
- align-items: center;
200
- gap: var(--spacing-xs);
201
- min-width: 0;
202
- `,$t=l.default.span`
203
- flex: 1;
204
- min-width: 0;
205
- color: var(--text-color-primary);
206
- font-size: var(--font-size-sm);
207
- font-weight: var(--font-weight-medium);
208
- line-height: var(--line-height-sm);
209
- overflow: hidden;
210
- text-overflow: ellipsis;
211
- white-space: nowrap;
212
- `,Ht=l.default.span`
213
- flex-shrink: 0;
214
- font-family: var(--code-block-font-family, var(--font-family-monospace, monospace));
215
- font-size: var(--font-size-sm);
216
- font-weight: var(--font-weight-regular);
217
- line-height: var(--line-height-sm);
218
- color: var(--text-color-secondary);
219
- `,zt=l.default(v.CheckboxIcon).attrs({"aria-hidden":!0})`
220
- --checkbox-border-color: var(--color-blueberry-6);
221
- --checkbox-box-color: var(--color-blueberry-6);
222
- --checkbox-box-color-active: var(--color-blueberry-6);
223
- `,Vt=l.default.span`
224
- position: relative;
225
- display: inline-flex;
226
- flex-shrink: 0;
227
- width: 16px;
228
- height: 16px;
229
- `,Bt=l.default.input`
230
- position: absolute;
231
- inset: 0;
232
- width: 16px;
233
- height: 16px;
234
- margin: 0;
235
- opacity: 0;
236
- cursor: pointer;
237
- `,Ft=l.default.span`
238
- display: inline-flex;
239
- flex-shrink: 0;
240
- width: 16px;
241
- height: 16px;
242
- align-items: center;
243
- justify-content: center;
244
- `,Gt=l.default(v.CheckmarkFilledIcon)`
245
- color: var(--color-success-base);
246
- `,Wt=l.default(v.CloseFilledIcon)`
247
- color: var(--text-color-description);
248
- `,Ut=l.default.div`
249
- display: flex;
250
- flex-direction: column;
251
- gap: var(--spacing-xxs);
252
- min-width: 0;
253
- `;function Se({previews:e,handleToggle:t,readOnly:n}){return e.length===0?null:i.jsx(qt,{children:e.map((r,o)=>i.jsx(Mt,{preview:r,isIncluded:r.included,onToggle:t?()=>t(o):void 0,readOnly:n},r.id))})}const qt=l.default.div`
254
- display: flex;
255
- flex-direction: column;
256
- `,Yt={update_step:Zt,update_security:Xt,run_request:tn,web_search:nn,manage_environment:Qt,manage_collection:en};function Kt(e,t){const n=Yt[e];return n?n(t):Jt(e)}function Jt(e){return[{kind:"text",text:e.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}]}function Zt(e){return ke(e,"Update step")}function Xt(e){return ke(e,"Update security")}function ke(e,t){const{collectionId:n,workflowId:r,stepId:o}=rn(e);return!n||!r||!o?k(t):Ie(`${t} `,Ae({collectionId:n,workflowId:r,stepId:o}),o)}function k(e){return[{kind:"text",text:e}]}function P(e,t){return t?`${e} "${t}"`:e}function Ie(e,t,n){return[{kind:"text",text:e},{kind:"link",href:t,label:n}]}function Qt(e){const t=S(e,"action"),n=S(e,"environment"),r=n?` in environment "${n}"`:"";switch(t){case"add_environment":return k(P("Add environment",n));case"set_active_environment":return k(n?`Switch active environment to ${n}`:"Switch active environment");case"upsert_input":return k(P("Set input",S(e,"name"))+r);case"remove_input":return k(P("Remove input",S(e,"inputName"))+r);case"upsert_server":return k(P("Set server",S(e,"apiId"))+r);case"remove_server":return k(P("Remove server",S(e,"apiId"))+r);default:return k("Manage environment")}}function en(e){switch(S(e,"action")){case"create_collection":return k(P("Create collection",S(e,"title")));case"delete_collection":return k(P("Delete collection",S(e,"collectionId")));case"create_workflow":return k(P("Create workflow",S(e,"name")));case"delete_workflow":return k(P("Delete workflow",S(e,"workflowId")));case"create_step":return k(P("Create step",S(e,"stepName")));case"delete_step":{const n=S(e,"collectionId"),r=S(e,"workflowId"),o=S(e,"stepId");return!n||!r||!o?k("Delete step"):Ie("Delete step ",Ae({collectionId:n,workflowId:r,stepId:o}),o)}case"save_tab_to_collection":return k(P("Save tab as step",S(e,"newStepName")));default:return k("Manage collection")}}function tn(){return[{kind:"text",text:"Run current request"}]}function nn(e){return[{kind:"text",text:"Search the web at "},{kind:"link",href:e.url,label:e.url}]}function rn(e){return{collectionId:X(e,"collectionId"),workflowId:X(e,"workflowId"),stepId:X(e,"stepId")}}function X(e,t){if(!e||!(t in e))return null;const n=e[t];return typeof n=="string"&&n.trim()||null}function Ee({toolName:e,input:t}){const n=Kt(e,t),r=Te();return i.jsx(on,{onClick:r,children:i.jsx(an,{children:n.map((o,a)=>o.kind==="text"?i.jsx("span",{children:o.text},a):i.jsx(sn,{href:o.href,children:o.label},a))})})}const on=l.default.div`
257
- display: flex;
258
- flex-direction: column;
259
- gap: 0;
260
- min-width: 0;
261
- padding: var(--spacing-xs) var(--spacing-sm);
262
-
263
- &:not(:last-child) {
264
- border-bottom: 1px solid var(--border-color-secondary);
265
- }
266
- `,an=l.default.span`
267
- font-family: var(--font-family-base);
268
- font-size: var(--font-size-sm);
269
- font-weight: var(--font-weight-regular);
270
- line-height: var(--line-height-sm);
271
- color: var(--text-color-primary);
272
- `,sn=l.default.a`
273
- color: var(--link-color-primary);
274
- cursor: pointer;
275
- text-decoration: none;
276
-
277
- &:hover {
278
- color: var(--link-color-primary, var(--text-color-link));
279
- }
280
- `;function j({id:e,targetType:t,targetKey:n,oldValue:r,newValue:o}){return{kind:"single",id:e,target:n===void 0?{type:t}:{type:t,key:n},oldValue:r,newValue:o,included:!0}}function D(e,t){return j({id:e,targetType:t,oldValue:void 0,newValue:void 0})}function z({data:e,baseId:t,targetType:n,batchTargetKey:r,getOldValue:o,getNewValue:a=(c,d)=>String(d??""),resolveTargetKey:s=c=>c}){const c=Object.entries(e).filter(([,p])=>p!==void 0);if(c.length===0)return D(t,n);if(c.length>=2){const p=c.map(([m,b])=>j({id:`${t}:${m}`,targetType:n,targetKey:s(m),oldValue:o(m),newValue:a(m,b)}));return{kind:"batch",id:t,target:r!==void 0?{type:n,key:r}:{type:n},changes:p,included:!0}}const[d,u]=c[0];return j({id:t,targetType:n,targetKey:s(d),oldValue:o(d),newValue:a(d,u)})}function ln({store:e,input:t}){if(!cn(t))return[];const n=new Map,r=o=>{const a=n.get(o);if(a)return a;const s=g.resolveStepOrDraft(e,t.collectionId,t.workflowId,o),c=s.ok?s.value:null,d=c?Array.from(c.security.get({noproxy:!0})):[];return n.set(o,d),d};return t.changes.map((o,a)=>{const s=o.stepId?.trim(),c=s||t.stepId;return dn(r(c),o,a,s)})}function cn(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.collectionId=="string"&&typeof t.workflowId=="string"&&typeof t.stepId=="string"&&Array.isArray(t.changes)&&t.changes.length>0}function $(e,t){return e?t?`${e}: ${t}`:e:t}function dn(e,t,n,r){const o=`security[${n}]`;switch(t.action){case g.CHANGE_ACTION.ADD:{const{type:a,schemeId:s,data:c}=t;return!c||Object.keys(c).length===0?j({id:o,targetType:a,targetKey:$(r,s),oldValue:void 0,newValue:a}):z({data:c,baseId:o,targetType:a,batchTargetKey:$(r,s),getOldValue:()=>{},resolveTargetKey:d=>$(r,d)})}case g.CHANGE_ACTION.UPDATE:{const{type:a,schemeId:s,data:c}=t,d=t.index!==void 0?e[t.index]:void 0;return!c||Object.keys(c).length===0?j({id:o,targetType:a,targetKey:$(r,s),oldValue:ue(d),newValue:a}):z({data:c,baseId:o,targetType:a,batchTargetKey:$(r,s),getOldValue:u=>d?un(d,u):void 0,resolveTargetKey:u=>$(r,u)})}case g.CHANGE_ACTION.REMOVE:{const a=g.resolveRemovalTarget(e,t),s=a.ok?a.entry:void 0;return j({id:o,targetType:s?.securityType??"Security",targetKey:$(r,Pe(s)),oldValue:ue(s),newValue:void 0})}}}function un(e,t){switch(e.securityType){case f.SecurityTypes.NoAuth:return;case f.SecurityTypes.OAuth2:return de(e[f.SecurityTypes.OAuth2],t);case f.SecurityTypes.OpenIDConnect:{const n=e[f.SecurityTypes.OpenIDConnect];return t==="openIdConnectUrl"?n.openIdConnectUrl||void 0:t==="userInfoUrl"?n.userInfoUrl||void 0:de(n,t)}default:{const n=e[e.securityType];return Re(n,t)}}}function de(e,t){if(t==="grantType")return e.grantType||void 0;if(!e.grantType)return;const n=e[e.grantType];return Re(n,t)}function Re(e,t){const n=e[t];return n!==void 0&&n!==""?String(n):void 0}function ue(e){if(!e||e.securityType===f.SecurityTypes.NoAuth)return;const t=Pe(e);return t?`${e.securityType} (${t})`:e.securityType}function Pe(e){return!e||e.securityType===f.SecurityTypes.NoAuth?void 0:e[e.securityType]?.schemeName||void 0}function fn({store:e,input:t}){if(!pn(t))return[];const n=g.resolveStepOrDraft(e,t.collectionId,t.workflowId,t.stepId),r=n.ok?n.value:null;return t.changes.map((o,a)=>hn(r,o,a))}function pn(e){return typeof e!="object"||e===null?!1:"collectionId"in e&&"workflowId"in e&&"stepId"in e&&"changes"in e&&Array.isArray(e.changes)&&e.changes.length>0&&typeof e.collectionId=="string"&&typeof e.workflowId=="string"&&typeof e.stepId=="string"}function hn(e,t,n){const r=t.id??`${t.field}[${n}]`;switch(t.field){case"method":case"url":case"description":return gn(e,t,r);case"parameters":return xn(e,t,r);case"outputs":return vn(e,t,r);case"body":return mn(e,t,r);case"successCriteria":return yn(e,t,r)}}function gn(e,t,n){const r=v.capitalize(t.field);switch(t.action){case g.CHANGE_ACTION.ADD:return j({id:n,targetType:r,oldValue:void 0,newValue:t.data});case g.CHANGE_ACTION.UPDATE:return j({id:n,targetType:r,oldValue:fe(e,t.field),newValue:t.data});case g.CHANGE_ACTION.REMOVE:return j({id:n,targetType:r,oldValue:fe(e,t.field),newValue:void 0})}}function xn(e,t,n){switch(t.action){case g.CHANGE_ACTION.ADD:{if(!t.data)return D(n,"parameter");const{in:r,name:o,value:a}=t.data;return j({id:n,targetType:v.capitalize(r),targetKey:o,oldValue:void 0,newValue:a})}case g.CHANGE_ACTION.UPDATE:{if(!t.id&&!t.data?.name)return D(n,"parameter");const r=pe(e,t),o=t.data?.in??r?.in??"parameter";return j({id:n,targetType:v.capitalize(o),targetKey:t.data?.name??r?.key,oldValue:r?r.value??"":void 0,newValue:t.data?.value})}case g.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return D(n,"parameter");const r=pe(e,t),o=t.data?.in??r?.in??"parameter";return j({id:n,targetType:v.capitalize(o),targetKey:r?.key??t.data?.name,oldValue:r?r.value??"":void 0,newValue:void 0})}}}function vn(e,t,n){switch(t.action){case g.CHANGE_ACTION.ADD:return t.data?j({id:n,targetType:"Output",targetKey:t.data.name,oldValue:void 0,newValue:t.data.expression}):j({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});case g.CHANGE_ACTION.UPDATE:{if(!t.data)return j({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});const r=t.id&&e?ge(e,t.id):void 0;return j({id:n,targetType:"Output",targetKey:t.data.name,oldValue:r?.value,newValue:t.data.expression})}case g.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return D(n,"Output");let r=t.id&&e?ge(e,t.id):void 0;return!r&&e&&t.data?.name&&(r=Cn(e,t.data.name)),j({id:n,targetType:"Output",targetKey:r?.key??t.data?.name,oldValue:r?.value,newValue:void 0})}}}function mn(e,t,n){const{data:r}=t;switch(t.action){case g.CHANGE_ACTION.ADD:return z({data:r,baseId:n,targetType:"Body",getOldValue:()=>{},getNewValue:o=>o==="content"?Q(r.content,r.contentType):K(r[o]),resolveTargetKey:o=>o==="content"?void 0:o});case g.CHANGE_ACTION.UPDATE:{const o=e?.requestBody.type.get(),a=r.contentType??o;return z({data:r,baseId:n,targetType:"Body",getOldValue:s=>{if(e){if(s==="content")return Q(e.requestBody.content.get(),o)||void 0;if(s==="contentType")return o}},getNewValue:s=>s==="content"?Q(r.content,a):K(r[s]),resolveTargetKey:s=>s==="content"?void 0:s})}case g.CHANGE_ACTION.REMOVE:{const o=e?f.toCompactJson({contentType:e.requestBody.type.get(),content:e.requestBody.content.get()}):void 0;return j({id:n,targetType:"Body",oldValue:o,newValue:void 0})}}}function yn(e,t,n){switch(t.action){case g.CHANGE_ACTION.ADD:return t.data?z({data:t.data,baseId:n,targetType:"successCriteria",getOldValue:()=>{},getNewValue:r=>K(t.data[r])}):D(n,"successCriteria");case g.CHANGE_ACTION.UPDATE:{if(!t.data)return D(n,"successCriteria");const r=typeof t.id=="string"&&e?he(e,t.id):void 0;return z({data:t.data,baseId:n,targetType:"successCriteria",getOldValue:o=>{if(r){if(o==="condition")return r.condition;if(o==="context")return r.context??void 0;if(o==="type")return r.type}},getNewValue:o=>K(t.data[o])})}case g.CHANGE_ACTION.REMOVE:{if(typeof t.id!="string")return D(n,"successCriteria");const r=e?he(e,t.id):void 0;return j({id:n,targetType:"successCriteria",targetKey:r?.condition,oldValue:r?f.toCompactJson(r):void 0,newValue:void 0})}}}function fe(e,t){if(e)switch(t){case"method":return e.xOperation.ornull?.method.get();case"url":return e.xOperation.ornull?.url.get();case"description":return e.description.get()}}function pe(e,t){let n=t.id&&e?bn(e,t.id):null;return!n&&e&&t.data?.name&&(n=wn(e,t.data.name)),n}function Le(e,t){for(const n of["path","query","header","cookie"]){const r=e.parameters[g.LOCATION_TO_FIELD[n]].get().find(o=>f.isInlineRequestParameter(o)&&t(o));if(r)return r}return null}function bn(e,t){return Le(e,n=>n.id===t)}function wn(e,t){return Le(e,n=>n.key===t)}function he(e,t){return e.successCriteria.get().find(n=>n.condition===t)}function Oe(e,t){for(const n of e.outputs.get())if(t(n))return{key:Y(n.key),value:Y(n.value)}}function ge(e,t){return Oe(e,n=>Y(n.id)===t)}function Cn(e,t){return Oe(e,n=>Y(n.key)===t)}function Y(e){return typeof e=="string"?e:e.get()}function K(e){return e==null?"":typeof e=="string"?e:f.toCompactJson(e)}function Q(e,t){if(!e||t!==f.TextContentType.JSON)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const An={update_security:ln,update_step:fn};function _e(e,t){const n=f.useGlobalStore(),r=h.useMemo(()=>{const d=e?An[e]:void 0;if(!d)return[];try{return d({store:n,input:t})}catch(u){return console.error("Unable to build change previews",u),[]}},[e,n,t]),[o,a]=h.useState(()=>Object.fromEntries(r.map(d=>[d.id,d.included]))),s=h.useMemo(()=>r.map(d=>({...d,included:o[d.id]??d.included})),[r,o]),c=h.useCallback(d=>{a(typeof d=="function"?u=>{const p=r.map(x=>({...x,included:u[x.id]??x.included}));return Object.fromEntries(d(p).map(x=>[x.id,x.included]))}:Object.fromEntries(d.map(u=>[u.id,u.included])))},[r]);return{previews:s,setPreviews:c}}function Tn({toolCallId:e,toolName:t,input:n,onApprove:r,onDeny:o}){const{updateMessages:a}=g.useAiConversationContext(),{previews:s,setPreviews:c}=_e(t,n),{includedCount:d,totalCount:u}=h.useMemo(()=>({includedCount:s.filter(y=>y.included).length,totalCount:s.length}),[s]),{approveLabel:p,denyLabel:x}=h.useMemo(()=>Rt(t,n),[t,n]),m=h.useCallback(()=>{a(y=>{const A=[];for(let C=0;C<y.length;C++){const T=y[C],{parts:w}=T,I=T.role==="assistant",N=w.some(R=>je(R,e));if(I&&N){const R=Ot(T,e,s);A.push({index:C,message:R})}}return A}),r()},[s,r,a,e]),b=h.useCallback(y=>{c(A=>A.map((C,T)=>T===y?{...C,included:!C.included}:C))},[c]);return i.jsxs(jn,{children:[i.jsx(Ee,{toolName:t,input:n}),s.length?i.jsx(Sn,{children:i.jsx(Se,{previews:s,handleToggle:b})}):null,s.length?i.jsx(f.Divider,{}):null,i.jsxs(kn,{children:[u>1?i.jsxs(In,{children:[d," of ",u," selected"]}):null,i.jsx(En,{size:"small",variant:"secondary",onClick:o,children:x}),i.jsx(Rn,{size:"small",variant:"primary",onClick:m,disabled:u>0?d===0:!1,children:p})]})]})}const jn=l.default.div`
281
- display: flex;
282
- color: var(--text-color-primary);
283
- flex-direction: column;
284
- gap: var(--spacing-xs);
285
- width: 100%;
286
- min-width: 0;
287
- border-radius: var(--border-radius-md, 10px);
288
- border: 1px solid var(--border-color-secondary);
289
- background: var(--layer-color);
290
- line-height: var(--line-height-sm);
291
- `,Sn=l.default.div`
292
- display: flex;
293
- flex-direction: column;
294
- gap: var(--spacing-xs);
295
- min-width: 0;
296
- `,kn=l.default.div`
297
- display: flex;
298
- flex-wrap: wrap;
299
- justify-content: flex-end;
300
- align-items: center;
301
- padding: 0 var(--spacing-sm) var(--spacing-xs) var(--spacing-sm);
302
- gap: var(--spacing-xxs);
303
- `,In=l.default.span`
304
- flex: 1;
305
- font-size: var(--font-size-sm);
306
- font-weight: var(--font-weight-regular);
307
- line-height: var(--line-height-sm);
308
- color: var(--text-color-secondary);
309
- `,En=l.default(v.Button)`
310
- background: none;
311
- `,Rn=l.default(v.Button)`
312
- border: 1px solid var(--button-bg-color);
313
- padding-top: 0;
314
- padding-bottom: 0;
315
- &:disabled {
316
- border: 1px solid var(--button-border-color-disabled);
317
- }
318
- `;function Pn({approvalId:e,toolCallId:t,toolName:n,input:r}){const{addToolApprovalResponse:o}=g.useAiConversationContext(),a=h.useCallback(()=>{o({id:e,approved:!0})},[e,o]),s=h.useCallback(()=>{o({id:e,approved:!1})},[e,o]);return i.jsx(Tn,{onApprove:a,onDeny:s,toolCallId:t,toolName:n,input:r})}function Ln({toolName:e,toolCallId:t,input:n,isDenied:r,messageMetadata:o,onUndo:a}){const s=h.useMemo(()=>Lt(o,t),[o,t]),{previews:c}=_e(s?void 0:e,n),d=h.useMemo(()=>{const m=s??c;if(r)return m.map(y=>({...y,included:!1}));const b=Pt(n);return m.map((y,A)=>({...y,included:b[A]??y.included}))},[s,c,n,r]);if(d.length===0)return null;const u=d.filter(m=>m.included).length,x=u===0?"Nothing applied":`${u} ${u===1?"change":"changes"} applied`;return i.jsxs(On,{children:[i.jsx(Ee,{toolName:e,input:n}),i.jsx(_n,{children:i.jsx(Se,{previews:d,readOnly:!0})}),i.jsx(f.Divider,{}),i.jsxs(Mn,{children:[i.jsx(Nn,{children:x}),a?i.jsx(Dn,{size:"small",variant:"outlined",onClick:a,children:"Undo"}):null]})]})}const On=l.default.div`
319
- display: flex;
320
- color: var(--text-color-primary);
321
- flex-direction: column;
322
- width: 100%;
323
- min-width: 0;
324
- border-radius: var(--border-radius-md, 10px);
325
- border: 1px solid var(--border-color-secondary);
326
- background: var(--layer-color);
327
- line-height: var(--line-height-sm);
328
- `,_n=l.default.div`
329
- display: flex;
330
- flex-direction: column;
331
- min-width: 0;
332
- `,Mn=l.default.div`
333
- display: flex;
334
- justify-content: space-between;
335
- align-items: center;
336
- padding: var(--spacing-xs) var(--spacing-sm);
337
- gap: var(--spacing-xs);
338
- `,Nn=l.default.span`
339
- font-size: var(--font-size-sm);
340
- font-weight: var(--font-weight-regular);
341
- line-height: var(--line-height-sm);
342
- color: var(--text-color-secondary);
343
- `,Dn=l.default(v.Button)`
344
- padding-top: 0;
345
- padding-bottom: 0;
346
- `;function $n({items:e,isLast:t}){const[n,r]=h.useState(t),o=h.useCallback(()=>{r(s=>!s)},[]),a=h.useMemo(()=>e.filter(s=>s.kind==="action"),[e]);return i.jsxs(zn,{children:[i.jsxs(Vn,{type:"button",onClick:o,"aria-expanded":n,children:[i.jsx(Bn,{children:n?i.jsx(v.ChevronDownIcon,{size:"12px",color:"var(--icon-color-additional)"}):i.jsx(v.ChevronRightIcon,{size:"12px",color:"var(--icon-color-additional)"})}),i.jsxs(Fn,{children:[a.length," ",a.length===1?"action":"actions"]})]}),n&&i.jsx(Gn,{children:a.map((s,c)=>i.jsx(Hn,{text:s.text},c))})]})}function Hn({text:e}){return i.jsxs(Wn,{children:[i.jsxs(Un,{children:[i.jsx(qn,{"aria-hidden":!0}),i.jsx(Yn,{children:i.jsx(Kn,{"aria-hidden":!0})}),i.jsx(Me,{"aria-hidden":!0})]}),i.jsx(Jn,{children:e})]})}const zn=l.default.div`
347
- display: flex;
348
- flex-direction: column;
349
- width: 100%;
350
- min-width: 0;
351
- `,Vn=l.default.button`
352
- display: flex;
353
- align-items: center;
354
- cursor: pointer;
355
- user-select: none;
356
- width: fit-content;
357
- padding: 0;
358
- `,Bn=l.default.span`
359
- display: flex;
360
- align-items: center;
361
- flex-shrink: 0;
362
- `,Fn=l.default.span`
363
- font-size: var(--font-size-sm);
364
- font-weight: var(--font-weight-regular);
365
- line-height: var(--line-height-sm);
366
- color: var(--text-color-description);
367
- `,Gn=l.default.div`
368
- display: flex;
369
- flex-direction: column;
370
- gap: 0;
371
- `,Me=l.default.span`
372
- display: block;
373
- width: 1px;
374
- flex-shrink: 0;
375
- align-self: center;
376
- background: var(--border-color-secondary);
377
- flex: 1 1 auto;
378
- min-height: 8px;
379
- `,Wn=l.default.div`
380
- display: flex;
381
- flex-direction: row;
382
- align-items: stretch;
383
- gap: var(--spacing-xxs);
384
- min-width: 0;
385
-
386
- &:last-child {
387
- ${Me} {
388
- display: none;
389
- }
390
- }
391
- `,Un=l.default.div`
392
- display: flex;
393
- flex-direction: column;
394
- align-items: center;
395
- box-sizing: border-box;
396
- width: 12px;
397
- flex: 0 0 auto;
398
- align-self: stretch;
399
- min-height: 0;
400
- `,qn=l.default.span`
401
- display: block;
402
- width: 1px;
403
- height: 4px;
404
- flex: 0 0 auto;
405
- flex-shrink: 0;
406
- background: var(--border-color-secondary);
407
- `,Yn=l.default.div`
408
- width: 12px;
409
- height: 12px;
410
- flex: 0 0 auto;
411
- flex-shrink: 0;
412
- display: flex;
413
- align-items: center;
414
- justify-content: center;
415
- `,Kn=l.default.span`
416
- width: 4px;
417
- height: 4px;
418
- flex-shrink: 0;
419
- border-radius: 50%;
420
- box-sizing: border-box;
421
- border: 1px solid var(--border-color-secondary);
422
- background: transparent;
423
- `,Jn=l.default.span`
424
- flex: 1;
425
- min-width: 0;
426
- align-self: flex-start;
427
- font-size: var(--font-size-sm);
428
- font-weight: var(--font-weight-regular);
429
- line-height: var(--line-height-sm);
430
- color: var(--text-color-helper);
431
- `;function Zn({items:e,messageMetadata:t}){return i.jsx(Qn,{children:e.map((n,r)=>{if(n.kind==="reasoning-block"){const s=r===e.length-1;return i.jsx($n,{items:n.items,isLast:s},n.key)}if(n.kind==="text")return i.jsx(Xn,{rawMarkdown:n.text,workflowRunHistoryIds:n.workflowRunHistoryIds},n.key);const{part:o}=n,a=g.parseToolName(o.type);return a&&g.isApprovalRequested(o)?i.jsx(Pn,{approvalId:o.approval.id,toolCallId:o.toolCallId,toolName:a,input:o.input},n.key):a&&g.isApprovalSettled(o)?i.jsx(Ln,{toolName:a,toolCallId:o.toolCallId,input:o.input,isDenied:o.state==="output-denied",messageMetadata:t},n.key):null})})}function Xn({rawMarkdown:e,workflowRunHistoryIds:t}){const n=Te({workflowRunHistoryIds:t});return i.jsx(er,{onClick:n,children:i.jsx(f.Markdown,{rawMarkdown:e,parser:f.markdownParserMarked})})}const Qn=l.default.div`
432
- display: flex;
433
- flex-direction: column;
434
- gap: var(--spacing-xs);
435
- `,er=l.default.div`
436
- white-space: normal;
437
-
438
- max-width: 100%;
439
- overflow: hidden;
440
-
441
- p:first-child {
442
- margin-top: 0;
443
- }
444
-
445
- p:last-child {
446
- margin-bottom: 0;
447
- }
448
- `,Ne=l.default.div`
449
- font-family: var(--font-family-base);
450
- font-size: var(--font-size-sm);
451
- line-height: var(--line-height-sm);
452
- color: var(--text-color-primary);
453
- `;function tr(){return i.jsxs(nr,{children:[i.jsx(W,{}),i.jsx(W,{}),i.jsx(W,{})]})}const nr=l.default.div`
454
- display: flex;
455
- align-items: center;
456
- justify-content: space-between;
457
- width: 24px;
458
- height: 24px;
459
- `;function rr(){return i.jsxs(or,{children:[i.jsx(tr,{}),i.jsx(ir,{children:"Thinking"})]})}const or=l.default.div`
460
- display: flex;
461
- align-items: center;
462
- gap: var(--spacing-xxs);
463
- `,ir=l.default.span`
464
- font-family: var(--font-family-base);
465
- font-size: var(--font-size-sm);
466
- line-height: var(--line-height-sm);
467
- color: var(--text-color-helper);
468
- `;function ar({items:e}){return i.jsx(h.Fragment,{children:e.map(t=>t.kind!=="text"?null:i.jsx(Ne,{children:t.text},t.key))})}const sr="Something went wrong. Please try again.";function lr(e){const t=e?.message?.trim();return t||sr}function cr({message:e,isLastMessage:t}){const{chatStatus:n,chatError:r}=g.useAiConversationContext(),{role:o,parts:a}=e,s=o===_.MESSAGE_ROLE.ASSISTANT,c=h.useMemo(()=>g.getContentItems(a),[a]),d=c.length>0,u=n==="error"&&t&&s&&!d;return!d&&!u?null:i.jsx(De,{$role:o,children:i.jsx(ur,{isFailedEmptyAssistant:u,chatError:r,isAssistant:s,contentItems:c,messageMetadata:e.metadata})})}function dr(){return i.jsx(De,{$role:_.MESSAGE_ROLE.ASSISTANT,children:i.jsx(ee,{children:i.jsx(rr,{})})})}function ur({isFailedEmptyAssistant:e,chatError:t,isAssistant:n,contentItems:r,messageMetadata:o}){return e?i.jsx(ee,{children:i.jsx(Ne,{children:lr(t)})}):i.jsx(ee,{children:n?i.jsx(Zn,{items:r,messageMetadata:o}):i.jsx(ar,{items:r})})}const De=l.default.div`
469
- display: flex;
470
- flex-direction: column;
471
- padding: var(--spacing-xs) var(--spacing-sm);
472
- gap: var(--spacing-xxs);
473
- min-width: 0;
474
- width: ${({$role:e})=>e===_.MESSAGE_ROLE.ASSISTANT?"100%":"fit-content"};
475
- border-radius: ${({$role:e})=>e===_.MESSAGE_ROLE.USER?"6px 0px 6px 6px":"0px 6px 6px 6px"};
476
- background: ${({$role:e})=>e===_.MESSAGE_ROLE.USER?"var(--replay-ai-user-message-gradient)":"transparent"};
477
- border: none;
478
- color: var(--text-color-primary);
479
- box-sizing: border-box;
480
- word-wrap: break-word;
481
- white-space: pre-wrap;
482
- max-width: 100%;
483
- `,ee=l.default.div`
484
- display: flex;
485
- flex-direction: column;
486
- gap: var(--spacing-xxs);
487
- min-width: 0;
488
- width: 100%;
489
- `;function fr(){const{messages:e,isStreaming:t}=g.useAiConversationContext(),n=e.at(-1),r=h.useMemo(()=>{const o=n?.role===_.MESSAGE_ROLE.ASSISTANT,a=n?.parts.at(-1)?.type==="text";return t&&!(o&&a)},[t,n?.parts,n?.role]);return i.jsxs(pr,{children:[e.map((o,a)=>i.jsx(xe,{$role:o.role,children:i.jsx(ve,{$role:o.role,children:i.jsx(cr,{message:o,isLastMessage:a===e.length-1})})},o.id)),r&&i.jsx(xe,{$role:_.MESSAGE_ROLE.ASSISTANT,children:i.jsx(ve,{$role:_.MESSAGE_ROLE.ASSISTANT,children:i.jsx(dr,{})})})]})}const pr=l.default.div`
490
- display: flex;
491
- flex-direction: column;
492
- gap: var(--spacing-xs);
493
- width: 100%;
494
- `,xe=l.default.div`
495
- display: flex;
496
- width: 100%;
497
- justify-content: ${({$role:e})=>e===_.MESSAGE_ROLE.USER?"flex-end":"flex-start"};
498
- `,ve=l.default.div`
499
- display: flex;
500
- flex-direction: column;
501
- align-items: ${({$role:e})=>e===_.MESSAGE_ROLE.USER?"flex-end":"stretch"};
502
- gap: var(--spacing-xs);
503
- min-width: 0;
504
- width: 100%;
505
- max-width: 100%;
506
- `;function hr(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}const $e=l.default.div`
507
- display: flex;
508
- flex-direction: column;
509
- flex: 1;
510
- width: 100%;
511
- overflow: auto;
512
- padding: var(--spacing-xs);
513
- `,gr=e=>i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",fill:"none",...e,children:[i.jsx("path",{d:"M12.1683 8.65224C13.4439 7.91782 13.4439 6.08176 12.1683 5.34733L8.48891 3.22903L5.13033 6.57817C5.03961 6.66863 5.03961 6.8153 5.13033 6.90577L8.81674 10.5818L12.1683 8.65224Z",fill:"url(#replay-icon-gradient)"}),i.jsx("path",{d:"M7.56707 11.3013L3.81522 13.4613C2.53957 14.1957 0.945007 13.2777 0.945007 11.8088L0.945008 2.19072C0.945008 0.721872 2.53957 -0.196157 3.81522 0.538267L7.23924 2.50957L4.14475 5.59536C3.5097 6.22861 3.5097 7.25532 4.14475 7.88858L7.56707 11.3013Z",fill:"url(#replay-icon-gradient)"}),i.jsx("defs",{children:i.jsxs("linearGradient",{id:"replay-icon-gradient",x1:"12.0947",y1:"10.9627",x2:"1.65018",y2:"0.120816",gradientUnits:"userSpaceOnUse",children:[i.jsx("stop",{stopColor:"#C361FF"}),i.jsx("stop",{offset:"0.411322",stopColor:"#9461FF"}),i.jsx("stop",{offset:"0.73777",stopColor:"#207DFF"}),i.jsx("stop",{offset:"1",stopColor:"#1DA8F6"})]})})]}),xr=l.default(gr)`
514
- height: ${({size:e})=>e||"14px"};
515
- width: ${({size:e})=>e||"14px"};
516
- `;function vr(e){const t="var(--font-size-base)";switch(e){case f.REUNITE_AI_PROVIDER:return i.jsx(xr,{size:t});case f.AI_PROVIDERS.OPENAI:return i.jsx(v.ChatGptIcon,{size:t,color:"var(--text-color-primary)"});case f.AI_PROVIDERS.GEMINI:return i.jsx(v.GeminiIcon,{size:t});case f.AI_PROVIDERS.ANTHROPIC:return i.jsx(v.ClaudeIcon,{size:t,color:"var(--replay-claude-icon-color)"})}}function mr({models:e,selectedModelId:t,placement:n,onModelSelect:r,onSettingsOpen:o}){const a=e.find(x=>x.id===t),s=a?.label??"Replay AI",c=a?.id,d=e.filter(x=>x.provider===f.REUNITE_AI_PROVIDER),u=e.filter(x=>x.provider!==f.REUNITE_AI_PROVIDER),p=d.length>0&&u.length>0;return i.jsx(Cr,{children:i.jsx(Ar,{trigger:i.jsx(yr,{label:s}),placement:n,alignment:"start",withArrow:!0,children:i.jsxs(Tr,{children:[i.jsxs(kr,{children:[d.map(x=>i.jsx(me,{model:x,activeModelId:c,onModelSelect:r},x.id)),p&&i.jsx(ye,{"aria-hidden":!0}),u.length>0&&i.jsx(i.Fragment,{children:u.map(x=>i.jsx(me,{model:x,activeModelId:c,onModelSelect:r},x.id))})]}),o&&e.length>0&&i.jsx(ye,{"aria-hidden":!0}),o&&i.jsx(Ir,{prefix:i.jsx(v.SettingsCogIcon,{size:"var(--font-size-base)",color:"var(--text-color-secondary)"}),content:"Manage models",onAction:()=>o("ai-providers")})]})})})}function yr({label:e,icon:t,onClick:n,onKeyDown:r}){return i.jsxs(br,{onClick:n,onKeyDown:r,children:[i.jsx(wr,{children:e}),t]})}function me({model:e,activeModelId:t,onModelSelect:n}){const r=e.id===t;return i.jsx(v.DropdownMenuItem,{prefix:vr(e.provider),suffix:r?i.jsx(Sr,{size:"var(--font-size-base)",color:"var(--text-color-primary)"}):void 0,onAction:()=>n(e.id),active:r,children:i.jsx(jr,{children:e.label})})}const br=l.default.div`
517
- display: flex;
518
- align-items: center;
519
- min-width: 0;
520
- gap: var(--spacing-xxs);
521
- height: 24px;
522
- padding: 0 var(--spacing-xs);
523
- border-radius: var(--border-radius);
524
- background: var(--bg-color-active);
525
- cursor: pointer;
526
- user-select: none;
527
-
528
- &:hover {
529
- background: var(--layer-color-active);
530
- }
531
- `,wr=l.default.span`
532
- overflow: hidden;
533
- text-overflow: ellipsis;
534
- font-family: var(--font-family-base);
535
- font-size: var(--font-size-base);
536
- font-weight: var(--font-weight-regular);
537
- line-height: var(--line-height-base);
538
- color: var(--text-color-primary);
539
- white-space: nowrap;
540
- `,Cr=l.default.div`
541
- --dropdown-menu-padding-top: 0;
542
-
543
- min-width: 0;
544
- flex: 1;
545
- position: relative;
546
- `,Ar=l.default(v.Dropdown)`
547
- width: 100%;
548
- min-width: 0;
549
- flex: 1;
550
-
551
- > :last-child {
552
- width: 100%;
553
- max-width: 200px;
554
- }
555
- `,Tr=l.default(v.DropdownMenu)`
556
- --dropdown-menu-item-gap: calc(var(--spacing-unit) / 2);
557
- --dropdown-menu-item-padding-vertical: var(--spacing-xxs);
558
- --dropdown-menu-item-padding-horizontal: var(--spacing-xs);
559
-
560
- padding: var(--spacing-xxs);
561
- margin: 5px 0;
562
- border-radius: var(--border-radius-lg);
563
- background: var(--bg-color);
564
- `,jr=l.default.span`
565
- flex: 1;
566
- min-width: 0;
567
- overflow: hidden;
568
- text-overflow: ellipsis;
569
- white-space: nowrap;
570
- `,Sr=l.default(v.CheckmarkIcon)`
571
- margin-left: var(--spacing-xxs);
572
- `,ye=l.default.li`
573
- flex-shrink: 0;
574
- list-style: none;
575
- width: 100%;
576
- height: 1px;
577
- margin: 0;
578
- background: var(--border-color-secondary);
579
- `,kr=l.default.li`
580
- display: flex;
581
- flex-direction: column;
582
- gap: var(--dropdown-menu-item-gap);
583
- list-style: none;
584
- min-height: 0;
585
- overflow-y: auto;
586
- `,Ir=l.default(v.DropdownMenuItem)`
587
- flex-shrink: 0;
588
- `;function Er(){const{chatId:e,isLoading:t,pendingComposerPreset:n,clearPendingComposerPreset:r,availableModels:o,selectedModelId:a,selectModel:s,onSettingsOpen:c}=f.useAiChatContext(),{messages:d,isStreaming:u,sendMessage:p,stopGeneration:x}=g.useAiConversationContext(),{isOpen:m}=f.useAiPanel(),[b,y]=h.useState(""),A=h.useRef(null),C=h.useRef(null),T=h.useRef(!0),w=d.length>0,I=hr(d.length),R=I!==void 0&&I>0&&!w,M=h.useCallback((E="smooth")=>{C.current&&C.current.scrollTo({top:C.current.scrollHeight,behavior:E})},[]),B=h.useCallback(()=>{const E=C.current;if(!E)return;E.scrollHeight-E.scrollTop-E.clientHeight<50&&(T.current=!0)},[]);h.useEffect(()=>{const E=C.current;if(!E)return;const Z=Ve=>{Ve.deltaY<0&&(T.current=!1)};return E.addEventListener("wheel",Z,{passive:!0}),()=>E.removeEventListener("wheel",Z)},[]);const F=h.useCallback(async()=>{b&&(y(""),T.current=!0,await p(b),A.current&&requestAnimationFrame(()=>A.current?.focus()))},[p,b]);return h.useEffect(()=>{m&&(A.current&&A.current.focus(),T.current=!0,M())},[m,d.length,M]),h.useEffect(()=>{u&&T.current&&M()}),h.useEffect(function(){m&&A.current&&(A.current.focus(),M("instant"))},[e,m,M]),h.useEffect(function(){!m||n===null||(y(n),r())},[m,n,r]),i.jsxs($e,{children:[i.jsx(Rr,{ref:C,$isExpanded:t||w,$isAnimated:u||R,onScroll:B,children:t?i.jsx(Pr,{children:i.jsx(f.StyledSpinner,{size:"20px"})}):i.jsx(fr,{})}),i.jsx(Qe,{value:b,onValueChange:y,onSubmit:F,isStreaming:u,onStop:x,textareaRef:A,modelSelector:i.jsx(mr,{models:o,selectedModelId:a,placement:w?"top":"bottom",onModelSelect:s,onSettingsOpen:c})})]})}const Rr=l.default.div`
589
- flex: ${({$isExpanded:e})=>e?1:0};
590
- width: 100%;
591
- overflow: auto;
592
- padding-bottom: ${e=>e.$isExpanded?"var(--spacing-xs)":"0"};
593
- transition-property: flex;
594
- transition-duration: ${e=>e.$isAnimated?"var(--replay-transition-duration)":"0s"};
595
- transition-timing-function: var(--replay-transition-timing-function);
596
- `,Pr=l.default.div`
597
- display: flex;
598
- justify-content: center;
599
- height: 100%;
600
- padding-top: var(--spacing-lg);
601
- `,O={TODAY:"today",YESTERDAY:"yesterday",LAST_WEEK:"last_week",LAST_MONTH:"last_month",OLDER:"older"},Lr={[O.TODAY]:"Today",[O.YESTERDAY]:"Yesterday",[O.LAST_WEEK]:"Last 7 days",[O.LAST_MONTH]:"Last 30 days",[O.OLDER]:"Older"};function Or(e,t=Date.now()){const n=f.dayjs(e).startOf("day"),r=f.dayjs(t).startOf("day"),o=f.dayjs(t).subtract(1,"day").startOf("day"),a=f.dayjs(t).subtract(7,"day").startOf("day"),s=f.dayjs(t).subtract(30,"day").startOf("day");return n.isSame(r,"day")?O.TODAY:n.isSame(o,"day")?O.YESTERDAY:!n.isBefore(a,"day")&&n.isBefore(o,"day")?O.LAST_WEEK:!n.isBefore(s,"day")&&n.isBefore(a,"day")?O.LAST_MONTH:O.OLDER}function _r(e){const t=[];for(const n of e){const r=Or(n.updatedAt),o=t[t.length-1];!o||o.bucket!==r?t.push({bucket:r,chats:[n]}):o.chats.push(n)}return t}function Mr(e){const{scrollRef:t,sentinelRef:n,hasNextPage:r,isFetchingNextPage:o,fetchNextPage:a,observerResetKey:s}=e;h.useLayoutEffect(()=>{const c=t.current,d=n.current;if(!c||!d)return;const u=new IntersectionObserver(p=>{const x=p[0];x&&x.isIntersecting&&r&&(o||a())},{root:c,rootMargin:"80px"});return u.observe(d),()=>{u.disconnect()}},[s,a,r,o,t,n])}const He=l.default($e)`
602
- gap: var(--spacing-xxs);
603
- user-select: none;
604
- `,Nr=l.default.div`
605
- display: flex;
606
- flex-direction: column;
607
- gap: var(--spacing-xs);
608
- `,Dr=l.default.div`
609
- display: flex;
610
- flex-direction: column;
611
- gap: var(--spacing-xxs);
612
- `,$r=l.default(He)`
613
- display: flex;
614
- flex-grow: 1;
615
- align-items: center;
616
- flex-direction: column;
617
- padding: var(--spacing-md);
618
- `,Hr=l.default.div`
619
- display: flex;
620
- flex-grow: 1;
621
- align-items: center;
622
- justify-content: center;
623
- `,zr=l.default.div`
624
- display: flex;
625
- flex-direction: column;
626
- align-items: center;
627
- max-width: 75%;
628
- gap: var(--spacing-xxs);
629
- `,Vr=l.default.div`
630
- display: flex;
631
- justify-content: center;
632
- padding: var(--spacing-xs);
633
- `,Br=l.default(v.Typography)`
634
- padding-left: var(--spacing-xs);
635
- font-size: var(--font-size-sm);
636
- color: var(--color-warm-grey-7);
637
- `,Fr=l.default.div`
638
- display: flex;
639
- flex-grow: 1;
640
-
641
- .tooltip-expanded {
642
- flex-grow: 1;
643
- min-width: 0;
644
- }
645
- `,Gr=l.default.div`
646
- display: flex;
647
- align-items: center;
648
- justify-content: space-between;
649
- flex-grow: 1;
650
- min-width: 0;
651
- border-radius: var(--border-radius);
652
- padding: calc(var(--spacing-xxs) / 2) var(--spacing-xs);
653
- gap: calc(var(--spacing-xxs) * 2.5);
654
- cursor: pointer;
655
-
656
- ${v.Button} {
657
- display: none;
658
- }
659
-
660
- &:focus-within,
661
- &:hover {
662
- background-color: var(--color-hover-base);
663
-
664
- ${v.Button} {
665
- display: inline-flex;
666
- }
667
- }
668
- `,Wr=l.default(v.Typography)`
669
- overflow: hidden;
670
- white-space: nowrap;
671
- text-overflow: ellipsis;
672
- `,Ur=l.default.div`
673
- height: 1px;
674
- flex-shrink: 0;
675
- `;function qr(e){const{chat:t,onSelect:n,onRemove:r}=e;return i.jsx(Fr,{children:i.jsx(v.Tooltip,{tip:f.dayjs(t.updatedAt).format("MMM DD, YYYY, hh:mm:ss A"),className:"expanded",children:i.jsxs(Gr,{role:"button",onClick:()=>n?.(t.id),children:[i.jsx(Wr,{children:t.title??"New chat"}),i.jsx(v.Button,{variant:"ghost",size:"small",tone:"danger",icon:i.jsx(v.TrashCanIcon,{}),onClick:o=>{o.stopPropagation(),r?.(t.id)}})]})})})}function Yr(e){const{group:t,onChatSelect:n,onChatRemove:r}=e;return i.jsxs(Dr,{children:[i.jsx(Br,{children:Lr[t.bucket]}),t.chats.map(o=>i.jsx(qr,{chat:o,onSelect:n,onRemove:r},o.id))]})}function Kr(){return i.jsx(Hr,{children:i.jsxs(zr,{children:[i.jsx(v.Typography,{textAlign:"center",fontWeight:"var(--font-weight-semibold)",children:"No chat history"}),i.jsx(v.Typography,{textAlign:"center",children:"Ask questions or let the assistant take action for you."})]})})}function Jr(){return i.jsx($r,{children:i.jsx(f.StyledSpinner,{})})}const Zr=50;function Xr(e){const{onChatSelect:t,onChatRemove:n}=e,r=h.useRef(null),o=h.useRef(null),{data:a,isPending:s,hasNextPage:c,isFetchingNextPage:d,fetchNextPage:u}=g.useInfiniteChatHistory(Zr),p=h.useMemo(()=>(a?.pages??[]).flatMap(m=>m.items),[a?.pages]),x=h.useMemo(()=>_r(p),[p]);return Mr({scrollRef:r,sentinelRef:o,hasNextPage:c,isFetchingNextPage:d,fetchNextPage:u,observerResetKey:a?.pages.length}),s&&!a?i.jsx(Jr,{}):p.length===0?i.jsx(Kr,{}):i.jsxs(He,{ref:r,children:[i.jsx(Nr,{children:x.map(m=>i.jsx(Yr,{group:m,onChatSelect:t,onChatRemove:n},`${m.bucket}-${m.chats[0]?.id??""}`))}),c&&i.jsx(Ur,{ref:o,"aria-hidden":!0}),d&&i.jsx(Vr,{children:i.jsx(f.StyledSpinner,{})})]})}const Qr=h.createContext(null);function eo(e){const t=h.useContext(Qr);if(t?.components){const{LinkComponent:s}=t.components;return i.jsx(s,{...e})}const{external:n,languageInsensitive:r,innerRef:o,...a}=e;return i.jsx(Be.Link,{ref:o,...a})}const to=()=>V.keyframes`
676
- 0% {
677
- color: var(--button-content-color);
678
- background-color: var(--button-bg-color-active);
679
- }
680
-
681
- 50% {
682
- background-color: var(--button-bg-color);
683
- }
684
-
685
- 100% {
686
- color: var(--button-content-color);
687
- background-color: var(--button-bg-color-active);
688
- }
689
- `,no=l.default(eo)`
690
- text-decoration: none;
691
- &:focus-visible {
692
- outline: 1px solid var(--button-border-color-focused);
693
- }
694
- border-radius: var(--button-border-radius);
695
- `;function ro({variant:e="secondary",tone:t="default",size:n="medium",extraClass:r="",className:o=""}){return["button",r,`button-tone-${t}`,`button-variant-${e}`,`button-size-${n}`,o].filter(s=>s).join(" ").trim()}const oo=l.default.button`
696
- width: ${({$fullWidth:e})=>e?"100%":"auto"};
697
-
698
- display: inline-flex;
699
- align-items: center;
700
- justify-content: center;
701
- gap: var(--button-gap);
702
- margin: var(--button-margin);
703
- cursor: pointer;
704
- text-wrap: var(--button-text-wrap);
705
-
706
- color: var(--button-color);
707
- background-color: var(--button-bg-color);
708
- border: var(--button-border-width) var(--button-border-style) var(--button-border-color);
709
- box-shadow: var(--button-box-shadow);
710
- backdrop-filter: var(--button-backdrop-filter, none);
711
-
712
- font-weight: var(--button-font-weight);
713
- font-size: var(--button-font-size);
714
- line-height: var(--button-line-height);
715
- padding: ${({$icon:e,$iconPosition:t,$iconOnly:n})=>e?`var(--button-icon-${n?"":`${t||"left"}-`}padding)`:"var(--button-padding)"};
716
- border-radius: var(--button-border-radius);
717
-
718
- svg {
719
- width: var(--button-icon-size);
720
- height: var(--button-icon-size);
721
- }
722
-
723
- &:hover {
724
- background-color: var(--button-bg-color-hover);
725
- color: var(--button-color-hover);
726
- border-color: var(--button-border-color-hover);
727
- }
728
-
729
- &:active,
730
- &.active {
731
- background-color: var(--button-bg-color-active);
732
- border-color: var(--button-border-color-active);
733
- color: var(--button-color-active);
734
- }
735
-
736
- &:focus-visible {
737
- outline: 1px solid var(--button-border-color-focused);
738
- }
739
-
740
- &.button-tone-danger {
741
- color: var(--button-content-color-danger);
742
- border-color: var(--button-border-color-danger);
743
- background-color: var(--button-bg-color-danger);
744
-
745
- &:hover {
746
- color: var(--button-content-color-danger-hover);
747
- border-color: var(--button-border-color-danger-hover);
748
- background-color: var(--button-bg-color-danger-hover);
749
- }
750
-
751
- &:active {
752
- color: var(--button-content-color-danger-pressed);
753
- border-color: var(--button-border-color-danger-pressed);
754
- background-color: var(--button-bg-color-danger-pressed);
755
- }
756
- }
757
-
758
- &:disabled {
759
- pointer-events: none;
760
- background-color: var(--button-bg-color-disabled);
761
- color: var(--button-content-color-disabled);
762
- border-color: var(--button-border-color-disabled);
763
- border-width: var(--button-border-width-disabled);
764
- }
765
-
766
- ${({$variant:e,$size:t})=>(e==="link"||e==="ghost")&&t==="small"&&V.css`
767
- --button-font-size: var(--font-size-sm);
768
- --button-line-height: var(--line-height-sm);
769
- --button-icon-padding: var(--button-icon-padding-small) !important;
770
- `}
771
-
772
- ${({$blinking:e})=>e&&V.css`
773
- pointer-events: none;
774
- animation: ${to()} 1.2s infinite;
775
- `}
776
- `,io=e=>{const{languageInsensitive:t,fullWidth:n,blinking:r,iconPosition:o,icon:a,children:s,variant:c,tone:d,size:u,extraClass:p,to:x,external:m,className:b,...y}=e,A="tabIndex"in e?e.tabIndex:e.to?-1:void 0,C=i.jsxs(oo,{"data-component-name":"Button/Button",...y,className:ro({variant:c,tone:d,size:u,extraClass:p,className:b}),$fullWidth:n,$blinking:r,$iconPosition:o,$icon:a,$iconOnly:!s&&a!=null,$variant:c,$size:u,tabIndex:A,children:[a&&o!=="right"&&a,s,a&&o==="right"&&a]});return x?i.jsx(no,{to:x,external:m,languageInsensitive:t,onClick:e.onClick,children:C}):C},U=l.default(io)``;function ao(){const e=h.useRef(null),[t,n]=h.useState(!1);return h.useLayoutEffect(()=>{if(!e.current)return;const r=e.current;function o(){n(r.scrollWidth>r.clientWidth)}o();const a=new ResizeObserver(o);return a.observe(r),()=>a.disconnect()},[]),{ref:e,value:t}}function so(e){const{ref:t,value:n}=ao();return i.jsx(lo,{children:i.jsx(v.Tooltip,{tip:e.value,className:"no-overflow",disabled:!n,children:i.jsx(co,{ref:t,children:e.value})})})}const lo=l.default.div`
777
- overflow: hidden;
778
- .tooltip-no-overflow {
779
- overflow: hidden;
780
- }
781
- `,co=l.default.div`
782
- color: var(--text-color-primary);
783
- font-size: var(--font-size-base);
784
- line-height: var(--line-height-base);
785
- overflow: hidden;
786
- white-space: nowrap;
787
- text-overflow: ellipsis;
788
- user-select: none;
789
- `;function ze(e){const{children:t,buttons:n}=e;return i.jsxs(uo,{children:[i.jsx(fo,{children:t}),n&&i.jsx(po,{children:n})]})}const uo=l.default.div`
790
- display: flex;
791
- flex-direction: row;
792
- align-items: center;
793
- padding: var(--spacing-xs);
794
- gap: var(--spacing-xs);
795
- width: 100%;
796
- flex-shrink: 0;
797
- `,fo=l.default.div`
798
- display: flex;
799
- align-items: center;
800
- gap: var(--spacing-xs);
801
- min-width: 0;
802
- flex: 1;
803
- `,po=l.default.div`
804
- display: flex;
805
- align-items: center;
806
- gap: 2px;
807
- `;function ho(e){const{title:t,onCreateNewChat:n,onViewHistory:r,onClose:o}=e,a=i.jsxs(i.Fragment,{children:[i.jsx(v.Tooltip,{tip:"New chat",children:i.jsx(U,{size:"small",variant:"text","aria-label":"Create new chat",onClick:n,icon:i.jsx(v.NewChatIcon,{})})}),i.jsx(v.Tooltip,{tip:"Chat history",children:i.jsx(U,{size:"small",variant:"text","aria-label":"View chat history",onClick:r,icon:i.jsx(v.RecentlyViewedIcon,{})})}),i.jsx(xo,{children:i.jsx(f.VerticalDivider,{})}),i.jsx(v.Tooltip,{tip:"Close",arrowPosition:"left",children:i.jsx(U,{variant:"text",size:"small","aria-label":"Close panel",icon:i.jsx(v.CloseIcon,{}),onClick:o})})]});return i.jsxs(ze,{buttons:a,children:[i.jsx(go,{children:i.jsx(v.AiStarsGradientIcon,{size:"14px"})}),i.jsx(so,{value:t})]})}const go=l.default.div`
808
- display: flex;
809
- `,xo=l.default.div`
810
- display: flex;
811
- height: 14px;
812
- `,vo=new Set(["color","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","letterSpacing","marginBottom","marginTop","textAlign"]),mo=l.default.span.withConfig({shouldForwardProp:e=>!vo.has(e)}).attrs({"data-component-name":"Typography/Typography"})`
813
- color: ${({color:e})=>e||"var(--text-color-primary)"};
814
- font-family: ${({fontFamily:e})=>e||"var(--font-family-base)"};
815
- font-size: ${({fontSize:e})=>e||"var(--font-size-base)"};
816
- font-style: ${({fontStyle:e})=>e};
817
- font-weight: ${({fontWeight:e})=>e||"var(--font-weight-regular)"};
818
- line-height: ${({lineHeight:e})=>e||"var(--line-height-base)"};
819
- letter-spacing: ${({letterSpacing:e})=>e};
820
- margin-bottom: ${({marginBottom:e})=>e};
821
- margin-top: ${({marginTop:e})=>e};
822
- text-align: ${({textAlign:e})=>e};
823
- `;function yo(e){const{onReturnFromHistory:t}=e;return i.jsxs(ze,{children:[i.jsx(U,{size:"small",variant:"text","aria-label":"Return to chat",onClick:t,icon:i.jsx(v.ArrowLeftIcon,{})}),i.jsx(bo,{children:i.jsx(mo,{children:"Chat history"})})]})}const bo=l.default.div`
824
- user-select: none;
825
- `;function wo(){const[e,t]=h.useState(g.AI_TAB.CHAT),n=f.useAiPanel(),r=f.useAiChatContext(),o=()=>{t(g.AI_TAB.HISTORY)},a=()=>{t(g.AI_TAB.CHAT)},s=async c=>{r.selectChat(c),t(g.AI_TAB.CHAT)};return i.jsxs(Co,{children:[i.jsxs(be,{isActive:e===g.AI_TAB.CHAT,children:[i.jsx(ho,{title:r.title,onCreateNewChat:r.createNewChat,onViewHistory:o,onClose:n.closePanel}),i.jsx(Er,{}),i.jsx(we,{children:i.jsx(te,{})})]}),i.jsxs(be,{isActive:e===g.AI_TAB.HISTORY,isSliding:!0,children:[i.jsx(yo,{onReturnFromHistory:a}),i.jsx(Xr,{onChatSelect:s,onChatRemove:r.removeChat}),i.jsx(we,{children:i.jsx(te,{})})]})]})}function be(e){const{children:t,isActive:n,isSliding:r=!1}=e,o=i.jsx(Ao,{inert:!n,children:t});return r?i.jsx(To,{$isExpanded:n,children:o}):o}const Co=l.default.div`
826
- position: relative;
827
- height: 100%;
828
- overflow: clip;
829
- `,Ao=l.default.div`
830
- display: flex;
831
- height: 100%;
832
- flex-direction: column;
833
- align-items: flex-start;
834
- border-radius: var(--border-radius-md);
835
- background: var(--bg-color);
836
- margin-left: var(--spacing-xxs);
837
- `,To=l.default.div`
838
- position: absolute;
839
- inset: 0;
840
- transform: translateX(${e=>e.$isExpanded?"0%":"100%"});
841
- transition-property: transform;
842
- transition-duration: 400ms;
843
- transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
844
- @media (prefers-reduced-motion: reduce) {
845
- transition-duration: 0ms;
846
- }
847
- `,we=l.default.div`
848
- width: 100%;
849
- `;exports.AiPanel=wo;