@redocly/replay 0.28.0-next.0 → 0.28.0-next.10

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 (82) hide show
  1. package/dist/replay-AiChatProvider-BWL86hXh.js +6 -0
  2. package/dist/{replay-AiChatProvider-BZUzXfD-.js → replay-AiChatProvider-CY3b_ggu.js} +376 -376
  3. package/dist/{replay-AiChatSqliteDBStorage-CTVtufnx.js → replay-AiChatSqliteDBStorage-BtV53vvj.js} +1 -1
  4. package/dist/{replay-AiChatSqliteDBStorage-JpKE0iGm.js → replay-AiChatSqliteDBStorage-CjzLqUwK.js} +6 -6
  5. package/dist/{replay-AiPanel-DkR-vZTK.js → replay-AiPanel-B3HBaMPh.js} +706 -709
  6. package/dist/replay-AiPanel-BzaoPsXZ.js +742 -0
  7. package/dist/replay-FileWatcher-BFtAqsmL.js +1 -0
  8. package/dist/replay-FileWatcher-d1_qKRfS.js +364 -0
  9. package/dist/{replay-HistorySqliteDBStorage-CtF6-vY8.js → replay-HistorySqliteDBStorage-Bi5vBQ2T.js} +2 -2
  10. package/dist/replay-SemanticSearchService-CTWesmRy.js +1 -0
  11. package/dist/{replay-SemanticSearchService-CSsOmkV_.js → replay-SemanticSearchService-DcR4Q6w6.js} +27 -31
  12. package/dist/{replay-SqliteDBStorage-DpAEbsAQ.js → replay-SqliteDBStorage-BeDAsnlF.js} +1 -1
  13. package/dist/{replay-SqliteDBStorage-BSMAgfUS.js → replay-SqliteDBStorage-BlVDbZhU.js} +49 -49
  14. package/dist/{replay-StepContextSqliteDBStorage-BfAAKDwA.js → replay-StepContextSqliteDBStorage-BkB2NM27.js} +2 -2
  15. package/dist/replay-TauriFileSystemAdapter-B_VaAUfL.js +1 -0
  16. package/dist/replay-TauriFileSystemAdapter-Cu-Q6QS_.js +108 -0
  17. package/dist/replay-TauriRootStorage-Cidjagk-.js +1 -0
  18. package/dist/{replay-TauriRootStorage-g9zf2-FS.js → replay-TauriRootStorage-DVeU3RvV.js} +213 -210
  19. package/dist/{replay-agent-loop-be2meQsN.js → replay-agent-loop-B42P9R-q.js} +1 -1
  20. package/dist/{replay-agent-loop-ClVUvt0C.js → replay-agent-loop-DweKWrQp.js} +5 -5
  21. package/dist/{replay-ai-chat-mappers-JOZvaHV_.js → replay-ai-chat-mappers-Cno0s3T8.js} +1 -1
  22. package/dist/{replay-ai-chat-mappers-CwvRub6i.js → replay-ai-chat-mappers-DusPRQPG.js} +3 -3
  23. package/dist/{replay-ai-message-parts.schema-E9u9-nqr.js → replay-ai-message-parts.schema-DKLf0SiG.js} +1 -1
  24. package/dist/{replay-create-model-rzGPB8KT.js → replay-create-model-CeSlm24x.js} +4 -4
  25. package/dist/{replay-create-model-CJ3dsZg8.js → replay-create-model-DdPq1CIm.js} +3 -3
  26. package/dist/{replay-db-CW7044b2.js → replay-db-Bj8Qpvpw.js} +1 -1
  27. package/dist/{replay-db-zC1KPTH0.js → replay-db-he8XQjrM.js} +1 -1
  28. package/dist/{replay-external-resolver-BDPRz7Xd.js → replay-external-resolver-BRs5F07f.js} +7 -7
  29. package/dist/{replay-external-resolver-Dty0CDYE.js → replay-external-resolver-gQ0egbx7.js} +1 -1
  30. package/dist/{replay-history.schema-5ce6X0R1.js → replay-history.schema-B0lLwmdG.js} +3 -3
  31. package/dist/replay-index-B1qPs-GR.js +4 -0
  32. package/dist/replay-index-C2b91LJZ.js +7013 -0
  33. package/dist/{replay-index--hMZLQs8.js → replay-index-CA6OI1Qg.js} +1 -1
  34. package/dist/replay-index-CYphcClc.js +1 -0
  35. package/dist/{replay-index-F4GEOEUz.js → replay-index-DRb3mixV.js} +65311 -63618
  36. package/dist/replay-index-Dtxwps1s.js +574 -0
  37. package/dist/replay-index-NgGicGfR.js +1 -0
  38. package/dist/{replay-index-DZN7KzbY.js → replay-index-uF3nFq_Y.js} +1 -1
  39. package/dist/{replay-indexes-CfsvVMi_.js → replay-indexes-B3PJtgeh.js} +43 -43
  40. package/dist/replay-lint-C2hyYWRS.js +177 -0
  41. package/dist/{replay-lint-9YeYgRBU.js → replay-lint-gY_wyYPJ.js} +17581 -21140
  42. package/dist/{replay-lint-graphql-Dba0twW-.js → replay-lint-graphql-BA9t8-Ua.js} +1 -1
  43. package/dist/{replay-lint-graphql-BelJUl9-.js → replay-lint-graphql-DDrnrINc.js} +1 -1
  44. package/dist/replay-periodic-revalidation-BbAt74oL.js +21 -0
  45. package/dist/replay-periodic-revalidation-kmD2RQn1.js +1 -0
  46. package/dist/replay-resolve-BJ_AY-Mn.js +47 -0
  47. package/dist/{replay-resolve-RxCCaHXw.js → replay-resolve-_V8uYdTK.js} +470 -468
  48. package/dist/replay-respect-run-CLLZoRh1.js +8392 -0
  49. package/dist/replay-respect-run-qOz91QPQ.js +82 -0
  50. package/dist/replay-step-context.schema-BOprzd6Z.js +21 -0
  51. package/dist/{replay-tauri-path-hGM_JYax.js → replay-tauri-path-lH8t5rdX.js} +1 -1
  52. package/dist/replay-tauri-path-twTA2lKs.js +22 -0
  53. package/dist/replay-useAiChatQueries-BIqM2KQW.js +215 -0
  54. package/dist/{replay-useAiChatQueries-DD84oZan.js → replay-useAiChatQueries-yCsYY1j2.js} +1583 -1371
  55. package/dist/{replay-validate-key-xk-9xmJ6.js → replay-validate-key-Bh41yY9h.js} +2 -2
  56. package/dist/{replay-validate-key-PS5qrafQ.js → replay-validate-key-_oaOw5Jy.js} +1 -1
  57. package/dist/replay.cjs +1 -1
  58. package/dist/replay.d.ts +10 -3
  59. package/dist/replay.js +14 -14
  60. package/package.json +20 -13
  61. package/dist/replay-AiChatProvider-Dllh11wo.js +0 -6
  62. package/dist/replay-AiPanel-DruBN19L.js +0 -742
  63. package/dist/replay-FileWatcher-D3W6TGFC.js +0 -1
  64. package/dist/replay-FileWatcher-v7Qw29PS.js +0 -343
  65. package/dist/replay-SemanticSearchService-Dfx2W4Za.js +0 -1
  66. package/dist/replay-TauriFileSystemAdapter-BLPH1Vx3.js +0 -1
  67. package/dist/replay-TauriFileSystemAdapter-Ddq9xfo1.js +0 -99
  68. package/dist/replay-TauriRootStorage-l_sNXRNW.js +0 -1
  69. package/dist/replay-index-5UkXwLrd.js +0 -504
  70. package/dist/replay-index-9h4E2FR8.js +0 -1
  71. package/dist/replay-index-B7GU_aMu.js +0 -25
  72. package/dist/replay-index-DbWKCsKW.js +0 -6906
  73. package/dist/replay-index-ko78Z8QX.js +0 -1
  74. package/dist/replay-lint-DK6LCpO2.js +0 -184
  75. package/dist/replay-periodic-revalidation-BoyLQHtg.js +0 -1
  76. package/dist/replay-periodic-revalidation-Dsp-n7ui.js +0 -21
  77. package/dist/replay-resolve-CRBvIGPM.js +0 -47
  78. package/dist/replay-respect-run-BP5Q5L8N.js +0 -78
  79. package/dist/replay-respect-run-CRGPD-UQ.js +0 -8200
  80. package/dist/replay-step-context.schema-DBk4jufr.js +0 -21
  81. package/dist/replay-tauri-path-BmHpvlYp.js +0 -22
  82. package/dist/replay-useAiChatQueries-KVveua_P.js +0 -215
@@ -1,742 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("react"),X=require("styled-components"),f=require("./replay-index-DbWKCsKW.js"),x=require("./replay-useAiChatQueries-KVveua_P.js"),Ue=require("@redocly/theme/core/constants/search"),E=require("@redocly/theme/components/Button/Button"),We=require("@redocly/theme/icons/SendIcon/SendIcon"),Ye=require("@redocly/theme/icons/StopIcon/StopIcon"),M=require("./replay-db-CW7044b2.js"),Ke=require("@redocly/theme/icons/CheckboxIcon/CheckboxIcon"),Je=require("@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon"),Xe=require("@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon"),Ze=require("@redocly/theme/icons/AddIcon/AddIcon"),Qe=require("@redocly/theme/icons/SubtractIcon/SubtractIcon"),K=require("@redocly/theme/core/utils"),et=require("@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon"),tt=require("@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon"),nt=require("@redocly/theme/components/Dropdown/Dropdown"),rt=require("@redocly/theme/components/Dropdown/DropdownMenu"),je=require("@redocly/theme/components/Dropdown/DropdownMenuItem"),ot=require("@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon"),it=require("@redocly/theme/icons/SettingsCogIcon/SettingsCogIcon"),st=require("@redocly/theme/icons/ChatGptIcon/ChatGptIcon"),at=require("@redocly/theme/icons/GeminiIcon/GeminiIcon"),lt=require("@redocly/theme/icons/ClaudeIcon/ClaudeIcon"),B=require("@redocly/theme/components/Tooltip/Tooltip"),le=require("./replay-SemanticSearchService-Dfx2W4Za.js");require("@tanstack/react-query");const G=require("@redocly/theme/components/Typography/Typography"),ct=require("@redocly/theme/icons/TrashCanIcon/TrashCanIcon"),dt=require("@redocly/theme/icons/AiStarsGradientIcon/AiStarsGradientIcon"),ut=require("@redocly/theme/icons/CloseIcon/CloseIcon"),ft=require("@redocly/theme/icons/NewChatIcon/NewChatIcon"),pt=require("@redocly/theme/icons/RecentlyViewedIcon/RecentlyViewedIcon"),ht=require("@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon"),xt=e=>e&&e.__esModule?e:{default:e},l=xt(X);function gt({placeholder:e="Ask anything...",className:t,disabled:n,isStreaming:r=!1,onStop:o,modelSelector:s,value:a,onValueChange:d,onSubmit:c,textareaRef:u}){const h=a.trim(),g=!n&&h.length>0&&!r,v=!n&&h.length>0,w=A=>{d(A.target.value)},m=()=>{!h||n||r||c()},b=()=>{!r||!o||o()},C=A=>{A.key==="Enter"&&!A.shiftKey&&!A.nativeEvent.isComposing&&(A.preventDefault(),r&&o?b():m())};return i.jsxs(vt,{className:t,$isActive:v,children:[i.jsx(mt,{ref:u,rows:1,maxLength:Ue.AI_SEARCH_MAX_MESSAGE_LENGTH,placeholder:e,value:a,disabled:n,spellCheck:!1,onChange:w,onKeyDown:C}),i.jsxs(yt,{children:[s,r&&o?i.jsx(bt,{type:"button",size:"small","aria-label":"Stop generating",icon:i.jsx(Ye.StopIcon,{color:"var(--icon-color-on-color)"}),onClick:b}):i.jsx(wt,{type:"button",size:"small","aria-label":"Send message",icon:i.jsx(We.SendIcon,{color:"var(--icon-color-on-color)"}),onClick:m,disabled:!g})]})]})}const vt=l.default.div`
2
- display: flex;
3
- flex-direction: column;
4
- gap: var(--spacing-xs);
5
- width: 100%;
6
- padding: var(--spacing-xs);
7
- border: var(--search-ai-conversation-input-border, 1px solid var(--border-color-secondary));
8
- border-radius: var(--search-ai-conversation-input-border-radius, var(--border-radius-lg));
9
- background-color: var(--layer-color);
10
- box-sizing: border-box;
11
-
12
- &:hover,
13
- &:focus-within {
14
- border-color: transparent;
15
- background:
16
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
17
- var(--replay-ai-gradient-soft) border-box;
18
- }
19
-
20
- ${({$isActive:e})=>e&&X.css`
21
- border-color: transparent;
22
- background:
23
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
24
- var(--replay-ai-gradient-soft) border-box;
25
- `}
26
- `,mt=l.default.textarea`
27
- max-height: 150px;
28
- min-height: var(--search-ai-conversation-input-min-height);
29
-
30
- resize: none;
31
- border: none;
32
- outline: none;
33
- padding: 0;
34
- font-family: var(--font-family-base);
35
- font-size: var(--font-size-base);
36
- line-height: var(--line-height-base);
37
- color: var(--text-color-primary);
38
- caret-color: var(--text-color-primary);
39
- background-color: transparent;
40
- field-sizing: content;
41
-
42
- &::placeholder {
43
- color: var(--text-color-helper);
44
- text-indent: 2px;
45
- }
46
- `,yt=l.default.div`
47
- display: flex;
48
- justify-content: space-between;
49
- align-items: center;
50
- gap: var(--spacing-xs);
51
- `,wt=l.default(E.Button)`
52
- box-sizing: border-box;
53
- background: var(--search-ai-gradient);
54
-
55
- &:disabled {
56
- background: var(--replay-ai-gradient-disabled);
57
- border: var(--replay-ai-send-button-disabled-border);
58
- width: 24px;
59
- height: 24px;
60
- }
61
- `,bt=l.default(E.Button)`
62
- box-sizing: border-box;
63
- background: var(--color-warm-grey-9);
64
- border-radius: var(--border-radius-xxl);
65
- `,Ct=new Set(["collection","workflow","step","operation","workflow-run"]);function oe(e){return`replay://step?${new URLSearchParams({collectionId:e.collectionId.trim(),workflowId:e.workflowId.trim(),stepId:e.stepId.trim()}).toString()}`}function O(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(!Ct.has(n))return null;const r=t.searchParams;switch(n){case"collection":{const o=O(r,"collectionId");return o?{kind:"collection",collectionId:o}:null}case"workflow":{const o=O(r,"collectionId"),s=O(r,"workflowId");return!o||!s?null:{kind:"workflow",collectionId:o,workflowId:s}}case"step":{const o=O(r,"collectionId"),s=O(r,"workflowId"),a=O(r,"stepId");return!o||!s||!a?null:{kind:"step",collectionId:o,workflowId:s,stepId:a}}case"operation":{const o=O(r,"operationId");return o?{kind:"operation",operationId:o}:null}case"workflow-run":{const o=O(r,"collectionId"),s=O(r,"workflowId");if(!o||!s)return null;const a=O(r,"historyId"),d=a==="null"||a==="undefined"?null:a;return{kind:"workflow-run",collectionId:o,workflowId:s,...d?{historyId:d}:{}}}default:return null}}function Tt(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 It(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?.[x.workflowRunKey(n.collectionId,n.workflowId)]??[],s=n.historyId&&o.includes(n.historyId)?n.historyId:o.at(-1)??n.historyId;if(s){t.openWorkflowRunTabFromHistory(s,{state:f.TabState.Normal});break}const a=Tt(e,n.collectionId,n.workflowId);if(a!==-1){e.tabsState.tabs.get({noproxy:!0})[a].state===f.TabState.Preview&&t.changeTabState(a,f.TabState.Normal),t.handleTabChange(a);break}t.openWorkflowRunTab({collectionId:n.collectionId,workflowId:n.workflowId});break}case"operation":{const o=x.resolveOperation(e,n.operationId);if(!o.ok){console.warn("[executeReplayChatLink] Operation not resolved",{operationId:n.operationId,message:o.message});return}x.openOrFocusOperationEditorTab(e,x.operationListItemToCollectionOperation(o.value),t);break}}}function jt(e,t,n,r={}){const o=At(n);o&&It(e,t,o,r)}function Se({workflowRunHistoryIds:e}={}){const t=f.useGlobalStore(),{getApiOperation:n}=f.useApiOperation(),{handleTabChange:r,addNewTab:o,openCollectionTab:s,openWorkflowTab:a,openStepTabFromCollection:d,openWorkflowRunTab:c,openWorkflowRunTabFromHistory:u,changeTabState:h}=f.useTabHandlers();return p.useCallback(g=>{const v=g.target;if(!(v instanceof Element))return;const w=v.closest("a[href]");if(!(w instanceof HTMLAnchorElement))return;const m=w.getAttribute("href");m?.startsWith("replay:")&&(g.preventDefault(),g.stopPropagation(),jt(t,{getApiOperation:n,handleTabChange:r,addNewTab:o,openCollectionTab:s,openWorkflowTab:a,openStepTabFromCollection:d,openWorkflowRunTab:c,openWorkflowRunTabFromHistory:u,changeTabState:h},m,{workflowRunHistoryIds:e}))},[e,t,n,r,o,s,a,d,c,u,h])}class St{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const s=this.castInput(t,r),a=this.castInput(n,r),d=this.removeEmpty(this.tokenize(s,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(d,c,r,o)}diffWithOptionsObj(t,n,r,o){var s;const a=y=>{if(y=this.postProcess(y,r),o){setTimeout(function(){o(y)},0);return}else return y},d=n.length,c=t.length;let u=1,h=d+c;r.maxEditLength!=null&&(h=Math.min(h,r.maxEditLength));const g=(s=r.timeout)!==null&&s!==void 0?s:1/0,v=Date.now()+g,w=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(w[0],n,t,0,r);if(w[0].oldPos+1>=c&&m+1>=d)return a(this.buildValues(w[0].lastComponent,n,t));let b=-1/0,C=1/0;const A=()=>{for(let y=Math.max(b,-u);y<=Math.min(C,u);y+=2){let S;const R=w[y-1],P=w[y+1];R&&(w[y-1]=void 0);let V=!1;if(P){const U=P.oldPos-y;V=P&&0<=U&&U<d}const D=R&&R.oldPos+1<c;if(!V&&!D){w[y]=void 0;continue}if(!D||V&&R.oldPos<P.oldPos?S=this.addToPath(P,!0,!1,0,r):S=this.addToPath(R,!1,!0,1,r),m=this.extractCommon(S,n,t,y,r),S.oldPos+1>=c&&m+1>=d)return a(this.buildValues(S.lastComponent,n,t))||!0;w[y]=S,S.oldPos+1>=c&&(C=Math.min(C,y-1)),m+1>=d&&(b=Math.max(b,y+1))}u++};if(o)(function y(){setTimeout(function(){if(u>h||Date.now()>v)return o(void 0);A()||y()},0)})();else for(;u<=h&&Date.now()<=v;){const y=A();if(y)return y}}addToPath(t,n,r,o,s){const a=t.lastComponent;return a&&!s.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,o,s){const a=n.length,d=r.length;let c=t.oldPos,u=c-o,h=0;for(;u+1<a&&c+1<d&&this.equals(r[c+1],n[u+1],s);)u++,c++,h++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return h&&!s.oneChangePerToken&&(t.lastComponent={count:h,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,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 s;for(;t;)o.push(t),s=t.previousComponent,delete t.previousComponent,t=s;o.reverse();const a=o.length;let d=0,c=0,u=0;for(;d<a;d++){const h=o[d];if(h.removed)h.value=this.join(r.slice(u,u+h.count)),u+=h.count;else{if(!h.added&&this.useLongestToken){let g=n.slice(c,c+h.count);g=g.map(function(v,w){const m=r[u+w];return m.length>v.length?m:v}),h.value=this.join(g)}else h.value=this.join(n.slice(c,c+h.count));c+=h.count,h.added||(u+=h.count)}}return o}}class kt extends St{constructor(){super(...arguments),this.tokenize=Rt}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
66
- `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
67
- `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
68
- `)&&(t=t.slice(0,-1)),n.endsWith(`
69
- `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const Et=new kt;function Lt(e,t,n){return Et.diff(e,t,n)}function Rt(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
70
- `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const s=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}const Pt=500;function Ot(e,t){const n=_t(e,t);if(n.length===0)return[];const r=[];let o=0;for(;o<n.length;){let s=o;const a=n[o].type==="context";for(;s<n.length&&n[s].type==="context"===a;)s++;const d=n.slice(o,s);r.push({start:o,end:s,rows:d,hasAdditions:d.some(c=>c.type==="add"),hasRemovals:d.some(c=>c.type==="remove")}),o=s}return r}function _t(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 Lt(e,t,{timeout:Pt})}catch{return}}function H(e,t){const n=e.split(`
71
- `);return n.length>1&&n[n.length-1]===""&&n.pop(),n.map(r=>({type:t,text:r}))}const ce=1,de=e=>e&&e.hasAdditions!==e.hasRemovals,ue=e=>e&&(e.hasAdditions||e.hasRemovals);function Dt(e,t,n){if(e.hasAdditions||e.hasRemovals)return W(e.rows);const r=n[t-1],o=n[t+1],s=de(r)?ce:0,a=de(o)?ce:0;if(s+a>=e.rows.length)return W(e.rows);const d=e.rows.slice(0,s),c=a>0?e.rows.slice(-a):[],u=[];return u.push(...W(d)),ue(r)&&ue(o)&&u.push({kind:"separator"}),u.push(...W(c)),u}function W(e){return e.map(t=>({kind:"row",row:t}))}const Nt=200;function fe({oldValue:e,newValue:t}){const n=p.useMemo(()=>Ot(e,t),[e,t]),r=p.useMemo(()=>n.flatMap(Dt),[n]);return p.useMemo(()=>n.some(s=>s.hasAdditions||s.hasRemovals),[n])?i.jsx(Bt,{$maxHeight:Nt,children:r.map((s,a)=>{if(s.kind==="separator")return i.jsx(qt,{children:i.jsx(pe,{children:"···"})},a);const{row:d}=s,c=Ht(d.type);return i.jsxs(c,{children:[i.jsxs(Ft,{children:[d.type==="remove"&&i.jsx(Qe.SubtractIcon,{size:"12px"}),d.type==="add"&&i.jsx(Ze.AddIcon,{size:"12px"})]}),i.jsx(pe,{children:d.text===""?" ":d.text})]},a)})}):null}function Ht(e){return e==="remove"?zt:e==="add"?Vt:$t}const Bt=l.default.div`
72
- display: flex;
73
- flex-direction: column;
74
- width: 100%;
75
- min-width: 0;
76
- max-height: ${({$maxHeight:e})=>e}px;
77
- overflow-y: auto;
78
- border-radius: var(--border-radius);
79
- &::-webkit-scrollbar-track {
80
- margin: var(--spacing-xxs) 0;
81
- }
82
- `,te=l.default.div`
83
- display: flex;
84
- font-size: var(--font-size-sm);
85
- line-height: var(--line-height-sm);
86
- font-weight: var(--font-weight-regular);
87
- padding-right: var(--spacing-xxs);
88
- `,zt=l.default(te)`
89
- background: var(--admonition-danger-bg-color);
90
- color: var(--color-raspberry-7);
91
- `,Vt=l.default(te)`
92
- background: var(--admonition-success-bg-color);
93
- color: var(--color-green-7);
94
- `,$t=l.default(te)`
95
- background: transparent;
96
- color: var(--text-color-secondary);
97
- `,Ft=l.default.span`
98
- display: flex;
99
- align-items: center;
100
- justify-content: center;
101
- min-width: 16px;
102
- height: 20px;
103
- flex-shrink: 0;
104
- `,pe=l.default.span`
105
- width: 100%;
106
- min-width: 0;
107
- line-height: var(--line-height-sm);
108
- font-size: var(--font-size-sm);
109
- font-weight: var(--font-weight-regular);
110
- white-space: pre-wrap;
111
- word-break: break-all;
112
- `,qt=l.default(te)`
113
- user-select: none;
114
- `,Gt=e=>typeof e!="object"||e===null?!1:"kind"in e&&e.kind==="batch"?"changes"in e?Array.isArray(e.changes)&&e.changes.every(he):!1:he(e);function he(e){return typeof e!="object"||e===null||!("id"in e)||!("target"in e)||!("included"in e)||!("kind"in e)?!1:e.kind==="single"}const Ut={approveLabel:"Approve",denyLabel:"Deny"};function Wt(e,t){const n=T(t,"action");if(n){const o=x.TOOL_APPROVAL_ACTION_BUTTON_LABELS[n];if(o)return o}const r=x.TOOL_APPROVAL_BUTTON_LABELS[e];return r||Ut}function T(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 Y(e,t){if(!(typeof t>"u"))return e?`${e}: ${t}`:t}function Yt(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 Kt(e,t){if(!e||typeof e!="object")return;const n=Z(e,f.REPLAY_MESSAGE_METADATA_NS),r=Z(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(Gt))return o}function ke(e,t){return x.isToolApprovalPart(e)&&x.isApprovalRequested(e)&&e.toolCallId===t}function Jt(e,t,n){const r=e.parts.map(c=>ke(c,t)?{...c,input:Xt(c.input,n)}:c),o=e.metadata&&typeof e.metadata=="object"?e.metadata:{},s=Z(o,f.REPLAY_MESSAGE_METADATA_NS),d={...Z(s,f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY),[t]:f.cloneObject(n)};return{...e,parts:r,metadata:{...o,[f.REPLAY_MESSAGE_METADATA_NS]:{...s,[f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY]:d}}}}function Z(e,t){const n=e[t];return typeof n=="object"&&n!==null?n:{}}function Xt(e,t){if(!e||!("changes"in e)||!Array.isArray(e.changes))return e;const{changes:n,...r}=e;return{...r,changes:n.map((o,s)=>({...o,approved:t[s]?.included??!1}))}}function Zt({preview:e,isIncluded:t,onToggle:n,readOnly:r}){const{primaryLabel:o,categoryLabel:s,diffLineKey:a}=Qt(e.target);return i.jsx(en,{isIncluded:t,onToggle:n,readOnly:r,primaryLabel:o,categoryLabel:s,children:e.kind==="batch"?i.jsx(fn,{children:e.changes.map(d=>i.jsx(fe,{oldValue:Y(d.target.key,d.oldValue),newValue:Y(d.target.key,d.newValue)},d.id))}):i.jsx(fe,{oldValue:Y(a,e.oldValue),newValue:Y(a,e.newValue)})})}function Qt(e){const t=e.schemeId??e.type;return e.stepId||e.schemeId?{primaryLabel:e.stepId??t,categoryLabel:e.stepId?t:void 0,diffLineKey:e.key}:{primaryLabel:e.key??e.type,categoryLabel:e.key?e.type:void 0,diffLineKey:void 0}}function en({isIncluded:e,onToggle:t,readOnly:n,primaryLabel:r,categoryLabel:o,children:s}){return i.jsxs(tn,{$dimmed:n&&!e,children:[i.jsxs(nn,{children:[n?i.jsx(cn,{children:e?i.jsx(dn,{size:"16px"}):i.jsx(un,{size:"16px"})}):i.jsxs(an,{children:[i.jsx(sn,{checked:e}),i.jsx(ln,{type:"checkbox",checked:e,onChange:t})]}),i.jsx(rn,{children:r}),o?i.jsx(on,{children:o}):null]}),s]})}const tn=l.default.div`
115
- display: flex;
116
- flex-direction: column;
117
- gap: var(--spacing-xs);
118
- min-width: 0;
119
- padding: var(--spacing-xs);
120
- border-bottom: 1px solid var(--border-color-secondary);
121
- box-sizing: border-box;
122
- opacity: ${({$dimmed:e})=>e?.4:1};
123
- &:last-child {
124
- border-bottom: none;
125
- }
126
- `,nn=l.default.div`
127
- display: flex;
128
- align-items: center;
129
- gap: var(--spacing-xs);
130
- min-width: 0;
131
- `,rn=l.default.span`
132
- flex: 1;
133
- min-width: 0;
134
- color: var(--text-color-primary);
135
- font-size: var(--font-size-sm);
136
- font-weight: var(--font-weight-medium);
137
- line-height: var(--line-height-sm);
138
- overflow: hidden;
139
- text-overflow: ellipsis;
140
- white-space: nowrap;
141
- `,on=l.default.span`
142
- flex-shrink: 0;
143
- font-family: var(--code-block-font-family, var(--font-family-monospace, monospace));
144
- font-size: var(--font-size-sm);
145
- font-weight: var(--font-weight-regular);
146
- line-height: var(--line-height-sm);
147
- color: var(--text-color-secondary);
148
- `,sn=l.default(Ke.CheckboxIcon).attrs({"aria-hidden":!0})`
149
- --checkbox-border-color: var(--color-blueberry-6);
150
- --checkbox-box-color: var(--color-blueberry-6);
151
- --checkbox-box-color-active: var(--color-blueberry-6);
152
- `,an=l.default.span`
153
- position: relative;
154
- display: inline-flex;
155
- flex-shrink: 0;
156
- width: 16px;
157
- height: 16px;
158
- `,ln=l.default.input`
159
- position: absolute;
160
- inset: 0;
161
- width: 16px;
162
- height: 16px;
163
- margin: 0;
164
- opacity: 0;
165
- cursor: pointer;
166
- `,cn=l.default.span`
167
- display: inline-flex;
168
- flex-shrink: 0;
169
- width: 16px;
170
- height: 16px;
171
- align-items: center;
172
- justify-content: center;
173
- `,dn=l.default(Je.CheckmarkFilledIcon)`
174
- color: var(--color-success-base);
175
- `,un=l.default(Xe.CloseFilledIcon)`
176
- color: var(--text-color-description);
177
- `,fn=l.default.div`
178
- display: flex;
179
- flex-direction: column;
180
- gap: var(--spacing-xxs);
181
- min-width: 0;
182
- `;function Ee({previews:e,handleToggle:t,readOnly:n}){return e.length===0?null:i.jsx(pn,{children:e.map((r,o)=>i.jsx(Zt,{preview:r,isIncluded:r.included,onToggle:t?()=>t(o):void 0,readOnly:n},r.id))})}const pn=l.default.div`
183
- display: flex;
184
- flex-direction: column;
185
- `,hn={update_step:vn,update_security:mn,run_request:Cn,web_search:An,manage_environment:wn,manage_collection:bn};function xn(e,t){const n=hn[e];return n?n(t):gn(e)}function gn(e){return[{kind:"text",text:e.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}]}function vn(e){return Le(e,"Update step")}function mn(e){const t=yn(e);if(t.size>1)return j("Update security");const[n]=t;return Le(e,"Update security",n)}function yn(e){const t=e&&"changes"in e?e.changes:void 0;if(!Array.isArray(t))return new Set;const n=F(e,"stepId"),r=t.map(o=>F(o,"stepId")??n);return new Set(r.filter(o=>!!o))}function Le(e,t,n){const{collectionId:r,workflowId:o,stepId:s}=Tn(e),a=n??s;return!r||!o||!a?j(t):ie(`${t} `,oe({collectionId:r,workflowId:o,stepId:a}),a)}function j(e){return[{kind:"text",text:e}]}function L(e,t){return t?`${e} "${t}"`:e}function ie(e,t,n){return[{kind:"text",text:e},{kind:"link",href:t,label:n}]}function wn(e){const t=T(e,"action"),n=T(e,"environment"),r=n?` in environment "${n}"`:"";switch(t){case"add_environment":return j(L("Add environment",n));case"set_active_environment":return j(n?`Switch active environment to ${n}`:"Switch active environment");case"upsert_input":return j(L("Set input",T(e,"name"))+r);case"remove_input":return j(L("Remove input",T(e,"inputName"))+r);case"upsert_server":return j(L("Set server",T(e,"apiId"))+r);case"remove_server":return j(L("Remove server",T(e,"apiId"))+r);default:return j("Manage environment")}}function bn(e){switch(T(e,"action")){case"create_collection":return j(L("Create collection",T(e,"title")));case"delete_collection":return j(L("Delete collection",T(e,"collectionId")));case"create_workflow":return j(L("Create workflow",T(e,"name")));case"delete_workflow":return j(L("Delete workflow",T(e,"workflowId")));case"create_step":return j(L("Create step",T(e,"stepName")));case"delete_step":{const n=T(e,"collectionId"),r=T(e,"workflowId"),o=T(e,"stepId");return!n||!r||!o?j("Delete step"):ie("Delete step ",oe({collectionId:n,workflowId:r,stepId:o}),o)}case"move_step":{const n=T(e,"collectionId"),r=T(e,"workflowId"),o=T(e,"stepId");return!n||!r||!o?j("Move step"):ie("Move step ",oe({collectionId:n,workflowId:r,stepId:o}),o)}case"save_tab_to_collection":return j(L("Save tab as step",T(e,"newStepName")));default:return j("Manage collection")}}function Cn(){return[{kind:"text",text:"Run current request"}]}function An(e){return[{kind:"text",text:"Search the web at "},{kind:"link",href:e.url,label:e.url}]}function Tn(e){return{collectionId:F(e,"collectionId"),workflowId:F(e,"workflowId"),stepId:F(e,"stepId")}}function F(e,t){if(typeof e!="object"||e===null||!(t in e))return null;const n=e[t];return typeof n=="string"&&n.trim()||null}function Re({toolName:e,input:t}){const n=xn(e,t),r=Se();return i.jsx(In,{onClick:r,children:i.jsx(jn,{children:n.map((o,s)=>o.kind==="text"?i.jsx("span",{children:o.text},s):i.jsx(Sn,{href:o.href,children:o.label},s))})})}const In=l.default.div`
186
- display: flex;
187
- flex-direction: column;
188
- gap: 0;
189
- min-width: 0;
190
- padding: var(--spacing-xs) var(--spacing-sm);
191
-
192
- &:not(:last-child) {
193
- border-bottom: 1px solid var(--border-color-secondary);
194
- }
195
- `,jn=l.default.span`
196
- font-family: var(--font-family-base);
197
- font-size: var(--font-size-sm);
198
- font-weight: var(--font-weight-regular);
199
- line-height: var(--line-height-sm);
200
- color: var(--text-color-primary);
201
- `,Sn=l.default.a`
202
- color: var(--link-color-primary);
203
- cursor: pointer;
204
- text-decoration: none;
205
-
206
- &:hover {
207
- color: var(--link-color-primary, var(--text-color-link));
208
- }
209
- `;function Pe(e,t,n){const r={type:e};return t!==void 0&&(r.key=t),n&&(r.stepId=n),r}function I({id:e,targetType:t,targetKey:n,targetStepId:r,oldValue:o,newValue:s}){return{kind:"single",id:e,target:Pe(t,n,r),oldValue:o,newValue:s,included:!0}}function N(e,t,n){return I({id:e,targetType:t,targetStepId:n,oldValue:void 0,newValue:void 0})}function z({data:e,baseId:t,targetType:n,batchTargetKey:r,targetStepId:o,getOldValue:s,getNewValue:a=(c,u)=>String(u??""),resolveTargetKey:d=c=>c}){const c=Object.entries(e).filter(([,g])=>g!==void 0);if(c.length===0)return N(t,n,o);if(c.length>=2){const g=c.map(([v,w])=>I({id:`${t}:${v}`,targetType:n,targetKey:d(v),oldValue:s(v),newValue:a(v,w)}));return{kind:"batch",id:t,target:Pe(n,r,o),changes:g,included:!0}}const[u,h]=c[0];return I({id:t,targetType:n,targetKey:d(u),targetStepId:o,oldValue:s(u),newValue:a(u,h)})}function kn({store:e,input:t}){if(!En(t))return[];const n=new Map,r=o=>{const s=n.get(o);if(s)return s;const a=x.resolveStepOrDraft(e,t.collectionId,t.workflowId,o),d=a.ok?a.value:null,c=d?Array.from(d.security.get({noproxy:!0})):[];return n.set(o,c),c};return t.changes.map((o,s)=>{const a=o.stepId?.trim(),d=a||t.stepId;return Ln(r(d),o,s,a)})}function En(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 Ln(e,t,n,r){const o=`security[${n}]`;switch(t.action){case x.CHANGE_ACTION.ADD:{const{type:s,schemeId:a,data:d}=t;return!d||Object.keys(d).length===0?$(I({id:o,targetType:s,targetStepId:r,oldValue:void 0,newValue:s}),a):$(z({data:d,baseId:o,targetType:s,targetStepId:r,getOldValue:()=>{}}),a)}case x.CHANGE_ACTION.UPDATE:{const{type:s,data:a}=t,d=t.index!==void 0?e[t.index]:void 0,c=t.schemeId||se(d);return!a||Object.keys(a).length===0?$(I({id:o,targetType:s,targetStepId:r,oldValue:ge(d),newValue:s}),c):$(z({data:a,baseId:o,targetType:s,targetStepId:r,getOldValue:u=>d?Rn(d,u):void 0}),c)}case x.CHANGE_ACTION.REMOVE:{const s=x.resolveRemovalTarget(e,t),a=s.ok?s.entry:void 0;return $(I({id:o,targetType:a?.securityType??"Security",targetStepId:r,oldValue:ge(a),newValue:void 0}),se(a))}}}function $(e,t){return t?{...e,target:{...e.target,schemeId:t}}:e}function Rn(e,t){switch(e.securityType){case f.SecurityTypes.NoAuth:return;case f.SecurityTypes.OAuth2:return xe(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:xe(n,t)}case f.SecurityTypes.APIKey:{const n=e[f.SecurityTypes.APIKey];return t==="location"?J(n,t)?.toLowerCase():J(n,t)}default:{const n=e[e.securityType];return J(n,t)}}}function xe(e,t){if(t==="grantType")return e.grantType||void 0;if(!e.grantType)return;const n=e[e.grantType];return J(n,t)}function J(e,t){const n=e[t];return n!==void 0&&n!==""?String(n):void 0}function ge(e){if(!e||e.securityType===f.SecurityTypes.NoAuth)return;const t=se(e);return t?`${e.securityType} (${t})`:e.securityType}function se(e){return!e||e.securityType===f.SecurityTypes.NoAuth?void 0:e[e.securityType]?.schemeName||void 0}function Pn({store:e,input:t}){if(!On(t))return[];const n=x.resolveStepOrDraft(e,t.collectionId,t.workflowId,t.stepId),r=n.ok?n.value:null;return t.changes.map((o,s)=>_n(r,o,s))}function On(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 _n(e,t,n){const r=t.id??`${t.field}[${n}]`;switch(t.field){case"method":case"url":case"description":return Mn(e,t,r);case"parameters":return Dn(e,t,r);case"outputs":return Nn(e,t,r);case"body":return Hn(e,t,r);case"successCriteria":return Bn(e,t,r)}}function Mn(e,t,n){const r=K.capitalize(t.field);switch(t.action){case x.CHANGE_ACTION.ADD:return I({id:n,targetType:r,oldValue:void 0,newValue:t.data});case x.CHANGE_ACTION.UPDATE:return I({id:n,targetType:r,oldValue:ve(e,t.field),newValue:t.data});case x.CHANGE_ACTION.REMOVE:return I({id:n,targetType:r,oldValue:ve(e,t.field),newValue:void 0})}}function Dn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:{if(!t.data)return N(n,"parameter");const{in:r,name:o,value:s}=t.data;return I({id:n,targetType:K.capitalize(r),targetKey:o,oldValue:void 0,newValue:s})}case x.CHANGE_ACTION.UPDATE:{if(!t.id&&!t.data?.name)return N(n,"parameter");const r=me(e,t),o=t.data?.in??r?.in??"parameter";return I({id:n,targetType:K.capitalize(o),targetKey:t.data?.name??r?.key,oldValue:r?r.value??"":void 0,newValue:t.data?.value})}case x.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return N(n,"parameter");const r=me(e,t),o=t.data?.in??r?.in??"parameter";return I({id:n,targetType:K.capitalize(o),targetKey:r?.key??t.data?.name,oldValue:r?r.value??"":void 0,newValue:void 0})}}}function Nn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:return t.data?I({id:n,targetType:"Output",targetKey:t.data.name,oldValue:void 0,newValue:t.data.expression}):I({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});case x.CHANGE_ACTION.UPDATE:{if(!t.data)return I({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});const r=t.id&&e?we(e,t.id):void 0;return I({id:n,targetType:"Output",targetKey:t.data.name,oldValue:r?.value,newValue:t.data.expression})}case x.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return N(n,"Output");let r=t.id&&e?we(e,t.id):void 0;return!r&&e&&t.data?.name&&(r=$n(e,t.data.name)),I({id:n,targetType:"Output",targetKey:r?.key??t.data?.name,oldValue:r?.value,newValue:void 0})}}}function Hn(e,t,n){const{data:r}=t;switch(t.action){case x.CHANGE_ACTION.ADD:return z({data:r,baseId:n,targetType:"Body",getOldValue:()=>{},getNewValue:o=>o==="content"?re(r.content,r.contentType):ee(r[o]),resolveTargetKey:o=>o==="content"?void 0:o});case x.CHANGE_ACTION.UPDATE:{const o=e?.requestBody.type.get(),s=r.contentType??o;return z({data:r,baseId:n,targetType:"Body",getOldValue:a=>{if(e){if(a==="content")return re(e.requestBody.content.get(),o)||void 0;if(a==="contentType")return o}},getNewValue:a=>a==="content"?re(r.content,s):ee(r[a]),resolveTargetKey:a=>a==="content"?void 0:a})}case x.CHANGE_ACTION.REMOVE:{const o=e?f.toCompactJson({contentType:e.requestBody.type.get(),content:e.requestBody.content.get()}):void 0;return I({id:n,targetType:"Body",oldValue:o,newValue:void 0})}}}function Bn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:return t.data?z({data:t.data,baseId:n,targetType:"successCriteria",getOldValue:()=>{},getNewValue:r=>ee(t.data[r])}):N(n,"successCriteria");case x.CHANGE_ACTION.UPDATE:{if(!t.data)return N(n,"successCriteria");const r=typeof t.id=="string"&&e?ye(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=>ee(t.data[o])})}case x.CHANGE_ACTION.REMOVE:{if(typeof t.id!="string")return N(n,"successCriteria");const r=e?ye(e,t.id):void 0;return I({id:n,targetType:"successCriteria",targetKey:r?.condition,oldValue:r?f.toCompactJson(r):void 0,newValue:void 0})}}}function ve(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 me(e,t){let n=t.id&&e?zn(e,t.id):null;return!n&&e&&t.data?.name&&(n=Vn(e,t.data.name)),n}function Oe(e,t){for(const n of["path","query","header","cookie"]){const r=e.parameters[x.LOCATION_TO_FIELD[n]].get().find(o=>f.isInlineRequestParameter(o)&&t(o));if(r)return r}return null}function zn(e,t){return Oe(e,n=>n.id===t)}function Vn(e,t){return Oe(e,n=>n.key===t)}function ye(e,t){return e.successCriteria.get().find(n=>n.condition===t)}function _e(e,t){for(const n of e.outputs.get())if(t(n))return{key:Q(n.key),value:Q(n.value)}}function we(e,t){return _e(e,n=>Q(n.id)===t)}function $n(e,t){return _e(e,n=>Q(n.key)===t)}function Q(e){return typeof e=="string"?e:e.get()}function ee(e){return e==null?"":typeof e=="string"?e:f.toCompactJson(e)}function re(e,t){if(!e||t!==f.TextContentType.JSON)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const Fn={update_security:kn,update_step:Pn};function Me(e,t){const n=f.useGlobalStore(),r=p.useMemo(()=>{const c=e?Fn[e]:void 0;if(!c)return[];try{return c({store:n,input:t})}catch(u){return console.error("Unable to build change previews",u),[]}},[e,n,t]),[o,s]=p.useState(()=>Object.fromEntries(r.map(c=>[c.id,c.included]))),a=p.useMemo(()=>r.map(c=>({...c,included:o[c.id]??c.included})),[r,o]),d=p.useCallback(c=>{s(typeof c=="function"?u=>{const h=r.map(g=>({...g,included:u[g.id]??g.included}));return Object.fromEntries(c(h).map(g=>[g.id,g.included]))}:Object.fromEntries(c.map(u=>[u.id,u.included])))},[r]);return{previews:a,setPreviews:d}}function qn({toolCallId:e,toolName:t,input:n,onApprove:r,onDeny:o}){const{updateMessages:s}=x.useAiConversationContext(),{previews:a,setPreviews:d}=Me(t,n),{includedCount:c,totalCount:u}=p.useMemo(()=>({includedCount:a.filter(m=>m.included).length,totalCount:a.length}),[a]),{approveLabel:h,denyLabel:g}=p.useMemo(()=>Wt(t,n),[t,n]),v=p.useCallback(()=>{s(m=>{const b=[];for(let C=0;C<m.length;C++){const A=m[C],{parts:y}=A,S=A.role==="assistant",R=y.some(P=>ke(P,e));if(S&&R){const P=Jt(A,e,a);b.push({index:C,message:P})}}return b}),r()},[a,r,s,e]),w=p.useCallback(m=>{d(b=>b.map((C,A)=>A===m?{...C,included:!C.included}:C))},[d]);return i.jsxs(Gn,{children:[i.jsx(Re,{toolName:t,input:n}),a.length?i.jsx(Un,{children:i.jsx(Ee,{previews:a,handleToggle:w})}):null,a.length?i.jsx(f.Divider,{}):null,i.jsxs(Wn,{children:[u>1?i.jsxs(Yn,{children:[c," of ",u," selected"]}):null,i.jsx(Kn,{size:"small",variant:"secondary",onClick:o,children:g}),i.jsx(Jn,{size:"small",variant:"primary",onClick:v,disabled:u>0?c===0:!1,children:h})]})]})}const Gn=l.default.div`
210
- display: flex;
211
- color: var(--text-color-primary);
212
- flex-direction: column;
213
- gap: var(--spacing-xs);
214
- width: 100%;
215
- min-width: 0;
216
- border-radius: var(--border-radius-md, 10px);
217
- border: 1px solid var(--border-color-secondary);
218
- background: var(--layer-color);
219
- line-height: var(--line-height-sm);
220
- `,Un=l.default.div`
221
- display: flex;
222
- flex-direction: column;
223
- gap: var(--spacing-xs);
224
- min-width: 0;
225
- `,Wn=l.default.div`
226
- display: flex;
227
- flex-wrap: wrap;
228
- justify-content: flex-end;
229
- align-items: center;
230
- padding: 0 var(--spacing-sm) var(--spacing-xs) var(--spacing-sm);
231
- gap: var(--spacing-xxs);
232
- `,Yn=l.default.span`
233
- flex: 1;
234
- font-size: var(--font-size-sm);
235
- font-weight: var(--font-weight-regular);
236
- line-height: var(--line-height-sm);
237
- color: var(--text-color-secondary);
238
- `,Kn=l.default(E.Button)`
239
- background: none;
240
- `,Jn=l.default(E.Button)`
241
- border: 1px solid var(--button-bg-color);
242
- padding-top: 0;
243
- padding-bottom: 0;
244
- &:disabled {
245
- border: 1px solid var(--button-border-color-disabled);
246
- }
247
- `;function Xn({approvalId:e,toolCallId:t,toolName:n,input:r}){const{addToolApprovalResponse:o}=x.useAiConversationContext(),s=p.useCallback(()=>{o({id:e,approved:!0})},[e,o]),a=p.useCallback(()=>{o({id:e,approved:!1})},[e,o]);return i.jsx(qn,{onApprove:s,onDeny:a,toolCallId:t,toolName:n,input:r})}function Zn({toolName:e,toolCallId:t,input:n,isDenied:r,messageMetadata:o,onUndo:s}){const a=p.useMemo(()=>Kt(o,t),[o,t]),{previews:d}=Me(a?void 0:e,n),c=p.useMemo(()=>{const v=a??d;if(r)return v.map(m=>({...m,included:!1}));const w=Yt(n);return v.map((m,b)=>({...m,included:w[b]??m.included}))},[a,d,n,r]);if(c.length===0)return null;const u=c.filter(v=>v.included).length,g=u===0?"Nothing applied":`${u} ${u===1?"change":"changes"} applied`;return i.jsxs(Qn,{children:[i.jsx(Re,{toolName:e,input:n}),i.jsx(er,{children:i.jsx(Ee,{previews:c,readOnly:!0})}),i.jsx(f.Divider,{}),i.jsxs(tr,{children:[i.jsx(nr,{children:g}),s?i.jsx(rr,{size:"small",variant:"outlined",onClick:s,children:"Undo"}):null]})]})}const Qn=l.default.div`
248
- display: flex;
249
- color: var(--text-color-primary);
250
- flex-direction: column;
251
- width: 100%;
252
- min-width: 0;
253
- border-radius: var(--border-radius-md, 10px);
254
- border: 1px solid var(--border-color-secondary);
255
- background: var(--layer-color);
256
- line-height: var(--line-height-sm);
257
- `,er=l.default.div`
258
- display: flex;
259
- flex-direction: column;
260
- min-width: 0;
261
- `,tr=l.default.div`
262
- display: flex;
263
- justify-content: space-between;
264
- align-items: center;
265
- padding: var(--spacing-xs) var(--spacing-sm);
266
- gap: var(--spacing-xs);
267
- `,nr=l.default.span`
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-secondary);
272
- `,rr=l.default(E.Button)`
273
- padding-top: 0;
274
- padding-bottom: 0;
275
- `;function or({items:e,isLast:t}){const[n,r]=p.useState(t),o=p.useCallback(()=>{r(a=>!a)},[]),s=p.useMemo(()=>e.filter(a=>a.kind==="action"),[e]);return i.jsxs(sr,{children:[i.jsxs(ar,{type:"button",onClick:o,"aria-expanded":n,children:[i.jsx(lr,{children:n?i.jsx(et.ChevronDownIcon,{size:"12px",color:"var(--icon-color-additional)"}):i.jsx(tt.ChevronRightIcon,{size:"12px",color:"var(--icon-color-additional)"})}),i.jsxs(cr,{children:[s.length," ",s.length===1?"action":"actions"]})]}),n&&i.jsx(dr,{children:s.map((a,d)=>i.jsx(ir,{text:a.text},d))})]})}function ir({text:e}){return i.jsxs(ur,{children:[i.jsxs(fr,{children:[i.jsx(pr,{"aria-hidden":!0}),i.jsx(hr,{children:i.jsx(xr,{"aria-hidden":!0})}),i.jsx(De,{"aria-hidden":!0})]}),i.jsx(gr,{children:e})]})}const sr=l.default.div`
276
- display: flex;
277
- flex-direction: column;
278
- width: 100%;
279
- min-width: 0;
280
- `,ar=l.default.button`
281
- display: flex;
282
- align-items: center;
283
- cursor: pointer;
284
- user-select: none;
285
- width: fit-content;
286
- padding: 0;
287
- `,lr=l.default.span`
288
- display: flex;
289
- align-items: center;
290
- flex-shrink: 0;
291
- `,cr=l.default.span`
292
- font-size: var(--font-size-sm);
293
- font-weight: var(--font-weight-regular);
294
- line-height: var(--line-height-sm);
295
- color: var(--text-color-description);
296
- `,dr=l.default.div`
297
- display: flex;
298
- flex-direction: column;
299
- gap: 0;
300
- `,De=l.default.span`
301
- display: block;
302
- width: 1px;
303
- flex-shrink: 0;
304
- align-self: center;
305
- background: var(--border-color-secondary);
306
- flex: 1 1 auto;
307
- min-height: 8px;
308
- `,ur=l.default.div`
309
- display: flex;
310
- flex-direction: row;
311
- align-items: stretch;
312
- gap: var(--spacing-xxs);
313
- min-width: 0;
314
-
315
- &:last-child {
316
- ${De} {
317
- display: none;
318
- }
319
- }
320
- `,fr=l.default.div`
321
- display: flex;
322
- flex-direction: column;
323
- align-items: center;
324
- box-sizing: border-box;
325
- width: 12px;
326
- flex: 0 0 auto;
327
- align-self: stretch;
328
- min-height: 0;
329
- `,pr=l.default.span`
330
- display: block;
331
- width: 1px;
332
- height: 4px;
333
- flex: 0 0 auto;
334
- flex-shrink: 0;
335
- background: var(--border-color-secondary);
336
- `,hr=l.default.div`
337
- width: 12px;
338
- height: 12px;
339
- flex: 0 0 auto;
340
- flex-shrink: 0;
341
- display: flex;
342
- align-items: center;
343
- justify-content: center;
344
- `,xr=l.default.span`
345
- width: 4px;
346
- height: 4px;
347
- flex-shrink: 0;
348
- border-radius: 50%;
349
- box-sizing: border-box;
350
- border: 1px solid var(--border-color-secondary);
351
- background: transparent;
352
- `,gr=l.default.span`
353
- flex: 1;
354
- min-width: 0;
355
- align-self: flex-start;
356
- font-size: var(--font-size-sm);
357
- font-weight: var(--font-weight-regular);
358
- line-height: var(--line-height-sm);
359
- color: var(--text-color-helper);
360
- `;function vr({items:e,messageMetadata:t}){return i.jsx(yr,{children:e.map((n,r)=>{if(n.kind==="reasoning-block"){const a=r===e.length-1;return i.jsx(or,{items:n.items,isLast:a},n.key)}if(n.kind==="text")return i.jsx(mr,{rawMarkdown:n.text,workflowRunHistoryIds:n.workflowRunHistoryIds},n.key);const{part:o}=n,s=x.parseToolName(o.type);return s&&x.isApprovalRequested(o)?i.jsx(Xn,{approvalId:o.approval.id,toolCallId:o.toolCallId,toolName:s,input:o.input},n.key):s&&x.isApprovalSettled(o)?i.jsx(Zn,{toolName:s,toolCallId:o.toolCallId,input:o.input,isDenied:o.state==="output-denied",messageMetadata:t},n.key):null})})}function mr({rawMarkdown:e,workflowRunHistoryIds:t}){const n=Se({workflowRunHistoryIds:t});return i.jsx(wr,{onClick:n,children:i.jsx(f.Markdown,{rawMarkdown:e,parser:f.markdownParserMarked})})}const yr=l.default.div`
361
- display: flex;
362
- flex-direction: column;
363
- gap: var(--spacing-xs);
364
- `,wr=l.default.div`
365
- white-space: normal;
366
-
367
- max-width: 100%;
368
- overflow: hidden;
369
-
370
- p:first-child {
371
- margin-top: 0;
372
- }
373
-
374
- p:last-child {
375
- margin-bottom: 0;
376
- }
377
- `,Ne=l.default.div`
378
- font-family: var(--font-family-base);
379
- font-size: var(--font-size-sm);
380
- line-height: var(--line-height-sm);
381
- color: var(--text-color-primary);
382
- `,q=l.default.div`
383
- width: var(--search-ai-thinking-dot-size);
384
- height: var(--search-ai-thinking-dot-size);
385
- border-radius: 50%;
386
- background: var(--search-ai-thinking-dot-color);
387
- animation: bounce 1.4s infinite ease-in-out;
388
-
389
- &:nth-child(1) {
390
- animation-delay: -0.32s;
391
- }
392
-
393
- &:nth-child(2) {
394
- animation-delay: -0.16s;
395
- }
396
-
397
- &:nth-child(3) {
398
- animation-delay: 0s;
399
- }
400
-
401
- @keyframes bounce {
402
- 0%,
403
- 80%,
404
- 100% {
405
- opacity: 0.2;
406
- transform: scale(0.8);
407
- }
408
- 40% {
409
- opacity: 1;
410
- transform: scale(1);
411
- }
412
- }
413
- `;function br(){return i.jsxs(Cr,{children:[i.jsx(q,{}),i.jsx(q,{}),i.jsx(q,{})]})}const Cr=l.default.div`
414
- display: flex;
415
- align-items: center;
416
- justify-content: space-between;
417
- width: 24px;
418
- height: 24px;
419
- `;function Ar(){return i.jsxs(Tr,{children:[i.jsx(br,{}),i.jsx(Ir,{children:"Thinking"})]})}const Tr=l.default.div`
420
- display: flex;
421
- align-items: center;
422
- gap: var(--spacing-xxs);
423
- `,Ir=l.default.span`
424
- font-family: var(--font-family-base);
425
- font-size: var(--font-size-sm);
426
- line-height: var(--line-height-sm);
427
- color: var(--text-color-helper);
428
- `;function jr({items:e}){return i.jsx(p.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 kr(e){const t=e?.message?.trim();return t||Sr}function Er({message:e,isLastMessage:t}){const{chatStatus:n,chatError:r}=x.useAiConversationContext(),{role:o,parts:s}=e,a=o===M.MESSAGE_ROLE.ASSISTANT,d=p.useMemo(()=>x.getContentItems(s),[s]),c=d.length>0,u=n==="error"&&t&&a&&!c;return!c&&!u?null:i.jsx(He,{$role:o,children:i.jsx(Rr,{isFailedEmptyAssistant:u,chatError:r,isAssistant:a,contentItems:d,messageMetadata:e.metadata})})}function Lr(){return i.jsx(He,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(ae,{children:i.jsx(Ar,{})})})}function Rr({isFailedEmptyAssistant:e,chatError:t,isAssistant:n,contentItems:r,messageMetadata:o}){return e?i.jsx(ae,{children:i.jsx(Ne,{children:kr(t)})}):i.jsx(ae,{children:n?i.jsx(vr,{items:r,messageMetadata:o}):i.jsx(jr,{items:r})})}const He=l.default.div`
429
- display: flex;
430
- flex-direction: column;
431
- padding: var(--spacing-xs) var(--spacing-sm);
432
- gap: var(--spacing-xxs);
433
- min-width: 0;
434
- width: ${({$role:e})=>e===M.MESSAGE_ROLE.ASSISTANT?"100%":"fit-content"};
435
- border-radius: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"6px 0px 6px 6px":"0px 6px 6px 6px"};
436
- background: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"var(--replay-ai-user-message-gradient)":"transparent"};
437
- border: none;
438
- color: var(--text-color-primary);
439
- box-sizing: border-box;
440
- word-wrap: break-word;
441
- white-space: pre-wrap;
442
- max-width: 100%;
443
- `,ae=l.default.div`
444
- display: flex;
445
- flex-direction: column;
446
- gap: var(--spacing-xxs);
447
- min-width: 0;
448
- width: 100%;
449
- `;function Pr(){const{messages:e,isStreaming:t}=x.useAiConversationContext(),n=e.at(-1),r=p.useMemo(()=>{const o=n?.role===M.MESSAGE_ROLE.ASSISTANT,s=n?.parts.at(-1)?.type==="text";return t&&!(o&&s)},[t,n?.parts,n?.role]);return i.jsxs(Or,{children:[e.map((o,s)=>i.jsx(be,{$role:o.role,children:i.jsx(Ce,{$role:o.role,children:i.jsx(Er,{message:o,isLastMessage:s===e.length-1})})},o.id)),r&&i.jsx(be,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(Ce,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(Lr,{})})})]})}const Or=l.default.div`
450
- display: flex;
451
- flex-direction: column;
452
- gap: var(--spacing-xs);
453
- width: 100%;
454
- `,be=l.default.div`
455
- display: flex;
456
- width: 100%;
457
- justify-content: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"flex-end":"flex-start"};
458
- `,Ce=l.default.div`
459
- display: flex;
460
- flex-direction: column;
461
- align-items: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"flex-end":"stretch"};
462
- gap: var(--spacing-xs);
463
- min-width: 0;
464
- width: 100%;
465
- max-width: 100%;
466
- `;function _r(e){const t=p.useRef(void 0);return p.useEffect(()=>{t.current=e}),t.current}const Be=l.default.div`
467
- display: flex;
468
- flex-direction: column;
469
- flex: 1;
470
- width: 100%;
471
- overflow: auto;
472
- padding: var(--spacing-xs);
473
- `,Mr=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"})]})})]}),Dr=l.default(Mr)`
474
- height: ${({size:e})=>e||"14px"};
475
- width: ${({size:e})=>e||"14px"};
476
- `;function Nr(e){const t="var(--font-size-base)";switch(e){case f.REUNITE_AI_PROVIDER:return i.jsx(Dr,{size:t});case f.AI_PROVIDERS.OPENAI:return i.jsx(st.ChatGptIcon,{size:t,color:"var(--text-color-primary)"});case f.AI_PROVIDERS.GEMINI:return i.jsx(at.GeminiIcon,{size:t});case f.AI_PROVIDERS.ANTHROPIC:return i.jsx(lt.ClaudeIcon,{size:t,color:"var(--replay-claude-icon-color)"})}}function Hr({models:e,selectedModelId:t,placement:n,onModelSelect:r,onSettingsOpen:o}){const s=e.find(g=>g.id===t),a=s?.label??"Replay AI",d=s?.id,c=e.filter(g=>g.provider===f.REUNITE_AI_PROVIDER),u=e.filter(g=>g.provider!==f.REUNITE_AI_PROVIDER),h=c.length>0&&u.length>0;return i.jsx($r,{children:i.jsx(Fr,{trigger:i.jsx(Br,{label:a}),placement:n,alignment:"start",withArrow:!0,children:i.jsxs(qr,{children:[i.jsxs(Wr,{children:[c.map(g=>i.jsx(Ae,{model:g,activeModelId:d,onModelSelect:r},g.id)),h&&i.jsx(Te,{"aria-hidden":!0}),u.length>0&&i.jsx(i.Fragment,{children:u.map(g=>i.jsx(Ae,{model:g,activeModelId:d,onModelSelect:r},g.id))})]}),o&&e.length>0&&i.jsx(Te,{"aria-hidden":!0}),o&&i.jsx(Yr,{prefix:i.jsx(it.SettingsCogIcon,{size:"var(--font-size-base)",color:"var(--text-color-secondary)"}),content:"Manage models",onAction:()=>o("ai-providers")})]})})})}function Br({label:e,icon:t,onClick:n,onKeyDown:r}){return i.jsxs(zr,{onClick:n,onKeyDown:r,children:[i.jsx(Vr,{children:e}),t]})}function Ae({model:e,activeModelId:t,onModelSelect:n}){const r=e.id===t;return i.jsx(je.DropdownMenuItem,{prefix:Nr(e.provider),suffix:r?i.jsx(Ur,{size:"var(--font-size-base)",color:"var(--text-color-primary)"}):void 0,onAction:()=>n(e.id),active:r,children:i.jsx(Gr,{children:e.label})})}const zr=l.default.div`
477
- display: flex;
478
- align-items: center;
479
- min-width: 0;
480
- gap: var(--spacing-xxs);
481
- height: 24px;
482
- padding: 0 var(--spacing-xs);
483
- border-radius: var(--border-radius);
484
- background: var(--bg-color-active);
485
- cursor: pointer;
486
- user-select: none;
487
-
488
- &:hover {
489
- background: var(--layer-color-active);
490
- }
491
- `,Vr=l.default.span`
492
- overflow: hidden;
493
- text-overflow: ellipsis;
494
- font-family: var(--font-family-base);
495
- font-size: var(--font-size-base);
496
- font-weight: var(--font-weight-regular);
497
- line-height: var(--line-height-base);
498
- color: var(--text-color-primary);
499
- white-space: nowrap;
500
- `,$r=l.default.div`
501
- --dropdown-menu-padding-top: 0;
502
-
503
- min-width: 0;
504
- flex: 1;
505
- position: relative;
506
- `,Fr=l.default(nt.Dropdown)`
507
- width: 100%;
508
- min-width: 0;
509
- flex: 1;
510
-
511
- > :last-child {
512
- width: 100%;
513
- max-width: 200px;
514
- }
515
- `,qr=l.default(rt.DropdownMenu)`
516
- --dropdown-menu-item-gap: calc(var(--spacing-unit) / 2);
517
- --dropdown-menu-item-padding-vertical: var(--spacing-xxs);
518
- --dropdown-menu-item-padding-horizontal: var(--spacing-xs);
519
-
520
- padding: var(--spacing-xxs);
521
- margin: 5px 0;
522
- border-radius: var(--border-radius-lg);
523
- background: var(--bg-color);
524
- `,Gr=l.default.span`
525
- flex: 1;
526
- min-width: 0;
527
- overflow: hidden;
528
- text-overflow: ellipsis;
529
- white-space: nowrap;
530
- `,Ur=l.default(ot.CheckmarkIcon)`
531
- margin-left: var(--spacing-xxs);
532
- `,Te=l.default.li`
533
- flex-shrink: 0;
534
- list-style: none;
535
- width: 100%;
536
- height: 1px;
537
- margin: 0;
538
- background: var(--border-color-secondary);
539
- `,Wr=l.default.li`
540
- display: flex;
541
- flex-direction: column;
542
- gap: var(--dropdown-menu-item-gap);
543
- list-style: none;
544
- min-height: 0;
545
- overflow-y: auto;
546
- `,Yr=l.default(je.DropdownMenuItem)`
547
- flex-shrink: 0;
548
- `,Kr=280;function ze({pinToBottom:e=!1}){const[t,n]=p.useState(()=>le.getSemanticSearchService().getIndexingActivityState().inProgress);return p.useEffect(()=>le.getSemanticSearchService().subscribe("indexing-activity",o=>{n(o.inProgress)}),[]),i.jsx(Jr,{$open:t,$pinToBottom:e,"aria-hidden":!t,children:i.jsx(B.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(Xr,{role:"status","aria-live":"polite","aria-label":"Indexing in progress...",children:[i.jsx("div",{children:i.jsx(q,{})}),i.jsx(Zr,{children:"Indexing in progress..."})]})})})}const Jr=l.default.div`
549
- width: 100%;
550
- display: block;
551
-
552
- ${({$pinToBottom:e})=>e?X.css`
553
- order: 1;
554
- margin-top: auto;
555
- `:X.css`
556
- position: absolute;
557
- left: 0;
558
- right: 0;
559
- bottom: 100%;
560
- z-index: 1;
561
- margin-bottom: 4px;
562
- `}
563
-
564
- opacity: ${({$open:e})=>e?1:0};
565
- transition: opacity ${Kr}ms ease-out;
566
- pointer-events: ${({$open:e})=>e?"auto":"none"};
567
-
568
- ${q} {
569
- animation-play-state: ${({$open:e})=>e?"running":"paused"};
570
- }
571
- `,Xr=l.default.div`
572
- width: 100%;
573
- display: flex;
574
- align-items: center;
575
- gap: var(--spacing-xxs);
576
- background: var(--layer-color);
577
- padding: 2px var(--spacing-sm);
578
- border-radius: 4px;
579
- font-size: var(--font-size-sm);
580
- line-height: 12px;
581
- `,Zr=l.default.div`
582
- flex: 1;
583
- min-width: 0;
584
- `;function Qr(){const{chatId:e,isLoading:t,pendingComposerPreset:n,clearPendingComposerPreset:r,availableModels:o,selectedModelId:s,selectModel:a,onSettingsOpen:d}=f.useAiChatContext(),{messages:c,isStreaming:u,sendMessage:h,stopGeneration:g}=x.useAiConversationContext(),{isOpen:v}=f.useAiPanel(),[w,m]=p.useState(""),b=p.useRef(null),C=p.useRef(null),A=p.useRef(!0),y=c.length>0,S=t||y,R=_r(c.length),V=R!==void 0&&R>0&&!y,D=p.useCallback((k="smooth")=>{C.current&&C.current.scrollTo({top:C.current.scrollHeight,behavior:k})},[]),U=p.useCallback(()=>{const k=C.current;if(!k)return;k.scrollHeight-k.scrollTop-k.clientHeight<50&&(A.current=!0)},[]);p.useEffect(()=>{const k=C.current;if(!k)return;const ne=Ge=>{Ge.deltaY<0&&(A.current=!1)};return k.addEventListener("wheel",ne,{passive:!0}),()=>k.removeEventListener("wheel",ne)},[]);const Fe=p.useCallback(async()=>{w&&(m(""),A.current=!0,await h(w),b.current&&requestAnimationFrame(()=>b.current?.focus()))},[h,w]);p.useEffect(()=>{v&&(b.current&&b.current.focus(),A.current=!0,D())},[v,c.length,D]),p.useEffect(()=>{u&&A.current&&D()}),p.useEffect(function(){v&&b.current&&(b.current.focus(),D("instant"))},[e,v,D]),p.useEffect(function(){!v||n===null||(m(n),r())},[v,n,r]);const qe=i.jsx(gt,{value:w,onValueChange:m,onSubmit:Fe,isStreaming:u,onStop:g,textareaRef:b,modelSelector:i.jsx(Hr,{models:o,selectedModelId:s,placement:y?"top":"bottom",onModelSelect:a,onSettingsOpen:d})});return i.jsxs(Be,{children:[i.jsx(eo,{ref:C,$isExpanded:S,$isAnimated:u||V,onScroll:U,children:t?i.jsx(no,{children:i.jsx(f.StyledSpinner,{size:"20px"})}):i.jsx(Pr,{})}),i.jsxs(to,{$isExpanded:!S,children:[i.jsx(ze,{pinToBottom:!S}),qe]})]})}const eo=l.default.div`
585
- flex: ${({$isExpanded:e})=>e?1:0};
586
- width: 100%;
587
- overflow: auto;
588
- padding-bottom: ${e=>e.$isExpanded?"var(--spacing-xs)":"0"};
589
- transition-property: flex;
590
- transition-duration: ${e=>e.$isAnimated?"var(--replay-transition-duration)":"0s"};
591
- transition-timing-function: var(--replay-transition-timing-function);
592
- `,to=l.default.div`
593
- position: relative;
594
- display: flex;
595
- flex-direction: column;
596
- width: 100%;
597
- flex: ${({$isExpanded:e})=>e?1:0};
598
- `,no=l.default.div`
599
- display: flex;
600
- justify-content: center;
601
- height: 100%;
602
- padding-top: var(--spacing-lg);
603
- `,_={TODAY:"today",YESTERDAY:"yesterday",LAST_WEEK:"last_week",LAST_MONTH:"last_month",OLDER:"older"},ro={[_.TODAY]:"Today",[_.YESTERDAY]:"Yesterday",[_.LAST_WEEK]:"Last 7 days",[_.LAST_MONTH]:"Last 30 days",[_.OLDER]:"Older"};function oo(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"),s=f.dayjs(t).subtract(7,"day").startOf("day"),a=f.dayjs(t).subtract(30,"day").startOf("day");return n.isSame(r,"day")?_.TODAY:n.isSame(o,"day")?_.YESTERDAY:!n.isBefore(s,"day")&&n.isBefore(o,"day")?_.LAST_WEEK:!n.isBefore(a,"day")&&n.isBefore(s,"day")?_.LAST_MONTH:_.OLDER}function io(e){const t=[];for(const n of e){const r=oo(n.updatedAt),o=t[t.length-1];!o||o.bucket!==r?t.push({bucket:r,chats:[n]}):o.chats.push(n)}return t}function so(e){const{scrollRef:t,sentinelRef:n,hasNextPage:r,isFetchingNextPage:o,fetchNextPage:s,observerResetKey:a}=e;p.useLayoutEffect(()=>{const d=t.current,c=n.current;if(!d||!c)return;const u=new IntersectionObserver(h=>{const g=h[0];g&&g.isIntersecting&&r&&(o||s())},{root:d,rootMargin:"80px"});return u.observe(c),()=>{u.disconnect()}},[a,s,r,o,t,n])}const Ve=l.default(Be)`
604
- gap: var(--spacing-xxs);
605
- user-select: none;
606
- `,ao=l.default.div`
607
- display: flex;
608
- flex-direction: column;
609
- gap: var(--spacing-xs);
610
- `,lo=l.default.div`
611
- display: flex;
612
- flex-direction: column;
613
- gap: var(--spacing-xxs);
614
- `,co=l.default(Ve)`
615
- display: flex;
616
- flex-grow: 1;
617
- align-items: center;
618
- flex-direction: column;
619
- padding: var(--spacing-md);
620
- `,uo=l.default.div`
621
- display: flex;
622
- flex-grow: 1;
623
- align-items: center;
624
- justify-content: center;
625
- `,fo=l.default.div`
626
- display: flex;
627
- flex-direction: column;
628
- align-items: center;
629
- max-width: 75%;
630
- gap: var(--spacing-xxs);
631
- `,po=l.default.div`
632
- display: flex;
633
- justify-content: center;
634
- padding: var(--spacing-xs);
635
- `,ho=l.default(G.Typography)`
636
- padding-left: var(--spacing-xs);
637
- font-size: var(--font-size-sm);
638
- color: var(--color-warm-grey-7);
639
- `,xo=l.default.div`
640
- display: flex;
641
- flex-grow: 1;
642
-
643
- .tooltip-expanded {
644
- flex-grow: 1;
645
- min-width: 0;
646
- }
647
- `,go=l.default.div`
648
- display: flex;
649
- align-items: center;
650
- justify-content: space-between;
651
- flex-grow: 1;
652
- min-width: 0;
653
- border-radius: var(--border-radius);
654
- padding: calc(var(--spacing-xxs) / 2) var(--spacing-xs);
655
- gap: calc(var(--spacing-xxs) * 2.5);
656
- cursor: pointer;
657
-
658
- ${E.Button} {
659
- display: none;
660
- }
661
-
662
- &:focus-within,
663
- &:hover {
664
- background-color: var(--color-hover-base);
665
-
666
- ${E.Button} {
667
- display: inline-flex;
668
- }
669
- }
670
- `,vo=l.default(G.Typography)`
671
- overflow: hidden;
672
- white-space: nowrap;
673
- text-overflow: ellipsis;
674
- `,mo=l.default.div`
675
- height: 1px;
676
- flex-shrink: 0;
677
- `;function yo(e){const{chat:t,onSelect:n,onRemove:r}=e;return i.jsx(xo,{children:i.jsx(B.Tooltip,{tip:f.dayjs(t.updatedAt).format("MMM DD, YYYY, hh:mm:ss A"),className:"expanded",children:i.jsxs(go,{role:"button",onClick:()=>n?.(t.id),children:[i.jsx(vo,{children:t.title??"New chat"}),i.jsx(E.Button,{variant:"ghost",size:"small",tone:"danger",icon:i.jsx(ct.TrashCanIcon,{}),onClick:o=>{o.stopPropagation(),r?.(t.id)}})]})})})}function wo(e){const{group:t,onChatSelect:n,onChatRemove:r}=e;return i.jsxs(lo,{children:[i.jsx(ho,{children:ro[t.bucket]}),t.chats.map(o=>i.jsx(yo,{chat:o,onSelect:n,onRemove:r},o.id))]})}function bo(){return i.jsx(uo,{children:i.jsxs(fo,{children:[i.jsx(G.Typography,{textAlign:"center",fontWeight:"var(--font-weight-semibold)",children:"No chat history"}),i.jsx(G.Typography,{textAlign:"center",children:"Ask questions or let the assistant take action for you."})]})})}function Co(){return i.jsx(co,{children:i.jsx(f.StyledSpinner,{})})}const Ao=50;function To(e){const{onChatSelect:t,onChatRemove:n}=e,r=p.useRef(null),o=p.useRef(null),{data:s,isPending:a,hasNextPage:d,isFetchingNextPage:c,fetchNextPage:u}=x.useInfiniteChatHistory(Ao),h=p.useMemo(()=>(s?.pages??[]).flatMap(v=>v.items),[s?.pages]),g=p.useMemo(()=>io(h),[h]);return so({scrollRef:r,sentinelRef:o,hasNextPage:d,isFetchingNextPage:c,fetchNextPage:u,observerResetKey:s?.pages.length}),a&&!s?i.jsx(Co,{}):h.length===0?i.jsx(bo,{}):i.jsxs(Ve,{ref:r,children:[i.jsx(ao,{children:g.map(v=>i.jsx(wo,{group:v,onChatSelect:t,onChatRemove:n},`${v.bucket}-${v.chats[0]?.id??""}`))}),d&&i.jsx(mo,{ref:o,"aria-hidden":!0}),c&&i.jsx(po,{children:i.jsx(f.StyledSpinner,{})})]})}function Io(){const e=p.useRef(null),[t,n]=p.useState(!1);return p.useLayoutEffect(()=>{if(!e.current)return;const r=e.current;function o(){n(r.scrollWidth>r.clientWidth)}o();const s=new ResizeObserver(o);return s.observe(r),()=>s.disconnect()},[]),{ref:e,value:t}}function jo(e){const{ref:t,value:n}=Io();return i.jsx(So,{children:i.jsx(B.Tooltip,{tip:e.value,className:"no-overflow",disabled:!n,children:i.jsx(ko,{ref:t,children:e.value})})})}const So=l.default.div`
678
- overflow: hidden;
679
- .tooltip-no-overflow {
680
- overflow: hidden;
681
- }
682
- `,ko=l.default.div`
683
- color: var(--text-color-primary);
684
- font-size: var(--font-size-base);
685
- line-height: var(--line-height-base);
686
- overflow: hidden;
687
- white-space: nowrap;
688
- text-overflow: ellipsis;
689
- user-select: none;
690
- `;function $e(e){const{children:t,buttons:n}=e;return i.jsxs(Eo,{children:[i.jsx(Lo,{children:t}),n&&i.jsx(Ro,{children:n})]})}const Eo=l.default.div`
691
- display: flex;
692
- flex-direction: row;
693
- align-items: center;
694
- padding: var(--spacing-xs);
695
- gap: var(--spacing-xs);
696
- width: 100%;
697
- flex-shrink: 0;
698
- `,Lo=l.default.div`
699
- display: flex;
700
- align-items: center;
701
- gap: var(--spacing-xs);
702
- min-width: 0;
703
- flex: 1;
704
- `,Ro=l.default.div`
705
- display: flex;
706
- align-items: center;
707
- gap: 2px;
708
- `;function Po(e){const{title:t,onCreateNewChat:n,onViewHistory:r,onClose:o}=e,s=i.jsxs(i.Fragment,{children:[i.jsx(B.Tooltip,{tip:"New chat",children:i.jsx(E.Button,{size:"small",variant:"text","aria-label":"Create new chat",onClick:n,icon:i.jsx(ft.NewChatIcon,{})})}),i.jsx(B.Tooltip,{tip:"Chat history",children:i.jsx(E.Button,{size:"small",variant:"text","aria-label":"View chat history",onClick:r,icon:i.jsx(pt.RecentlyViewedIcon,{})})}),i.jsx(_o,{children:i.jsx(f.VerticalDivider,{})}),i.jsx(B.Tooltip,{tip:"Close",arrowPosition:"left",children:i.jsx(E.Button,{variant:"text",size:"small","aria-label":"Close panel",icon:i.jsx(ut.CloseIcon,{}),onClick:o})})]});return i.jsxs($e,{buttons:s,children:[i.jsx(Oo,{children:i.jsx(dt.AiStarsGradientIcon,{size:"14px"})}),i.jsx(jo,{value:t})]})}const Oo=l.default.div`
709
- display: flex;
710
- `,_o=l.default.div`
711
- display: flex;
712
- height: 14px;
713
- `;function Mo(e){const{onReturnFromHistory:t}=e;return i.jsxs($e,{children:[i.jsx(E.Button,{size:"small",variant:"text","aria-label":"Return to chat",onClick:t,icon:i.jsx(ht.ArrowLeftIcon,{})}),i.jsx(Do,{children:i.jsx(G.Typography,{children:"Chat history"})})]})}const Do=l.default.div`
714
- user-select: none;
715
- `;function No(){const[e,t]=p.useState(x.AI_TAB.CHAT),n=f.useAiPanel(),r=f.useAiChatContext(),o=()=>{t(x.AI_TAB.HISTORY)},s=()=>{t(x.AI_TAB.CHAT)},a=async d=>{r.selectChat(d),t(x.AI_TAB.CHAT)};return i.jsxs(Ho,{children:[i.jsxs(Ie,{isActive:e===x.AI_TAB.CHAT,children:[i.jsx(Po,{title:r.title,onCreateNewChat:r.createNewChat,onViewHistory:o,onClose:n.closePanel}),i.jsx(Qr,{})]}),i.jsxs(Ie,{isActive:e===x.AI_TAB.HISTORY,isSliding:!0,children:[i.jsx(Mo,{onReturnFromHistory:s}),i.jsx(To,{onChatSelect:a,onChatRemove:r.removeChat}),i.jsx(zo,{children:i.jsx(ze,{pinToBottom:!0})})]})]})}function Ie(e){const{children:t,isActive:n,isSliding:r=!1}=e,o=i.jsx(Bo,{inert:!n,children:t});return r?i.jsx(Vo,{$isExpanded:n,children:o}):o}const Ho=l.default.div`
716
- position: relative;
717
- height: 100%;
718
- overflow: clip;
719
- `,Bo=l.default.div`
720
- display: flex;
721
- height: 100%;
722
- flex-direction: column;
723
- align-items: flex-start;
724
- border-radius: var(--border-radius-md);
725
- background: var(--bg-color);
726
- margin-left: var(--spacing-xxs);
727
- `,zo=l.default.div`
728
- display: flex;
729
- flex-direction: column;
730
- width: 100%;
731
- padding: 0 var(--spacing-xs) var(--spacing-xs);
732
- `,Vo=l.default.div`
733
- position: absolute;
734
- inset: 0;
735
- transform: translateX(${e=>e.$isExpanded?"0%":"100%"});
736
- transition-property: transform;
737
- transition-duration: 400ms;
738
- transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
739
- @media (prefers-reduced-motion: reduce) {
740
- transition-duration: 0ms;
741
- }
742
- `;exports.AiPanel=No;